This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* The first commented line is your dabblet’s title | |
*/ | |
background: #f06; | |
background: linear-gradient(45deg, #f06, yellow); | |
min-height: 100%; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[NSNumber numberWithInt:[@"12345" intValue]]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Blink | |
Turns on an LED on for one second, then off for one second, repeatedly. | |
This example code is in the public domain. | |
*/ | |
void setup() { | |
// initialize the digital pin as an output. | |
// Pin 13 has an LED connected on most Arduino boards: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Fade | |
This example shows how to fade an LED on pin 9 | |
using the analogWrite() function. | |
This example code is in the public domain. | |
*/ | |
int brightness = 0; // how bright the LED is |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/****************************************************** | |
Arduino EEPROM Read-Write Test | |
by Ted Hayes 2012 | |
[email protected] | |
Demonstrates the usage of the EEPROM Library for checking the state of a single value, | |
changing it, and resetting it. To use: | |
1) Put a momentary switch between ground and pin 11 on your Arduino. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AA = Rickard Stark (M) AB = Eddard Stark (M) AC = Catelyn Tully (F) | |
AD = Brandon Stark (M) AE = Benjen Stark (M) AF = Jon Snow (M) | |
AG = Robb Stark (M) AH = Sansa Stark (F) AI = Arya Stark (F) | |
AJ = Bran Stark (M) AK = Rickon Stark (M) AL = Hoster Tully (M) | |
AM = Minisa Whent (F) AN = Edmure Tully (M) AO = Lysa Tully (F) | |
AP = Jon Arryn (M) AQ = Robert Arryn (M) AR = Tytos Lannister (M) | |
AS = Tywin Lannister (M) AT = Joanna Lannister (F) AU = Kevan Lannister (M) | |
AV = Cersei Lannister (F) AW = Jamie Lannister (M) AX = Tyrion Lannister (M) | |
AY = Robert Baratheon (M) AZ = Joffrey Baratheon (M) BA = Myrcella Baratheon (F) | |
BB = Tommen Baratheon (M) BC = Lancel Lannister (M) BD = Steffon Baratheon (M) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSString *someScript = [[NSBundle mainBundle] pathForResource:@"some_script" ofType:@"osascript"]; | |
NSString *contents = [NSString stringWithContentsOfFile:someScript encoding:NSUTF8StringEncoding error:nil]; | |
NSAppleScript *script =[[NSAppleScript alloc] initWithSource:contents]; | |
[script executeAndReturnError:nil]; |