This file contains hidden or 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
ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR = | |
"#{ActionView::Helpers::AssetTagHelper::ASSETS_DIR}/javascriptx" | |
ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR = | |
"#{ActionView::Helpers::AssetTagHelper::ASSETS_DIR}/stylesheetx" |
This file contains hidden or 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
def self.make_zip_io | |
cmd = "sh -c 'cd /somewhere && zip -r - stuff'" | |
IO.popen(cmd) | |
end | |
def zip | |
io = self.class.make_zip_io | |
send_data(io.read, :filename => 'filename.zip', :type => 'application/zip') | |
end |
This file contains hidden or 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
# modifications from standard capistrano deploy as taken from: | |
# http://devthatweb.com/view/deploy-any-project-using-capistrano-2 | |
set :application, "name removed" | |
set :repository, "url to trunk of repo" | |
# If you aren't deploying to /u/apps/#{application} on the target | |
# servers (which is the default), you can specify the actual location | |
# via the :deploy_to variable: | |
set :deploy_to, "/var/www/#{application}" |
This file contains hidden or 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
sql = 'a big honking sql statement' | |
conditions = conditions_for_doodad | |
order = "#{params[:order_by]} #{params[:order]}" | |
Doodad.send(:add_conditions!, sql, conditions) | |
Doodad.send(:add_order!, sql, order) | |
@rs = ActiveRecord::Base.connection.select_all(sql) |
This file contains hidden or 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
# Returns hierarchical data structure rooted at this node. When converting to | |
# json make sure to remove :parent to avoid circular reference: | |
# message.full_hierarchy.to_json(:only => [:id, :subject, :children, ...]) | |
def full_hierarchy | |
the_full_set = full_set | |
ancestry = [build_node(the_full_set.shift)] | |
while !the_full_set.empty? | |
next_node = build_node(the_full_set.shift) | |
while next_node[:level] <= ancestry.last[:level] | |
ancestry.pop |
This file contains hidden or 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 Message < ActiveRecord::Base | |
acts_as_nested_set :scope => 'discussable_id = #{discussable_id} AND discussable_type = \'#{discussable_type}\'' | |
belongs_to :discussable, :polymorphic => true | |
# ... | |
end | |
class Foo < ActiveRecord::Base |
This file contains hidden or 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
mysqldump -u user_name -p database_name > dump.sql |
This file contains hidden or 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
cat dump.sql | mysql -u user_name -p database_name |
This file contains hidden or 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
ssh some.server 'mysqldump -u user_name -p remote_database_name' | mysql -u user_name -p local_database_name |
This file contains hidden or 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
#!/usr/bin/env bash | |
if [ $# -eq 2 ]; then | |
user=$1 | |
dbname=$2 | |
basecmd="mysql -u ${user} -D ${dbname}" | |
elif [ $# -eq 3 ]; then | |
user=$1 | |
PASS=$2 | |
dbname=$3 |