Skip to content

Instantly share code, notes, and snippets.

View straypacket's full-sized avatar

Daniel Pereira straypacket

  • Shibuya, Tokyo, Japan
View GitHub Profile
@straypacket
straypacket / hierarchical_clustering.rb
Last active December 26, 2015 04:49
Analysis of passers-by vs stable clients, over wifi mac monitoring
# Do this in a rails console @ footprint-tracker
# Weekend
we = [12, 13, 14, 19, 20]
#Workdays
wd = [11, 15, 16, 17, 18, 21, 22, 23]
#2D Matrices for weekend and worddays, Weekdays x Requests_per_distinct_mac
we_a = []
wd_a = []
@straypacket
straypacket / sinatra.rb
Last active December 20, 2015 16:29
Sample Sinatra server
##
# Call with:
# curl -i -H "Accept: application/json" "http://localhost:4567/?foo=1"
# or post with:
# curl -X POST -H "Accept: application/json" "http://localhost:4567/?foo=1" --data "foo=2"
##
require 'rubygems'
require 'sinatra'
require 'json'
@straypacket
straypacket / tws.py
Last active December 19, 2015 08:19
Tornado websocket server and html client
import tornado.httpserver
import tornado.websocket
import tornado.ioloop
import tornado.web
import time
import random
# Preload data
# ... use from previous gists
#import numpy as np
@straypacket
straypacket / index.html
Created June 26, 2013 23:58
Hierarchical edge bundling, adapted from Mike Bostock's work and Danny Holten's paper: http://www.win.tue.nl/~dholten/papers/bundles_infovis.pdf
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<link type="text/css" rel="stylesheet" href="flare-style.css"/>
<style type="text/css">
path.arc {
cursor: move;
fill: #fff;
}
@straypacket
straypacket / demo.html
Last active December 18, 2015 12:09
Walk server - from a road .shp file to a full walk
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>SUJ Geo walks</title>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>
<script type="text/javascript">
var path = [];
@straypacket
straypacket / bench.jl
Created June 7, 2013 00:43
Short Julia benchmark
# Run with PATH=/Applications/Julia.app/Contents/Resources/julia/bin:/usr/bin:/bin:/usr/sbin:/sbin FONTCONFIG_PATH=/Applications/Julia.app/Contents/Resources/julia/etc/fonts PKG_CONFIG_PATH=/Applications/Julia.app/Contents/Resources/julia/lib/pkgconfig GIT_EXEC_PATH=/Applications/Julia.app/Contents/Resources/julia/libexec/git-core GIT_TEMPLATE_DIR=/Applications/Julia.app/Contents/Resources/julia/share/git-core /Applications/Julia.app/Contents/Resources/julia/bin/julia -p 2
# Typically n > 2000000000
@everywhere function pbench(n)
it = time()
nheads = @parallel (+) for i=1:n
int(randbool())
end
ft = time()-it
end
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.node {
font: 10px sans-serif;
}
.link {
stroke: steelblue;