Skip to content

Instantly share code, notes, and snippets.

@orls
orls / README.md
Last active August 29, 2015 14:03 — forked from mbostock/.block

Crude demo of a 'layered' force-layout graph.

Run flip() in JS console to switch layers. (You need to change the context fo the chrom dev console to the right iframe first, or use window.frames[0].flip())

This uses the character co-occurence in Les Misérables dataset from the canonical D3 force-layout demo.

The choice of what's in what layer is just based on even/odd-numbered node index. This selection mechanism, and the fact that the graph is very dense, means this might not be the most appropriate dataset to demo the 'layering', but hopefully it gives some hint of its potential.

The intent is that slightly different force-layout rules apply to different layers, giving them structural focus as well as visual.

@orls
orls / README.md
Created July 11, 2014 16:27 — forked from mbostock/.block

Click to add nodes! Nodes near the cursor will be linked to the new node.

D3's force layout uses the Barnes–Hut approximation to compute repulsive charge forces between all nodes efficiently. Links are implemented as geometric constraints on top of position Verlet integration, offering greater stability. A virtual spring between each node and the center of the chart prevents nodes from drifting into space.

@orls
orls / MetaObject.php
Created September 3, 2011 20:35 — forked from CHH/MetaObject.php
PHP does Meta Programming too! (Requires PHP 5.4)
<?php
namespace CHH;
trait MetaObject
{
protected static $metaClass;
static function setMetaClass(MetaClass $metaClass)
{
@orls
orls / loader.js
Created February 7, 2011 16:04 — forked from cyu/loader.js
var fs = require('fs');
var http = require('http');
var path = require('path');
var console = require('sys');
var url = require('url');
var Script = process.binding('evals').Script;
var couchURL = url.parse(process.argv[2]),
couchUser = process.argv[3],
couchPass = process.argv[4],
@orls
orls / tsp.rb
Created February 3, 2011 12:21 — forked from beastaugh/tsp.rb
#!/usr/bin/env ruby
require 'oyster'
spec = Oyster.spec do
name "tsp -- Generate 1x1 PNG files with a particular background colour and opacity"
description <<-EOS
tsp is a command-line utility for generating 1x1 pixel PNG files with a given
background colour and opacity. Due to the relative lack of support for RGBA
amongst web browsers, it's useful to be able to generate background images