Skip to content

Instantly share code, notes, and snippets.

# 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 http://blog.geekq.net/2009/11/25/minimalist-testing-ruby/ for explanation
require 'test/unit'
class << Test::Unit::TestCase
$(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) {
//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) {
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
aslam / application.rb
Created December 10, 2010 06:10
Rails 3 reset session using devise (actually not using devise)
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')
request.reset_session
flash[:notice] = "Signed out successfully."
end
end
@aslam
aslam / post-checkout
Created May 10, 2011 17:37 — forked from robbyrussell/post-checkout
post-checkout hook to reload bundler and restart passenger
#!/bin/sh
#
# Just save this as .git/hooks/post-checkout in your Rails application
#
env ARCHFLAGS="-arch x86_64" bundle install
touch tmp/restart.txt
@aslam
aslam / rails_3_1_beta_1_changes.md
Created May 13, 2011 14:06 — forked from ryanb/rails_3_1_rc4_changes.md
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
aslam / random-number.rb
Created August 9, 2011 10:37
Create random numbers easily in Rails
# The output is double the input value
ActiveSupport::SecureRandom.hex(3)
@aslam
aslam / about.md
Created August 9, 2011 14:22 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
@aslam
aslam / _form.html.erb
Created September 18, 2011 09:36 — forked from vjm/_form.html.erb
CRUD Devise Example
<%= 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>
<ul>
<% @user.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>