Skip to content

Instantly share code, notes, and snippets.

View gist:33692
require 'yaml'
class Company
attr_accessor :name, :street, :town, :state, :postcode, :phone, :website, :fax, :categories
end
y = File.open( "companies.yaml" )
counter = 0
yp = YAML::load_documents( y ) { |doc|
View mysql dump with timestamp
#!/bin/bash
db_name=$1
date_time=`date +%Y%m%d_%H%M_%S_`
file_name=${date_time}${db_name}.sql
echo "Dumping the database ${db_name} in ${file_name}..."
mysqldump5 pregnancy_directory_development --user=root > ${file_name}
echo "Sayonara"
@agenteo
agenteo / backup_db.sh
Created Mar 20, 2009
mysql database timestamped backup
View backup_db.sh
#!/bin/bash
db_name=$1
date_time=`date +%Y%m%d_%H%M_%S`
file_name=${db_name}_${date_time}.sql
echo "Dumping the database ${db_name} in ${file_name}..."
mysqldump5 ${db_name} --user=root > ${file_name}
echo "Sayonara"
@agenteo
agenteo / restore_db.sh
Created Mar 20, 2009
restore db from a sql file
View restore_db.sh
#!/bin/bash
db_name=$1
db_dump_file=$2
echo "Dropping the database ${db_name}..."
mysqladmin5 drop ${db_name} --user=root
echo "Creating the database ${db_name}..."
mysqladmin5 create ${db_name} --user=root
echo "Restore structure and data from ${db_dump_file}"
View rails_snippets.rb
Recipe.all.each(&:save)
YAML::load( File.open( 'README' ) )
self.class.helpers.link_to(
include ActionController::UrlWriter
View http_auth_with_soap4r.rb
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
helpers for capybara
View gist:400879
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)
View gist:404489
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
View RVM warning: getc is obsolete; use STDIN.getc instead
### 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
View .gitconfig
[color]
branch = auto
diff = auto
status = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold