16 August 2010, 4:08 pm
I found this useful class for base64 encoding / decoding. It is written by Kiichi Takeuchi
Base64.h
@interface Base64 : NSObject {
}
+ (void) initialize;
+ (NSString*) encode:(const uint8_t*) input length:(NSInteger) length;
+ (NSString*) encode:(NSData*) rawBytes;
+ (NSData*) decode:(const char*) string length:(NSInteger) inputLength;
+ (NSData*) decode:(NSString*) string;
@end
Sample Usage
[Base64 initialize];
NSData * data = [Base64 decode:@"SGVsbG8gV29ybGQ="];
NSString * actualString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"%@",actualString);
[actualString release];
Download base64 encode / decode class
16 August 2010, 3:44 pm
This function will help you generate MD5 hash of a given string
Class.h
+ (NSString *)getMD5FromString:(NSString *)source;
Class.m
+ (NSString *)getMD5FromString:(NSString *)source{
const char *src = [source UTF8String];
unsigned char result[CC_MD5_DIGEST_LENGTH];
CC_MD5(src, strlen(src), result);
NSString *ret = [[[NSString alloc] initWithFormat:@"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
result[0], result[1], result[2], result[3],
result[4], result[5], result[6], result[7],
result[8], result[9], result[10], result[11],
result[12], result[13], result[14], result[15]
] autorelease];
return [ret lowercaseString];
}
16 August 2010, 3:22 pm
This function will help you to convert hex color string to UIColor
Class.h
+ (UIColor *) colorWithHexString: (NSString *) stringToConvert;
Class.m
+ (UIColor *) colorWithHexString: (NSString *) stringToConvert{
NSString *cString = [[stringToConvert stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString];
// String should be 6 or 8 characters
if ([cString length] < 6) return [UIColor blackColor];
// strip 0X if it appears
if ([cString hasPrefix:@"0X"]) cString = [cString substringFromIndex:2];
if ([cString length] != 6) return [UIColor blackColor];
// Separate into r, g, b substrings
NSRange range;
range.location = 0;
range.length = 2;
NSString *rString = [cString substringWithRange:range];
range.location = 2;
NSString *gString = [cString substringWithRange:range];
range.location = 4;
NSString *bString = [cString substringWithRange:range];
// Scan values
unsigned int r, g, b;
[[NSScanner scannerWithString:rString] scanHexInt:&r];
[[NSScanner scannerWithString:gString] scanHexInt:&g];
[[NSScanner scannerWithString:bString] scanHexInt:&b];
return [UIColor colorWithRed:((float) r / 255.0f)
green:((float) g / 255.0f)
blue:((float) b / 255.0f)
alpha:1.0f];
}
29 June 2010, 10:20 am

The problem is due to my DNS, but is still funny as hell.
20 June 2010, 7:59 pm
Couple of months before one of my friend was asking about Amazon S3 plugin for wordpress. For me most of them were either complicated or not working. So my main focus of the plugin was to be really simple and in the same time effective. I would say I have kind of achieved the goal to some extend in version 1.0 of this plugin release.
The toughest part in the plugin is to configure the Amazon S3 Setting, create a folder for caching and setup the wordpress cron file. Once these settings are done you don’t have to worry about anything else. The plugin will look for media files in your post and automatically schedule the files for amazon upload. Once the file is uploaded the media urls will be from the CDN. There are no changes done in your database and if you disable the plugin everything will go back to the old state.
Download WordPress Amazon S3 Plugin
WordPress Amazon S3 Plugin
More information on WordPress Amazon S3 Plugin
19 June 2010, 7:42 pm
It has been a while since I wrote anything on the blog. I don’t want to give any excuse as it was mostly being lazy. After a while I started to get a feeling what to blog and I was really running out of topics. Yesterday I got an email from WordPress team that their new version 3.0 is out. This gave me a reason to goto my blog and start updating the software. As usual the upgrade was smooth as silk and everything worked spot on. I even upgraded my plugins and themes so everything works fine. All my plugins except organizer is working fine in the latest wordpress 3.0
Apart from that I was busy past month updating iPhone app Naviflix. The new version is already submitted to the app store. Once it is approved I will share some the hurdles I crossed while development.
Some of my friends requested me to write a plugin which helps to move the media files in their blog to Amazon S3. I have written a simple plugin and once I get the space in wordpress subversion I will be posting more details about the same. I have uploaded my niece Afifa picture below.

If my plugin is working fine it should be serving the image from the S3 cdn.