This file contains 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
require 'rubygems' | |
require 'net/http' | |
require 'json' | |
require 'date' | |
if ARGV[0] | |
username = ARGV[0] | |
else | |
abort("You must supply a Fitocracy username.") | |
end |
This file contains 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
import random | |
if random.randint(0,1): | |
(True,False) = (False,True) |
This file contains 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
char input = 0; | |
int blue = 9; | |
int red = 10; | |
int green = 11; | |
void setup() { | |
// put your setup code here, to run once: | |
Serial.begin(9600); | |
delay(100); |
This file contains 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
def from(n: Int): Stream[Int] = n #:: from(n + 1) | |
def sieve(s: Stream[Int]): Stream[Int] = s.head #:: sieve(s.tail filter (_ % s.head != 0)) | |
val primes = sieve(from(2)) | |
primes.take(10).toList // produces first 10 primes | |
primes.take(100).toList // produces first 100 primes |
This file contains 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
fs.project.template.fields.map{ |x| fs.field_values.select{|fv| fv.field == x }.map{|fv| {x.name => fv.string_value}}} |
This file contains 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
#define trigPin 13 | |
#define echoPin 12 | |
#define tonePin 8 | |
#define ledPin 7 | |
#define keyPin 0 | |
#include "notes.h" | |
const int threshold = 200; | |
int notes[] = { NOTE_B0,NOTE_C1,NOTE_CS1,NOTE_D1,NOTE_DS1,NOTE_E1,NOTE_F1,NOTE_FS1,NOTE_G1,NOTE_GS1,NOTE_A1,NOTE_AS1,NOTE_B1,NOTE_C2,NOTE_CS2,NOTE_D2,NOTE_DS2,NOTE_E2,NOTE_F2,NOTE_FS2,NOTE_G2,NOTE_GS2,NOTE_A2, NOTE_AS2,NOTE_B2, NOTE_C3, NOTE_CS3,NOTE_D3, NOTE_DS3,NOTE_E3, NOTE_F3, NOTE_FS3,NOTE_G3, NOTE_GS3,NOTE_A3, NOTE_AS3,NOTE_B3, NOTE_C4, NOTE_CS4,NOTE_D4, NOTE_DS4,NOTE_E4, NOTE_F4, NOTE_FS4,NOTE_G4, NOTE_GS4,NOTE_A4, NOTE_AS4,NOTE_B4, NOTE_C5, NOTE_CS5,NOTE_D5, NOTE_DS5,NOTE_E5, NOTE_F5, NOTE_FS5,NOTE_G5, NOTE_GS5,NOTE_A5, NOTE_AS5,NOTE_B5, NOTE_C6, NOTE_CS6, NOTE_D6, NOTE_DS6, NOTE_E6, NOTE_F6, NOTE_FS6, NOTE_G6, NOTE_GS6, NOTE_A6, NOTE_AS6, NOTE_B6, NOTE_C7, NOTE_CS7, NOTE_D7, NOTE_DS7, NOTE_E7, NOTE_F7, NOTE_FS7, NOTE_G7, NOTE_GS7, NOTE_A7, NOTE_AS7, NOTE_B7, NOTE_C8, NOTE_CS8, NOTE_D8, NOTE_DS8 }; |
This file contains 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
class Struct | |
def self.new_singleton(name, *fields) | |
if Struct::const_defined?(name) | |
Struct.const_get(name) | |
else | |
Struct.new(name, *fields) | |
end | |
end | |
end |
This file contains 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
git pull -r # pull with rebase instead of merge | |
rspec -c -fd # run rspec tests with color, verbose output | |
######################### | |
# Sane Ruby Setup on OSX | |
# Install X-Code Command Line Tools | |
xcode-select --install | |
# Install Home Brew |
This file contains 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
class Node | |
getter name, edges | |
def initialize(@name : String) | |
@edges = {} of Node => Float64 | |
end | |
def add_edge(node, weight) | |
@edges[node] = weight | |
end |
This file contains 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
# this works! | |
🐙 = 8 | |
puts 🐙 | |
#> 8 | |
# this doesn't work | |
class 🍕 | |
def eat |
OlderNewer