Thursday, February 26, 2009

Power Copy-n-Paste

Have you ever copied something to your Windows clipboard and were ready to paste it when you realized you needed to copy and paste something else? Yep, you had to go copy and paste the new item, then go back to your original source and the copy and paste that again. What a hassle. Here's a little timesaver I've discovered. Don't copy and paste the new item - instead, select the new text with your cursor and the ctr+drag it to its new location (or just drag it for cut and paste). Then when you hit "paste" or ctrl+v - you're original text is still in the clipboard and gets pasted!
Reblog this post [with Zemanta]

Tuesday, February 17, 2009

Testing PayPal IPN

When working with PayPal as a payment provider, you'll inevitable wind up dealing with their Instant Payment Notification (or IPN). Its not always instant and not always payment related but is a notification.

An IPN is a simple HTTP form post that PayPal sends your server (to a url specified in your account settings or the "notify_url" parameter of the transaction) that provides information about the transaction that just took place. It contains information like item names and codes, price information, and the buyers shipping info. Because it is sent directly from PayPal's servers to yours without passing through the user's browser, it is much more secure and less susceptible to tampering.

However, when working behind a firewall or NATed router, PayPal's IPN has no way of reaching your development machine! Sure, you can forward a port to your PC but chances are, your port 80 is already being forwarded to a real web server (or you might not have access to the router).

To get around this problem, I built a simple ASP.Net page on our public facing test server (that has access to our internal network) that simply accepts the post from PayPal and reposts it to my development machine. The code is very simple:


_internalURL = "http://mydevmachineurlhere";

string postData = "a=" + "a";
for (int i = 0; i < Request.Form.Count; i++) {
postData += "&" + Request.Form.AllKeys[i] + "=" + Request.Form[Request.Form.AllKeys[i]];
}

encoding = new ASCIIEncoding();
byte[] data = encoding.GetBytes(postData);

// Prepare web request...
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(_internalURL); myRequest.Method = "POST";
myRequest.ContentType = "application/x-www-form-urlencoded";
myRequest.ContentLength = data.Length;
Stream newStream = myRequest.GetRequestStream();

// Send the data. newStream.Write(data, 0, data.Length);
newStream.Close();


As you can see, this page will redirect the POST to an internal URL of your choice. You can even get fancier and have the repost go to different URL's based on any parameter you want (e.g. "payer_email", "item_name" etc.) to facilitate testing for multiple developers - without having to mess with your firewall.
Reblog this post [with Zemanta]

Thursday, February 12, 2009

First!

How often do you get to do something first? I'm not talking about being the first to comment "First!" on a forum post or YouTube video or grabbing a hot new video game console at 5am. I mean true pioneering, creating technology that has not been created before. That's part of what I love about working at Aviary. We just launched our vector editor, Raven. It's the first web based vector editor out there. We may not have cured cancer but it still feels great! Way to go guys!

Tuesday, February 3, 2009

Computer Savvy-ness

Working in the computer field has taught me several things. One of the biggest lessons I've learned is that if your job description, company name or industry has the word "computer" or "internet" in it, friends and family assume you know the answer to all their computer problems and have the time (and desire) to fix their issues.

The truth is, computer savvy is not about having all the answers in your head. Sure, its gratifying when a stymied colleague ooh's and ah's when you pull a nugget about an Asus motherboard driver incompatibility out of thin air, but usually, 5 minutes on Google can come up with the same answer. Its more about the understanding that computers are not infallible machines and the patience to research, try and fail until the problem is solved. "Unsavvy" people are used to dealing with machines like blenders and power tools. These machines seldom fail in a way that the average layman can fix so an expectation of unwavering mechanical reliability is created. When these expectations are transferred over to computers (and cars to some extent), people develop an intolerance for anything other than normal operation. When computers do fail, whether its an OS or hardware issue, this intolerance will cause people to throw up their hands and call.... me.

The cycle of research, try and fail is not something magical that only computer savvy people can perform. It is the standard process of learning. Although it may be time consuming at first, the more you learn, the more you know. The more you know, the shorter the cycle is next time around. And there's always a next time, believe me - I know.