This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ready: function(fn) { | |
// Attach the listeners | |
bindReady(); | |
// If the DOM is already ready | |
if ( jQuery.isReady ) | |
// Execute the function immediately | |
fn.call( document, jQuery ); | |
// Otherwise, remember the function for later |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I add authorization query methods to every ActiveRecord model (through ActiveRecord::Base). | |
# | |
# Each model is given the following methods: | |
# | |
# == Class methods: | |
# | |
# Model.creatable? | |
# Model.creatable_by? user | |
# | |
# == Instance methods: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mislav-will_paginate --version '= 2.3.11' --source http://gems.github.com | |
justinfrench-formtastic --version '= 0.2.2' --source http://gems.github.com | |
josevalim-inherited_resources --version '= 0.8.5' --source http://gems.github.com | |
thoughtbot-paperclip --version '= 2.3.1' --source http://gems.github.com | |
authlogic --version '= 2.1.1' | |
yard --version '= 0.2.3.5' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProductState < ActiveRecord::Base | |
attr_accessible :name, :description | |
acts_as_enumeration :new, :active, :locked, :sold, :expired, :removed, :deleted | |
validates_presence_of :description | |
def to_s | |
name | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module IdEnumeration | |
def acts_as_enumeration(*ordered_list_of_values) | |
ordered_list_of_values.map(&:to_s).each_with_index do |value, index| | |
const_set(value.upcase, index + 1) | |
self.class.send(:define_method, "find_#{value}!") do | |
find(const_get(value.upcase)) | |
end | |
self.class.send(:define_method, "find_#{value}") do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ShoppingCart < ActiveRecord::Base | |
has_many :shopping_cart_items | |
def remove_product(product) | |
for item in shopping_cart_items do | |
if item.product == product then | |
item.destroy | |
shopping_cart_items.reload | |
break | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#header { | |
color: black; | |
.navigation; /* this is a mixin, cause it doesn't have a {}? */ | |
.logo { /* this is a scoped rule cause it does? */ | |
width: 300px; | |
:hover { text-decoration: none } | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d1d466fa50fb8ffe876161bdf42d454e2951291e foo bar - Tammer Saleh | |
cda4cc825c031f8c72069acbf06dfa20e9ba5a1d bar - Tammer Saleh | |
c15cd6ce3468c44bb537bdbeb6147398fd14cc18 foo - Tammer Saleh | |
31d5f34297a231493c3db68536c64ef0ec273b2c more work - Tammer Saleh | |
d772be305b23b54da42cdb8a8e978ce6c936c29e stuf - Tammer Saleh | |
27a7952319856dca1325c64b3ad137643dc4b018 stuff. - Tammer Saleh | |
19e0bb28a3d67a2588454f9cf769f0b577464e33 more. - Tammer Saleh | |
8fd6ef48ffc7321da2c87b6f8b3d60061e0f4d0a moved files into files. duh. - Tammer Saleh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scroll_page_to: function(element, doc) { | |
if (element.length < 1) { log("Error: cannot find element for scrolling."); }; | |
var offset = element.offset().top; | |
log("scrolling to element " + element.attr("id") + " at " + offset); | |
$('html').animate({scrollTop: offset}, 500); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Counterpoint < ActiveRecord::Base | |
belongs_to :owner, :class_name => "User" | |
validate :ensure_owned_by_journalist | |
def self.creatable? | |
return false unless user_from_session | |
return false if user_from_session.company_representative? | |
return true | |
end |