Skip to content

Instantly share code, notes, and snippets.


Brian Donohue Donohue

View GitHub Profile
#!usr/bin/env python
import sys
with open(sys.argv[1]) as f:
unified_set = set([])
for line in f.readlines():
for item in unified_set:
print item
View Instapaper Database Error Messasge
OperationalError: (OperationalError) (1114, "The table 'bookmarks' is full")

Keybase proof

I hereby claim:

  • I am donohue on github.
  • I am bthdonohue ( on keybase.
  • I have a public key whose fingerprint is 6782 B8C0 FF5D CE47 80DE 6E44 CF38 6FB3 4639 9BD7

To claim this, I am signing this object:

View gist:b7d17e93c6fccf6fb0f6
- (NSURL *)URLFromText:(NSString *)text {
NSArray *components = [text componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSURL *ret = nil;
for (NSString *part in components) {
NSURL *urlCheck = [NSURL URLWithString:part];
if (urlCheck &&
([urlCheck.scheme isEqualToString:@"http"] ||
[urlCheck.scheme isEqualToString:@"https"])) {
ret = urlCheck;
View gist:2aa0e2f31c1155d717fe
- (UIImage *)scaleAndRotateImage:(UIImage *)image {
int kMaxResolution = 320; // Or whatever
CGFloat scale = 1.0;
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {
scale = [[UIScreen mainScreen] scale];
kMaxResolution *= scale;
CGImageRef imgRef = image.CGImage;
View gist:46b8f719f4d37f379f9f
def fragmention(self, bookmark):
# Normalize whitespace and encode text as UTF8
text = ' '.join(self.text.split()).encode('utf-8')
url_parts = urlparse(bookmark.url)
# If the URL has no path (i.e. add a "/" then append fragmention
formatter = '%s/##%s' if not len(url_parts.path) else '%s##%s'
fragmention_url = formatter % (url_parts.geturl(), urllib.quote_plus(text))
Donohue / voip_keep_alive_handler
Last active Dec 17, 2015
Register for VOIP keep alive handler
View voip_keep_alive_handler
BOOL ret = [[UIApplication sharedApplication] setKeepAliveTimeout:600 handler:^(void) {
if (updating_location) {
[location_manager stopUpdatingLocation];
NSLog(@"Keep alive: Stopping location updates");
else {
[location_manager startUpdatingLocation];
NSLog(@"Keep alive: Starting location updates");
Donohue / background_location_updates
Last active Dec 17, 2015
Register for background location updates
View background_location_updates
location_manager = [[CLLocationManager alloc] init];
location_manager.desiredAccuracy = kCLLocationAccuracyBest;
location_manager.delegate = self;
[location_manager startUpdatingLocation];
updating_location = YES;