Skip to content

Instantly share code, notes, and snippets.

View tristanwietsma's full-sized avatar

Tristan Wietsma tristanwietsma

  • Chicago, Illinois
View GitHub Profile
//Practically all this code comes from https://github.com/alangrafu/radar-chart-d3
//I only made some additions and aesthetic adjustments to make the chart look better
//(of course, that is only my point of view)
//Such as a better placement of the titles at each line end,
//adding numbers that reflect what each circular level stands for
//Not placing the last level and slight differences in color
//
//For a bit of extra information check the blog about it:
//http://nbremer.blogspot.nl/2013/09/making-d3-radar-chart-look-bit-better.html
@tristanwietsma
tristanwietsma / data.json
Last active August 9, 2018 12:04
Datamaps with points in JSON
[
{"radius": 3, "fillKey": "pnt", "latitude": 41.89, "longitude": -88.31},
{"radius": 3, "fillKey": "pnt", "latitude": 40.113, "longitude": -88.261},
{"radius": 3, "fillKey": "pnt", "latitude": 25.7877, "longitude": -80.2241}
]
@tristanwietsma
tristanwietsma / govfeed.py
Created June 12, 2014 15:59
Bit.ly USA.gov feed
import socket, time
# http://www.usa.gov/About/developer-resources/1usagov.shtml
s = socket.socket()
s.connect(('developer.usa.gov', 80))
s.send('GET /1usagov HTTP/1.0\n\n')
s.setblocking(False)
while True:
@tristanwietsma
tristanwietsma / a.py
Created June 6, 2014 14:18
Futures example with multiple input params
from concurrent.futures import ProcessPoolExecutor
def myfunc(a, b, c):
return a + b + c
if __name__ == '__main__':
workers = 3
result = []
@tristanwietsma
tristanwietsma / auth.go
Created May 15, 2014 04:15
Golang web server example
package main
import (
"encoding/base64"
"net/http"
"strings"
)
type handler func(w http.ResponseWriter, r *http.Request)
!function(){
var Donut3D={};
function pieTop(d, rx, ry, ir ){
if(d.endAngle - d.startAngle == 0 ) return "M 0 0";
var sx = rx*Math.cos(d.startAngle),
sy = ry*Math.sin(d.startAngle),
ex = rx*Math.cos(d.endAngle),
ey = ry*Math.sin(d.endAngle);

Inspired by Trulia Trends - but with code and using SVG.

Example data shows concurrent user sessions over time, taken from a development environment.

@tristanwietsma
tristanwietsma / fix.diff
Created April 11, 2014 00:59
sqlautocode patch
diff -r 08a7912b8a09 -r 4c04152dfffe sqlautocode/config.py
--- a/sqlautocode/config.py Mon Sep 24 10:44:30 2012 +0200
+++ b/sqlautocode/config.py Wed Apr 17 13:26:23 2013 +0300
@@ -140,7 +140,7 @@
engine = sqlalchemy.create_engine(url)
test = engine.connect()
test.close()
- except sqlalchemy.exceptions.SQLAlchemyError, ex:
+ except sqlalchemy.exc.SQLAlchemyError, ex:
parser.error('Could not connect to "%s": %s' % (url, ex))
@tristanwietsma
tristanwietsma / batchjobs.py
Last active August 29, 2015 13:58
batching out jobs to separate processes with python futures
#!/usr/local/bin/python3
import sys, os
from concurrent.futures import ProcessPoolExecutor
def osjob(cmd):
print("running `{}`".format(cmd))
os.system(cmd)
print("finished `{}`".format(cmd))