Skip to content

Instantly share code, notes, and snippets.

View arwagner's full-sized avatar

Andrew Wagner arwagner

  • Northern Virginia
View GitHub Profile
@arwagner
arwagner / gist:1291172
Created October 16, 2011 17:32
permission error
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /Users/andrewwagner/.rvm/gems/rbx-head-head-master directory.
@arwagner
arwagner / gist:1291183
Created October 16, 2011 17:45
can't uninstall
rvm rubies
jruby-1.6.4 [ darwin-x86_64-java ]
rbx-master [ x86_64 ]
=> ruby-1.8.7-p352 [ x86_64 ]
ruby-1.9.2-p290 [ x86_64 ]
new-host-3% sudo uninstall rbx-master
sudo: uninstall: command not found
new-host-3% sudo rvm uninstall rbx-master
@arwagner
arwagner / gist:1291200
Created October 16, 2011 17:58
rvm install rbx error
new-host-3% rvm install rbx
rbx-head installing #dependencies
Cloning git://github.com/rubinius/rubinius.git
mkdir: /Users/andrewwagner/.rvm/log/rbx-head: Permission denied
touch: /Users/andrewwagner/.rvm/log/rbx-head/rbx.repo.log: No such file or directory
/Users/andrewwagner/.rvm/scripts/functions/utility: line 152: /Users/andrewwagner/.rvm/log/rbx-head/rbx.repo.log: No such file or directory
/Users/andrewwagner/.rvm/scripts/functions/utility: line 159: /Users/andrewwagner/.rvm/log/rbx-head/rbx.repo.log: No such file or directory
ERROR: Error running 'git clone --depth 1 git://github.com/rubinius/rubinius.git /Users/andrewwagner/.rvm/repos/rbx-head', please read /Users/andrewwagner/.rvm/log/rbx-head/rbx.repo.log
Could not fetch git://github.com/rubinius/rubinius.git - trying http://github.com/rubinius/rubinius.git
Cloning http://github.com/rubinius/rubinius.git
@arwagner
arwagner / gist:1291220
Created October 16, 2011 18:11
rvm install rbx
new-host-3% rvm install rbx
rbx-head installing #dependencies
Cloning git://github.com/rubinius/rubinius.git
Copying from repo to source...
rbx-head - #configuring
rbx-head - #compiling
rbx-head - adjusting #shebangs for (erb ri rdoc).
rbx-head - #importing default gemsets (/Users/andrewwagner/.rvm/gemsets/)
WARN: rbx rbx-head-head is not installed.
To install do: 'rvm install rbx-head-head'
@arwagner
arwagner / gist:1302751
Created October 21, 2011 00:02
rspec spec exclusion
require 'rspec'
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:core) do |t|
t.rspec_opts = "-t ~foo"
end
describe "foo", :foo => true do
it "should be awesome" do
puts "foooooo!"
>> class Foo; def a; end; end
=> nil
>> class Bar < Foo; def a; super; end; end
=> nil
>> Bar.new.a
=> nil
/Users/andrewwagner> which ruby
ruby not found
/Users/andrewwagner> rvm list
rvm rubies
ruby-1.9.2-p290 [ i386 ]
/Users/andrewwagner> rvm use 1.9.2
Using /Users/andrewwagner/.rvm/gems/ruby-1.9.2-p290
@arwagner
arwagner / gist:1308151
Created October 24, 2011 01:06
Genetic algorithm
class ProceduralFiveDigits
def initialize
@new_population = Array.new(100) { generate_individual }
reset
end
def evolve
1000.times do
100.times do
@parent_a, @parent_b = [pick_individual, pick_individual]
@arwagner
arwagner / gist:1323952
Created October 29, 2011 01:13
Combinatorial explosion and testing
I found http://groups.google.com/group/growing-object-oriented-software/browse_thread/thread/47695af2c6b5adda fascinating, so I decided to make it a little more concrete. It's also in ruby using rspec, sorry about that. Here's the code under test:
class EligibleForDiscountPolicy
def initialize transaction, user
@transaction = transaction
@user = user
end
def decide
return true if @user.is_gold_member?
class Foo
def not
3
end
end
Foo.new.instance_eval { not } #=> syntax error, unexpected '}'
Foo.new.instance_eval { not() } #=> true
Foo.new.send :not #=> 3