Skip to content

Instantly share code, notes, and snippets.

View ashtom's full-sized avatar
🤖
the job is not to know; it's to become

Thomas Dohmke ashtom

🤖
the job is not to know; it's to become
View GitHub Profile
### Keybase proof
I hereby claim:
* I am ashtom on github.
* I am ashtom (https://keybase.io/ashtom) on keybase.
* I have a public key whose fingerprint is E34B 112A 5FA7 D46A 7455 9E11 6E71 8750 737E 08F6
To claim this, I am signing this object:
// Resetting the application badge number
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
// How to encode NSData for a HTTP request
NSString *dataString = [[NSString alloc] initWithFormat:@"%@", someData];
NSString *dataEncoded = [dataString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(@"Encoded data = %@", dataEncoded);
if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:nil error:&error]) {
if ([error code] == NSPersistentStoreIncompatibleVersionHashError) {
NSLog(@"Persistent Store Incompatible Version error. Please check %@", storeUrl);
} else {
NSLog([error description]);
}
}
# Size of preview images for Safari's top sites / history
du -ch {~/Library/Caches/,`getconf DARWIN_USER_CACHE_DIR`}com.apple.Safari
# Fixing error code 133
cd /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/IOKit.framework/Versions/A/
sudo mv IOKit IOKit.saved
sudo lipo IOKit.saved -extract_family i386 -output IOKit
-- OmniFocus to Pomodoro App for iPad
-- This script practically takes text that's on your clipboard
-- and generates a Pomodoro App for iPad compatible JSON file
-- for you to import in to the app (using Dropbox)
--
-- I'm using it with OmniFocus, where copied tasks remain
-- on the clipboard as lines of text, basically.
-- If you're stuck on Things and this script is not working,
-- NOW might be a good time to switch.
--
-- Things to Pomodoro App for iPad
-- This script asks Things for the currently selected todos
-- and generates a Pomodoro App for iPad compatible JSON file
-- for you to import in to the app (using Dropbox)
--
-- Created by Thomas on 2011-02-17
-- Inspired by Andreas on 2011-02-17
--
@ashtom
ashtom / battery_low.sh
Created July 13, 2011 12:31
Show a growl notification every minute if battery is below threshold
#!/bin/bash
#
# Show a growl notification every minute if battery is below threshold.
#
# Setup:
# 1. Install growlnotify
# 2. Adjust threshold in line 20 (here 656mAh)
# 3. Create line in crontab like this:
# * * * * * /path/to/script/battery_low.sh
@ashtom
ashtom / gist:2049389
Created March 16, 2012 10:03
Sort by pubDate
#import <Foundation/Foundation.h>
int main(int argc, char *argv[]) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSDictionary *one = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:1], @"pubDate", nil];
NSDictionary *two = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:2], @"pubDate", nil];
NSDictionary *three = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:3], @"pubDate", nil];
NSArray *array = [NSArray arrayWithObjects:three, one, two, nil];