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
class ReportCard | |
def initialize(print_strategy) | |
@print_strategy = print_strategy.new | |
@grades = Hash.new | |
end | |
def add_grade(subject, grade) | |
@grades[subject] = grade | |
end |
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
ANTELOPES = [:addax,:antelope,:antilopine,:ariel,:blackbuck,:blaubok,:bluebuck,:bloubok,:blesbok,:blesbuck,:bok,:bongo,:bontebok,:boschbok,:boshbok,:bosbok,:bubal,:bubale,:bubalis,:bubaline,:cabrie,:cabrit,:chamois,:chikara,:chinkara,:chiru,:dikdik,:duiker,:duyker,:duikerbok,:dzeren,:eland,:gazelle,:gemsbok,:gemsbuck,:gerenuk,:gnu,:goa,:gooral,:goral,:grysbok,:hartbees,:hartebeest,:hartbeest,:impala,:inyala,:nyala,:kaama,:klipspringer,:kob,:kongoni,:koodoo,:kudu,:lechwe,:madoqua,:marshbuck,:mhorr,:mohr,:nagor,:nilgai,:nilgau,:nilghai,:nilghau,:nylghai,:nylghau,:oribi,:ourebi,:oryx,:palebuck,:pallah,:prongbuck,:pronghorn,:puku,:pygarg,:reebok,:rhebok,:reedbuck,:reitbok,:saiga,:sasin,:sassaby,:tsessebe,:serow,:shamois,:sitatunga,:situtunga,:springbok,:springbuck,:steenbok,:steinbok,:steinbock,:stembok,:stembuck,:steenbuck,:thar,:topi,:tragelaph,:antelope,:antilopine,:ariel,:blackbuck,:blaubok,:bluebuck,:bloubok,:blesbok,:blesbuck,:bok,:bongo,:bontebok,:boschbok,:boshbok,:bosbok,:bubal,:bubale,:bubalis,:bubaline |
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
; SICP Exercise 1.1 | |
10 => 10 | |
(+ 5 3 4) => 12 | |
(- 9 1) => 8 | |
(/ 6 2) => 3 | |
(+ (* 2 4) (- 4 6)) => 6 | |
(define a 3) | |
(define b (+ a 1)) | |
(+ a b (* a b)) => 19 |
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
; SICP Exercise 1.8 | |
#lang racket | |
(define (cube-root x) | |
(define (square y) (* y y)) | |
(define (good-enough? guess) | |
(< (abs (- (square guess) x)) 0.001)) | |
(define (improve guess) | |
(/ (+ (square (/ guess x)) (* 2 guess))) 3) |
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
def add(m, n) | |
total = m | |
for i in 1..n do | |
total += 1 | |
end | |
total | |
end | |
def exp(m, n) | |
total = 1 |
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
#include <stdio.h> | |
#include <string.h> | |
#define MAXLEN 256 | |
void reverse(char *s, char *r); | |
main() { | |
char s[MAXLEN] = "hello reversed world!"; | |
char r[MAXLEN]; |
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
# based on Heroku's documentation | |
require './streaming' | |
run Sinatra::Application |
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
$ pwd | |
/Users/gar/code/chef-repo | |
$ knife client list | |
tangleofwire-validator | |
$ diff client-config/validation.pem /etc/chef/validation.pem | |
$ diff client-config/validation.pem .chef/tangleofwire-validator.pem | |
$ sudo chef-client | |
[2012-08-11T12:05:26+01:00] INFO: *** Chef 10.12.0 *** | |
[2012-08-11T12:05:28+01:00] INFO: Client key /etc/chef/client.pem is not present - registering | |
[2012-08-11T12:05:29+01:00] INFO: HTTP Request Returned 403 Forbidden: Merb::ControllerExceptions::Forbidden |
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
13.591438 seconds on ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-linux] | |
6.887000 seconds on jruby 1.7.12 (1.9.3p392) 2014-04-15 643e292 on OpenJDK 64-Bit Server VM 1.7.0_55-b14 [linux-amd64] | |
24.593889 seconds on rubinius 2.2.6 (2.1.0 68d916a5 2014-03-10 JI) [x86_64-linux-gnu] |
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
(ns luhn) | |
(defn last-digit [n] | |
(mod n 10)) | |
(defn drop-last-digit [n] | |
(long (/ n 10))) | |
(defn to-rev-digits | |
([n] (to-rev-digits n [])) |
OlderNewer