Skip to content

Instantly share code, notes, and snippets.

@mislav
mislav / gist:17371
Created October 17, 2008 07:42
haml2erb
class ErbEngine < Haml::Engine
def push_script(text, preserve_script, in_tag = false, preserve_tag = false,
escape_html = false, nuke_inner_whitespace = false)
push_text "<%= #{text.strip} %>"
end
def push_silent(text, can_suppress = false)
push_text "<% #{text.strip} %>"
end
end
@jzajpt
jzajpt / haml2erb
Created March 11, 2009 07:59
Simple & stupid HAML to ERB convertor...
#!/usr/bin/env ruby
#
# haml2erb
require 'rubygems'
require 'haml'
class ErbEngine < Haml::Engine
def push_script(text, preserve_script, in_tag = false, preserve_tag = false,
escape_html = false, nuke_inner_whitespace = false)
gemcutter => redis downloads spec
=================================
keys
----
downloads => global counter for all gem downloads
downloads:today => sorted set for downloads from today
downloads:rubygem:rails => counter for all rails downloads
downloads:version:rails-2.3.5 => counter for all rails 2.3.5 downloads
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
ru:
devise:
sessions:
link: 'Войти'
signed_in: 'Вы вошли.'
signed_out: 'Вы вышли.'
unauthenticated: 'Вы должны войти или зарегистрироваться, прежде чем сможете продолжить.'
unconfirmed: 'Вы должны подтвердить Ваш аккаунт, прежде чем сможете продолжить.'
locked: 'Ваш аккаунт заблокирован.'
invalid: 'Неверный пароль или email.'
@nruth
nruth / cookie_steps.rb
Created July 21, 2010 17:16
Testing login "remember me" feature with Capybara (rack::test or selenium) - deleting the session cookie (only)
@dnagir
dnagir / rspec-syntax-cheat-sheet.rb
Created November 5, 2010 09:29
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For Less, I'm using the JavaScript version because this is what they suggest on the website. The ruby version may be different.

Variables

@madhums
madhums / omniauth.rb
Created November 15, 2010 10:49
OmniAuth configuration for rails 2.3.x
#config/initializers/omniauth.rb
require 'openid/store/filesystem'
ActionController::Dispatcher.middleware.use OmniAuth::Builder do #if you are using rails 2.3.x
#Rails.application.config.middleware.use OmniAuth::Builder do #comment out the above line and use this if you are using rails 3
provider :twitter, 'key', 'secret'
provider :facebook, 'app_id', 'secret'
provider :linked_in, 'key', 'secret'
provider :open_id, OpenID::Store::Filesystem.new('/tmp')
end
#admin_routes_spec.rb
require "spec_helper"
describe "Admin Routes" do
describe "GET '/admin'" do
it "should block access if not on www" do
{ :get => "http://foo.example.com/admin" }.should_not be_routable
end