Skip to content

Instantly share code, notes, and snippets.

View sgwizdak's full-sized avatar

Sean Gwizdak sgwizdak

View GitHub Profile
@sgwizdak
sgwizdak / FKPresidents.txt
Created November 23, 2011 07:10
F-K of all Presidents
abrahamlincoln 11.22
andrewjackson 18.56
andrewjohnson 14.73
benjaminharrison 15.99
billclinton 9.18
chesterarthur 16.36
coolidge 12.60
eisenhower 11.28
franklinpierce 18.55
franklinroosevelt 11.08
@sgwizdak
sgwizdak / fk-repubs.txt
Created November 23, 2011 07:01
F-K scores for Republican Presidential Candidates
bachmann:
Flesh-Kincaid Grade Level: 8.47
Flesh Reading Ease Score: 65.88
Sentences: 232
Words: 4,113
Averaage Syllables per Word: 1.45
Average Words per Sentence: 17.73
cain:
@sgwizdak
sgwizdak / wordCloud.r
Created November 10, 2011 06:10
WordCloud
require(tm)
require(wordcloud)
require(RColorBrewer)
presidentplot <- function(president)
{
u <- Corpus(DirSource(paste("/Users/someuser/projects/blog/presidents/txt/", president, sep="", collapse="")), readerControl = list(reader = readPlain))
ap.corpus <- tm_map(u, removePunctuation)
ap.corpus <- tm_map(ap.corpus, tolower)
ap.corpus <- tm_map(ap.corpus, function(x) removeWords(x, stopwords("english")))
@sgwizdak
sgwizdak / gatherSpeeches.sh
Created November 10, 2011 06:07
gatherSpeeches.sh
#!/bin/bash
BASEDIRECTORY="/Users/someuser/projects/blog/presidents/txt"
# Make it as non-html as possible and save the file in .txt
function cleanup() {
awk '/\/article/{f=0}/div id=transcript class=indent>/{f=1;next}f' $1 | sed 's/<div>//g' | sed 's/<\/div>//g' | sed 's/<p>//g' | sed 's/<\/p>//g' | sed 's/&nbsp;//g' | sed 's/<br\/>//g' | sed 's/mdash;//g' > $1.txt
}
function get_speech() {
@sgwizdak
sgwizdak / mathematicaMandelbrot.nb
Created November 8, 2011 04:24
Mathematica Mandelbrot
Mandelbrot[c_] := Module[{z = 0, i = 0}, While[i < 100 && Abs[z] < 2, z = z^2 + c; i++]; i];
DensityPlot[Mandelbrot[xc + I yc], {xc, -2, 1}, {yc, -1.5, 1.5},
PlotPoints -> 275, Mesh -> False, Frame -> False,
ColorFunction -> (If[# != 1, Hue[#], Hue[0, 0, 0]] &)]