Skip to content

Instantly share code, notes, and snippets.

View msszczep's full-sized avatar

Mitchell Szczepanczyk msszczep

View GitHub Profile
@msszczep
msszczep / gist:5d15b2ad8efa4faebdca
Created February 20, 2016 02:27
What are the most frequently used letters in English?
(->> (slurp "ni2.txt")
clojure.string/split-lines
(map clojure.string/lower-case)
(map #(map char %))
flatten
frequencies
(map #(vector (key %)
(read-string
(format "%.2f" (* 100 (/ (val %) 2251877.0))))))
(sort-by last)
@msszczep
msszczep / gist:f327c2f46d1503361a1b
Created March 10, 2016 03:38
Two hard problems
for (i=0; i< 2; i++) {
if (i == 0) {printf "naming";}
if (i == 1) {invalidate_cache;}
if (i == 2) {printf "off by 1 error";}
}
@msszczep
msszczep / jfile.html
Created March 28, 2016 18:09
Map of Jeopardy! airtimes across USA
<html>
<head>
<script type='text/javascript' src='https://www.google.com/jsapi'></script>
<script type='text/javascript'>
google.load('visualization', '1', {'packages': ['geochart']});
google.setOnLoadCallback(drawMarkersMap);
function drawMarkersMap() {
var data = google.visualization.arrayToDataTable([
['City', 'Time', 'Size'],
#!/usr/bin/python
# Source: http://ubuntuforums.org/showthread.php?t=1215158
import urllib2
import sys
from BeautifulSoup import BeautifulSoup
file = sys.argv[1]
# assumes file is a list of valid URLs, one URL per line
@msszczep
msszczep / gist:52fe8c2ab63065793dca
Last active April 22, 2016 01:31
Wikipedia Wordcloud in Wolfram
CloudDeploy[FormFunction[{"article" -> "String"},Show[WordCloud[DeleteStopwords[WikipediaData[#article]], ImageSize -> Large]] &,
"GIF", AppearanceRules -> <|"Title" -> "Wikipedia Wordcloud", "Description" -> "Type in the name of a Wikipedia article
and get a word cloud of the article."|>, FormTheme -> "Blue" ], Permissions->"Public"]
https://www.wolframcloud.com/objects/f7615524-b20b-4427-b4fa-ac4dec8dd651
@msszczep
msszczep / gist:710dafcd2d0119e934759a71fd6f1af1
Created May 4, 2016 04:18
Wolfram Language: NYTimes Noun Wordcloud
CloudDeploy[WordCloud[Flatten[TextCases[StringCases[URLFetch["www.nytimes.com"], Shortest["<p class=\"summary\" ~~ x__ ~~ "</p>"] -> x], "Noun"]]]]
https://www.wolframcloud.com/objects/aad30d4c-cce8-45c2-b0c3-afa03f606f64
@msszczep
msszczep / gist:5b55a9f87e8941d58a63e27a1a613e5b
Last active May 7, 2016 13:24
Dead or Not Dead (in Wolfram Language)
CloudDeploy[APIFunction[{"p" -> "String"}, DateString[Interpreter["Person"][#p]["DeathDate"], {"MonthName", " ", "DayShort", ", ", "Year"}] &]]
-- e.g., https://www.wolframcloud.com/objects/29dd4c7b-77f3-49ff-84be-fc557ddfc9a0?p=Michael+Jackson
-- https://www.wolframcloud.com/objects/fa2cf38e-b000-4762-b249-8d19bfaef1a0?p=Doris+Day
CloudDeploy[APIFunction[{"p" -> "String"}, Which[
FailureQ[Interpreter["Person"][#p]],
"I'm sorry, but I cannot determine that.",
MissingQ[Interpreter["Person"][#p]["DeathDate"]],
StringJoin[#p, " is still alive, and is ", ToString[Floor[DateDifference[Interpreter["Person"][#p]["BirthDate"], Now, "Year"]]], " old." ],
@msszczep
msszczep / gist:daff445a6d7107d31933a72c7e21a2f6
Created May 26, 2016 00:19
Notes From React/Trivia Meetup (May 25, 2016)
Round {question: {}, responses: []} // initial state
Actions Actions {answerQuestion(choice) advanceQuestion()}
Redux Act
@msszczep
msszczep / gist:d74014b94eb6220f8c8289179ba69349
Created July 28, 2016 15:46
Wolfram Language code and list of English words classified as Noun, Verb, AND Adjective
Intersection[WordData[All, "Verb"], WordData[All, "Noun"], WordData[All, "Adjective"]]
{abstract,ace,ad-lib,advance,agglomerate,aggregate,alert,alien,alternate,antic,antique,arch,associate,average,azure,back,backhand,bankrupt,base,
bay,beat,beetle,best,better,bias,birch,bitter,black,blame,blank,blanket,blind,blindfold,blue,bluff,bombproof,bone,bootleg,boss,bottom,bound,
brag,brave,brief,broadside,bronze,brown,buckram,buff,bully,bum,burlesque,bush,bust,calm,camp,carmine,center,champion,chance,charcoal,
chelate,clarion,clean,clear,close,cod,collect,color,colour,compact,compound,concrete,confederate,conglomerate,conjugate,content,converse,cool,
coordinate,correlate,counter,counterfeit,crack,crackle,crank,crescendo,crimson,crisp,crisscross,cross,cut,damascene,damn,damp,deaf,
decrescendo,degenerate,deviate,discontent,divine,double,down,dread,dress,dry,dummy,dun,duplex,duplicate,elect,empty,equal,even,express,
faint,fair,fake,fancy,fast,fat,fell,fine,firm,fit,flagellate,flash,fleet,flip,flush,fly,forfeit,forward
@msszczep
msszczep / subanagram.pl
Created August 22, 2016 09:18
Subanagram Generator in Perl, version 1
#!/usr/local/bin/perl
# subanagram.pl
# This program receives as input an English word, and then
# delivers as output those English words which can be spelled with the
# letters in the input word.
# This script is Copyleft 2002 by Mitchell Szczepanczyk under the
# terms of the General Public License. Anyone is free to copy, modify,