Skip to content

Instantly share code, notes, and snippets.

View moonmaster9000's full-sized avatar

moonmaster9000 moonmaster9000

View GitHub Profile
(function() {
var HomeController, app, routes;
HomeController = {
index: function() {
return $('#main').text('Welcome!');
}
};
routes = function() {
return this.get('#/', HomeController.index);
};
class Array
def make_flat
flat_array = []
self.each do |element|
if element.respond_to? :make_flat
flat_array += element.make_flat
else
flat_array << element
end
end
def my_reverse( a )
#... fill in this code
end
a = [1,2,3,4]
b = my_reverse a
puts b.inspect
#==> [4, 3, 2, 1]
def my_reverse( a )
reversed = []
length_a = a.length
for counter in Array.new( length_a )
last = a.pop
reversed.push( last )
end
reversed
end
@moonmaster9000
moonmaster9000 / bash_errors
Created April 20, 2011 18:31
errors when opening a new terminal after installing the latest rvm from github
-bash: /Users/mparker/.rvm/scripts/selector: line 202: syntax error near unexpected token `('
-bash: /Users/mparker/.rvm/scripts/selector: line 202: ` if [[ -z "${rvm_ruby_version:-""}" ]] (( rvm_head_flag == 0 ))'
-bash: /Users/mparker/.rvm/scripts/selector: line 202: syntax error near unexpected token `('
-bash: /Users/mparker/.rvm/scripts/selector: line 202: ` if [[ -z "${rvm_ruby_version:-""}" ]] (( rvm_head_flag == 0 ))'
@moonmaster9000
moonmaster9000 / rack-test-port.rb
Created June 9, 2011 20:57
rack-test port settings
get "/", {}, "HTTP_HOST" => "example.org:9000"
last_request.port.should == 9000
get "/", {}, "SERVER_PORT" => "9000"
last_request.port.should == 9000
header "Host", "example.org:9000"
get "/"
last_request.port.should == 9000
@moonmaster9000
moonmaster9000 / gist:1242032
Created September 26, 2011 11:17
parsing .travis.yml
ruby-1.8.7-p334 :001 > require 'yaml'
=> true
ruby-1.8.7-p334 :002 > YAML.load File.read(".travis.yml")
=> {"before_script"=>"echo 'before start' && sed -i '' -e 's/admin:password\\@//' features/support/env.rb && echo 'before end'", "rvm"=>["1.8.7", "1.9.2", "1.9.3", "rbx-2.0", "ree"]}
#
# Feature: Test How Spinach Works
#
# Scenario: Test triple equals
# Given I have an empty array:
# """
# @array = []
# """
#
# Then it should be empty:
@moonmaster9000
moonmaster9000 / imperative.feature
Created November 24, 2012 20:10
Imperative Tweet Feature
Scenario: Valid tweet
Given there is a user "bob" with password "password"
And there is a user "alice" with password "password"
And I visit "/"
And I fill in "username" with "bob"
And I fill in "password" with "password"
And I click "Log in"
When I fill in "Tweet" with "this is a test tweet noise noise noise noise noise noise noise noise noise noise noise noise noise noise noise noise haha I'm less than 140 characters."
And I click "Submit"
Then I should see "Your tweet was submitted"