backuping up/restring pgsql
pg_dump dbname > dbname.sql cat dbname.sql | psql dbname
12388 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Rick Olson http://techno-weenie.net
pg_dump dbname > dbname.sql cat dbname.sql | psql dbname
desc "Checks out rails" task :init do ENV['SHARED_PATH'] = '../../shared' unless ENV['SHARED_PATH'] ENV['RAILS_PATH'] ||= File.join(ENV['SHARED_PATH'], 'rails') checkout_path = File.join(ENV['RAILS_PATH'], 'trunk') export_path = "#{ENV['RAILS_PATH']}/rev_#{ENV['REVISION']}" symlink_path = 'vendor/rails' # do we need to checkout the file? unless File.exists?(checkout_path) puts 'setting up rails trunk' get_framework_for checkout_path do |framework| system "svn co http://dev.rubyonrails.org/svn/rails/trunk/#{framework}/lib #{checkout_path}/#{framework}/lib --quiet" end end # do we need to export the revision? unless File.exists?(export_path) puts "setting up rails rev #{ENV['REVISION']}" get_framework_for export_path do |framework| system "svn up #{checkout_path}/#{framework}/lib -r #{ENV['REVISION']} --quiet" system "svn export #{checkout_path}/#{framework}/lib #{export_path}/#{framework}/lib" end end puts 'linking rails' rm_rf symlink_path mkdir_p symlink_path get_framework_for symlink_path do |framework| ln_s File.expand_path("#{export_path}/#{framework}/lib"), "#{symlink_path}/#{framework}/lib" end end def get_framework_for(*paths) %w( railties actionpack activerecord actionmailer activesupport actionwebservice ).each do |framework| paths.each { |path| mkdir_p "#{path}/#{framework}" } yield framework end end
set :rails_version, 3517 desc "Checks out rails rev ##{rails_version}" task :after_symlink do run <<-CMD cd #{current_release} && rake init REVISION=#{rails_version} RAILS_PATH=/home/username/projects/rails CMD end
$HTTP["host"] =~ "^.*\.([^.]+\.[^.:]+)(:|^)" { url.rewrite = ( "^/images/(.*)" => "/%1/images/$1", "^/files/(.*)" => "/%1/files/$1", "^/$" => "index.html", "^([^.]+)$" => "$1.html") }
# /app/views/articles/_article.rhtml <script type="text/javascript"><!-- if(!mmposts){var mmposts=[];}mmposts[mmposts.length]="<%= article.id %>"; //--></script> <!-- mmp mmid:<%= article.id %> mmdate:<%= article.created_at.to_s(:db) %> mmurl:<%=h article_url(article, true) %> mmtitle:<%=h article.title %> --> # /app/views/articles/_comment.rhtml <script type="text/javascript"><!-- if(!mmcomments){var mmcomments=[];}mmcomments[mmcomments.length]="<%= comment.id %>"; //--></script> <!-- mmc mmid:<%= comment.id %> mmdate:<%= comment.created_at.to_s(:db) %> mmauthor:<%=h comment.author %> --> # /app/views/articles/read.rhtml # This is the same as the _article.rhtml snippet, but using the @article instance var instead of the article local var <script type="text/javascript"><!-- if(!mmposts){var mmposts=[];}mmposts[mmposts.length]="<%= @article.id %>"; //--></script> <!-- mmp mmid:<%= @article.id %> mmdate:<%= @article.created_at.to_s(:db) %> mmurl:<%=h article_url(@article, true) %> mmtitle:<%=h @article.title %> --> </div>
set :rails_version, 2871
desc "Checks out rails rev ##{rails_version}" task :after_symlink do run "cd #{current_release} && rake init SHARED_PATH=#{shared_path} CURRENT_RELEASE=#{current_release} REVISION=#{rails_version}" end
desc "Performs an export of the rails trunk" task :init do return unless ENV['SHARED_PATH'] and ENV['CURRENT_RELEASE'] puts 'copying files...' cp "#{ENV['SHARED_PATH']}/database.yml", "#{ENV['CURRENT_RELEASE']}/config" cp "#{ENV['SHARED_PATH']}/dispatch.fcgi", "#{ENV['CURRENT_RELEASE']}/public" puts 'setting permissions...' chmod 0600, "#{ENV['CURRENT_RELEASE']}/config/database.yml" chmod 0700, "#{ENV['CURRENT_RELEASE']}/public/dispatch.fcgi" checkout_path = "#{ENV['SHARED_PATH']}/rails/trunk" export_path = "#{ENV['SHARED_PATH']}/rails/rev_#{ENV['REVISION']}" symlink_path = "#{ENV['CURRENT_RELEASE']}/vendor/rails" # do we need to checkout the file? unless File.exists?(checkout_path) puts 'setting up rails trunk' get_framework_for checkout_path do |framework| system "svn co http://dev.rubyonrails.org/svn/rails/trunk/#{framework}/lib #{checkout_path}/#{framework}/lib --quiet" end end # do we need to export the revision? unless File.exists?(export_path) puts "setting up rails rev #{ENV['REVISION']}" get_framework_for export_path, symlink_path do |framework| system "svn up #{checkout_path}/#{framework}/lib -r #{ENV['REVISION']} --quiet" system "svn export #{checkout_path}/#{framework}/lib #{export_path}/#{framework}/lib" end end puts 'linking rails' rm_rf "vendor/rails" mkdir_p "vendor/rails" get_framework_for checkout_path, export_path, symlink_path do |framework| ln_s File.expand_path("#{export_path}/#{framework}/lib"), "#{ENV['CURRENT_RELEASE']}/vendor/rails/#{framework}/lib" end end def get_framework_for(*paths) %w( railties actionpack activerecord actionmailer activesupport actionwebservice ).each do |framework| paths.each { |path| mkdir_p "#{path}/#{framework}" } yield framework end end
desc "Restart the FCGI processes on the app server." task :restart, :roles => :app do run "ruby #{current_path}/script/process/reaper" end
class MyController < ActionController::Base before_filter :set_site_template_root def set_site_template_root self.class.template_root = "#{RAILS_ROOT}/#{app}/#{views}/#{current_site.domain}") @template.base_path = template_root end end
module ActionView class Base private alias_method :rails_assign_method_name, :assign_method_name # add a domain prefix at the end def assign_method_name(extension, template, file_name) rails_method_name = rails_assign_method_name(extension, template, file_name) @@method_names[file_name || template] = respond_to?(:current_site) ? "#{rails_method_name}_#{current_site.domain}".intern : rails_method_name end end end
* html #blah { filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/full/path/to/img.png', sizingMethod='crop'); background:none; cursor:hand; /* only if this is a link */ position:relative; }
opacity:.7; /* css standard */ filter:alpha(opacity=70); /* IE patch */
document.getElementsByTagName('div').map(function(el) {});
Object.extend(String.prototype, { tags_in: function(el) { nodes = []; elems = $(el).getElementsByTagName(this); for(var i = 0; i < elems.length; i++) nodes.push(elems[i]); return nodes; } });
'div'.tags_in(document).map(function(el) {});