Skip to content

Instantly share code, notes, and snippets.

View davidgtonge's full-sized avatar

Dave Tonge davidgtonge

View GitHub Profile
@davidgtonge
davidgtonge / replace.js
Created February 1, 2018 14:38
replace
const replace = require("replace-in-file")
const files = "./test/**/*.js"
const opts1 = {
files,
from: /import\s([a-zA-Z]*)\sfrom\s("[a-z\.\/\_\-\@]*")/g,
to: (match, p1, p2) => `const ${p1} = require(${p2})`,
}
@davidgtonge
davidgtonge / keybase.md
Created April 28, 2017 11:15
keybase proof

Keybase proof

I hereby claim:

  • I am davidgtonge on github.
  • I am davidgtonge (https://keybase.io/davidgtonge) on keybase.
  • I have a public key ASBBSg-GEvhAI3QaCjVBMAlnOjHy900waad7MYyXSyRlugo

To claim this, I am signing this object:

input {
syslog {
add_field => {
"docker" => "true"
}
}
}
output {
@davidgtonge
davidgtonge / README.md
Last active December 12, 2015 00:08 — forked from mbostock/.block

This examples demonstrates how to use D3's brush component to implement focus + context zooming. Click and drag in the small chart below to pan or zoom.

@davidgtonge
davidgtonge / README.md
Last active December 10, 2015 12:29 — forked from mbostock/.block

This stacked bar chart is constructed from a CSV file storing the populations of different states by age group. The chart employs conventional margins and a number of D3 features:

@davidgtonge
davidgtonge / graticules.coffee
Last active December 10, 2015 12:09
D3 Projections Animation
width = 960
height = 500
projections =
"Aitoff": d3.geo.aitoff
"Albers equal": d3.geo.albers
"August conformal": d3.geo.august
"Lambert azimuthal equal": d3.geo.azimuthalEqualArea
"Azimuthal equidistant": d3.geo.azimuthalEquidistant
"Bonne": d3.geo.bonne
@davidgtonge
davidgtonge / gist:1408899
Created November 30, 2011 12:26
simple infinite scroller
scroller = (elem, width, initialised = false) ->
multiple = 1
unless initialised
if width < 960
mutiple += Math.floor(960 / width)
cloned = (elem.text() for i in [1...multiple]).join('...')
elem.text cloned
animateBy = multiple * width
@davidgtonge
davidgtonge / ward_from_postcode.php
Created September 20, 2011 22:42
UK Ward from Post Code
<?php
/*
* This function uses the mapit.mysociety.org api to
* retrieve ward names based on postcode
*/
function sc_get_ward_from_postcode($postcode)
{
//remove spaces and plus signs from the postcode
$postcode = str_replace(" ", "", $postcode);
$postcode = str_replace("+", "", $postcode);
@davidgtonge
davidgtonge / templates.coffee
Created September 20, 2011 06:29
Simple CoffeeScript Templating
# Simple Coffeescript Templating
# Global Object to hold the templates
window.simpleCoffeeTemplates =
# An example template
example: (a) ->
"""
<div>
<h1 class='header'>#{a.header}</h1>
@davidgtonge
davidgtonge / gist:1227605
Created September 19, 2011 21:01
home_page_ids
<?php
function get_wpml_home_ids(){
//Globalizse the $wpdb variable (instantiation of the wpdb class)
global $wpdb;
//Get the front-page id from the options table
$home_id = get_option('page_on_front');
//Run the query