Skip to content

Instantly share code, notes, and snippets.

View morshedalam's full-sized avatar
🏔️

Morshed Alam morshedalam

🏔️
View GitHub Profile
@morshedalam
morshedalam / OSX UTC Time Zone
Created April 21, 2020 18:30 — forked from nick-desteffen/OSX UTC Time Zone
Set Time zone in OSX to UTC
sudo ln -sf /usr/share/zoneinfo/UTC /etc/localtime
@morshedalam
morshedalam / nginx.conf
Created June 14, 2016 11:30 — forked from billie66/nginx.conf
Deploy Rails on Ubuntu server 12.04 with Nginx, Unicorn, Mongodb, Mongoid
# This file should be placed on the directory of ~/blog/config
upstream unicorn {
server unix:/tmp/unicorn.todo.socket fail_timeout=0;
}
server {
listen 80 default;
#server_name example.com;
root /home/username/blog/public;
@morshedalam
morshedalam / gist:2f73867b2b5f494cd387
Created February 14, 2016 19:30 — forked from saetia/gist:1623487
Clean Install – OS X 10.11 El Capitan

OS X Preferences


most of these require logout/restart to take effect

# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false

# Set a shorter Delay until key repeat
var initializeUploaderWithFiles = function (file_types) {
var url = $('#fileupload').attr('action'),
uploadButton = $('<button/>')
.addClass('btn btn-primary')
.prop('disabled', true)
.text('Processing...')
.on('click', function () {
var $this = $(this),
data = $this.data();
$this
# Usage:
# In your (Application)Controller:
# include Concerns::ForceNonSSL
# force_non_ssl
#
# You can use the same options as with force_ssl.
# See: http://api.rubyonrails.org/classes/ActionController/ForceSSL/ClassMethods.html#method-i-force_ssl
#
# Code based on: https://github.com/rails/rails/blob/ab08519b1aed46dbd4b3e13932bbaddfe42d8315/actionpack/lib/action_controller/metal/force_ssl.rb
#
We couldn’t find that file to show.
@morshedalam
morshedalam / custom-file.css
Last active August 29, 2015 14:19
Custom file field
.custom-file-upload {
width: 100%;
position: relative;
padding: 0px;
}
.custom-file-upload:before {
content: 'Browse';
position: absolute;
right: 0px;
@morshedalam
morshedalam / filterable.rb
Created April 18, 2015 06:02
Filter model by dynamic scope using fields
module Filterable
extend ActiveSupport::Concern
module ClassMethods
def filter(filtering_params = [])
results = self.where(nil)
filtering_params.each do |key, value|
results = results.public_send(key, value) if value.present?
end if filtering_params.any?
results
@morshedalam
morshedalam / exportable.rb
Created April 18, 2015 06:00
Export to CSV
module Exportable
extend ActiveSupport::Concern
module ClassMethods
def to_csv(options = {})
columns = options[:columns] || column_names
CSV.generate do |csv|
csv << columns
all.each do |item|
@morshedalam
morshedalam / has_no_table.rb
Last active August 29, 2015 14:19
Table less model in Rails
module HasNoTable
extend ActiveSupport::Concern
include ActiveModel::Validations
include ActiveModel::Conversion
extend ActiveModel::Naming
def initialize(attributes = {})
attributes.each do |name, value|
send("#{name}=", value)