Category Archives: programming

Using Ruby and HTTParty to consume web services the easy way

Web services seem to be multiplying like rabbits these days. For a good sampling of just how many there are check out the Programmable Web API list. In general it is pretty easy to consume basic REST web services but after you have done it enough it starts getting old. Thankfully for those of us who like to tinker with a lot of the new APIs there is HTTParty to make it quick and easy.

Continue reading

SOAP on the Google App Engine platform

I generally don't recomend using SOAP instead of REST but I have been required to use SOAP so much now that I think it is inevitably going to be a requirement for a long time for certain projects. So when I noticed a question on stack overflow about using SOAP on the Google App Engine I thought it might be a nice exercise to see how easy it is to get fringe toolsets to work in the GAE.

Continue reading

C# custom SOAP header

While working on an SOAP service I needed to create a number of clients for different languages. This would normally not be that big of a challenge except that the SOAP service had custom headers for doing authentication. Because of the complexity in setting up Axis to use WS-Security the choice was made to do authentication by adding a few out of band SOAP header values. The first few implementations went fine but then I came to C# and had a problem.

Continue reading

Anonymous functions in PHP

I ran into this and found it interesting. Someone has added support for anonymous functions in PHP.

With the patch you can now do stuff like:

$data = array("zoo", "orange", "car", "lemon", "apple");
usort($data, function($a, $b) { return strcmp($a, $b); });
var_dump($data); # data is sorted alphabetically 

Before you had to use a funky function generation call.


Howto base64 decode with C/C++ and OpenSSL

Someone asked for an example of decoding with OpenSSL on the Howto base64 encode with C/C++ and OpenSSL post. So here it is:

#include <string.h>

#include <openssl/sha.h>
#include <openssl/hmac.h>
#include <openssl/evp.h>
#include <openssl/bio.h>
#include <openssl/buffer.h>

char *unbase64(unsigned char *input, int length);

int main(int argc, char **argv)
  char *output = unbase64("WU9ZTyEA\n\0", strlen("WU9ZTyEA\n\0"));
  printf("Unbase64: *%s*\n", output);

char *unbase64(unsigned char *input, int length)
  BIO *b64, *bmem;

  char *buffer = (char *)malloc(length);
  memset(buffer, 0, length);

  b64 = BIO_new(BIO_f_base64());
  bmem = BIO_new_mem_buf(input, length);
  bmem = BIO_push(b64, bmem);

  BIO_read(bmem, buffer, length);


  return buffer;

Tags: , ,

How to build FlowPlayer from source

I have mentioned the free open source flash video player FlowPlayer before in my post about adding cuepoints and create flash videos. It is a great free flash video player that you can modify yourself. After writing about adding metadata to your flash videos I decided to add support for calling javascript from FlowPlayer one cue events. The first step to modifying the FlowPlayer source is to be able to build FlowPlayer from source.

Continue reading

Upgrade to PHP 5.2 and Get JSON For Free

A few days ago when PHP 5.2 was released one of the things that caught my eye was that it now includes the JSON extension. For anyone doing AJAXy type stuff JSON is an easy way to martial your data between your server side language and javascript.

For the longest time I've been using the older PHP JSON library to do JSON with PHP but now that the extension is included in the core I decided it was time to test it out. I took a couple of minutes and converted my DNSBL checker as a test since it has a fairly large data-set that gets converted and sent back. The json functions provided by the extension are probably easier to use since the JSON library needed you to create an object first but that wasn't a real issue. After making the change I could tell JSON extension was faster than the library. After a little digging I found that someone has done a little extension vs library testing and claims the JSON extension is 153 times as fast as the library.

Tags: ,

Easier scrolling images with Yahoo UI

This is a great article about the yahoo ui tools. I mention it mainly because they have a nice scrolling widget a lot like what I put together as an example of the things you can do with (see Smooth Scrolling Image List).

A link to the demo: Sliding demo

The entire article: 15 things you can do with yahoo ui

Tags: , ,

Creating S3 URLs that expire using PHP

After reading this post on the S3 forum I realized that other people are thinking about doing some of the same stuff I have. paolonew was looking for a way to for a way to create URLs to S3 objects that expired. I did this a while back when I was thinking about how to host objects that I wanted to protect with some outside scheme. The confusion on the forum seemed to be about the timestamps used to expire the URL. For PHP it is fairly easy.

Continue reading