Skip to content

Instantly share code, notes, and snippets.

View jbn's full-sized avatar

John B Nelson jbn

View GitHub Profile
@jbn
jbn / dump.java
Created September 14, 2010 22:45
public class Classifier{
public static boolean[] stringToBoolean(String s){
boolean[] b = new boolean[s.length()];
for(int i=0; i<s.length(); ++i){
b[i] = (s.charAt(i) == '1');
}
return b;
}
public static void main(String[] args){
import java.util.LinkedList;
/*
Curves:
probabilityOfHavingChild(deltaWealth, inflation)
wealth/inflation
consumptionCurve(deltaWealth, inflation)
adolesentConsumptionRequirements
adulthoodBetsowment
adulthoodYearlyExpense
module MiniMagick
class Image
# Size is in 'WidthxHeight' string format.
def resize_and_crop(target_size)
target_width, target_height = *target_size.split('x').collect{|x| x.to_f}
width, height = self[:width].to_f, self[:height].to_f
# If the width or height are already less than the targets
# just take the extent -- no resizing nessessary.
if width >= target_width && height >= target_height
@jbn
jbn / setup_mason.sh
Created March 6, 2012 17:43
Setup MASON in an SBT project
#!/bin/bash -v
# MASON (http://cs.gmu.edu/~eclab/projects/mason/) has no MAVEN repository, and
# is built with Makefiles. Sinec I build MASON simulations in Scala with SBT,
# this is inconvienent. This script downloads the latest version of MASON and
# its listed dependencies, and places them in the lib directory. I've never been
# very clear on licensing issues, so I hope I'm not in violation (and I hope
# I'm not stepping on anyone's toes.) If I am, please let me know.
#
# The most convienent way to run is to CD into your scripts base directory and
@jbn
jbn / setup_geomason.sh
Created April 28, 2012 17:46
setup GeoMASON in a MASON sbt project
#!/bin/bash -v
# A script to make using GeoMASON easier in SBT projects, given lack of a
# MAVEN repository.
#
# See: http://cs.gmu.edu/~eclab/projects/mason/extensions/geomason/
#
# The most convienent way to run is to CD into your scripts base directory and
# issue the command:
#
@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
@jbn
jbn / masonify.html
Created April 9, 2015 16:53
Bookmarklet to access academic resources through MASON
<html>
<head>
<title>External Access for GMU Library Resources</title>
</head>
<body>
<a href="javascript:(function() {window.location = 'http://mutex.gmu.edu/login?url=' + window.location;
})();">MASONify</a> Bookmarklet
</body>
</html>
@jbn
jbn / gv_layouts.ipynb
Created July 1, 2015 23:54
ipython-magic pull request 1 demo
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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)