Tag Archives: Tutorial

Getting started with PayPal Sandbox

Apparently PayPal has changed their sandbox developer account setup UI and such since I wrote this post together with the PDT and IPN blog posts.

Luckily it’s much easier now, and you should be able to get all the information you need from their own PayPal Sandbox Testing Guide. I’ve also decided to delete the old contents of this post to prevent anyone from trying to follow the now incorrect steps ๐Ÿ™‚

PHP: Generating transparent PNG fillers

So, I was fooling around the other day with an HTML table and wanted to make the odd rows slightly darker. Figured I could use for example an 80% transparent black PNG to do that (or could have just assigned a darker color, but where’s the fun in that?). Either way, ended up making a little something that I thought I could share just for the fun of it. I learned a few things, so maybe someone else can too ๐Ÿ™‚

So, here’s how to make a small transparent PNG filler image on-the-fly using PHP ๐Ÿ™‚

Continue reading PHP: Generating transparent PNG fillers

MySQL: How to reset the root account

I just managed to mess up the MySQL root account. Not a smart idea. After some MySQL manual reading and some serious Google-Fu, I figured out how to fix it.

  1. Stop the mysql server
  2. Add the following to the my.cnf file
    [mysqld]
    skip-grant-tables
  3. Start the mysql server
  4. Start a mysql client and run the following query
    REPLACE INTO mysql.user VALUES ('localhost','root',PASSWORD('blah'),'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
  5. Quit the mysql client
  6. Stop the mysql server
  7. Remove what we added to my.cnf in step 2
  8. Restart the mysql server

Tadaa.

C#: How to use assembly embedded resources

After some digging around, I found that it actually wasn’t that difficult at all.

Getting it in

Putting something in an assembly as an embedded resource is pretty easy. At least if you are using Visual Studio. Just add the file to your project, click on it, and then under Properties set Build Action to Embedded Resource. And thats it!

Getting it out

Lets say we want an image called hello.png in a folder called Wopdidoo as a Stream.

If we are executing code in the same assembly, we can do as follows:

Assembly assembly = Assembly.GetExecutingAssembly();
Stream imageStream = assembly
    .GetManifestResourceStream("DefaultNameSpaceOfAssembly.Wopdidoo.hello.png");

If you are not executing code in the same assembly you just have to get that assembly reference in a different way. I often use Assembly.GetAssembly(typeof(T)), where T is some type you know exists in the same assembly as the file you want. The rest is the same.

As far as I know, you use the stream as any other stream. Not sure if it is writable though? Probably not… let me know if you have some brilliant clues on that matter ๐Ÿ™‚

รขลกย  Remember to Dispose it when you are done.

Finding it

I sometimes find it a bit difficult to figure out that string which identifies the resource. I then often use the following code to “find” it:

foreach (string s in assembly.GetManifestResourceNames())
    System.Diagnostics.Debug.WriteLine(s);

It basically just scans through all the resource names and prints them out to the debug console ๐Ÿ™‚