Skip to content

Instantly share code, notes, and snippets.

@rahulcn
rahulcn / README.md
Created September 12, 2013 17:14 — forked from netmute/README.md

Game of Life

An implementation of Conway's Game of Life in 140 characters of Ruby.

Author

Created by Simon Ernst (@sier).

// overriding sync to use local storage when possible
sync : function(method, model, options){
var key, now, timestamp, refresh;
if(method === 'read' && this.constants.isStoredInLocalStorage) {
// only override sync if it is a fetch('read') request
key = this.getKey();
if(key) {
now = new Date().getTime();
timestamp = $storage.get(key + ":timestamp");
refresh = options.forceRefresh;
@rahulcn
rahulcn / new_gist_file
Created April 22, 2013 11:05
Check for browser javascript.
check_browser: (navigator) ->
N = navigator.appName
ua = navigator.userAgent
tem = undefined
M = ua.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i)
M[2] = tem[1] if M and (tem = ua.match(/version\/([\.\d]+)/i))?
M = (if M then [M[1], M[2]] else [N, navigator.appVersion, "-?"])
M
@rahulcn
rahulcn / User model
Created November 27, 2011 17:09
method error
class User
include Mongoid::Document
include Mongoid::Timestamps
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_one :profile, :class_name => 'Profile', :foreign_key => :person_id
@rahulcn
rahulcn / .errors
Created October 28, 2011 04:47
Tests r not passing for create action please help....
Failures:
1) MicropostsController POST 'create' failure should render the home page
Failure/Error: response.should render_template('pages/home')
expecting <"pages/home"> but rendering with <"">
# ./spec/controllers/microposts_controller_spec.rb:38:in `block (4 levels) in <top (required)>'
2) MicropostsController POST 'create' success should create a micropost
Failure/Error: lambda do
count should have been changed by 1, but was changed by 0