Skip to content

Instantly share code, notes, and snippets.

View bradhe's full-sized avatar
👋
looking for friendship

Brad Heller bradhe

👋
looking for friendship
  • Berlin
View GitHub Profile
@bradhe
bradhe / generic_iterator.java
Created June 24, 2012 05:33
Is this even possible in Java??
public <T> MyList ofType(Class<T> klass) {
MyList list = new MyList();
for(MyElement elem : this) {
if(elem instanceof klass) {
list.add(elem);
}
}
return(list);

This is a gist.

What do yuo think of it?

@bradhe
bradhe / setup_machine.sh
Created September 3, 2012 09:39
Sets up a new machine in EC2 with RVM in the current shell.
sudo apt-get install build-essential zlib1g-dev libreadline-dev libssl-dev libxml2-dev git
curl -L https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
@bradhe
bradhe / test.rb
Created September 21, 2012 21:09
begin
raise "Hello, World!"
rescue => e
puts "#{e.class.name}: #{e}"
end
begin
raise ArgumentError, "Hello, World!"
rescue => e
puts "#{e.class.name}: #{e}"
@bradhe
bradhe / test_array_addition.rb
Created October 19, 2012 22:22
What do you think the output of this script is?
arr = []
my_variable = false
my_other_variable = true
arr << my_variable ? "This was true." : "This was false."
arr << my_other_variable ? "This was true." : "This was false."
p arr
/my_ruby/gems/rspec-gc-control-1.0.1/lib/rspec-gc-control/configuration.rb:30: [BUG] Segmentation fault
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin12.0.0]
-- Control frame information -----------------------------------------------
c:0029 p:---- s:0115 b:0115 l:000114 d:000114 CFUNC :start
c:0028 p:0138 s:0112 b:0112 l:000111 d:000111 METHOD /my_ruby/gems/rspec-gc-control-1.0.1/lib/rspec-gc-control/configuration.rb:30
c:0027 p:0045 s:0107 b:0104 l:000103 d:000103 METHOD /my_ruby/gems/rspec-gc-control-1.0.1/lib/rspec-gc-control/example.rb:21
c:0026 p:0036 s:0101 b:0100 l:0011f0 d:001360 BLOCK /my_ruby/gems/rspec-core-2.11.1/lib/rspec/core/example.rb:119
c:0025 p:0024 s:0097 b:0097 l:0013d8 d:0013d8 METHOD /my_ruby/gems/rspec-core-2.11.1/lib/rspec/core/example.rb:253
c:0024 p:0059 s:0092 b:0092 l:0011f0 d:0011f0 METHOD /my_ruby/gems/rspec-core-2.11.1/lib/rspec/core/example.rb:110
@bradhe
bradhe / Fib.java
Last active December 12, 2015 06:58
Timing results of generating the first 40 fibonacci numbers using Topaz Ruby, MRI 1.9.3-p374, Rubinius 2.x, Go 1.0.2, C w/ clang, and C w/ GCC.
public class Fib {
public static int fib(int n) {
if(n <= 2) {
return 1;
} else {
return fib(n-1) + fib(n-2);
}
}
public static void main(String[] args) {
@bradhe
bradhe / generate_mongo_data.go
Created February 22, 2013 23:03
Generates "random" documents, each with a batch ID, in a parallel way using a fan-out pattern.
package main
import (
"runtime"
"time"
"math/rand"
"fmt"
"labix.org/v2/mgo"
)
@bradhe
bradhe / heroku_rell_test.sh
Last active December 15, 2015 19:49
Results of ab against ruby 2.0 + reel + Heroku #disappointed
brad@/www/reel_test [master] $ heroku scale web=40
Scaling web processes... done, now running 40
brad@/www/reel_test [master] $ ab -c 1 -n 100 http://reel-test.herokuapp.com/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking reel-test.herokuapp.com (be patient).....done
RPC to '[email protected]' failed: {'EXIT',
{timeout,
{gen_server,call,
[riak_core_gossip,
legacy_gossip]}}}