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
  • 18:56 (UTC +08:00)
View GitHub Profile
@iqbalhasnan
iqbalhasnan / production.rb
Created August 26, 2015 02:55
Rails 3 Upgrade To Rails 4 minify CSS and JS
config.assets.js_compressor = :uglifier
config.assets.css_compressor = :sass
class ArticleImageUploader < ImageUploader
process :fix_exif_rotation
process :strip
process :convert => 'jpg'
process :quality => 85 # Percentage from 0 - 100
version :gallery_thumb do
process :resize_to_fill => Settings.images.article_images.processing.gallery_thumb #44x44
end
@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

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

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