Skip to content

Instantly share code, notes, and snippets.

Avatar
🌄
playing outdoors, in the mountains (hopefully)

Nicholas Young secretfader

🌄
playing outdoors, in the mountains (hopefully)
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am secretfader on github.
  • I am secretfader (https://keybase.io/secretfader) on keybase.
  • I have a public key ASAXYRdegSysfkENZLYjO3C5Z9-preG46I4av2__bcJa-Qo

To claim this, I am signing this object:

View Dockerfile
FROM alpine:3.4
MAINTAINER Nicholas Young <nicholas@nicholaswyoung.com>
# Set environment variables
ENV HOME /root
ENV GOPATH /go
ENV PATH ${PATH}:${GOPATH}/bin
# Add development essentials and create required path
RUN sed -i -e 's/v3\.4/edge/g' /etc/apk/repositories && \
View mongoose-unique-validator.js
/**
* Dependencies
*/
var MongooseError = require('mongoose/lib/error')
, Promise = require('bluebird');
/**
* Module body / Expose
*/
var parseError = function (err, options) {
@secretfader
secretfader / mongodb.js
Created Jun 11, 2015
Naïve benchmark, comparing RethinkDB to MongoDB.
View mongodb.js
/**
* Shim
*/
var Promise = require('bluebird');
/**
* Dependencies
*/
var mongo = require('mongodb')
, router = require('koa-router')()
@secretfader
secretfader / handler.js
Last active Aug 29, 2015
koa multipart
View handler.js
router.post('/', multipart, function *() {
if (this.state.files && this.state.files.media) {
this.state.files.media.pipe(fs.createWriteStream(/* output */));
// stream error handling omitted
}
});
@secretfader
secretfader / Uploader.js
Created Jan 26, 2015
A simple, Busboy-powered streaming file upload interface.
View Uploader.js
var util = require('util')
, path = require('path')
, Busboy = require('busboy')
, Emitter = require('events').EventEmitter
, Uploader;
Uploader = function () {
Emitter.call(this);
};
View almost a module
var EventEmitter = require("events").EventEmitter,
redis = require("redis"),
dateformat = require("dateformat");
function population32(x)
{
x -= ((x >> 1) & 0x55555555);
x = (((x >> 2) & 0x33333333) + (x & 0x33333333));
x = (((x >> 4) + x) & 0x0f0f0f0f);
x += (x >> 8);
View README.md

replace

var manta = require('manta');

with

var manta = require('./mock-manta');
View distill.js
var distill = require('distill');
var data = {
id: 1,
title: 'Hello, World',
dirty_field: 'This field should not be exposed.',
authors: {
id: 2,
name: 'Joshua',
email: 'joshua@example.org'
}
@secretfader
secretfader / array_conundrum.rb
Last active Jan 1, 2016
Ruby Array Conundrum
View array_conundrum.rb
elements = [["accesses.2013.12", "17"], ["accesses.2013.12", "18"], ["accesses.2013.12", "19"], ["accesses.2013.12", "20"], ["accesses.2013.12", "21"], ["accesses.2013.12", "22"], ["accesses.2013.12", "23"], ["accesses.2013.12", "24"], ["accesses.2013.12", "25"], ["accesses.2013.12", "26"], ["accesses.2013.12", "27"], ["accesses.2013.12", "28"], ["accesses.2013.12", "29"], ["accesses.2013.12", "30"], ["accesses.2013.12", "31"], ["accesses.2014.1", "01"]]
#
# I need to pair down this array into something usable, like:
#
elements = [
{
key: 'accesses.2013.12',
days: [ 17, 18, 19 ]
},
You can’t perform that action at this time.