Skip to content

Instantly share code, notes, and snippets.

View rymai's full-sized avatar
🙌
Working from home

Rémy Coutable rymai

🙌
Working from home
View GitHub Profile
1. Run: rails new_project
2. In Gemfile:
source 'http://rubygems.org'
gem 'rails', '3.0.0.beta3'
gem 'heroku'
gem 'i18n'
gem 'haml'
→ bundle -v
Bundler version 0.9.25

→ ruby -v
ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-darwin10.2.0]

→ rvm -v
rvm 0.1.37 by Wayne E. Seguin ([email protected]) [http://rvm.beginrescueend.com/]

passenger version: 2.2.13

# Don't change this file!
# Configure your app in config/environment.rb and config/environments/*.rb
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
module Rails
class << self
def boot!
unless booted?
preinitialize
begin
require "rubygems"
require "bundler"
rescue LoadError
raise "Could not load the bundler gem. Install it with `gem install bundler`."
end
if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new("0.9.24")
raise RuntimeError, "Your bundler version is too old." +
"Run `gem install bundler` to upgrade."
require File.join(File.dirname(__FILE__), 'boot')
Rails::Initializer.run do |config|
# Add additional load paths for your own custom dirs
config.load_paths += %W[#{Rails.root}/app/mailers]
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
@rymai
rymai / gist:723780
Created December 1, 2010 16:49
Arel 2.0.5 LEFT OUTER JOIN bug
TableA
has_and_belongs_to_many :table_b
TableB
has_and_belongs_to_many :table_a
TableC is the join table of TableA and TableB
---------------------------------------
Arel 2.0.4 (Good query)
@rymai
rymai / Guardfile
Created December 13, 2010 22:57
When a controller file is modified, it will execute the associated: - routing spec, - controller spec, - acceptance spec
# When a controller file is modified, it will execute the associated:
# - routing spec,
# - controller spec,
# - acceptance spec
guard 'rspec' do
watch(%r|app/controllers/(.*)_controller\.rb|) do |m|
["spec/routing/#{m[1]}_routing_spec.rb",
"spec/controllers/#{m[1]}_controller_spec.rb",
"spec/acceptance/#{m[1]}_spec.rb"]
end
@rymai
rymai / gist:919105
Created April 14, 2011 08:09
SublimeVideo: Loop (snippet)
<!-- Inside the <head> tag -->
<script type="text/javascript" src="http://cdn.sublimevideo.net/js/YOUR_TOKEN.js"></script>
<!-- Inside the <body> tag -->
<video class="sublime" poster="posterframe.jpg" width="640" height="360" preload="none">
<source src="video.mp4" />
<source src="video.ogv" />
</video>
<!-- Just before </body> (or in the <head> tag) -->
@rymai
rymai / gist:919915
Created April 14, 2011 16:54
SublimeVideo: Autoplay (snippet)
<!-- Inside the <head> tag -->
<script type="text/javascript" src="http://cdn.sublimevideo.net/js/YOUR_TOKEN.js"></script>
<!-- Inside the <body> tag -->
<video id="video1" poster="posterframe.jpg" width="640" height="360" preload="none">
<source src="video.mp4" />
<source src="video.ogv" />
</video>
<!-- Just before </body> (or in the <head> tag) -->
@rymai
rymai / gist:921421
Created April 15, 2011 08:54
SublimeVideo: Video "On Demand" (snippet)
<!-- Inside the <head> tag -->
<script type="text/javascript" src="http://cdn.sublimevideo.net/js/YOUR_TOKEN.js"></script>
<!-- Inside the <body> tag -->
<img class="needs_sublime" src="video1.jpg" width="640" height="360" />
<!-- Just before </body> (or in the <head> tag) -->
<script type="text/javascript">
sublimevideo.load(); // When this page is first loaded there are no <video> element on the page, so SublimeVideo is not loaded unless we load it manually with this method
// see: http://docs.sublimevideo.net/javascript-api#load