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 validateAgeOlderOrExactly = function(date_string, age_limit_year, age_limit_month) { | |
var ageLimitDate, birthDate, today; | |
if (age_limit_month == null) { | |
age_limit_month = 0; | |
} | |
today = new Date(); | |
birthDate = new Date(date_string); | |
ageLimitDate = new Date(today.getFullYear() - age_limit_year, today.getMonth() - age_limit_month, today.getDate()); | |
return birthDate <= ageLimitDate; | |
}; |
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
switch dots.html().length | |
when 3 then dots.html("") | |
when 2 then dots.html("...") | |
when 1 then dots.html("..") | |
when 0 then dots.html(".") | |
else dots.html("...") |
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
require 'net/http' | |
module Net | |
class HTTP | |
def self.enable_debug! | |
raise "You don't want to do this in anything but development mode!" unless Rails.env == 'development' | |
class << self | |
alias_method :__new__, :new | |
def new(*args, &blk) | |
instance = __new__(*args, &blk) | |
instance.set_debug_output($stderr) |
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 (){ | |
var ua = navigator.userAgent.toLowerCase(); | |
var android = /Android/gi.test(ua); | |
var iOS = /(iPad|iPhone|iPod)/gi.test(ua); | |
if(android) { $("body").addClass("device-running-android"); } | |
if(iOS) { $("body").addClass("device-running-ios"); } | |
if(!iOS && !android) { $("body").addClass("device-not-running-ios-or-android"); } | |
})(); |
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
// Bad | |
"Your Framework Sucks." | |
// Bad | |
"Browserify? Have you heard about WebPack?" | |
// Bad | |
"Ember vs Angular: 10 Things You Should Know" |
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
#/bin/bash | |
#-- Script to automate https://help.github.com/articles/why-is-git-always-asking-for-my-password | |
REPO_URL=`git remote -v | grep -m1 '^origin' | sed -Ene's#.*(https://[^[:space:]]*).*#\1#p'` | |
if [ -z "$REPO_URL" ]; then | |
echo "-- ERROR: Could not identify Repo url." | |
echo " It is possible this repo is already using SSH instead of HTTPS." | |
exit | |
fi |
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
<!--[if lte IE 6]> | |
<style type="text/css"> | |
#ie6msg{border:3px solid #090; margin:8px 0; background:#cfc; color:#000;} | |
#ie6msg h4{margin:8px; padding:0;} | |
#ie6msg p{margin:8px; padding:0;} | |
#ie6msg p a.getie8{font-weight:bold; color:#006;} | |
#ie6msg p a.ie6expl{font-weight:normal; color:#006;} | |
</style> | |
<div id="ie6msg"> | |
<h4>Did you know that your browser is out of date?</h4> |
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('a').filter(function() { | |
return jQuery(this).attr('href').match(/\.(jpg|png|gif|JPG)/); | |
}).prepend(function(index,html){return '<img src="'+html+'" />'}); |
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.Event is based on DOM3 Events as specified by the ECMAScript Language Binding | |
// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html | |
jQuery.Event.prototype = { | |
preventDefault: function() { | |
this.isDefaultPrevented = returnTrue; | |
var e = this.originalEvent; | |
if ( !e ) { | |
return; | |
} |
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 Array | |
# Array#to_ranges | |
# Converts an array of values to an array of ranges. For example, | |
# [2, 3, 33, 34, 110, 1, 111, 112, 4].to_ranges => [1..4, 33..34, 110..112] | |
def to_ranges | |
return nil unless self.all?{|item| item.is_a?Fixnum} | |
self.sort.uniq.inject([]) do |spans, n| | |
if spans.empty? || spans.last.last != n - 1 | |
spans + [n..n] | |
else |
OlderNewer