Skip to content

Instantly share code, notes, and snippets.

_ = require 'underscore'
module.exports = (robot) ->
class Leaderboard
constructor: ->
robot.brain.once 'loaded', =>
robot.brain.data.leaderboard ?= {}
@games = robot.brain.data.leaderboard.games ?= []
addGame: (winner, loser) ->
@games.push
@zacstewart
zacstewart / clean_users.sh
Created July 21, 2012 22:00
EMI Music Data Science Hackathon data cleaning scripts
#!/usr/bin/env sh
# This transforms the 13 answers to the WORKING column
# into integers 0-12, 5 answers to MUSIC into 0-4,
# normailizes LIST_OWN, and LIST_BACK into integer values
# and drops rows with variations of "16+ hours"
# (loses 2.623031698% of the data)
INFILE=$1
sed -e "
s/\"Employed 30+ hours a week\"/0/g;
s/\"Employed 8-29 hours per week\"/1/g;
@zacstewart
zacstewart / breakfast.md
Created August 9, 2012 20:35
Cherri's breakfast shake recipe
  • ice cream
  • 1/2 cup milk
  • 2 tbsp Ovaltine
  • 1-2 tbsp peanut butter
  • 1-2 raw eggs
  • 1 banana
@zacstewart
zacstewart / object_allocation_tracer.rb
Created July 15, 2015 15:28
Shitty Ruby Rack memory profiler
require 'objspace'
require 'set'
class ObjectAllocationTracer
include ObjectSpace
def initialize(app)
@app = app
@sources = Set.new
@traces = []
@zacstewart
zacstewart / zacstewart.pub.gpg
Last active October 13, 2015 11:38
My GnuPG Public Key
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.15 (Darwin)
mQINBFC7ikIBEAC/ps60Orp8iuX2CH3JD/VfjqPVVlqWBh40aa9dayMKTHRCHXLC
hTttTcHKeCsLnvmIHqxCxNBJu18kgX6Vvrc2xFO8KHldFxpQOX2oCVVOrDm7Sfc/
eRk61Ey0KCGQca3gNjlYzWOvtYhvL0yMyA/VLQcBdgm5vlkDFaBzvbRmhUZx2sZ1
nzhW7dyTbGOf6TD101MS3otrVxy3Tx4cm5lBdMxvNwutgqtGy75AElzOHg9zZ6kk
4ZF2Ll76wHSQOgrLShIEu2ymQLoS+VwpZeA4ab4FoP1CqxQd3GYPa5dhe6EakDf8
XH+x3CncV/cO2gDIwqE/lZv2yq004yrHAO4bhia8ndTJboNIQvwJICjJy5WIgU4s
MXs5YUZv8su4T1f95+xSSjEjfI6X2zA4WnekzCLUFfGHkr+KMOKUHRQIRVHOwP/X

Breaking table–model–controller symmetry

A while ago I hit a lull in my skill advancement as a Rails developer. I had long since learned to think of my resources as resources. I did my best to limit my controller actions the basic CRUD methods. I considered the "fat model, skinny controller" mantra to be sacrosanct. But I was still often finding myself going way out of my way to implement otherwise mundane features, for example sending mail after saving an object or adding a routine accept/reject to something.

Verifying that +zacstewart is my blockchain ID. https://onename.com/zacstewart
@zacstewart
zacstewart / tap_transformer_sklearn.py
Last active November 22, 2015 12:33
Example transformer for tapping into your Pipeline
def TapTransformer(TransformerMixin):
def __init__(self, fn):
self.fn = fn
def transform(self, X, **transform_params):
self.fn(x)
return X
def fit(self, X, y=none, **fit_params):
return self
@zacstewart
zacstewart / 1-minecraft_account_verifier.rb
Last active December 10, 2015 02:48
These two classes are the two strategies I went about to verify Minecraft accounts for Civtrade http://civtrade.herokuapp.com.
class MinecraftAccountVerifier
require 'net/http'
require 'uri'
AUTH_URI = URI.parse('https://login.minecraft.net/').freeze
CLIENT_VERSION = 13
attr_reader :error
# Public: verify an account as a true Minecraft account this user has access to.
@zacstewart
zacstewart / msttcorefonts-2.0-1.spec
Created January 7, 2013 18:00
msttcorefonts spec with updated SourceForge mirrors
# This is the msttcorefonts spec file as distributed from
# http://corefonts.sourceforge.net/.
%define name msttcorefonts
# nowdays most (all?) distributions seems to use this. Oh the joys of the FHS
%define ttmkfdir /usr/bin/ttmkfdir
%define fontdir /usr/share/fonts/%{name}