Skip to content

Instantly share code, notes, and snippets.

View neilk's full-sized avatar

Neil Kandalgaonkar neilk

View GitHub Profile
@neilk
neilk / promiseForEach.js
Last active January 3, 2016 13:09
implementations of looping with Bluebird promises
// promisey foreach loop
'use strict';
var Promise = require('bluebird'),
promiseWhile = require('./promiseWhile');
/**
* Promisey foreach
*
@neilk
neilk / node upserter
Created January 14, 2014 17:43
python versus node for stateful upserting
/**
* postgres does not have replace into, so...
*
* @param {Object} tile specification {tx: ty: zoom:}
* @param {Object} quad properties of that tile
* @param {Knex.transaction} t database transaction
* @return {Promise}
*/
function insertOrUpdateTile(tile, quad, t) {
@neilk
neilk / mockify.css
Created December 15, 2013 00:46
CSS to turn an existing website into something resembling a mock. Requires the font "Redacted Script" (https://github.com/christiannaths/Redacted-Font). One way to use it: get Live CSS Editor (http://www.livecsseditor.com/), pop open the window, and paste the contents of mockify.css.
* {
-webkit-filter: grayscale(100%) !important;
background-color: white !important;
border-color: black !important;
color: black !important;
font-family: "redacted script" !important;
}
@neilk
neilk / iteratePromiseTest.js
Created August 23, 2013 21:56
Recursive iterating with promises; done "manually", and with when/unfold
'use strict';
var when = require('when'),
delay = require('when/delay'),
unfold = require('when/unfold');
function getNumber() {
var deferred = when.defer();
deferred.resolve(Math.floor(Math.random() * 10));
return deferred.promise;
// sign up
account.signUp('joe@example.com', 'secret');
// sign in
account.signIn('joe@example.com', 'secret');
// sign in via oauth
account.signInWith('twitter');
// sign out
@neilk
neilk / testRoute.js
Last active December 16, 2015 06:19
Attempt to use node-webworker threads
var Worker = require('webworker-threads').Worker;
var worker = new Worker('bin/testWorker.js');
var workerSend;
(function() {
var idCounter = 0;
var callbacks = {};
worker.onmessage = function(oEvent) {
var message = oEvent.data;
@neilk
neilk / video2podcast.sh
Created October 8, 2012 05:49
Video to podcast VLC sample invocation
# A VLC invocation that converts a movie file into an audio file that iTunes will sync to your iPhone
/Applications/VLC.app/Contents/MacOS/vlc -I dummy --no-sout-video --sout-audio --no-sout-rtp-sap --no-sout-standard-sap --ttl=1 --sout-keep --sout "#transcode{acodec=s16l,channels=2}:std{access=file,mux=wav,dst=podcast.wav}" movie.mp4
Verifying that +neilk is my openname (Bitcoin username). https://onename.io/neilk
@neilk
neilk / softStars
Last active August 29, 2015 14:08
softStars for weatherStrip ElectricImp project
// WS2812 "Neopixel" LED Driver
// Copyright (C) 2014 Electric Imp, inc.
//
// Uses SPI to emulate 1-wire
// http://learn.adafruit.com/adafruit-neopixel-uberguide/advanced-coding
// This class requires the use of SPI257, which must be run at 7.5MHz
// to support neopixel timing.
const SPICLK = 7500; // kHz

Keybase proof

I hereby claim:

  • I am neilk on github.
  • I am neilk (https://keybase.io/neilk) on keybase.
  • I have a public key whose fingerprint is B969 3202 D54C BBA2 608F 1778 0CE3 13EC F872 D474

To claim this, I am signing this object: