Skip to content

Instantly share code, notes, and snippets.

View rahulcn's full-sized avatar

Rahul Chandra rahulcn

View GitHub Profile
@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
@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 / 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
// 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 / 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).

class Api::RegistrationsController < Api::BaseController
respond_to :json
def create
user = User.new(params[:user])
if user.save
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201
return
else
@rahulcn
rahulcn / xvfb
Last active August 29, 2015 13:57 — forked from jterrace/xvfb
### BEGIN INIT INFO
# Provides: Xvfb
# Required-Start: $local_fs $remote_fs
# Required-Stop:
# X-Start-Before:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Loads X Virtual Frame Buffer
### END INIT INFO

To run this, you can try:

curl -ks https://gist.github.com/nicerobot/2697848/raw/uninstall-node.sh | bash

I haven't tested this script doing it this way but i run a lot of my Gists like this so maybe this one'll work too.

Alternatively,

curl -ksO https://gist.github.com/nicerobot/2697848/raw/uninstall-node.sh

chmod +x ./uninstall-node.sh

@rahulcn
rahulcn / index.html
Last active August 29, 2015 14:17 — forked from JoshMock/index.html
<!DOCTYPE HTML>
<html>
<head>
<style type="text/css" media="all">
#main {
width: 300px;
height: 400px;
overflow: scroll;
}