Skip to content

Instantly share code, notes, and snippets.

View nickbenes's full-sized avatar

Nick Benes nickbenes

  • Leesburg, VA
View GitHub Profile
@nickbenes
nickbenes / README.md
Last active January 7, 2016 19:58 — forked from mbostock/.block
Brush Snapping with varying timespans

Tweaks to http://bl.ocks.org/mbostock/6232537 that adds data-driven timespans to the widget. This version allows timespans of varying sizes. It also modifies the brushend listener to log information based on the timespans where the brush's endpoints are located.

This brush snaps to day boundaries. When the user releases the brush, the brush fires a brushend event, allowing a listener to adjust the brush extent. Using the new brush transitions released in D3 3.3, the brush smoothly interpolates from the original extent to the rounded extent. Compare this approach to using immediate snapping while brushing.

@nickbenes
nickbenes / DoD_Active_Officer_Rank_Gender_Race.csv
Last active September 17, 2015 14:04
Military Officer Demographics
BRANCH SEX RACE HISPANIC O01 O02 O03 O04 O05 O06 O07 O08 O09 O10
ARMY MALE AMI/ALN HISP 2 0 5 0 1 0 0 1 0 0
ARMY MALE AMI/ALN NON-HISP 38 41 94 77 28 8 1 0 0 0
ARMY MALE ASIAN HISP 0 5 3 4 3 1 0 0 0 0
ARMY MALE ASIAN NON-HISP 361 432 1014 537 197 74 1 1 0 0
ARMY MALE BLACK HISP 18 8 28 19 9 1 0 0 0 0
ARMY MALE BLACK NON-HISP 746 781 2221 1495 895 363 12 8 3 1
ARMY MALE MULTI HISP 0 0 0 0 0 0 0 0 0 0
ARMY MALE MULTI NON-HISP 0 0 0 0 0 0 0 0 0 0
ARMY MALE P/I HISP 0 0 0 0 0 0 0 0 0 0
@nickbenes
nickbenes / images.js
Created June 7, 2015 15:16
Meteor collection for images using CollectionFS
var createThumb = function(fileObj, readStream, writeStream) {
// Transform the image into a 10x10px thumbnail
gm(readStream, fileObj.name()).resize('10', '10').stream().pipe(writeStream);
};
var createWeb = function(fileObj, readStream, writeStream) {
// Transform the image into a 10x10px thumbnail
gm(readStream, fileObj.name()).resize('320', '180').stream().pipe(writeStream);
};
var convertToPng = function(fileObj) {
return {