Tweet Every now and then you need to save command output into a bash var from a command. Generally it looks like
VAR=`command`
That will put the stdout of command into $VAR
There is an issue if the output has linebreaks. Recently I had this issue trying to email SVN diffs for DNS changes. My command to get the diffs looked like this
DIFF=`svn diff /var/named/chroot/var/named/ /var/named/chroot/etc/`
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.
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.
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.
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];
Tweet Make sure you have JSON Framework installed first.
This is a continuation of Post JSON to a webservice
So if you are writting your webservice application and you have to wait a few seconds to make the request and get the response you will notice that your main application gets locked up. This is due to having to wait for the request to complete and nothing else can work till that request is completed.
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.
Tweet The main project I am doing for Photoblog is an application to show all the latest entries and such. So I call a web service using JSON and it gives me the data I need. Now there might be a few second delay in sending the request and getting the request back. Once I get the request back I open my new view. So one way to show the user that activity is going on is creating a activity indicator.
Tweet Make sure you have JSON Framework installed first.
This is a continuation of Click a Cell
So there has been some requests to do this. If you want to display a image in a custom cell it is pretty easy. It is about the same as doing the title and the URL to the image we did before. This will take over where click a cell left off. So you can grab the source code from there and start.
Tweet I was working on appending to some strings and there is a way to do it with NSString but you are better off working with NSMutableString instead. I have a feeling doing it with NSString, if not done correctly, will leak memory.
NSMutableString *hello = [[NSMutableString alloc] initWithString:@"Hello"]; [hello appendString:@" World"];