All Posts

Bash Command Logger with Curl Support

Tweet There is a great project called Bash Paranoia. Right now their site is busted so I can’t link to it. Its a patch that applies to bash that allows commands to be logged to syslog. I basically took this one step further and added curl support. The bash paranoia patch and my curl addition can be found on my GitHub project page http://github.com/mzupan/bash-paranoia-curl Below is my patch I wrote.

View Images like Photos.app

Tweet Make sure you have JSON Framework installed first. This is a continuation of Using threads for a JSON request So right now we have four rows in our table. Each row has a image. So what if we want to view all the images at once. I really like viewing images at my own time. So I don’t want to use a timer and have them switch. If i want to skip a image I want to skip and if I want to take time to look, I want to look.

Add a Wiggle

Tweet This will be a continuation of Multiple Objects and UITouch If you do a long touch in the main section of the iPhone on a icon you will notice the icons will wiggle. This shows the user they can be deleted or moved around. So lets try to mimic that as best we can and when we stop a drag of our image it will wiggle for two seconds.

Multiple Objects and UITouch

Tweet Here is a bit of a continuation of Working with UITouch Please follow that tutorial first. We will be using the source code from that as our starting point. So once you have the source code in Xcode open up touchViewController.h and we need to add in one new outlet for our second image. So we want the file to look like this. I have commented the line I have added in.

Access the Address Book

Tweet I got a request on how do I access the address book in the iPhone. So I took around 30 minutes to learn how and here is how we will do it. First create a new View-Based Application and call it addressBook. Now the first thing we want to do is setup the 4 IBOutlets and the 1 IBAction for our project. We also need to include the headers for the address book framework.

Working with UITouch

Tweet So here is a quick post on how to work with a UITouch. This tutorial will put a UIImageView on a view and then when you touch around the image view will be placed where you touch. So lets start out by creating a new project and and use a View Based application as shown below. Now I called the project touch. So lets create an outlet for the image view we will create.

Change background of a UITableViewCell

Tweet I was asked this question by a co-worker on how to do this. My first answer was when you init the cell just set the backgroundColor but that did not work at all. If you followed my other tutorials and have a custom UITableViewCell open that file and in the initWithFrame method you want the following MyContentView.backgroundColor = [UIColor redColor];

Post a UIImage to the web

Tweet So here is something a lot of people have been wondering to do in the forums. How do I take a UIImage or any image and post it to a website. So this will go over how to do that. There are two ways to tackle this issue. One we can base64 encode the file and post is normally inside a XML or JSON instance or we can simulate a normal HTML post.

Using a UIImagePickerController

Tweet Apple allows you great access into the images you have taken with your camera or saved on the phone via Safari or such. It also allows you to load up the camera very easily in your code to take pictures from your application. So the first thing we want to do is start a new project and call it testPicker. You want to create a View based application.

Post JSON to a webservice

Tweet Make sure you have JSON Framework installed first. This is a continuation of UIImageView in a custom cell Here is a simple little code snippet on how to post some JSON to a webservice. NSString *requestString = [NSString stringWithFormat:@"json=%@", [loginDict JSONFragment], nil]; NSData *requestData = [NSData dataWithBytes: [requestString UTF8String] length: [requestString length]]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL: [NSURL URLWithString: @"http://domain.com/api/login/"]]; [request setHTTPMethod: @"POST"]; [request setHTTPBody: requestData]; NSData *returnData = [ NSURLConnection sendSynchronousRequest: request returningResponse: nil error: nil ]; NSString *returnString = [[NSString alloc] initWithData:returnData encoding: NSUTF8StringEncoding]; // decoding the json NSDictionary *loginArray = [NSDictionary alloc]; loginArray = [returnString JSONValue]; So below is what each line does.