Skip to content

Instantly share code, notes, and snippets.

View sudhirsb2003's full-sized avatar
:octocat:

Sudhir Vishwakarma sudhirsb2003

:octocat:
View GitHub Profile
@sudhirsb2003
sudhirsb2003 / gist:1064701
Created July 5, 2011 11:50
Naive CSRF-protection: Rails 3 and Ext.js 4's Ext.data.RestProxy
Ext.define('Ext.rails.ForgeryProtection', {
csrfParams: function() {
var params = {};
var metaCsrfParam = Ext.select('meta[name=csrf-param]').item(0);
var metaCsrfToken = Ext.select('meta[name=csrf-token]').item(0);
if (metaCsrfParam != undefined && metaCsrfToken != undefined) {
var name = metaCsrfParam.getAttribute('content');
var value = metaCsrfToken.getAttribute('content');
if (name != undefined && value != undefined) {
params[name] = value;
@sudhirsb2003
sudhirsb2003 / Rails 4 Deployment Configuration
Last active August 9, 2019 05:02
Ubuntu 14.04 x64 + Rails 4 + Nginx + Unicorn + PostgreSQL + Capistrano 3 Setup Instructions
### Ubuntu 14.04 x64 + Rails 4 + Nginx + Unicorn + PostgreSQL + Capistrano 3
SSH into Root
$ ssh root@123.123.123.123
Change Root Password
$ passwd
Interval Queries (Basically to find Age range)
User.where(%q{created_at - birthdate < interval '13 years'})
@sudhirsb2003
sudhirsb2003 / Questions.md
Last active November 30, 2017 07:54
Ruby & Rails questions

Ruby and Rails Interview Questions

Ruby

  • What is a class?
  • What is an object?
  • What is a module? Can you tell me the difference between classes and modules?
  • Can you tell me the three levels of method access control for classes and modules? What do they imply about the method?
  • There are three ways to invoke a method in ruby. Can you give me at least two?
  • Explain this ruby idiom: a ||= b
# YARD CHEATSHEET http://yardoc.org
cribbed from http://pastebin.com/xgzeAmBn
Templates to remind you of the options and formatting for the different types of objects you might
want to document using YARD.
## Modules
# Namespace for classes and modules that handle serving documentation over HTTP