Skip to content

Instantly share code, notes, and snippets.

View apcj's full-sized avatar

Alistair Jones apcj

  • Neo Technology
  • London
View GitHub Profile
@apcj
apcj / index.html
Created January 24, 2012 08:26 — forked from mbostock/README.md
Radial Node-Link Tree in D3
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Node-Link Tree (Radial)</title>
<script type="text/javascript" src="https://github.com/mbostock/d3/raw/2c030290457a4eac0efe34b1c7a61a29997ac3ef/d3.js"></script>
<script type="text/javascript" src="https://github.com/mbostock/d3/raw/2c030290457a4eac0efe34b1c7a61a29997ac3ef/d3.layout.js"></script>
<style type="text/css">
circle.node {
@apcj
apcj / index.html
Created January 24, 2012 16:51 — forked from enjalot/index.html
Shards and Machines
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Shards and Machines</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?2.7.1"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.geom.js?2.7.1"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.layout.js?2.7.1"></script>
<style type="text/css">
@apcj
apcj / index.html
Created January 25, 2012 13:42
Sharding picture - inside-out
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Shards and Machines</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?2.7.1"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.geom.js?2.7.1"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.layout.js?2.7.1"></script>
<style type="text/css">
@apcj
apcj / README.md
Last active December 19, 2015 13:28 — forked from mbostock/.block

Smooth graph exploration

D3 force layout keeps track of node positions by setting x and y properties on the underlying data. By default it chooses starting positions at random, which is convenient, but leads to high-velocity, distracting movements when force calculations begin.

For many graph structures, it's easy to do better than random for starting positions. We can set specific start positions on the data before handing over control to force layout.

In this example, clicking on a node expands its 10 immediate neighbours. For a short period

@apcj
apcj / .gitignore
Last active January 4, 2016 18:19 — forked from mbostock/.block
data.tsv
@apcj
apcj / gist:361a759dabfb1dc608f9
Created June 18, 2014 19:27
Squads that beat each other in the same world cup
MATCH (s:Squad) -[:BEAT]-> () -[:BEAT]-> (s)
RETURN s
@apcj
apcj / country_distance.cyp
Last active August 29, 2015 14:02
World cup country Geo location
MATCH (c1:Country)
MATCH (c2:Country)
WHERE c1 <> c2
WITH c1, c2, 2 * 6371 * asin(sqrt(haversin(radians(c1.lat - c2.lat))+ cos(radians(c1.lat))*
cos(radians(c2.lat))* haversin(radians(c1.lon - c2.lon)))) AS dist
WHERE dist > 0
RETURN c1.name, c2.name, dist
ORDER BY dist
LIMIT 1000
@apcj
apcj / results.txt
Last active August 29, 2015 14:02
World cup revenge
In 2010, Mexico gained revenge over France for beating them in 1930 after a wait of 80 years
In 1986, Argentina gained revenge over Uruguay for beating them in 1930 after a wait of 56 years
In 2010, Mexico gained revenge over France for beating them in 1954 after a wait of 56 years
In 1986, Brazil gained revenge over Spain for beating them in 1934 after a wait of 52 years
In 1982, France gained revenge over Austria for beating them in 1934 after a wait of 48 years
In 1986, France gained revenge over Italy for beating them in 1938 after a wait of 48 years
In 2006, France gained revenge over Brazil for beating them in 1958 after a wait of 48 years
In 2010, Switzerland gained revenge over Spain for beating them in 1966 after a wait of 44 years
In 1978, Brazil gained revenge over Italy for beating them in 1938 after a wait of 40 years
In 1998, France gained revenge over Brazil for beating them in 1958 after a wait of 40 years
@apcj
apcj / poms2cypher.py
Created July 1, 2014 14:00
Emit cypher statements to express maven module structure
#!/usr/bin/python
import os
import xml.etree.ElementTree as xml
ns = '{http://maven.apache.org/POM/4.0.0}'
print 'MATCH (n) OPTIONAL MATCH (n) -[r]-> () DELETE n, r;'
def mergeProject(domElement, variableName):
@apcj
apcj / README.md
Last active August 29, 2015 14:06
Cypher HTTP