Skip to content

Instantly share code, notes, and snippets.

View hidinginabunker's full-sized avatar

Gabriel Herrera hidinginabunker

View GitHub Profile
@hidinginabunker
hidinginabunker / rc.local
Created September 8, 2018 03:05
Starts a jupyter notebook on boot in an anaconda environment
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
@hidinginabunker
hidinginabunker / harmonic_series_1.scd
Last active May 28, 2018 14:18
Playing around with generating some descending harmonic series from a base tone in super collider: https://soundcloud.com/hidinginabunker/harmonic-series-1
// initialize some wiggle room to add some stank
var wiggle = [0.0, 0.2, 0.3, 0.4, 0.5].choose;
// select some base tone and add some wiggle room so we get some more interesting pure tones
var baseTone = [
440*2+wiggle,
440*3+wiggle,
440*4+wiggle
].choose;
@hidinginabunker
hidinginabunker / globalThrottleOnLock.js
Created October 4, 2017 18:22
Example of a global distributed lock in node using timeouts and redis for locks
const redis = require('redis')
const client = redis.createClient()
// will retry running a function until a lock is freed and it can run it
function retryUntilUnlocked(lock, func, seconds) {
client.get(lock, function (err, result) {
// while there is still a lock, keep re-trying every x seconds
if(result === 'true') {
setTimeout( () => {
@hidinginabunker
hidinginabunker / keybase.md
Created August 30, 2017 02:31
verifying myself on keybase

Keybase proof

I hereby claim:

  • I am hidinginabunker on github.
  • I am gabrielherrera (https://keybase.io/gabrielherrera) on keybase.
  • I have a public key ASDDNqyW7WERXuAiGW5tj8wHrsw1dFFlutwS13rGSUlWFgo

To claim this, I am signing this object:

@hidinginabunker
hidinginabunker / addToRecentlyViewed.js
Created May 4, 2013 18:43
Stores recently viewed urls to local storage along with their view times
/**
* Stores recently viewed urls to local storage along with their view times
*
* @param {String} key - the localStorage key where the list is stored
* @param {String} url - the location of the page that was viewed
* @param {Object} json - arbitrary json blob associated with a url
* @param {Integer} limit - the max number of urls to save
*/
function addToRecentlyViewed (key, url, json, limit) {
var app = require('http').createServer(handler)
, io = require('socket.io').listen(app)
, fs = require('fs')
, Redis = require('redis')
, redis1 = Redis.createClient()
, redis2 = Redis.createClient()
;
redis1.on('error', function(err) {
@hidinginabunker
hidinginabunker / naiveColorChanger.js
Created April 4, 2013 20:12
Changes the background color using setInterval. Pretty old school though, better to use requestAnimationFrame to not completely destroy the battery life of mobile devices
var intervalTicks = 100;
var redValue = 1;
var greenValue = 1;
var blueValue = 1;
var colorChangeMagnitude = 1.01;
var backgroundColor = "rgb("+redValue+","+greenValue+","+blueValue+")";
var redFlag = "down";
var greenFlag = "up";
var blueFlag; "up";
@hidinginabunker
hidinginabunker / githubPostReceive.py
Created May 11, 2011 23:52
Testing github post-receive hook
app = Flask(__name__)
@app.route("/", methods=['GET'])
def helloworld():
return "PostReceive Catch Active"
@app.route("/", methods=['POST'])
def hello():
payloadString = request.form['payload']
@hidinginabunker
hidinginabunker / mustache.js
Created April 16, 2011 17:18
Command line tool to render a mustache template with a json context file
#!/usr/bin/env node
var
mu = require('Mu'),
fs = require('fs');
var
usage = ''
+ '\n'
+ ' Usage: mustache.js [context] [template]\n'