Skip to content

Instantly share code, notes, and snippets.

View cbertoldi's full-sized avatar

Carlo Bertoldi cbertoldi

View GitHub Profile
@cbertoldi
cbertoldi / Desert 256.dvtcolortheme
Created October 6, 2011 15:42
256 colors desert color scheme for xCode
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>0.000 0.000 0.000 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>Inconsolata - 14pt</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>0.000 0.000 0.000 1</string>
// in the app delegate
RKObjectManager *objectManager = [RKObjectManager objectManagerWithBaseURL:@"http://192.168.0.29:8080/"];
RKManagedObjectStore *objectStore = [RKManagedObjectStore objectStoreWithStoreFilename:@"TestJSON.sqlite"];
[objectManager setObjectStore:objectStore];
// following is called within a view
if (self) {
@cbertoldi
cbertoldi / setUp
Created December 6, 2011 16:44
Simple setUp
- (void)setUp
{
[super setUp];
RKObjectManager *objectManager = [RKObjectManager
objectManagerWithBaseURL:@"http://192.168.0.29:8080/"];
[RKObjectManager setSharedManager:objectManager];
// [RKObjectManager sharedManager].objectStore = [RKManagedObjectStore objectStoreInMemory];
RKManagedObjectStore *objectStore = [RKManagedObjectStore objectStoreInMemory];
@cbertoldi
cbertoldi / gist:1498279
Created December 19, 2011 18:25
How to parse a JSON string using RestKit, without loading a remote resource
NSString *jsonString = [self readJSON:@"some_file"];
NSDictionary *dictionary = [jsonString objectFromJSONString];
RKObjectMapper *mapper = [RKObjectMapper mapperWithObject:dictionary
mappingProvider:[MappingFactory sharedMappingProvider]];
RKObjectMappingResult *result = [mapper performMapping];
// MappingFactory
+ (RKObjectMappingProvider *)sharedMappingProvider
{
@cbertoldi
cbertoldi / Receive
Created October 31, 2012 16:05
Problem with JMS transactions
public void receive() {
TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
Message msg = jmsTemplate.receive(queue);
boolean success = false;
if (msg != null) {
try {
success = handleMessage(msg);
if (success) {
msg.acknowledge(); // session is still open within the transaction
}
@cbertoldi
cbertoldi / Bash cheat sheet
Last active December 15, 2015 02:18
Some bash reminders. Copied here before the original file disappears :)
I have marked with a * those which I think are absolutely essential
Items for each section are sorted by oldest to newest. Come back soon for more!
BASH
* In bash, 'ctrl-r' searches your command history as you type
- Input from the commandline as if it were a file by replacing
'command < file.in' with 'command <<< "some input text"'
- '^' is a sed-like operator to replace chars from last command
'ls docs; ^docs^web^' is equal to 'ls web'. The second argument can be empty.
* '!!:n' selects the nth argument of the last command, and '!$' the last arg