Skip to content

Instantly share code, notes, and snippets.

@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}
@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
#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 / classifier.py
Last active March 27, 2023 15:59
Document Classification with scikit-learn
import os
import numpy
from pandas import DataFrame
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.naive_bayes import MultinomialNB
from sklearn.pipeline import Pipeline
from sklearn.cross_validation import KFold
from sklearn.metrics import confusion_matrix, f1_score
NEWLINE = '\n'
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
@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):
>> 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 / command_line_arguments.rb
Created September 19, 2013 17:03
Stubbing command line arguments in ruby
module CommandLineArguments
def argv
ARGV
end
end