Skip to content

Instantly share code, notes, and snippets.

require 'rubygems'
require 'active_record'
desc 'migrate legacy table to add column'
namespace :document_manager do
namespace :db do
task :migrate do
ActiveRecord::Base.clear_active_connections!
configs = open('config/database.yml') { |f| YAML.load(f) }
ActiveRecord::Base.logger = Logger.new(STDOUT)
#calling view
<%= growl4rails_includes(3000, 5) %>
<%=
periodically_call_remote(
:url => '/foos/loading_statuses.js',
:frequency => '4',
:complete => "request",
:method => 'GET'
)
find . -name "* *"|while read file
do
echo "$file"
mv "$file" "`echo "$file"| awk ' BEGIN {OFS="_"} $1=$1 '`"
done
@alkema
alkema / twat.rb
Created April 6, 2009 21:54 — forked from Aupajo/twat.rb
#!/usr/bin/env ruby
# Find common Twitter friends
# Usage: ./twat.rb user1 user2 ...
lists = ARGV.inject({}) do |hash, username|
page = 0
while !(output = `curl -s http://twitter.com/statuses/friends/#{username}.xml?page=#{page += 1} | grep "<screen_name>"`.gsub(%r{</?screen_name>}, '').split).empty?
hash[username] = ((hash[username] || []) + output).sort
end
hash
@alkema
alkema / seed.rake
Created August 17, 2009 04:37
rails 3 rake db:seed for now
namespace :db do
desc 'Drops and recreates the database from db/schema.rb for the current environment and loads the seeds.'
task :reset => [ 'db:drop', 'db:setup' ]
desc 'Create the database, load the schema, and initialize with the seed data'
task :setup => [ 'db:create', 'db:schema:load', 'db:seed' ]
desc 'Load the seed data from db/seeds.rb'
task :seed => :environment do
seed_file = File.join(Rails.root, 'db', 'seeds.rb')
#!/usr/bin/env ruby
require "cgi"
require 'active_record'
ActiveRecord::Base.establish_connection(
:adapter => ,
:database => ,
:username => ,
:password => ,
:host =>
task :bail do
hostname = `hostname`.to_s.strip
if hostname == 'prodsite.ca'
puts "this task cannot be run from this host (#{hostname})"
exit
end
end
desc "pull data from production server"
namespace :resources do
require 'rest_client'
params = { "accountType" => "HOSTED_OR_GOOGLE", "Email" => 'user@domain.com', "Passwd" => 'secret', "service" => "writely" }
result = RestClient.post "https://www.google.com/accounts/ClientLogin", params
result.to_s[/Auth=(.*)/, 1]
<link rel="stylesheet" href="/stylesheets/all.css" type="text/css" />
<link rel="stylesheet" href="/stylesheets/minimum.css" type="text/css" media="handheld, all" />
<style type="text/css" media="print, screen and (min-width: 481px)" xml:space="preserve">
@import url("/stylesheets/advanced.css");
</style>
# recent xcode
# http://developer.apple.com/technologies/xcode.html
# brew
ruby -e "$(curl -fsS http://gist.github.com/raw/323731/install_homebrew.rb)"
brew doctor
# UNIX stuff
brew install git
brew install imagemagick