Skip to content

Instantly share code, notes, and snippets.

View ishouvik's full-sized avatar
🎯
Focusing

Shouvik Mukherjee ishouvik

🎯
Focusing
View GitHub Profile
@ishouvik
ishouvik / Vagrantfile
Last active June 4, 2016 18:49
Vagrant file for rbenv rails
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "<box name>"
# Create port fowarding between guest and host
config.vm.network "forwarded_port", guest: 3000, host: 3000
config.vm.network "forwarded_port", guest: 80, host: 8080
@ishouvik
ishouvik / ability.rb
Created December 7, 2015 06:23
Default Ability Class with Devise, Rolify and Cancan
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new # guest user (not logged in)
if user.has_role? :admin
can :manage, :all
elsif user.has_role? :user
can :read, :all
@ishouvik
ishouvik / shared_helpers.rb
Created August 22, 2015 07:53
Share MainApp appplication helpers with Rails engines. This is more of a hack. Change your engine classname
# config/initializers/shared_helpers.rb
# Share main_app helpers with engine helpers
MyEngine::Engine.class_eval do
paths["app/helpers"] << File.join(File.dirname(__FILE__), '../..', 'app/helpers')
end
# Trick WordPress into thinking that www.example.com is example.com
RequestHeader edit Host "^www\.(.*)$" "$1"
[
{
"keys": ["control+alt+;"], "command": "align_tab",
"args" : {
"user_input" : ":/f",
}
},
{
"keys": ["control+alt+:"], "command": "align_tab",
"args" : {
@ishouvik
ishouvik / bootstrap_tab_bookmark.js
Created February 24, 2014 13:43
Javascript:TwitterBootstrap: bootstrap_tab_bookmark.js
function bootstrap_tab_bookmark (selector) {
if (selector == undefined) {
selector = "";
}
var bookmark_switch = function () {
url = document.location.href.split('#');
if(url[1] != undefined) {
$(selector + '[href=#'+url[1]+']').tab('show');
}
@ishouvik
ishouvik / carrierwave.rb
Created February 16, 2014 13:45
Rails: config/initializers/carrierwave.rb
CarrierWave.configure do |config|
if Rails.env.development? or Rails.env.test?
config.storage = :file
else
config.fog_credentials = {
:provider => 'AWS',
:aws_access_key_id => '<access key>',
:aws_secret_access_key => '<secrect acess key >'
}
@ishouvik
ishouvik / production.rb
Created February 16, 2014 13:14
Rails: config/environments/production.rb
Ishouvik::Application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both thread web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.