Skip to content

Instantly share code, notes, and snippets.

View robbrit's full-sized avatar
🏠
Working from home

Rob robbrit

🏠
Working from home
View GitHub Profile
@robbrit
robbrit / gist:33610
Created December 8, 2008 21:04 — forked from edward/gist:32225
class Hash
def except(*blacklist)
self.reject {|key, value| blacklist.include?(key) }
end
def only(*whitelist)
self.reject {|key, value| !whitelist.include?(key) }
end
end
require 'benchmark'
require 'andand'
class Hash
def except(*blacklist)
{}.tap do |h|
(keys - blacklist).each { |k| h[k] = self[k] }
end
end
#include <SDL/SDL.h>
#include <SDL/SDL_thread.h>
#include <cmath>
#include <iostream>
using namespace std;
double scale = 1.0;
double x_offset = 0.0, y_offset = 0.0;
/* This program uses SDL.
* To install:
*
* sudo apt-get install libsdl1.2-dev
*
* To compile:
*
* gcc -lSDL filename.c
*
*/
#include <SDL/SDL.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#define SIZE 800
#define PRECISION 300000
struct paird{
double x, y;
#!/usr/bin/env ruby
grammar, iterations, extra = ARGV
if grammar == nil or !File.exists?(grammar)
puts "no grammar file"
exit
end
symbols = {}
data2006 <- read.csv("census2006.csv", header = TRUE)
data1986 <- read.csv("census1986.csv", header = TRUE)
# Get the CPI for 1986, 2006, and 2010
cpi2006 <- 1.091
cpi1986 <- 0.656
cpi2010 <- 1.165
calc_avg <- function(w1986, w2006, message, png_file){
# scale by CPIs to give 2010 dollars
data2006 <- read.csv("census2006.csv", header = TRUE)
data1986 <- read.csv("census1986.csv", header = TRUE)
# Get the CPI for 1986, 2006, and 2010
cpi2006 <- 1.091
cpi1986 <- 0.656
cpi2010 <- 1.165
calc_avg <- function(w1986, w2006, message, png_file){
# scale by CPIs to give 2010 dollars
[1] "Average wages for degree in education:"
[1] "Confidence for 1986: 45951.512708 to 47462.916536"
[1] "Confidence for 2006: 48453.487226 to 49640.726011"
[1] "Standard Deviation for 1986: 28759.942381"
[1] "Standard Deviation for 2006: 37696.910023"
[1] "Median Confidence for 1986: 49299.946203 to 51002.542615"
[1] "Median Confidence for 2006: 47308.440547 to 48645.865039"
[1] ""
[1] "Average wages for degree in fine arts:"
[1] "Confidence for 1986: 30804.704353 to 34896.729876"
@robbrit
robbrit / gist:1522394
Created December 27, 2011 01:14
Canadian Oil Production
oil = read.csv("oil.csv", header = T)
# convert cubic metres to barrels
total = ts(oil$Total * 6.28981077 / 1000, start = 1971, end = 2010)
t = 1:length(total)
linear = lm(total ~ t)
expn = lm(log(total) ~ t)
# do a linear model