This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :backup do | |
desc "Backup database" | |
task :db do | |
RAILS_ENV = "development" if !defined?(RAILS_ENV) | |
app_root = File.join(File.dirname(__FILE__), "..", "..") | |
settings = YAML.load(File.read(File.join(app_root, "config", "database.yml")))[RAILS_ENV] | |
output_file = File.join(app_root, "..", "backup", "#{settings['database']}-#{Time.now.strftime('%Y%M%d')}.sql") | |
system("/usr/bin/env mysqldump -u #{settings['username']} -p#{settings['password']} #{settings['database']} > #{output_file}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :db do | |
desc "Reset database and load seed data" | |
task :seed do | |
Rake::Task["db:migrate:reset"].invoke | |
require 'active_record/fixtures' | |
ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym) | |
Dir.glob(File.join(RAILS_ROOT, 'db', 'seed', '*.{yml,csv}')).each do |fixture_file| | |
Fixtures.create_fixtures('db/seed', File.basename(fixture_file, '.*')) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd ~/Desktop | |
wget http://release.seleniumhq.org/selenium-remote-control/1.0.1/selenium-remote-control-1.0.1-dist.zip | |
unzip selenium-remote-control-1.0.1-dist.zip | |
echo 'Copying in latest selenium' | |
sudo cp selenium-remote-control-1.0.1/selenium-server-1.0.1/selenium-server.jar /usr/local/lib/ruby/gems/1.8/gems/Selenium-1.1.14/lib/selenium/openqa/selenium-server.jar.txt | |
echo 'Removing dirs' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
** Template.templates.customer_address = "<div class='address'>${name}, ${line1}, ${postcode}</div>" | |
** | |
** var address = jQuery.parseJSON('{"name": "Steve", "line1": test}') | |
** Template.render("customer_address", address) | |
** | |
*/ | |
var Template = { | |
templates : {}, | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd my-project | |
git clone --bare . ../my-project.git | |
scp -r ../my-project.git user@server:/path/to/git-repositories/ | |
git remote add origin user@server:/path/to/git-repositories/my-project.git | |
# then you can do: | |
git push | |
git pull | |
etc etc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :db do | |
namespace :test do | |
task :prepare_postgis do | |
`/usr/local/pgsql/bin/psql dbname -f /usr/local/pgsql-9.0/share/contrib/postgis-1.5/postgis.sql -U postgres` | |
`/usr/local/pgsql/bin/psql dbname -f /usr/local/pgsql-9.0/share/contrib/postgis-1.5/spatial_ref_sys.sql -U postgres` | |
end | |
end | |
end | |
Rake::Task["db:test:prepare"].enhance do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Quick and dirty JS test runner | |
# | |
# Required files: | |
# {testdir} | |
# /index.html (rails specific sample below) | |
# <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" | |
# "http://www.w3.org/TR/html4/loose.dtd"> | |
# <html> | |
# <head> | |
# <link rel="stylesheet" href="<%= JS_TEST_BASE %>/qunit.css" type="text/css" media="screen" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* | |
!y.php | |
!x.php | |
!folder_xy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example: | |
# rendered_content = t("rendering layout") do | |
# layout.render('item' => self, 'contents' => contents) | |
# end | |
# | |
def t(title, &block) | |
puts "===========" | |
puts title | |
beginning_time = Time.now | |
result = yield |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
def to_annotated_xml(root) | |
output = "<#{root}>" | |
each do |i| | |
if i.is_a?(Fixnum) | |
output << "<number>#{i}</number>" | |
elsif i.is_a?(String) | |
if i.match(/@/) | |
output << "<email>#{i}</email>" |
OlderNewer