Skip to content

Instantly share code, notes, and snippets.

@cbertoldi
cbertoldi / Bash cheat sheet
Last active Dec 15, 2015
Some bash reminders. Copied here before the original file disappears :)
View Bash cheat sheet
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
@cbertoldi
cbertoldi / Receive
Created Oct 31, 2012
Problem with JMS transactions
View Receive
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 / gist:1498279
Created Dec 19, 2011
How to parse a JSON string using RestKit, without loading a remote resource
View gist:1498279
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
{
View 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];
View restkit_coredata_problem.m
// 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 / Desert 256.dvtcolortheme
Created Oct 6, 2011
256 colors desert color scheme for xCode
View Desert 256.dvtcolortheme
<?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>