Skip to content

Instantly share code, notes, and snippets.

@agenteo
agenteo / rails_snippets.rb
Created October 1, 2009 00:34
rails snippets
Recipe.all.each(&:save)
YAML::load( File.open( 'README' ) )
self.class.helpers.link_to(
include ActionController::UrlWriter
require 'rubygems'
gem 'soap4r'
require 'soap/wsdlDriver'
wsdl_url = "http://YOU-URL-HERE?wsdl"
driver = SOAP::WSDLDriverFactory.new(wsdl_url).create_rpc_driver
driver.options["protocol.http.basic_auth"] << [wsdl_url, "USER", "PASS"]
response = driver.functionHere(1, 2, 3)
@agenteo
agenteo / gist:400879
Created May 14, 2010 06:27
helpers for capybara
module VerboseExpectationsHelpers
def expect_page_has(path, options={})
@path, @options = path, options
raise Capybara::ElementNotFound, text_found_instead if !page.has_css?(@path, @options)
end
def expect_page_count(path, options={})
@path, @options = path, options
raise Capybara::ElementNotFound, total_found_instead if !page.has_css?(@path, @options)
arbon:cos enricoant$ gem install rack -v 1.0.1
/Users/enricoant/.rvm/rubies/ruby-1.8.7-p248/lib/ruby/site_ruby/1.8/rubygems/spec_fetcher.rb:254: warning: getc is obsolete; use STDIN.getc instead
^CERROR: Interrupted
carbon:cos enricoant$ history | grep rack
135 gem list rack
139 gem install rack -v 1.0.1
145 gem install rack
146 history | grep rack
147 gem install rack -v 1.0.1
149 gem install rack -v 1.0.1
### Installing rack or rails was failinf when running 1.8.7-p249 via RVM
### /Users/enricoant/.rvm/rubies/ruby-1.8.7-p248/lib/ruby/site_ruby/1.8/rubygems/spec_fetcher.rb:254: warning: getc is obsolete; use STDIN.getc instead
### So i switched to 1.8.7-p248 via RVM
carbon:cos enricoant$ gem install rack -v 1.0.1
/Users/enricoant/.rvm/rubies/ruby-1.8.7-p248/lib/ruby/site_ruby/1.8/rubygems/spec_fetcher.rb:254: warning: getc is obsolete; use STDIN.getc instead
^CERROR: Interrupted
carbon:cos enricoant$ gem install rails
/Users/enricoant/.rvm/rubies/ruby-1.8.7-p248/lib/ruby/site_ruby/1.8/rubygems/spec_fetcher.rb:254: warning: getc is obsolete; use STDIN.getc instead
@agenteo
agenteo / .gitconfig
Created May 18, 2010 04:58
git config
[color]
branch = auto
diff = auto
status = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
def generate_display_name
@display_name_candidate = generate_display_name_candidate
if Member.find_by_display_name(@display_name_candidate)
self.display_name = find_next_display_name_available
else
self.display_name = @display_name_candidate
end
return true
end
@agenteo
agenteo / route_extract.rb
Created March 7, 2011 02:22
Collects the first level of routes from a file containing the 'rake routes' output.
require 'rubygems'
# Deletes standard route, standard route :format, root route
def delete_last_three_lines
3.times { @lines.delete_at(-1) } # TODO: change to .drop(3) when using Ruby 1.8.7
end
@paths = []
@lines = File.readlines('routes.txt')
@lines.delete_at(0)
@agenteo
agenteo / gist:3779919
Created September 25, 2012 04:06
json-schema specs
[{
"description":"It should fail when number is greater then maximum.",
"schema":{
"type":"number",
"maximum":2012
},
"data":{
"dob": 2013
},
"valid": false
@agenteo
agenteo / gist:3779950
Created September 25, 2012 04:14
json-schema grouped specs
[
{
"description": "integer type",
"schema": {"type": "number", "maximum": 2012},
"tests": [
{
"description": "It should pass when number is less then maximum",
"data": 1981,
"valid": true
},