Skip to content

Instantly share code, notes, and snippets.

View test_unit_plus.rb
# Helps to organize and structure your tests with
# * human readable test names
# * flagging tests as pending
# * structuring the test implementation with blocks
# Please see the documentation of single methods below.
# Written by Vladimir Dobriakov
# See for explanation
require 'test/unit'
class << Test::Unit::TestCase
View gist:569746
$(function() {
//run the accordion plugin, set height of sections to height of content
$("#accordion").accordion({ autoHeight: false });
;(function($) {
//write new sammy application
var app = new Sammy.Application(function() {
with(this) {
//corresponds to routes such as #/section/1
get('#/section/:section_id', function() { with(this) {
View gist:569747
//get first part of current url, without hash
var base_path = window.location.href.split("#")[0];
var real_id = 0;
var current_page;
;(function($) {
//create new sammy app
var app = new Sammy.Application(function() {
with(this) {
//corresponds to routes like #/slide/1
get('#/slide/:page_id', function() { with(this) {
View gist:569749
var next_path;
var form_stages;
var check_a;
var check_s;
var prev_path;
var field_val;
;(function($) {
var app = new Sammy.Application(function() {
with(this) {
get('#/stage/:id', function() { with(this) {
aslam / application.rb
Created December 10, 2010 06:10
Rails 3 reset session using devise (actually not using devise)
View application.rb
class ApplicationController < ActionController::Base
before_filter :save_or_clear_session
def save_or_clear_session
if controller_name.eql?('sessions') and action_name.eql?('destroy')
flash[:notice] = "Signed out successfully."
aslam / post-checkout
Created May 10, 2011 17:37 — forked from robbyrussell/post-checkout
post-checkout hook to reload bundler and restart passenger
View post-checkout
# Just save this as .git/hooks/post-checkout in your Rails application
env ARCHFLAGS="-arch x86_64" bundle install
touch tmp/restart.txt
aslam /
Created May 13, 2011 14:06 — forked from ryanb/
The Changelogs for Rails 3.1 Beta 1

Railties 3.1 Beta 1

  • The -j option of the application generator accepts an arbitrary string. If passed "foo", the gem "foo-rails" is added to the Gemfile, and the application JavaScript manifest requires "foo" and "foo_ujs". As of this writing "prototype-rails" and "jquery-rails" exist and provide those files via the asset pipeline. Default is "jquery". [fxn]

  • jQuery is no longer vendored, it is provided from now on by the jquery-rails gem. [fxn]

  • Prototype and Scriptaculous are no longer vendored, they are provided from now on by the prototype-rails gem. [fxn]

  • The scaffold controller will now produce SCSS file if Sass is available [Prem Sichanugrist]

aslam / random-number.rb
Created August 9, 2011 10:37
Create random numbers easily in Rails
View random-number.rb
# The output is double the input value
aslam / _form.html.erb
Created September 18, 2011 09:36 — forked from vjm/_form.html.erb
CRUD Devise Example
View _form.html.erb
<%= form_for(@user) do |f| %>
<% if @user.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>
<% @user.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>