Skip to content

Instantly share code, notes, and snippets.

View zomglings's full-sized avatar

Neeraj Kashyap zomglings

View GitHub Profile
(def test-tree {1 {:root nil} 2 {:root 1} 3 {:root 1} 4 {:root 2} 5 {:root 1} 6 {:root 4}})
(defn path-to-top [tree v]
(if (nil? v)
'()
(cons v (path-to-top tree (:root (get tree v))))))
(defn steps-indexed-path
([upward-path steps]
(if (= upward-path '())
@zomglings
zomglings / anchor.md
Last active June 19, 2017 23:49
Markdown anchors

OMG

WTF

BBQ

(Scroll all the way down beyond the wall of text)

(Wall of text generated by randomtextgenerator)

Necessary ye contented newspaper zealously breakfast he prevailed. Melancholy middletons yet understood decisively boy law she. Answer him easily are its barton little. Oh no though mother be things simple itself. Dashwood horrible he strictly on as. Home fine in so am good body this hope.

@zomglings
zomglings / serving-input-reception-bug.ipynb
Created July 21, 2017 20:28
serving-input-reception-bug
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@zomglings
zomglings / file-sms-signal.js
Last active April 22, 2018 00:24
Alert using SMS on file creation
var path = require('path');
var {poll} = require('@nkashy1/pollster');
var {spawnPredicate} = require('@nkashy1/pollster/predicates');
var twilio = require('twilio');
// START fs config
var rawFilepath = process.env.WATCH_FILE;
if (!rawFilepath) {
throw new Error('WATCH_FILE (undefined) should be the path that you want to poll for file existence');
}
@zomglings
zomglings / gce-instance-pollster.js
Created April 22, 2018 15:26
Poll GCE instance to make sure it hasn't died (or been pre-empted)...
var Compute = require('@google-cloud/compute');
var {poll} = require('@nkashy1/pollster');
var twilio = require('twilio');
// START gcp-related setup
const gcpProject = process.env.GOOGLE_CLOUD_PROJECT
const gcpSacred = process.env.GOOGLE_APPLICATION_CREDENTIALS
const gceZone = process.env.GOOGLE_COMPUTE_ZONE;
const gceInstance = process.env.GOOGLE_COMPUTE_INSTANCE;
@zomglings
zomglings / lint.sh
Last active August 26, 2019 20:24
Pylint wrapper with scripting-friendly exit codes
#!/usr/bin/env sh
# Wraps Pylint invocation to produce shell-friendly exit codes
# Because Pylint exit codes are weird:
# https://docs.pylint.org/en/1.6.0/run.html#exit-codes
PYTHON_EXECUTABLE=python
if [ ! -z $PYTHON_ENV ]; then
PYTHON_EXECUTABLE="$PYTHON_ENV/bin/python"
fi
@zomglings
zomglings / stanford-dogs.bash
Last active September 23, 2019 10:08
Upload Stanford Dogs dataset to S3 and register against Simiotics Data Registry
#!/usr/bin/env bash
STANFORD_DOG_IMAGES_DIR=${STANFORD_DOG_IMAGES_DIR:-~/data/stanford-dogs/Images}
DOG_DIRS=$(ls -1 $STANFORD_DOG_IMAGES_DIR)
BATCH_SIZE=${BATCH_SIZE:-100}
PARALLELISM=${PARALLELISM:-0}
SIMIOTICS_SOURCE=${SIMIOTICS_SOURCE}
if [ -z "$SIMIOTICS_SOURCE" ]; then
@zomglings
zomglings / simiotics_python.ipynb
Created October 30, 2019 02:47
Tutorial: Using Simiotics from Python
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# First, run:
# pip install simiotics
from simiotics.clients import SimioticsRESTClient
if __name__ == '__main__':
import json
import time
dataset_id = f'test-dataset-{int(time.time())}'
@zomglings
zomglings / Dockerfile
Created December 1, 2019 18:02
Powershell alpine docker image
FROM alpine:3.10.3
RUN apk add --no-cache \
ca-certificates \
less \
ncurses-terminfo-base \
krb5-libs \
libgcc \
libintl \
libssl1.1 \