gem install rails --pre
rails new my_app -T
| require 'action_controller/test_process' | |
| class Factory | |
| module FixtureFileUpload | |
| def fixture_file_upload(attr_name, path, mime_type=nil, binary=false) | |
| uploaded_file = ActionController::TestUploadedFile.new( | |
| Test::Unit::TestCase.respond_to?(:fixture_path) ? Test::Unit::TestCase.fixture_path + path : path, | |
| mime_type, | |
| binary | |
| ) | |
| add_attribute attr_name, uploaded_file |
| # USAGE: Hash.from_xml:(YOUR_XML_STRING) | |
| require 'nokogiri' | |
| # modified from http://stackoverflow.com/questions/1230741/convert-a-nokogiri-document-to-a-ruby-hash/1231297#1231297 | |
| class Hash | |
| class << self | |
| def from_xml(xml_io) | |
| begin | |
| result = Nokogiri::XML(xml_io) | |
| return { result.root.name.to_sym => xml_node_to_hash(result.root)} |
| # Switch to Ruby 1.8.7 | |
| rvm use 1.8.7 | |
| # Print out the ruby version | |
| ruby -v | |
| # But the output of this is: | |
| # | |
| # $ ./tryrvm | |
| # <i> Now using ruby 1.8.7 p249 </i> |
| // includes bindings for fetching/fetched | |
| PaginatedCollection = Backbone.Collection.extend({ | |
| initialize: function() { | |
| _.bindAll(this, 'parse', 'url', 'pageInfo', 'nextPage', 'previousPage'); | |
| this.page = 1; | |
| }, | |
| fetch: function(options) { | |
| options || (options = {}); | |
| this.trigger("fetching"); |
| # NOTICE: to get Nginx+Unicorn best-practices configuration see the gist https://gist.github.com/3052776 | |
| $ cd /usr/src | |
| $ wget http://nginx.org/download/nginx-1.2.1.tar.gz | |
| $ tar xzvf ./nginx-1.2.1.tar.gz && rm -f ./nginx-1.2.1.tar.gz | |
| $ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz | |
| $ tar xzvf pcre-8.30.tar.gz && rm -f ./pcre-8.30.tar.gz | |
| $ wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz |
| // | |
| // Backbone.Rails.js | |
| // | |
| // Makes Backbone.js play nicely with the default Rails setup, i.e., | |
| // no need to set | |
| // ActiveRecord::Base.include_root_in_json = false | |
| // and build all of your models directly from `params` rather than | |
| // `params[:model]`. | |
| // | |
| // Load this file after backbone.js and before your application JS. |
| def tip(msg); puts; puts msg; puts "-"*100; end | |
| # | |
| # 30 Ruby 1.9 Tips, Tricks & Features: | |
| # http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/ | |
| # | |
| tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2" | |
| tip "Ruby 1.9 supports named captures in regular expressions!" |
| $:.unshift(File.expand_path('./lib', ENV['rvm_path'])) | |
| require "rvm/capistrano" | |
| set :application, "my_app" | |
| set :repository, "git@trunksapp.com:myuser/myapp.git" | |
| set :branch, "production" | |
| set :rvm_ruby_string, "1.9.2" | |
| set :deploy_to, "/var/applications/" | |
| set :user, "username" |