Skip to content

Instantly share code, notes, and snippets.

print "hello, world"
BufferedReader reader;
String line;
class ShapePoint {
public int shape_id;
public float lat;
public float lon;
int WIDTH = 500;
int HEIGHT = 500;
int ANTS_AT_A_TIME = 30;
boolean DRAW_PATH = false;
float sum_array( float[] floats ) {
float ret = 0;
for(int i=0; i<floats.length; i++){
ret += floats[i];
int NGROUPS=5;
float INFINITY = 100000000;
int RANDOM_POINTS = 75;
boolean USE_RANDOM_POINTS = true;
float TRUCK_SLACK = 1.1;
class PointGroup {
ArrayList points;
PVector mean;
@bmander
bmander / rift.py
Created December 9, 2010 00:38
display maps color-coded by intersection connectivity
import sqlite3
def main(osmdb_name, gdb_name,map_filename):
osmdb = sqlite3.connect(osmdb_name)
gdb = sqlite3.connect(gdb_name)
c = gdb.cursor()
c.execute( "select vertex1, count(*) from edges where vertex1 LIKE 'osm%' group by vertex1" )
@bmander
bmander / transitmapper.py
Created December 9, 2010 00:40
print maps of stops coded by stoptime count
from gtfs import Schedule
from gtfs.entity import Trip, StopTime, Stop
from sqlalchemy.orm import eagerload
import csv
import sys
from prender import processing
def cons(ary):
for i in range(len(ary)-1):
@bmander
bmander / ntuplechain.py
Created December 18, 2010 00:52
Create markov chains using the Google ntuple dataset
"""Get a bunch of 2gram files. Then split the 2grams with spaceize(). Then set up a database like
create table digram (word1 text, word2 text, year integer, match_count integer, page_count integer, volume_count integer);
.separator "\t"
.import spaceized.csv digram
then you're set up to use chain()"""
import csv
import sqlite3
@bmander
bmander / energy.py
Created January 1, 2011 01:14
calculate total energy accumulation from insolation measurements
# wow. energy.
#
# grab source data from http://www-k12.atmos.washington.edu/k12/grayskies/nw_weather.html
import csv
from datetime import datetime, timedelta
MINS_IN_DAY=1440
fp = open( "LFEM_data-.csv" )
@bmander
bmander / radar.pde
Created March 24, 2011 17:21
grab radar data from the radarmatic API, convert to cartesian coordinates, and output as CSV, and then a Processing file to render it
/*
* Render the data output by radar.py as an image.
*/
void setup() {
size(700,700);
background(255);
stroke(0);
smooth();
scale(2,2);
@bmander
bmander / data
Created August 8, 2011 21:26
a trivial mmap example
abcdefghijklmnopqrstuvwxyz