Skip to content

Instantly share code, notes, and snippets.

View bryanhelmig's full-sized avatar
Zapier is hiring!

Bryan Helmig bryanhelmig

Zapier is hiring!
View GitHub Profile
var immer = require("immer");
var produce = immer.produce;
var patches = [];
var state0 = { a: 1 };
var state1 = produce(
state0,
function (draft) {
draft.b = 9;
},
package main
import (
"fmt"
)
func decorator(f func(s string)) func(s string) {
return func(s string) {
fmt.Println("Started")
@bryanhelmig
bryanhelmig / active_user_analysis.py
Last active February 8, 2017 23:47
Counts of users' events by day
"""
users if active or not on a given day plus counts of events
"""
import os
import csv
from collections import defaultdict
from collections import Counter
UFILE = 'data/users.csv'
@bryanhelmig
bryanhelmig / crushimg.sh
Created July 15, 2016 21:33 — forked from caiguanhao/crushimg.sh
Recursively crush/shrink/optimize/losslessly compress PNGs, JPEGs and GIFs.
#!/bin/bash
# This is modifed from https://gist.github.com/caiguanhao/4528926
# This is an improved script of pngfix.sh (https://gist.github.com/404909)
# which can also crush/shrink/optimize/losslessly compress JPEGs and GIFs.
# It is recommended you backup your image files before executing this script.
# Operation will be skipped if output file is bigger in size.
#
# use chmod +x crushimg.sh to make it executable and then ./crushimg.sh to run, or
# bash ./crushimg.sh to run it directly
#
@bryanhelmig
bryanhelmig / script_test.js
Last active November 24, 2016 05:15 — forked from billywhizz/script_test.js
record time spent on "each" run for nodejs or node vm module vs contextify, etc.
var vm = require('vm'),
Contextify = require('contextify'),
code = 'var square = n * n;',
fn = new Function('n', code),
script = vm.createScript(code);
n = 5;
benchmark = function(title, funk) {
var end, i, start, spins = 10000;
@bryanhelmig
bryanhelmig / setup-statsd.sh
Created August 10, 2012 00:10 — forked from rw/setup-statsd.sh
Turn an Ubuntu 11.10 EC2 into a StatsD/Graphite server
# install git
sudo apt-get install g++ curl libssl-dev apache2-utils
sudo apt-get install git-core
sudo apt-get install nodejs
# install the Node package manager for later use
curl http://npmjs.org/install.sh | sudo sh
sudo npm install express
# clone the statsd project
git clone https://github.com/etsy/statsd.git
# download everything for graphite
initRules: () ->
# Rules are children of reads. Setup the @rules collection, set a URL on the collection.
# then fetch all the children from the api
@rules = new Rules({})
@rules.urlRoot = "#{@url()}/rules"