Skip to content

Instantly share code, notes, and snippets.

View mattetti's full-sized avatar

Matt Aimonetti mattetti

View GitHub Profile
package main
import "fmt"
func main() {
type key struct {
door string
}
keys := []key{key{door: "x"}, key{door: "y"}, key{door: "z"}}
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@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]
### 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:
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
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"}
@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
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
#!/usr/bin/env bash
set -eu
## The Godeps file is expected to have lines like so:
#
# github.com/nu7hatch/gotrail v2.6
#
## where the first element is the import path and the second is a tag
## or commit SHA in the project.
@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))