Skip to content

Instantly share code, notes, and snippets.

View neilk's full-sized avatar

Neil Kandalgaonkar neilk

View GitHub Profile
@neilk
neilk / galaxy.applesoft.txt
Created May 1, 2019 02:04
Galaxy applesoft basic
10 HGR2: HCOLOR=3
11 R0 = 70
12 TAU = 6.282
13 SCREENX = 279: SCREENY = 191
15 CENTERX = INT(SCREENX / 2): CENTERY = INT(SCREENY / 2)
16 LINEDOTS = 3
17 R = R0
18 CIRCUM = TAU*R0: S = 1
19 J = 0:
20 REM J-LOOP
@neilk
neilk / PageRank in Python from Wikipedia example.ipynb
Created January 21, 2019 18:38 — forked from sebastien-bratieres/PageRank in Python from Wikipedia example.ipynb
IPython notebook to illustrate an algorithm to compute PageRanks.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@neilk
neilk / sbt-deps-changes
Last active July 11, 2017 21:07
In a Scala/SBT project, figure out what dependencies are added or removed in a branch
#!/bin/bash
# Find dependency changes in a branch in a scala project using sbt.
# You have to have the https://github.com/jrudolph/sbt-dependency-graph plugin installed.
# the standard `sed` on Mac OS X won't work, so make sure to install GNU sed via brew.
branch="$1"
@neilk
neilk / retry-promise.js
Last active June 9, 2017 23:11
Retry logic for promises
/**
* Retry a promise until success, up to a certain number of times.
* Returns the last error if it reaches maximum attempts.
*
* @param maxTries {Number} positive integer
* @param p {Promise}
* @return {Promise}
*/
function retry (maxTries, p) {
var tries = 0;
@neilk
neilk / .sharedhistory.sh
Last active April 11, 2017 03:47
Multiple bash hooks upon changing directories (set env var, switch node version, switch history file)
shopt -s histappend
PROMPT_COMMAND="history -a;history -c;history -r;$PROMPT_COMMAND"
SHARED_HISTORY_DIR="$HOME/.sharedhistory"
mkdir -p $SHARED_HISTORY_DIR
function __sharedhistory_chpwd() {
if [[ -n $PROJECT ]]; then
local pwd_escaped=$(echo $PWD | sed 's/[\/ ]/~/g')
HISTFILE="$SHARED_HISTORY_DIR/$PROJECT"
@neilk
neilk / git-purge.sh
Last active February 16, 2017 17:59
Purge a file from your git repo
#!/bin/bash
git filter-branch --force --index-filter \
"git rm -r --cached --ignore-unmatch $1" \
--prune-empty --tag-name-filter cat -- --all
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:

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");
}