Skip to content

Instantly share code, notes, and snippets.

@dggoldst
dggoldst / w2num.py
Created January 19, 2012 15:55
Generate a number for every English word via the digit sound method. See http://www.decisionsciencenews.com/2012/01/17/some-code-to-help-you-remember-numbers/
#!/usr/bin/python
# -*- coding: utf-8 -*-
import re
fh = open('cmudict-0.4.scm', 'r')
adict = {}
wl = open('wordlist.txt')
line = wl.readline()
while line:
line = line.strip()
@dggoldst
dggoldst / find.py
Created January 19, 2012 16:23
Given a long number, generate mnemonics using the digit-sound system, per http://www.decisionsciencenews.com/2012/01/17/some-code-to-help-you-remember-numbers/
#!/usr/bin/python
# -*- coding: utf-8 -*-
import re
from cStringIO import StringIO
from sys import argv
import random
mstr = str(argv[1])
adict = {}
wl = open('wordNum.txt')
mstr = '123456789' #Enter string to translate here
wordNum <- read.delim("~/bin/memory/wordNum.txt",
colClasses=c("character","character"),header=F)
dict<-new.env()
buildDict=function(word,num){
dict[[num]]<- paste(word,dict[[num]],sep=" ")
}
foo=mapply(buildDict,wordNum$V1,wordNum$V2)
rec <- function(x, y) {
if (is.null(x)) return;
library(ggplot2)
library(dplyr)
library(reshape2)
df=structure(list(Year = c(2013L, 2012L, 2011L, 2010L, 2009L, 2008L,
2007L, 2006L, 2005L, 2004L, 2003L, 2002L, 2001L, 2000L, 1999L,
1998L, 1997L),
City = structure(c(14L, 8L, 12L, 13L, 1L, 2L,
6L, 4L, 14L, 8L, 15L, 5L, 10L, 9L, 7L, 3L, 11L),
.Label = c("Boston", "Chicago", "Dallas", "Houston", "Kansas City", "Long Beach",
library(dplyr)
df=read.csv("directory.csv.gz")
df$dept2=tolower(df$dept)
df$dept2[grep("psych",df$dept2)]="Psychology"
df$dept2[grep("marketing",df$dept2)]="Marketing"
df$dept2[grep("economics",df$dept2)]="Economics"
df$dept2[df$dept2=="management"]="Management"
df$dept2[df$dept2=="management department"]="Management"
setwd("C:/Dropbox/Projects/20141002_SJDM_Member_Dir/")
library("dplyr")
library("maps")
library("ggplot2")
library("mapproj")
theme_clean <- function(base_size = 12) {
require(grid)
theme_grey(base_size) %+replace%
library("dplyr")
library("maps")
library("ggplot2")
library("mapproj")
theme_clean <- function(base_size = 12) {
require(grid)
theme_grey(base_size) %+replace%
theme(
axis.title = element_blank(),
library(ggplot2)
library(dplyr)
AGEMIN=30
AGEMAX=110
NR=AGEMAX-AGEMIN+1
best_ABSDEV=1e6
#If you want the original data, you can get it from
#http://www.ssa.gov/OACT/STATS/table4c6.html
library(Lahman)
library(plyr)
library(dplyr)
library(ggplot2)
master = Lahman::Master %>%
select(playerID,birthYear)
bstats <- battingStats() %>%
select(playerID, yearID,BA)
#data from http://www.transtats.bts.gov/DL_SelectFields.asp?Table_ID=236&DB_Short_Name=On-Time
#Ask for these fields
#"DAY_OF_WEEK" (IN UI DayOfWeek)
#"FL_DATE" (FlightDate)
#"CARRIER" (Carrier)
#"ORIGIN_CITY_MARKET_ID" (OriginCityMarketID)
#"ORIGIN" (Origin)
#"CRS_DEP_TIME" (CRSDepTime)
#"DEP_DELAY" (DepDelay)
#"ARR_DELAY" (ArrDelay)