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
import urllib2 | |
import csv | |
FIRST_LINE = 11 | |
LAST_LINE = 38 | |
def get_level(l): | |
for i, char in enumerate(l): | |
if char != " ": | |
break |
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 f(x): | |
return x**2 |
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
library(lme4) | |
library(ggplot2) | |
library(XML) | |
# grab the NFL data & compute the score difference (Home - Away) | |
nfl.raw <- read.csv("http://www.repole.com/sun4cast/stats/nfl2011stats.csv") | |
nfl.raw$delta <- with(nfl.raw, (ScoreOff - ScoreDef)) | |
# fit the model | |
m <- lmer(delta ~ (1 | TeamName) + (1|Opponent), data = nfl.raw) |
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
# John Horton | |
# www.john-joseph-horton.com | |
# Description: Answer to Quora question about machine learning hourly rates | |
# "http://www.quora.com/Machine-Learning/What-do-contractors-in-machine-learning-charge-by-the-hour" | |
from BeautifulSoup import BeautifulSoup | |
import urllib2 | |
def contractors(skill, offset): |
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
df$s.star <- with(df, log(-c/log(1-q))/log(1-q)) | |
df$s.star[df$s.star < 0] <- 0 | |
g.optimal <- ggplot(df, aes(x = q, y = s.star, colour=factor(c))) + geom_line(aes(group=factor(c))) + | |
xlab("Probability that an application is successful") + | |
ylab("Optimal number of applications to send") | |
png("optimal_apps.png") | |
print(g.optimal) | |
dev.off() |
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
import networkx as nx | |
import matplotlib.pyplot as plt | |
relationships = { | |
'cats':['cute', 'clean', 'curious', 'lazy'], | |
'children':['cruel', 'happy', 'mean', 'stupid'], | |
'cows':['fat', 'sacred to hindus', 'stupid', 'sacred'], | |
'dogs':['loyal', 'cute', 'loving', 'happy'], | |
'frogs':['happy', 'slimy', 'important', 'sensitive to pollution'], | |
'goldfish':['dirty', 'good', 'addicting', 'hard to keep alive'], |
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
(add-to-list 'load-path "~/.emacs.d/") | |
(add-to-list 'load-path (expand-file-name "~/elisp/org-mode/lisp")) | |
(add-to-list 'auto-mode-alist '("\\.\\(org\\ |org_archive\\|txt\\)$" . org-mode)) | |
(setq org-agenda-files '("/tmp/test.org")) | |
(require 'org-install) | |
(require 'org-habit) | |
(global-set-key "\C-cl" 'org-store-link) | |
(global-set-key "\C-ca" 'org-agenda) |
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
library(ggplot2) | |
library(sqldf) | |
# using the dataset 'raw' wich is a list of contractors by lat, long | |
df <- sqldf("SELECT COUNT(*) AS num, LocLat, LocLong | |
FROM raw GROUP BY LocLat, LocLong") | |
g <- qplot(LocLong,LocLat, colour=num, size=log(num), data = df) | |
png("india.png") | |
print(g) | |
dev.off() |
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
get.sql.out <- function(file, nrows = -1){ | |
raw <- read.table(file, header=TRUE, nrow = nrows, sep="|", fill=TRUE, strip.white=TRUE) | |
num.rows <- dim(raw)[1] | |
raw$index <- 1:num.rows | |
raw <- subset(raw, index != 1 & index != num.rows) | |
raw | |
} |
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
#!/bin/bash | |
cp $1 ~/Dropbox/Public/ | |
echo "http://dl.dropbox.com/u/<your id>/"$1 | xclip -i -selection clipboard |