Skip to content

Instantly share code, notes, and snippets.

View enjalot's full-sized avatar

Ian Johnson enjalot

View GitHub Profile
@enjalot
enjalot / arctween.js
Created March 23, 2012 00:48
inlets for tributary
var data = [5, 25, 40, 20, 10];
var sw = parseInt(svg.style("width"), 10);
var sh = parseInt(svg.style("height"), 10);
var r = Math.min(sw, sh)/2;
var color = d3.scale.category20();
var arc = d3.svg.arc().outerRadius(r);
var donut = d3.layout.pie();
//Try changing all these parameters
//Layout properties
var w = 700
, h = 500
, n = 25
, m = 40
, spacing = 65
, opacity = 0.8
, stroke_width = 15
@enjalot
enjalot / index.html
Created March 28, 2012 23:36
testing svg to canvas
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.v2.js"></script>
<script type="text/javascript" src="http://canvg.googlecode.com/svn/trunk/rgbcolor.js"></script>
<script type="text/javascript" src="http://canvg.googlecode.com/svn/trunk/canvg.js"></script>
<script type="text/javascript" src="http://www.nihilogic.dk/labs/canvas2image/canvas2image.js"></script>
<script type="text/javascript" src="http://www.nihilogic.dk/labs/canvas2image/base64.js"></script>
</head>
@enjalot
enjalot / boid.js
Created March 30, 2012 23:29 — forked from enjalot/boid.js
spermboids
// Boid flocking based on http://harry.me/2011/02/17/neat-algorithms---flocking
var boid = (function() {
function boid() {
var position = [0, 0],
velocity = [0, 0],
w = 960,
h = 500,
gravityCenter = null,
gravityMultiplier = 1,
neighborRadius = 50,
@enjalot
enjalot / index.html
Created April 3, 2012 18:56
webkit dom serialization issue
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<style>
#svg {
position: absolute;
top: 10px;
left: 10px;
}
@enjalot
enjalot / water.js
Created April 30, 2012 06:59
created by water, a live-coding editor (http://water.gabrielflor.it)
// chord diagram from http://mbostock.github.com/d3/ex/chord.html
// colors from the twilight theme: http://bit.ly/wufWv1
var chord = d3.layout.chord()
.padding(0.05)
.sortSubgroups(d3.descending)
.matrix([
[11975, 5871, 8916, 2868],
[ 1951, 10048, 2060, 6171],
@enjalot
enjalot / cors_server.py
Created June 10, 2012 06:19
Allow CORS with python simple http server
import SimpleHTTPServer
class CORSHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def send_head(self):
"""Common code for GET and HEAD commands.
This sends the response code and MIME headers.
Return value is either a file object (which has to be copied
to the outputfile by the caller unless the command was HEAD,
and must be closed by the caller under all circumstances), or
@enjalot
enjalot / index.html
Created June 19, 2012 06:05 — forked from chrisbrich/index.html
Line Chart with defaults example
<!DOCTYPE html>
<html>
<head>
<title>Line Chart</title>
<script src="http://mbostock.github.com/d3/d3.v2.js"></script>
<link href="lineplot.css" rel="stylesheet" type="text/css">
</head>
<body>
<script type="text/javascript">
function linePlot() {
@enjalot
enjalot / inlet.js
Created June 19, 2012 23:26
just another inlet to tributary
var x = 42;
@enjalot
enjalot / inlet.js
Created June 19, 2012 23:38
just another inlet to tributary
var test = 5;