Skip to content

Instantly share code, notes, and snippets.

with(document.documentElement){className=className.replace(/no-js/,'js')}
@drzax
drzax / jquery.plugin.js
Created August 8, 2012 09:56
jQuery Plugin Boilerplate
/*
* jQuery.name plugin
* https://github.com/{username}/{plugin-name}
*
* Copyright 2011, {real name}
* {website}
*
* This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
* http://creativecommons.org/licenses/by-sa/3.0/
*/
@drzax
drzax / Page.php
Created October 9, 2012 01:55
A pattern for creating 'singleton' page types in Silverstripe
class Page extends SiteTree {
...
/**
* Override the canCreate method to change the order of processing and allow
* the SingletonPage DataExtension to do its work.
*/
public function canCreate($member = null) {
if(!$member || !(is_a($member, 'Member')) || is_numeric($member)) {

I can recommend some general d3 resources I've found helpful (some of which you've probably already found, if you've been looking).

For a real step-by-step, the series of tutorials by Scott Murray look quite good, though I've not done them myself. I have done a MOOC with Scott as an instructor and I can vouch for his teaching skills. I think they'd be very useful for someone very new to HTML/CSS/JS (I'm not sure if that describes you) who also wants to start with d3 at the same time.

If you want to dive right in, I'd start on Thinking with Joins and How Selections Work, and for a practical example of those concepts, check out the General Update Pattern examples (one, [two](https://www

module.exports = function template(tmpl, data){
return tmpl.replace(/\{(\w*)\}/g,function(m,key){return data.hasOwnProperty(key)?data[key]:"";});
};
@drzax
drzax / elements.js
Created December 18, 2015 00:41
Javascript arrays
var elements = [
'Hydrogen',
'Helium',
'Lithium',
'Beryllium',
'Boron',
'Carbon',
'Nitrogen',
'Oxygen',
'Fluorine',
/**
* See: http://jsfromhell.com/math/dot-line-length
*
* Distance from a point to a line or segment.
*
* @param {number} x point's x coord
* @param {number} y point's y coord
* @param {number} x0 x coord of the line's A point
* @param {number} y0 y coord of the line's A point
* @param {number} x1 x coord of the line's B point
@drzax
drzax / log.js
Created November 15, 2013 01:58
Re-emit a log file generated by Winston.
Tail = require('tail').Tail;
Winston = require('winston');
tail = new Tail('logs/default.log');
logger = new Winston.Logger();
logger.add(Winston.transports.Console, {colorize:true});
tail.on('line', function(data){
var json, date;
try {
@drzax
drzax / README.md
Last active March 3, 2016 22:43 — forked from colingourlay/esnextbin.md
esnextbin sketch
We couldn’t find that file to show.

Keybase proof

I hereby claim:

  • I am drzax on github.
  • I am drzax (https://keybase.io/drzax) on keybase.
  • I have a public key ASAu0GD9qAR89fvoGxk9gVM0ei1B1Knd_1a62ynvZ7unygo

To claim this, I am signing this object: