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
var delay = (function(){ | |
var timer = 0; | |
return function(callback, ms){ | |
clearTimeout (timer); | |
timer = setTimeout(callback, ms); | |
}; | |
}()); | |
$('.basket-quantity').keyup(function() { | |
var $that = $(this); |
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
var price_format = (function () { | |
var rgx = /(\d+)(\d{3})/; | |
return function (nStr) { | |
var x = String(nStr).split('.'), | |
x1 = x[0], | |
x2 = x.length > 1 ? '.' + x[1] : ''; | |
while (rgx.test(x1)) { | |
x1 = x1.replace(rgx, '$1' + ',' + '$2'); |
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
$(function () { | |
var $places = $('#secondaryContent #places'), | |
$payment_amount = $('#secondaryContent #payment_amount'), | |
singular_amount = 145.00; | |
var delay = (function () { | |
var timer = 0; | |
return function (callback, ms) { | |
clearTimeout(timer); | |
timer = setTimeout(callback, ms); |
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
function days_between(date1, date2) { | |
var one_day = 1000 * 60 * 60 * 24, | |
date1_ms = date1.getTime(), | |
date2_ms = date2.getTime(), | |
difference_ms = Math.abs(date1_ms - date2_ms); | |
return Math.round(difference_ms / one_day); | |
} | |
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
/* | |
* March 2012 - TSJ | |
* ----------------------------------------------------------------- | |
* Loads charts in batches using Batchelor due to the maximum number | |
* of http request in most browsers being limited to 6. | |
* | |
*/ | |
var reportsPerBatch = 6; |
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
/** | |
* | |
* Demo URL: http://seo-stats-demo.datadial.net/test/tj/background/ | |
* | |
* This plugin will take a media type (colour, img, video). | |
* - Images: collection of URLs | |
* - Colour: hex values | |
* - Video: object with video type (youtube, vimeo) and url | |
* | |
* The plugin will allow the user to pass in a REST url so that media can be |
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
# Define a method to convert Cartesian (x,y) coordinates to Polar | |
def polar(x,y) | |
theta = Math.atan2(y,x) # Compute the angle | |
r = Math.hypot(x,y) # Compute the distance | |
[r, theta] # The last expression is the return value | |
end | |
# Here's how we use this method with parallel assignment | |
distance, angle = polar(2,2) |
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
# Determine US generation name based on birth year | |
# Case expression tests ranges with === | |
generation = case birthyear | |
when 1946..1963: "Baby Boomer" | |
when 1964..1976: "Generation X" | |
when 1978..2000: "Generation Y" | |
else nil | |
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
# | |
# This class represents a sequence of numbers characterized by the three | |
# parameters from, to, and by. The numbers x in the sequence obey the | |
# following two constraints: | |
# | |
# from <= x <= to | |
# x = from + n*by, where n is an integer | |
# | |
class Sequence |
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
Useful gem sub commands: | |
gem list # List installed gems | |
gem enviroment # Display RubyGems configuration information | |
gem update rails # Update a named gem | |
gem update # Update all installed gems | |
gem update --system # Update RubyGems itself | |
gem uninstall rails # Remove an installed gem |