Skip to content

Instantly share code, notes, and snippets.

View iqbalhasnan's full-sized avatar
:shipit:
shipit

Iqbal Hasnan iqbalhasnan

:shipit:
shipit
  • Kuala Lumpur, Malaysia
  • 12:32 (UTC +08:00)
View GitHub Profile
module RedisHelper
# decode Redis value back to Ruby object
def self.decode(json)
self.new(ActiveSupport::JSON.decode(json)["#{self.name.downcase}"])
end
# encode Ruby object for Redis
def encoded
self.updated_at = nil
self.to_json
@iqbalhasnan
iqbalhasnan / user_controller.rb
Created October 15, 2014 07:39
Pundit Authorized admin namespace controller
class Admin::UsersController < ApplicationController
before_filter :authenticate_user!
before_filter :check_if_admin
include Pundit
def index
@users = User.all
end
def update
@iqbalhasnan
iqbalhasnan / Gemfile
Last active August 29, 2015 14:07 — forked from Joseph-N/Gemfile
source 'https://rubygems.org'
# default gems here
#---------------------------
# add paperclip and bootstrap
gem "paperclip", "~> 4.1"
gem 'bootstrap-sass', '~> 3.1.1'
@iqbalhasnan
iqbalhasnan / gist:2d786a07102cfdc7751b
Created November 3, 2014 15:16
Fix for homebrew "error: unable to unlink old" error
sudo chown -R `whoami` /usr/local
cd /usr/local
git reset --hard origin/master
brew doctor
@iqbalhasnan
iqbalhasnan / gist:de60401b277f3ee07ec2
Created November 4, 2014 21:34
rvm bundler not found fix
echo "export PATH=$PATH:/Users/iqbalhasnan/.rvm/gems/ruby-1.9.3-p550/bin" >> ~/.bash_profile
@iqbalhasnan
iqbalhasnan / gist:cb422987dae859658721
Created November 10, 2014 08:57
FIX: Git GUI Crash Signal 6
git config --local --unset gui.geometry
@iqbalhasnan
iqbalhasnan / gist:821a3cd84df19ce3611e
Created November 14, 2014 04:21
Kill Rails Process
lsof -wni tcp:PORT
kill -9 PID
rvm use --create —ruby-version 1.9.3-p550@wrapper
This gist is the update of this post https://u.osu.edu/hasnan.1/2014/03/30/rails-4-multiple-file-upload-with-carrierwave-nested-form-and-jquery-file-upload/
License MIT