curl -L https://gist.github.com/theIV/5022219/raw/18b68d524870041138a4cc95320b99c949fd2e13/chef_solo_bootstrap.sh | bash
More context: http://railscasts.com/episodes/339-chef-solo-basics
| require 'autotest/redgreen' | |
| # require 'autotest/pretty' | |
| # require 'autotest/snarl' | |
| # require 'autotest/timestamp' | |
| module Autotest::Growl | |
| def self.growl title, msg, img, pri=0, sticky="" | |
| system "growlnotify -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title} #{sticky}" | |
| end |
| require 'digest/md5' | |
| def gfm(text) | |
| # Extract pre blocks | |
| extractions = {} | |
| text.gsub!(%r{<pre>.*?</pre>}m) do |match| | |
| md5 = Digest::MD5.hexdigest(match) | |
| extractions[md5] = match | |
| "{gfm-extraction-#{md5}}" | |
| end |
| # http://forums.shopify.com/categories/6/posts/42926 | |
| # This is a fairly simple mechanize script to create a few hundred or so shopify discounts from a CSV of groupon codes. | |
| # You'll want to change all of the "changeme" values to your own. | |
| # The script expects there to be a groupon_codes.csv in the same directory. | |
| # | |
| # The groupons_code.csv should look like this: | |
| # 8m7677 | |
| # 8m6749 | |
| # 8m5398 | |
| # 8m7699 |
curl -L https://gist.github.com/theIV/5022219/raw/18b68d524870041138a4cc95320b99c949fd2e13/chef_solo_bootstrap.sh | bash
More context: http://railscasts.com/episodes/339-chef-solo-basics
| # How to use Paperclip for generic attachment types on models in Ruby on Rails | |
| class User < ActiveRecord::Base | |
| has_many :user_assets | |
| end | |
| # example of building a model which is a generic attachment asset | |
| @user.build_user_asset(:asset_type => "podcast", :attached_file => some_uploaded_file_data) | |
| # make a generic asset class, with instances initialized for specific asset |
| # 1) Put 's3' gem in Gemfile. | |
| # 2) Create as3.yml configuration for S3 | |
| # 3) Create initializer for as3.yml | |
| # 4) Make "assets" folder inside your bucket | |
| # 5) After running task run "RAILS_ENV=production rake assets:precompile" | |
| # 6) Invoke task by running "rake as3:upload" | |
| namespace :as3 do | |
| desc "Uploads compiled assets (public/assets) to Amazone AS3" | |
| task :upload do |
| inputs = %w[ | |
| CollectionSelectInput | |
| DateTimeInput | |
| FileInput | |
| GroupedCollectionSelectInput | |
| NumericInput | |
| PasswordInput | |
| RangeInput | |
| StringInput | |
| TextInput |
| # Credits: | |
| # Jason Pirkey, Táve Corporation, http://www.tave.com/ | |
| # Jeremy Mickelson, https://github.com/CyborgMaster | |
| # See http://help.papertrailapp.com/kb/hosting-services/aws-elastic-beanstalk/ | |
| packages: | |
| yum: | |
| rubygems: [] | |
| ruby-devel: [] |
| # lib/tasks/db.rake | |
| namespace :db do | |
| desc "Dumps the database to db/APP_NAME.dump" | |
| task :dump => :environment do | |
| cmd = nil | |
| with_config do |app, host, db, user| | |
| cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump" | |
| end | |
| puts cmd |
| -- psql prompt can be customized | |
| \set PROMPT1 '%[%033[1;33m%]%M:%>%[%033[1;32m%] %n@%/%R%[%033[0m%]%# ' | |
| \set PROMPT2 :PROMPT1 | |
| \set PROMPT3 '>> ' | |
| -- Missing LIMIT fetch count is set to 1000 | |
| \set FETCH_COUNT 1000 | |
| -- Set pager to off | |
| \pset pager off |