Skip to content

Instantly share code, notes, and snippets.

View chrishulbert's full-sized avatar

Chris Hulbert chrishulbert

View GitHub Profile
@chrishulbert
chrishulbert / MyButton.m
Last active December 5, 2015 09:41
UIButton subclass
// How to subclass UIButton, given that it uses a static constructor so you can't override init.
@interface MyButton : UIButton
...
@end
@implementation MyButton
+ (instancetype)buttonWithType:(UIButtonType)buttonType {
MyButton *button = [super buttonWithType:buttonType];
@chrishulbert
chrishulbert / com.plex.plexconnect.plist
Created June 13, 2013 11:08
Launchctl startup script for plex connect
<?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>com.plex.plexconnect</string>
<key>WorkingDirectory</key>
<string>/Users/chris/PlexConnect</string>
<key>ProgramArguments</key>
@chrishulbert
chrishulbert / LocationHelper.m
Created May 7, 2012 12:11
Blocks location helper for finding a very rough location on an iphone
//
// LocationHelper.m
//
// Created by Chris Hulbert on 24/04/12.
//
#import "LocationHelper.h"
@interface LocationHelper()
@property(copy) LocationBlock locationBlock;
@chrishulbert
chrishulbert / LocationHelper.h
Created May 7, 2012 12:11
Blocks location helper for finding a very rough location on an iphone
//
// LocationHelper.h
//
// Created by Chris Hulbert on 24/04/12.
//
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#define locationHelperPurpose @"This app would like to know your location for some good reason." // Change this!
@chrishulbert
chrishulbert / Helper.h
Created April 17, 2012 12:31
Styling grouped table views
//
// Helpers.h
//
// Created by Chris Hulbert on 17/04/12.
//
#import <UIKit/UIKit.h>
@interface Helpers : NSObject
@chrishulbert
chrishulbert / Helpers.m
Created April 17, 2012 12:31
Helper to style grouped table views on the iphone
//
// Helpers.m
//
// Created by Chris Hulbert on 17/04/12.
//
#import "Helpers.h"
@implementation Helpers
@chrishulbert
chrishulbert / launchdexample.xml
Created February 21, 2012 10:13
launchd example plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.mycompanyname.mydepartment.mytaskname</string>
<key>ProgramArguments</key>
<array>
<string>/Users/myuser/Dashboard/mytask.sh</string>
</array>
@chrishulbert
chrishulbert / DictionaryTypesHelper.m
Created November 30, 2011 02:49
Dictionary Types Helper
// DictionaryTypesHelper.h
#import <Foundation/Foundation.h>
@interface NSDictionary (NSDictionary_DictionaryTypesHelper)
- (NSArray*)arrayForKey:(id)key;
- (NSDictionary*)dictionaryForKey:(id)key;
- (NSString*)stringForKey:(id)key;
- (NSNumber*)numberForKey:(id)key;
- (NSData*)dataForKey:(id)key;
@chrishulbert
chrishulbert / ADXL345.c
Created September 24, 2011 06:23
Read ADXL345 accelerometer on arduino
#include <Wire.h>
#define DEVICE (0x53) // ADXL345 device address when the SDO pin (12) is grounded
void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(115200); // start serial for output
// Wake up the accelerometer
@chrishulbert
chrishulbert / progressbar.m
Created August 22, 2011 10:18
Progress bar in your navigation bar
// Display a progressbar
- (void)progress:(int)progress withMessage:(NSString*)message {
UIView* v = [[[UIView alloc] init] autorelease];
v.frame = CGRectMake(0, 0, 200, 30);
v.backgroundColor = [UIColor clearColor];
UILabel* lbl = [[[UILabel alloc] init] autorelease];
lbl.frame = CGRectMake(0,0, 200, 15);
lbl.backgroundColor = [UIColor clearColor];
lbl.textColor = [UIColor whiteColor];