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
  • 23:37 (UTC +08:00)
View GitHub Profile
@iqbalhasnan
iqbalhasnan / gist:821a3cd84df19ce3611e
Created November 14, 2014 04:21
Kill Rails Process
lsof -wni tcp:PORT
kill -9 PID
@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: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: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 / 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 / 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
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

Deploy Rails app to digitalocean with nginx, unicorn, capistrano & postgres

Create droplet of your liking (ubuntu 12.10 x32)

ssh to root in terminal with your server ip

ssh root@123.123.123.123

Add ssh fingerprint and enter password provided in email

@iqbalhasnan
iqbalhasnan / User.rb
Created July 6, 2014 05:14
Rails 4.1.4 + Devise (3.2.4) + delayed_job mailer simple solution
# app/models/User.rb
#As we all know that Devise sends all emails through the send_devise_notification method
#So, without having to install devise-async gem , we just need to change the code to send it asynchronously
# send to the delayed_job queue
def send_devise_notification(notification, *args)
devise_mailer.delay.send(notification, self, *args)
end