This file contains 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 DateHelper = { | |
// Takes the format of "Jan 15, 2007 15:45:00 GMT" and converts it to a relative time | |
// Ruby strftime: %b %d, %Y %H:%M:%S GMT | |
time_ago_in_words_with_parsing: function(from) { | |
var date = new Date; | |
date.setTime(Date.parse(from)); | |
return this.time_ago_in_words(date); | |
}, | |
time_ago_in_words: function(from) { |
This file contains 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
/** | |
* jQuery.support.cssProperty | |
* To verify that a CSS property is supported | |
* (or any of its browser-specific implementations) | |
* | |
* @param p css property name | |
* @param rp optional, if set to true, the css property name will be returned | |
* instead of a boolean support indicator | |
* @return {mixed} | |
* |
This file contains 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 CustomFailure < Devise::FailureApp | |
# Never do http authentication through Devise | |
def http_auth? | |
false | |
end | |
def redirect_url | |
send(:"new_#{scope}_session_path", :format => (request.xhr? ? 'js' : nil )) | |
end |
This file contains 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([ | |
'jQuery', | |
'Underscore', | |
'Backbone', | |
'modules/feed', | |
'modules/files', | |
'modules/members', | |
'modules/misc/GBL', | |
'modules/misc/lightbox' | |
], function($, _, Backbone, Feed, Files, Members, GBL, Lightbox){ |
This file contains 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
ಠ_ಠ | |
ಠ~ಠ | |
ಠoಠ | |
ಠxಠ | |
ಠ.ಠ |
This file contains 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 parser = document.createElement('a'); | |
parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
parser.protocol; // => "http:" | |
parser.hostname; // => "example.com" | |
parser.port; // => "3000" | |
parser.pathname; // => "/pathname/" | |
parser.search; // => "?search=test" | |
parser.hash; // => "#hash" | |
parser.host; // => "example.com:3000" |
This file contains 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 updateQueryStringParameter(a, k, v) { | |
var re = new RegExp("([?|&])" + k + "=.*?(&|$)", "i"), | |
separator = a.indexOf('?') !== -1 ? "&" : "?"; | |
if (a.match(re)) return a.replace(re, '$1' + k + "=" + v + '$2'); | |
else return a + separator + k + "=" + v; | |
} |
This file contains 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
$(document).keypress(function(e) { | |
var code = (e.keyCode) ? e.keyCode : e.which, character; | |
if(e.charCode && code !== 32 && code !== 13 && !e.altKey && !e.ctrlKey && !e.metaKey){ | |
character = String.fromCharCode(e.charCode); | |
console.log('value: ', character); | |
} | |
}); |
This file contains 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
Date.prototype.toRelativeTime = function(date) { | |
var delta = date - this, units, conversions; | |
conversions = { | |
millisecond: 1, // ms -> ms | |
second: 1000, // ms -> sec | |
minute: 60, // sec -> min | |
hour: 60, // min -> hour | |
day: 24, // hour -> day | |
month: 30, // day -> month (roughly) |
This file contains 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
// Go to the URL below and execute this JavaScript to calculate your coinbase average Bitcoin purchase price and the total purchased. | |
// https://coinbase.com/transfers | |
// Bookmarklet can be found here: https://gist.github.com/sgreenfield/9258154 | |
var $rows = $('#transfers_list tr:gt(0)'), orders = [], totalQuantity = 0, totalPrice = 0; | |
$rows.each(function(){ | |
var rate = $.trim( $(this).find('td:eq(5)').text() ).split(' ')[0] * 1, | |
quantity = $.trim( $(this).find('td:eq(3)').text() ).split(' ')[0] * 1; | |
orders.push({ quantity: quantity, rate: rate }); |
OlderNewer