Skip to content

Instantly share code, notes, and snippets.

View grgcombs's full-sized avatar

Greg Combs grgcombs

View GitHub Profile
@landonf
landonf / coop.plausible.backupd-daily.plist
Created November 25, 2009 19:27
Drop in /Library/LaunchDaemons and disable TimeMachine's automated backups. Will run backups at 8:00 and 18:30, adjust by modifying the StartCalendarInterval array.
<?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>Label</key>
<string>coop.plausible.backupd-daily</string>
<key>ProgramArguments</key>
<array>
<string>/System/Library/CoreServices/backupd.bundle/Contents/Resources/backupd-helper</string>
</array>
@xslim
xslim / NSObject+AssociatedObjects.h
Created May 31, 2011 17:49
Blocks support for RestKit RKClient
#import <Foundation/Foundation.h>
@interface NSObject (AMAssociatedObjects)
- (void)associateValue:(id)value withKey:(void *)key; // Retains value.
- (id)associatedValueForKey:(void *)key;
@end
@blakewatters
blakewatters / gist:1114150
Created July 29, 2011 16:18
Attach an Image to an Object Loader
[[RKObjectManager sharedManager] postObject:contact delegate:self block:^(RKObjectLoader* loader) {
RKObjectMapping* serializationMapping = [[[RKObjectManager sharedManager] mappingProvider] serializationMappingForClass:[Contact class]];
NSError* error = nil;
NSDictionary* dictionary = [[RKObjectSerializer serializerWithObject:contact mapping:serializationMapping] serializedObject:&error];
RKParams* params = [RKParams paramsWithDictionary:dictionary];
[params setData:[contact avatarImageData] MIMEType:@"image/png" forParam:@"avatar_image"];
loader.params = params;
}];
- (void)viewDidLoad {
[super viewDidLoad];
// Configure RestKit Logging
RKLogConfigureByName("RestKit/UI", RKLogLevelTrace);
RKLogConfigureByName("RestKit/ObjectMapping", RKLogLevelTrace);
RKLogConfigureByName("RestKit/Network*", RKLogLevelDebug);
// Configure the object manager
RKObjectManager* manager = [RKObjectManager objectManagerWithBaseURL:@"http://localhost:4567/"];
@dhoerl
dhoerl / KeychainItemWrapper.h
Last active April 4, 2023 08:15
KeychainItemWrapper ARCified. Added the ability to manage a dictionary in place of just a string - the #define PASSWORD_USES_DATA in the .m file switches the mode.
/*
File: KeychainItemWrapper.h
Abstract:
Objective-C wrapper for accessing a single keychain item.
Version: 1.2 - ARCified
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
Inc. ("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of
@grgcombs
grgcombs / OpenStatesApiExamples.json
Created September 7, 2011 07:37
Open States API examples
/** Open States API - Data for all state legislatures (well, 38 states so far)
* API documentation, method listing, and example GISTs at:
* http://openstates.sunlightlabs.com/api/
*
* Base URL = http://openstates.sunlightlabs.com/api/v1
* NOTE: All GET requests to this base URL must include an 'apikey' query parameter.
*
* My API key looks like this "/districts/tx?apikey=350284d0c6af453b9b56f6c1c7fea1f9"
*
* Resource Path Examples:
@grgcombs
grgcombs / gist:1250824
Created September 29, 2011 14:24
RKTableViewSections from @jeffarena
// This would be inserted somewhere in your app-wide tableviewcontroller superclass configuration, to reap the benefits across all subsequent tables.
self.tableController.heightForHeaderInSection = 22;
self.tableController.onViewForHeaderInSection = ^UIView*(NSUInteger sectionIndex, NSString* sectionTitle) {
UIView* headerView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.bounds.size.width, 22)] autorelease];
headerView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"sectionheader_bg.png"]];
UILabel* label = [[UILabel alloc] initWithFrame:CGRectMake(5, 0, self.tableView.bounds.size.width, 22)];
label.text = sectionTitle;
label.textColor = [UIColor whiteColor];
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont boldSystemFontOfSize:12];
@kwylez
kwylez / gist:1348851
Created November 8, 2011 19:30
Loading Local UIWebView with GCD
UIWebView *webView = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].bounds];
webView.delegate = self;
webView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin;
NSURL *htmlPath = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"about" ofType:@"html"]isDirectory:NO];
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
dispatch_async(queue, ^{
//
// MNDocumentController.h
// MindNodeTouch
//
// Created by Markus Müller on 22.12.08.
// Copyright 2008 Markus Müller. All rights reserved.
//
#import <Foundation/Foundation.h>
@class MNDocumentReference;
@steipete
steipete / DrawInsetBeveledRoundedRect.m
Created December 17, 2011 10:00
DrawInsetBeveledRoundedRect
void DrawInsetBeveledRoundedRect( CGContextRef context, CGRect rect, CGFloat radius, UIColor *fillColor )
{
//contract the bounds of the rectangle in to account for the stroke
CGRect drawRect = CGRectInset(rect, 1.0f, 1.0f);
//contract the height by 1 to account for the white bevel at the bottom
drawRect.size.height -= 1.0f;
//Save the current state so we don't persist anything beyond this operation
CGContextSaveGState(context);