Skip to content

Instantly share code, notes, and snippets.

View cbertoldi's full-sized avatar

Carlo Bertoldi cbertoldi

View GitHub Profile
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!
* In bash, 'ctrl-r' searches your command history as you type
- Input from the commandline as if it were a file by replacing
'command <' 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
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 / 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 / setUp
Created December 6, 2011 16:44
Simple setUp
- (void)setUp
[super setUp];
RKObjectManager *objectManager = [RKObjectManager
[RKObjectManager setSharedManager:objectManager];
// [RKObjectManager sharedManager].objectStore = [RKManagedObjectStore objectStoreInMemory];
RKManagedObjectStore *objectStore = [RKManagedObjectStore objectStoreInMemory];
// in the app delegate
RKObjectManager *objectManager = [RKObjectManager objectManagerWithBaseURL:@""];
RKManagedObjectStore *objectStore = [RKManagedObjectStore objectStoreWithStoreFilename:@"TestJSON.sqlite"];
[objectManager setObjectStore:objectStore];
// following is called within a view
if (self) {
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" "">
<plist version="1.0">
<string>0.000 0.000 0.000 1</string>
<string>Inconsolata - 14pt</string>
<string>0.000 0.000 0.000 1</string>