Skip to content

Instantly share code, notes, and snippets.

>> IF = -> b { b }
=> #<Proc:0x007fb4e4049cc8 (lambda)>
>> LEFT = -> p { p[-> x { -> y { x } } ] }
=> #<Proc:0x007fb4e403d680 (lambda)>
>> RIGHT = -> p { p[-> x { -> y { y } } ] }
=> #<Proc:0x007fb4e4028ff0 (lambda)>
>> IS_EMPTY = LEFT
@zacstewart
zacstewart / gist:6000932
Created July 15, 2013 15:36
Linear kernel matrix inversion
>>> K = X.dot(X.transpose())
>>> K
array([[ 2, 3, 3, 5, 5, 6],
[ 3, 5, 4, 8, 7, 9],
[ 3, 4, 5, 7, 8, 9],
[ 5, 8, 7, 13, 12, 15],
[ 5, 7, 8, 12, 13, 15],
[ 6, 9, 9, 15, 15, 18]])
>>> np.linalg.inv(K)
Traceback (most recent call last):
data/H1/Tagged_Training_04_13_1334300401.mat
data/H1/Tagged_Training_10_22_1350889201.mat
data/H1/Tagged_Training_10_23_1350975601.mat
data/H1/Tagged_Training_10_24_1351062001.mat
0-length event:
36,Trash Compactor,1351104180,1351104180
0-length event:
36,Trash Compactor,1351104300,1351104300
0-length event:
36,Trash Compactor,1351104360,1351104360
#lang racket
(define (sum-of-multiples-of a b n)
(define (iter acc n)
(if (= n 0)
acc
(iter
(+ acc (if (or (= (modulo n a) 0) (= (modulo n b) 0)) n 0))
(- n 1))))
@zacstewart
zacstewart / gist:4942036
Last active December 13, 2015 16:39
Wat?
2013-02-13T03:58:36+00:00 app[web.2]: ** [NewRelic][02/13/13 03:58:36 +0000 32135350-f34d-445d-9360-85e5ef0df147 (2)] ERROR : Error establishing connection with New Relic Service at collector.newrelic.com:80:
2013-02-13T03:58:36+00:00 app[web.2]: ArgumentError: wrong number of arguments (2 for 1)
2013-02-13T03:58:36+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/core_ext/object/to_json.rb:15:in `to_json'
2013-02-13T03:58:36+00:00 app[web.2]: /usr/local/lib/ruby/1.9.1/json/common.rb:212:in `generate'
2013-02-13T03:58:36+00:00 app[web.2]: /usr/local/lib/ruby/1.9.1/json/common.rb:212:in `generate'
2013-02-13T03:58:36+00:00 app[web.2]: /usr/local/lib/ruby/1.9.1/json/common.rb:336:in `dump'
2013-02-13T03:58:36+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.5.5.38/lib/new_relic/agent/new_relic_service.rb:348:in `dump'
2013-02-13T03:58:36+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.5.5.38/lib/new_relic/agent/new_re
@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}
@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 / 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
Verifying that +zacstewart is my blockchain ID. https://onename.com/zacstewart

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.