This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
sudo apt-get -y update | |
sudo apt-get -y install build-essential zlib1g-dev libssl-dev libreadline5-dev libyaml-dev | |
cd /tmp | |
sudo wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz | |
sudo tar -xvzf ruby-1.9.3-p125.tar.gz | |
sudo cd ruby-1.9.3-p125/ | |
./configure --prefix=/usr/local | |
sudo make | |
sudo make install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
sudo su - | |
apt-get -y update | |
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline5-dev libyaml-dev | |
cd /tmp | |
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz | |
tar -xvzf ruby-1.9.3-p125.tar.gz | |
cd ruby-1.9.3-p125/ | |
./configure --prefix=/usr/local | |
make |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
sudo apt-get -y update | |
sudo apt-get -y install build-essential zlib1g-dev libssl-dev libreadline5-dev libyaml-dev | |
cd /tmp | |
sudo wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz | |
sudo tar -xvzf ruby-1.9.3-p125.tar.gz | |
sudo cd ruby-1.9.3-p125/ | |
sudo ./configure --prefix=/usr/local | |
sudo make | |
sudo make install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
sudo apt-get -y update | |
sudo apt-get -y install build-essential zlib1g-dev libssl-dev libreadline5-dev libyaml-dev | |
cd /tmp | |
sudo wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz | |
sudo tar -xvzf ruby-1.9.3-p125.tar.gz | |
sudo cd ruby-1.9.3-p125/ | |
sudo ./configure --prefix=/usr/local | |
sudo make | |
sudo make install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
apt-get -y update | |
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline5-dev libyaml-dev | |
cd /tmp | |
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz | |
tar -xvzf ruby-1.9.3-p125.tar.gz | |
cd ruby-1.9.3-p125/ | |
./configure --prefix=/usr/local | |
make | |
make install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// make the post using the objectManager if you want to map the response to a model | |
RKObjectManager* objectManager = [RKObjectManager sharedManager]; | |
[objectManager loadObjectsAtResourcePath:@"/api/" delegate:self block:^(RKObjectLoader* loader) { | |
loader.serializationMIMEType = RKMIMETypeJSON; // We want to send this request as JSON | |
loader.objectMapping = [objectManager.mappingProvider objectMappingForClass:[Plan class]]; | |
loader.resourcePath = @"/api/"; | |
loader.method = RKRequestMethodPOST; | |
loader.params = [RKRequestSerialization serializationWithData:[jsonString dataUsingEncoding:NSUTF8StringEncoding] MIMEType:RKMIMETypeJSON]; | |
}]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create a JSON string from your NSDictionary | |
NSError *error; | |
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:finalDict | |
options:NSJSONWritingPrettyPrinted // Pass 0 if you don't care about the readability of the generated string | |
error:&error]; | |
NSString *jsonString = [[NSString alloc] init]; | |
if (!jsonData) { | |
NSLog(@"Got an error: %@", error); | |
} else { | |
jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// make the inner dictionaries (probably would use a for loop for this) | |
NSDictionary *dict1 = [[NSDictionary alloc] initWithObjectsAndKeys:@"value1", @"key", nil]; | |
NSDictionary *dict2 = [[NSDictionary alloc] initWithObjectsAndKeys:@"value2", @"key", nil]; | |
// put them in an array | |
NSArray *types = [[NSArray alloc] initWithObjects:dict1, dict2, nil]; | |
// now put the array in a dictionary | |
NSDictionary *finalDict = [[NSDictionary alloc] initWithObjectsAndKeys:types, @"types", nil]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// make the inner dictionaries (probably would use a for loop for this) | |
NSDictionary *dict1 = [[NSDictionary alloc] initWithObjectsAndKeys:@"value1", @"1", nil]; | |
NSDictionary *dict7 = [[NSDictionary alloc] initWithObjectsAndKeys:@"value2", @"7", nil]; | |
// put them in an array | |
NSArray *types = [[NSArray alloc] initWithObjects:dict1, dict7, nil]; | |
// now put the array in a dictionary | |
NSDictionary *finalDict = [[NSDictionary alloc] initWithObjectsAndKeys:types, @"types", nil]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"types":[ { | |
"key" : "value1" | |
}, | |
{ | |
"key" : "value2" | |
} ] | |
} |