Skip to content

Instantly share code, notes, and snippets.

View jbn's full-sized avatar

John B Nelson jbn

View GitHub Profile
@jbn
jbn / nan_to_na.py
Last active October 16, 2015 20:52
import os
import numpy as np
import pandas as pd
import rpy2
from rpy2 import robjects
from rpy2.robjects.packages import importr
AMELIA = importr("Amelia")
@jbn
jbn / ulp_speed.scala
Created November 11, 2015 22:15
A script to test the time-expense of scala.math.ulp
import scala.math.ulp
/**
* ThirdWay calls `ulp` occasionally. This script tries to assess costs.
*/
def timeIt[R](f: => R): Long = {
val start = System.currentTimeMillis
f
System.currentTimeMillis - start
@jbn
jbn / epsilon_and_scheduling.scala
Created November 11, 2015 22:47
Double's epsilon and scheduling artifacts
/*
Consider two activities, A and B, both scheduled at the same time. When
activated, they schedule themselves for reactivation in a time delta of 0.1
and 0.2. If this is less than the ulp at a given time, both activities end
up being scheduled at the same time.
*/
import scala.math.ulp
val MaxTime = 9.007199254740991E15
@jbn
jbn / julia_type_hierarchy.jl
Created July 17, 2015 22:44
Julia Type Hierarchy
# Requested gist of code to produce:
# https://www.scribd.com/doc/271871142/Julia-Type-Hierarchy
#
# I just redirected the output to a dot file, then executed:
# dot -Tpdf julia.dot -o julia.pdf
function print_type_tree(t, parent=Any, seen=Set{DataType}())
# Avoid redundant edges.
t ∈ seen && return
push!(seen, t)
@jbn
jbn / cc_data_2013.csv
Created January 25, 2014 21:43
Credit Card Data for 2013
state search_vol unempl_rate pop_est avg_cc_debt avg_score unemployed med_inc
Mississippi 100 8.3 2991207.0 4594 610 24827018.1 39295
Georgia 64 7.7 9992167.0 5343 629 76939685.9 47527
Alabama 64 6.2 4833722.0 4817 620 29969076.400000002 43472
West Virginia 64 6.1 1854304.0 4315 625 11311254.399999999 43124
Louisiana 62 6.3 4625470.0 4773 621 29140461.0 40296
South Carolina 61 7.1 4774839.0 5389 618 33901356.9 42661
Arkansas 60 7.5 2959373.0 4535 619 22195297.5 40591
Florida 60 6.4 19552860.0 4861 639 125138304.0 46059
Kentucky 59 8.2 4395295.0 4436 629 36041419.0 40887
$ nslookup donaldjdrumpf.com
54.192.37.{240, 220, 36, 204, 108, 84, 38, 123}
$ nslookup optrump2016.com
104.18.47.68
104.18.46.68
$ nslookup donaldtrump.com
104.16.72.120
104.16.75.120
@jbn
jbn / Makefile
Created March 30, 2016 18:51
Fetch and Save First, Makefile
# Makefile
FETCH = data/raw/FETCHED
PROCESS = data/clean/CLEANED
all: $(FETCH) $(PROCESS)
$(FETCH): scripts/fetch.py
@mkdir -p data/raw
python scripts/fetch.py
@touch $(FETCH)
@jbn
jbn / step_spiral.py
Created May 22, 2016 15:59
Silly little step spiral in Python using itertools.
import itertools
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
def step_spiral(x_0=0, y_0=0):
point = (0, x_0, y_0)
yield point
from ftplib import FTP, error_perm, error_temp
# List passwords
passlist = ["azedaedaze" , "connerre" , "iazevbfhiazev"]
length = len(passlist)
# IP FTP
ftp = FTP('ftpperso.free.fr')
# User FTP
user = "esconnerre"