Skip to content

Instantly share code, notes, and snippets.

Avatar

Neil Kandalgaonkar neilk

View GitHub Profile
@neilk
neilk / galaxy.applesoft.txt
Created May 1, 2019
Galaxy applesoft basic
View galaxy.applesoft.txt
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 IPython notebook to illustrate an algorithm to compute PageRanks.
View PageRank in Python from Wikipedia example.ipynb
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 Jul 11, 2017
In a Scala/SBT project, figure out what dependencies are added or removed in a branch
View sbt-deps-changes
#!/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 Jun 9, 2017
Retry logic for promises
View retry-promise.js
/**
* 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 Apr 11, 2017
Multiple bash hooks upon changing directories (set env var, switch node version, switch history file)
View .sharedhistory.sh
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 Feb 16, 2017
Purge a file from your git repo
View git-purge.sh
#!/bin/bash
git filter-branch --force --index-filter \
"git rm -r --cached --ignore-unmatch $1" \
--prune-empty --tag-name-filter cat -- --all
View onename.io-verification
Verifying that +neilk is my openname (Bitcoin username). https://onename.io/neilk
@neilk
neilk / softStars
Last active Aug 29, 2015
softStars for weatherStrip ElectricImp project
View softStars
// 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
View keybase.md

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:

View gist:8949874
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");
}
You can’t perform that action at this time.