Skip to content

Instantly share code, notes, and snippets.


Rohit Joshi RohitRox

View GitHub Profile
RohitRox / cookie_utils.js
Created Apr 17, 2012
javascript cookie utils
View cookie_utils.js
RohitRox / rails_snippets_application_helper.rb
Last active Oct 5, 2015
Setting layouts and helper to access control
View rails_snippets_application_helper.rb
#in helper/application_helper.rb
def authorize_resources
unless user_signed_in?
redirect_to new_user_session_path
#in application_controller
View ubuntu_hacks
#starting sublime, opening whole directory and in background
#in .zshrc
alias e="path-to-sublime-executable ./ &"
#setting terminal real transparent (after setting metacity for windows manager )
gconftool-2 /apps/metacity/general/compositing_manager --type bool --set true
RohitRox / url_params.js
Created Jun 26, 2012
Read url params with javascript
View url_params.js
// one way
function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
return vars;
RohitRox / jquery.tabbie.js
Created Jul 18, 2012
Very small re-usable tabbifying jquery plugin
View jquery.tabbie.js
// Very small re-usable tabbifying jquery plugin , @roxxypoxxy
// Usage
The list
<ul class="my-tabs">
<li rel="div1">Div One</li>
<li rel="div2">Div Two</li>
View ruby_csv _to_hash
require 'csv'
csv = CSV::parse(, 'r') {|f| })
fields = csv.shift
csv.collect { |record| Hash[*(0..(fields.length - 1)).collect {|index| [fields[index],record[index].to_s] }.flatten ] }
RohitRox / sinatra app skeleton generator
Created Jan 19, 2013
Simple bash function to generate sinatra app skeleton. USAGE: $ sinatra app_name; shotgun
View sinatra app skeleton generator
function sinatra {
if [ "$1" == "" ]; then
echo "Usage:"
echo "'sinatra app_name' to create a new Sinatra app skeleton";
if [ ! -d "$1" ]; then
echo "Generating your app ... "
mkdir $1
mkdir $1/views;
RohitRox / ruby_notepad_bookmarklet
Created Jan 30, 2013
Ruby Notepad Bookmarklet
View ruby_notepad_bookmarklet
data:text/html, <style type%3D"text%2Fcss">%23e{position%3Aabsolute%3Btop%3A0%3Bright%3A0%3Bbottom%3A0%3Bleft%3A0%3B}<%2Fstyle><div id%3D"e"><%2Fdiv><script src%3D"" type%3D"text%2Fjavascript" charset%3D"utf-8"><%2Fscript><script>var e%3Dace.edit("e")%3Be.setTheme("ace%2Ftheme%2Fmonokai")%3Be.getSession().setMode("ace%2Fmode%2Fruby")%3B<%2Fscript>
View selenium boot
require 'rubygems'
require 'capybara'
require 'capybara/dsl'
Capybara.run_server = false
Capybara.current_driver = :selenium
Capybara.app_host = 'http://...'
module MyCapybara
class FireBro
include Capybara::DSL
View app.rb
require 'rubygems'
require 'capybara'
require 'capybara/dsl'
require 'pry'
require 'yaml'
require 'json'
require "net/http"
require "uri"
Capybara.run_server = false
You can’t perform that action at this time.