Skip to content

Instantly share code, notes, and snippets.

View tdhopper's full-sized avatar
©️
𝔀𝓸𝓻𝓴𝓲𝓷𝓰 𝓱𝓪𝓻𝓭

Tim Hopper tdhopper

©️
𝔀𝓸𝓻𝓴𝓲𝓷𝓰 𝓱𝓪𝓻𝓭
View GitHub Profile
@tdhopper
tdhopper / create_env.sh
Created October 9, 2016 00:39
Create conda environment
query="{query}"
fn=${query// /_}
p="/Users/tdhopper/repos/distil/data_science/$fn"
mkdir $p
cd $p && source /Users/tdhopper/.bash_functions && conda-env-file
/usr/local/bin/subl -n $p $p/environment.yml
@tdhopper
tdhopper / tweets.sh
Created August 5, 2016 12:40
Find your tweets from this date in earlier years.
# Find your tweets from this date in earlier years.
# OS X's date function doesn't have the required date math capabilities.
# This requires GNU date. You can get it on OS X with `brew install coreutils`
GDATE=/usr/local/bin/gdate
USERNAME=realDonaldTrump
export URL="https://twitter.com/search?q=from%3A$USERNAME%20("
for yearsago in {1..12}; do
16:36 $ sparse run Cleaning from prior builds... Creating topology Uber-JAR... Uber-JAR created: /Users/tdhopper/repos/distil/distil-ml-storm-test/wordcount/_build/wordcount-0.0.1-SNAPSHOT-standalone.jar Removing _resources temporary directory...done [localhost] local: storm jar /Users/tdhopper/repos/distil/distil-ml-storm-test/wordcount/_build/wordcount-0.0.1-SNAPSHOT-standalone.jar org.apache.storm.flux.Flux --local --no-splash --sleep 9223372036854775807 /var/folders/4l/b_gx3vx957g8lw0g__5nz9_h0000gn/T/tmpxLIxIb.yaml SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/usr/local/Cellar/storm/1.0.0/libexec/lib/log4j-slf4j-impl-2.1.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/Users/tdhopper/repos/distil/distil-ml-storm-test/wordcount/_build/wordcount-0.0.1-SNAPSHOT-standalone.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.a
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tdhopper
tdhopper / valid_user_agents.txt
Created February 24, 2016 20:43
All user agents from useragentstring.com
This file has been truncated, but you can view the full file.
!Susie (http://www.sync2it.com/susie)
(Windows NT 6.2; WOW64) KHTML/4.11 Gecko/20130308 Firefox/23.0 (PaleMoon/20.3)
(Windows NT 6.2; WOW64) KHTML/4.11 Gecko/20130308 Firefox/33.0 (PaleMoon/25.1)
ABACHOBot
Accoona-AI-Agent/1.1.1 (crawler at accoona dot com)
Accoona-AI-Agent/1.1.2
Accoona-AI-Agent/1.1.2 (aicrawler at accoonabot dot com)
AmigaVoyager/2.95 (compatible; MC680x0; AmigaOS)
AmigaVoyager/2.95 (compatible; MC680x0; AmigaOS; SV1)
AmigaVoyager/3.2 (AmigaOS/MC680x0)
0-1 integer programming is one of the 21 problems Richard Karp showed to be NP-Complete in 1972 http://j.mp/tgXFw5
The Karush-Kuhn-Tucker conditions are necessary for an optimal solution of a nonlinear program http://j.mp/sT4FSn
When operations researchers say "programming" they're referring to optimization problems, not computer programming http://j.mp/vthdSt
"OR is the science of decision making, the science of choice." (Saul Gass and Arjang Assad)
Video lectures from Econ 159: Game Theory at Yale http://j.mp/tzDb9P
Operations research, control theory, and machine learning intersect in the study of reinforcement learning http://j.mp/s0n6uN
Linear programs have the strong duality property; that is, the optimal values of the primal and dual problems are equal
Poisson process http://j.mp/snxTcP
The impact that variability of service and inter-arrival times have in queueing systems. http://j.mp/KFkj0z
dates = """16 October 2015
16 October 2015
24 September 2015
17 September 2015
16 September 2015
15 September 2015
11 September 2015
11 September 2015
09 September 2015
08 September 2015

Hashing

  • Introduction.
    • Example
    • Uses and Importance of Hashing
  • Lookup Tables
    • Introduction
    • Implementations
    • Applications
  • Hashing in Cryptography
@tdhopper
tdhopper / antoniak.py
Last active September 15, 2015 16:37
Sample from Antoniak Distribution with Python. `rand_antoniak` draws a sample from the distribution of tables created by a Chinese restaurant process with parameter `alpha` after `n` patrons are seated. Some notes on this distribution are here: http://www.cs.cmu.edu/~tss/antoniak.pdf.
import numpy as np
from numpy.random import choice
def stirling(N, m):
if N < 0 or m < 0:
raise Exception("Bad input to stirling.")
if m == 0 and N > 0:
return 0
elif (N, m) == (0, 0):
return 1