Skip to content

Instantly share code, notes, and snippets.

/*
http://arduino.cc/en/Tutorial/AnalogInput
*/
#define SENSOR_PIN A0 // select the input pin for the potentiometer
#define NUM_PINS 8
#define START_PIN 1
int pin_interval;
@KentaAkimoto
KentaAkimoto / gist:3227521
Created August 1, 2012 14:55
NSString -> NSNumber
[NSNumber numberWithInt:[@"12345" intValue]];
@raulandrisan
raulandrisan / dabblet.css
Created August 1, 2012 14:34
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
@Kevinwlee
Kevinwlee / gist:3226002
Created August 1, 2012 11:31
Date stuff
- (NSString *)currentDateString {
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"d"];
NSString *day = [df stringFromDate:self.currentDate];
return day;
}
- (NSString *)currentMonthString {
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"MMMM"];
NSString *day = [df stringFromDate:self.currentDate];
@bil-bas
bil-bas / gist:3221023
Created July 31, 2012 21:57
Random hash picker
heftig:
first, do target = rand(a.inject(0){|m,h| m + h[:prob]})
to get a value between 0 and (sum of all probs - 1)
then just a.find { |h| target -= h[:prob]; target < 0 }
steps through the array, reducing target by prob until it's < 0
@aaronjensen
aaronjensen / gist:3220780
Created July 31, 2012 21:34
tmux agenda
* What is tmux?
* Why tmux?
* tmux vs screen: http://www.wikivs.com/wiki/Screen_vs_tmux
* Install tmux
* brew install tmux
* tmux basics
* leader key (default sucks)
* sessions
* windows
* panes
@jwilling
jwilling / JWLocationManager.h
Created July 31, 2012 20:02
Block-based wrapper around Core Location
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
typedef void (^JWLocationManagerCallback)(CLLocation *location);
typedef void (^JWLocationManagerErrorCallback)(NSError *error);
@interface JWLocationManager : NSObject <CLLocationManagerDelegate>
@property (nonatomic, copy) NSString *purpose;
@property (nonatomic, copy) JWLocationManagerCallback locationUpdatedBlock;
@harperreed
harperreed / peter-thiels-cs183-startup-class-01-notes-essay.md
Created July 29, 2012 21:20
Notes Essays—Peter Thiel’s CS183: Startup—Stanford, Spring 2012

Here is an essay version of my class notes from Class 1 of CS183: Startup. Errors and omissions are my own. Credit for good stuff is Peter’s entirely.

CS183: Startup—Notes Essay—The Challenge of the Future

Purpose and Preamble

@mikeabdullah
mikeabdullah / gist:3200382
Created July 29, 2012 17:22
Power assertion example
// Begin the power assertion
IOPMAssertionID assertionID;
IOReturn asserted = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoIdleSleep,
kIOPMAssertionLevelOn,
CFSTR("Sandvox Publishing"),
&assertionID);
if (asserted != kIOReturnSuccess) // handle the error; log it or something
// Do your long-running work