Skip to content

Instantly share code, notes, and snippets.

View mattetti's full-sized avatar

Matt Aimonetti mattetti

View GitHub Profile
@mattetti
mattetti / gist:248
Created July 21, 2008 21:13 — forked from schacon/gist:1
my test fork!
This is gist.
There are many like it, but this one is mine.
It is my life.
I must master it as I must master my life.
Without me gist is useless.
Without gist, I am useless.
@mattetti
mattetti / bug.rb
Created February 12, 2014 20:01
typo bug that cost me a few hours of debugging
@iterations = opts[:iterations] || opts["iterations"] || 1000
keygen = ActiveSupport::CachingKeyGenerator.new(ActiveSupport::KeyGenerator.new(@secret, iterations: @iteration))
func APIToken(usr, password string) (string, error) {
req, err := http.NewRequest("GET", apiURL, nil)
if err != nil {
return "", fmt.Errorf("creating request")
}
req.SetBasicAuth(usr, password)
resp, err := client.Do(req)
if err != nil {
return "", err
@mattetti
mattetti / gist:f5b0c44830eb9b98178a
Created June 24, 2014 16:16
urls from Blake Mizerany's talk at #GoSF - June 23rd
http://www.cs.rutgers.edu/~muthu/bquant.pdf
http://godoc.org/github.com/bmizerany/perks/quantile
http://godoc.org/github.com/bmizerany/perks/quantile#NewBiased
https://github.com/bmizerany/perks/blob/da72989a59aaaecda7110926d3a6198ee4421c1f/quantile/stream.go#L48-L78
https://twitter.com/mrb_bk/status/461255692574527488
https://github.com/bmizerany/perks/pull/7/files
https://code.google.com/p/go/source/browse/misc/benchcmp?name=release-branch.go1
https://code.google.com/p/go/source/browse/?repo=tools#hg%2Fcmd%2Fbenchcmp
https://github.com/bmizerany/perks/pull/12
http://godoc.org/github.com/bmizerany/perks/quantile#hdr-Effective_Computation_of_Biased_Quantiles_over_Data_Streams
crypt_secret = key_generator.generate_key("signed encrypted cookie")
encryptor = ActiveSupport::MessageEncryptor.new(secret, crypt_secret)
encrypted_message = encryptor.encrypt_and_sign({msg: "hello world"})
encryptor.decrypt_and_verify(encrypted_message)
# => {:msg => "hello world"}
class ::Pwned
def marshal_load(*args)
ActiveRecord::Base.connection.tables.each do |t|
ActiveRecord::Base.connection.drop_table(t)
end
end
def marshal_dump; end
def by
### Keybase proof
I hereby claim:
* I am mattetti on github.
* I am mattetti (https://keybase.io/mattetti) on keybase.
* I have a public key whose fingerprint is EC60 B9C9 EE13 9B5D E626 5349 9012 5AAA CAEC EA7F
To claim this, I am signing this object:
@mattetti
mattetti / .gitconfig
Created May 28, 2015 20:20
cat ~/.gitconfig
[user]
name = Matt Aimonetti
email = mattaimonetti@gmail.com
[alias]
co = checkout
st = status
br = branch
ci = commit
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s - %an %Cgreen(%cr) %C(bold blue)%Creset' --abbrev-commit
[apply]
package main
import "fmt"
func main() {
type key struct {
door string
}
keys := []key{key{door: "x"}, key{door: "y"}, key{door: "z"}}
merb-gen app test
RubiGen::Scripts::Generate
undefined method `generator_scope' for Merb:Module
/opt/local/lib/ruby/gems/1.8/gems/merb-gen-0.9.4/lib/merb-gen/base.rb:15:in `initialize'
/opt/local/lib/ruby/gems/1.8/gems/merb-gen-0.9.4/app_generators/merb/merb_generator.rb:9:in `initialize'
/opt/local/lib/ruby/gems/1.8/gems/rubigen-1.3.2/lib/rubigen/lookup.rb:163:in `new'
/opt/local/lib/ruby/gems/1.8/gems/rubigen-1.3.2/lib/rubigen/lookup.rb:163:in `instance'
/opt/local/lib/ruby/gems/1.8/gems/rubigen-1.3.2/lib/rubigen/scripts/../scripts.rb:30:in `run'
/opt/local/lib/ruby/gems/1.8/gems/merb-gen-0.9.4/lib/merb-gen.rb:19:in `run'
/opt/local/lib/ruby/gems/1.8/gems/merb-gen-0.9.4/bin/merb-gen:72