Skip to content

Instantly share code, notes, and snippets.

Dia Kharrat dkharrat

Block or report user

Report or block dkharrat

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dkharrat
dkharrat / Enumeration.rb
Created May 7, 2012
Enumerations in ruby
View Enumeration.rb
# credit goes to http://stackoverflow.com/questions/265725/what-is-the-best-way-to-handle-constants-in-ruby-when-using-rails
class Enumeration
def self.def_enum(key,value)
@hash ||= Hash.new { |hash, key| raise NameError, "#{self.name}::#{key} is not defined" }
@hash[key] = value
end
def self.const_missing(key)
@hash[key]
end
@dkharrat
dkharrat / Article.rb
Created Jun 15, 2011
Sphinx test with STI models
View Article.rb
# == Schema Information
#
# Table name: posts
#
# id :integer(4) not null, primary key
# title :string(255)
# author :text
# content :text
# state :text
# type :text
@dkharrat
dkharrat / MarkItUpInlineUpload.js
Created Jan 18, 2011
upload feature for markitup...copied from http://pastebin.ca/1763467 as pastebin.ca seems to be down.
View MarkItUpInlineUpload.js
// ----------------------------------------------------------------------------
// markItUp!
// ----------------------------------------------------------------------------
// Copyright (C) 2008 Jay Salvat
// http://markitup.jaysalvat.com/
// ----------------------------------------------------------------------------
// Html tags
// http://en.wikipedia.org/wiki/html
// ----------------------------------------------------------------------------
// Basic set. Feel free to add more tags
You can’t perform that action at this time.