Skip to content

Instantly share code, notes, and snippets.

@garrilla
garrilla / wishlist-notelet
Created April 6, 2014 13:13
a notelet app with markdown, CLI (inc History)
I want a notelet app that has the following features
- web front-end
- CLI integration
- uses Markdown
The web fe should be a simple page display
- linear
- metro
@garrilla
garrilla / README.md
Last active February 11, 2016 07:47 — forked from mbostock/.block
Zoom + Pan with Limiting

This is an example of pan limiting, trapping for zoom.translate() by passing an array, which is determined by a simple boolean network for each of x and y of the translation to ensure that dragging is constrained within the panExtent.

It is a fork of Pan+Zoom demonstrating an example of d3.behavior.zoom applied using x- and y-scales.

Requirements

  1. create an object variable var panExtent = {x: [0,600], y: [-200,Infinity] }; to set the limits of the pan

  2. when setting the domain test for compliance with the panExtent (the domain should be no bigger than panExtent)

@garrilla
garrilla / aggregate
Created May 8, 2014 19:05
MongoDB shell use of aggregate [broke]
var eachN1byAggregate = function(){
print('Counting each \'n1\' in Main');
conn = new Mongo();
db = conn.getDB("beta3");
print('.. preparing to count');
start = Date.now();
n1_count = getAggregate();
end = Date.now();
elapsed2 = (end - start)/1000;
print('Count completed in '+elapsed2+' secs.');
Template.myTemplate.events({
'keypress #myclass': function (evt){
if(evt.which==13){
//do something because a return was pressed
}
}
);
@garrilla
garrilla / client.js
Last active August 29, 2015 14:06
refactor Meteor.methods
/* path ./client/client.js */
Template.myTemplate.events({
'click input': function () {
Meteor.call('bar',function(error,result){console.log(!error ? result : error)});
}
})
@garrilla
garrilla / gist:42844feba02d289a733b
Last active August 29, 2015 14:07
Template Utils
Template.myTemplate.utils={
someHelper: function(){
console.log('someHelper()')
}
}
Template.myTempalte.utils.someHelper() // prints someHelper()
@garrilla
garrilla / blah.css
Created October 2, 2014 10:32
helper and invocation [email protected]
/* CSS declarations go here */
@garrilla
garrilla / README.md
Last active August 29, 2015 14:07
Clusterfy

This example demonstrates how to add emphasis to points on a plot/map to highlight clusters. The size of each circle is determined by a how much it shares a characteristic with its surrounding neighbours of a grid 3x3.

It uses colour encoding taken from from various examples of cloropethic maps based on d3's quantile scale. I've added a similar method for opacity.

The input is an array of objects. Each object must have at least 3 key:value pairs - 2 representing a x & y for your plot, the other should be a value of some kind. In this example the x/y is the easterly and northerly of 10km grid, the value is a rate between 0 and 1. An example:

[ {e: 37, n: 45, rate: 0.68},
  {e: 51, n: 49, rate: 0.48},
 {e: 39, n: 51, rate: 0.71}