Skip to content

Instantly share code, notes, and snippets.

View neilk's full-sized avatar

Neil Kandalgaonkar neilk

View GitHub Profile
#!/usr/bin/env python
import os
import sys
import getopt
from sys import stderr
import boto.ec2
import boto.rds
var db = Knex({ /* connection properties */ });
function sessionToAccount(session) {
return db('accounts').where('user_ID', session.user_ID).select();
}
function withdraw(account, amount) {
if (account.balance < amount) {
throw new Error("insufficient funds");
}

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:

@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
Verifying that +neilk is my openname (Bitcoin username). https://onename.io/neilk
@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
@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;
// 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 / 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;
@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;
}