Skip to content

Instantly share code, notes, and snippets.

View jamilbk's full-sized avatar
🔥
Everything's fine

Jamil jamilbk

🔥
Everything's fine
View GitHub Profile
@jamilbk
jamilbk / gist:5629254
Created May 22, 2013 17:17
git ignore
.DS_Store
*.tmproj
log/*.lck
log/*.log
public/uploads
*.*.sw*
.notes
# Fixes OS X clipboard under tmux
set-option -g default-command "reattach-to-user-namespace -l zsh"
# Allows for faster key repetition
set -s escape-time 0
# Rather than constraining window size to the maximum size of any client
# connected to the *session*, constrain window size to the maximum size of any
# client connected to *that window*. Much more reasonable.
setw -g aggressive-resize on
@jamilbk
jamilbk / stuffed_table_columns.rb
Last active December 11, 2015 06:19
Implement status states in code using an integer column in the DB.
# Implement status states in code using an integer column in the DB
# Written by Jamil Bou Kheir, 2012
#
# Include this module at the top of your model and use the stuffed_table_columns
# method to assign the mappings. Requires a matching integer column present.
# Ex:
#
# class StirFry < ActiveRecord::Base
# include StuffedTableColumns
# stuffed_column :status, 'cold', 'hot', 'pickled', 'spicy', 'no_msg', 'noodling'
@jamilbk
jamilbk / nestedform
Created December 1, 2012 02:58 — forked from robertwclark/nestedform
Nested Form Build
class Organization < ActiveRecord::Base
attr_accessible :name, :employee_number, :country, :postal_code, :sic_code, :primary_url, :social_entities_attributes, :social_channels_attributes
has_one :user
has_one :social_score, :through => :social_entities
has_many :social_entities
has_many :social_channels, :through => :social_entities
accepts_nested_attributes_for :social_entities, :social_channels
end
@jamilbk
jamilbk / gist:3861162
Created October 9, 2012 20:17
Clean Install – Mountain Lion OS X 10.8 DP3 Update 4
@jamilbk
jamilbk / schedule.rb
Created May 3, 2012 08:02
example showing possible Rufus production env quirks
# Example of how I'm using Rufus. I'm basically starting a scheduler, then
# using my backend to persist the job_id for the option to cancel it later.
# config/initializers/schedule.rb
SCHEDULER = Rufus::Scheduler.start_new
#### image_map_coordinate.rb ####
class ImageMapCoordinate < ActiveRecord::Base
belongs_to :image_map
# FIXME: validation bug?
%w(w h x y).each do |v|
validates_numericality_of eval ":#{v}"
end
validate :href_validator
@jamilbk
jamilbk / stuffed_table_columns.rb
Created February 27, 2015 21:24
Stuffed Table Columns
# Represent states such as 'active', 'disabled', etc in the DB as an int
#
# Use like so:
#
# class MyModel < ActiveRecord::Base
# include StuffedTableColumns
# stuffed_column :status, *(%w(active inactive blocked disabled banned))
# end
# TODO: use method_missing to match the column name