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
# Bash snippet to open new shells in most recently visited dir. | |
# Useful if you want to open a new terminal tab at the present | |
# tab's location. | |
# | |
# Put this in your .bashrc or whatever. | |
pathed_cd () { | |
if [ "$1" == "" ]; then | |
cd | |
else |
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
require 'models/developer' | |
require 'models/project' | |
class JoinTableTimestampTest < ActiveRecord::TestCase | |
def test_should_create_fresh_timestamp_on_join_table | |
developer = Developer.create(:salary => 50000, :name => "Foobar Bacon") | |
project = Project.create | |
sleep 3 |
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
def index | |
@assets = current_account.assets.paginate :page => params[:page], :per_page => 10 | |
end | |
# How to spec this??? | |
before(:each) do | |
@account = Account.new | |
@assets = [Asset.new(:account => @account)] | |
end | |
it "should paginate the assets" |
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
// ============================================================================================ | |
// = Cachable Time Ago In Words - http://nullstyle.com/wp-content/uploads/2007/11/jsdates.txt = | |
// ============================================================================================ | |
var DateHelper = { | |
timeAgoInWords: function(from) { | |
return this.distanceOfTimeInWords(new Date().getTime(), from); | |
}, | |
distanceOfTimeInWords: function(to, from) { |
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 Liquid::Strainer | |
def is_haml?; false; end | |
def controller | |
@controller ||= @context.registers[:controller] | |
end | |
delegate :request, :to => :controller | |
delegate :params, :to => :request | |
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
def random_elements(arr, num_items) | |
el = arr.dup | |
results = [] | |
num_items.times{results << el.delete(el[rand(el.size)])} | |
return results | |
end | |
random_elements((1..10000).to_a, 25) |
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
# Bash snippet to open new shells in most recently visited dir. | |
# Useful if you want to open a new terminal tab at the present | |
# tab's location. | |
# | |
# Put this in your .bashrc or whatever. | |
pathed_cd () { | |
if [ "$1" == "" ]; then | |
cd | |
else |
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 VisitorStats | |
def initialize | |
@redis = Redis.new | |
end | |
# every time there's a hit, increment a counter for the | |
# day and week, and add the session id to a set of unique | |
# vistitors for the day/week | |
def hit(session_id) | |
today = Date.today |
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
/* Add this CSS to your store Styles section under CSS mode */ | |
/* http://www.storenvy.com/ */ | |
/* Photo Slider */ | |
.product_photo_slider { | |
background: #fff; /*: Product Slider Background :*/ | |
border: 5px solid #eaeaea; /*: Product Slider Border :*/ | |
color: #555; /*: Product Slider Product Description :*/ | |
display: block; | |
margin-left:8px; |
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
self.send_later :update_associations | |
Resque.enqueue UpdateAssociations, self.id |