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
# http://www.movable-type.co.uk/scripts/latlong.html | |
# Destination point given distance and bearing from start point | |
# Radius of earth | |
R=6371 | |
# Return the lat2 & lon2 of a point at distance d and | |
# bearing brng from an initial point wt coords lat1 & lon1 | |
def coords_at_dist lat1, lon1, d, brng | |
# lat1 => latitude at initial point |
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
#lang racket | |
(define (Pt x y) | |
(let ([self 0]) | |
(begin | |
(define (obj method) | |
(case method | |
[("getX") (lambda () x)] | |
[("getY") (lambda () y)] | |
[("moveX") (lambda (newx) (Pt (+ newx ((self "getX"))) y))])) |
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
#lang racket | |
(define (isort cs) | |
(define (insert x xs) | |
(cond [(empty? xs) (list x)] | |
[else (if (< x (first xs)) | |
(cons x xs) | |
(cons (first xs) (insert x (rest xs))))])) | |
(cond [(empty? cs) cs] | |
[else (insert (first cs) (isort (rest cs)))])) |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
// A class is used to mint new objects. The class here is used to create new car objects | |
// in the program. You may think of it as a car factory. | |
// Classes specify methods and attributes. | |
// Methods define operations that can be performed on (or by) an object: a car in this case. | |
// The methods defined in this Car class are "move" and "turn". See the comments written for | |
// each method for info on their functions. | |
// Attributes indicate well... attributes of objects. They help ho"ld the state of the object | |
// at any given instance. The attributes for the car are "location", "brand", "model", and "direction". | |
// Silly silly old Car |
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
awk -F '\t' -v rec=5 '{a[$rec]+=1; sum+=1} END{for(k in a) print k, ":", a[k] "(freq),", a[k]/sum "(prop)"; print "sum:", sum}' file.txt |
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
from distutils.sysconfig import get_python_lib | |
print(get_python_lib()) |
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 (fact n) | |
(cond ((= n 0) 1) | |
(else (* n (fact (- n 1)))))) | |
(fact 5) |
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 scala.language.implicitConversions | |
import scala.language.reflectiveCalls | |
// implicit def lilRock(foo : Int) = new { def mustEqual(actual : Int) : Boolean = actual == foo } | |
class Baz(actual: Int) { | |
def mustEqual(expected : Int) : Boolean = actual == expected | |
def mustBeGreaterThan(expected : Int) : Boolean = actual > expected | |
} |
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
#!/usr/bin/env ruby | |
error_message = "Must be run from the root directory of a rails app." | |
abort(error_message) unless File.exist?("config/database.yml") | |
app_name = Dir.pwd.split("/")[-1] | |
dev_db = app_name + "_dev" | |
test_db = app_name + "_test" | |
if ARGV[0] == '--delete' | |
`dropdb #{dev_db} && dropdb #{test_db}` |
NewerOlder