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
# Prevent double-clicking on things, with fix for button value | |
$(document).on 'click', '[data-disable-with]', -> | |
$element = $(this) | |
this.disabled = true | |
if disableWith = $element.attr('data-disable-with') | |
$element.html(disableWith) | |
# This is a hilarious and gross fix to get the clicked button's name and |
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
hash = {:dog => 'woof', :cat => 'meow'} | |
without_dup = hash | |
with_dup = hash.dup | |
# BEFORE CHANGE | |
puts "hash: #{hash.inspect}" | |
puts "without_dup: #{without_dup.inspect}" | |
puts "with_dup: #{with_dup.inspect}" |
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
# sinatra | |
get "/:arg" do | |
render my_database.send arg | |
end | |
def refactored_call_on_upcased_string(str, method_name) | |
str.upcase.send(method_name) | |
end | |
def call_on_upcased_string(str, method_name) |
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
# Save this file as hey.rb | |
# | |
# $ ruby hey.rb | |
# HEY GURL | |
puts DATA.read.upcase | |
__END__ | |
hey gurl |
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
<script type="text/javascript"> | |
if (self == top) { | |
var theBody = document.getElementsByTagName('body')[0]; | |
theBody.style.display = "block"; | |
} | |
else {top.location = self.location;} | |
</script> |
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
# Prevent double-clicking on things | |
$(document).on 'click', '.js-disable-on-click', -> | |
$element = $(this) | |
$element.attr('disabled', 'disabled') | |
$element.html($element.data('disabled-text')) | |
# Disabling the button prevents the form from submitting, so we have to force | |
# the submit here. | |
$element.closest('form').submit() |
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 dateValue = 504001800000; // Saturday, December 21st, 1985 at 3:30am EST | |
var date1 = new Date(dateValue); | |
var date2 = new Date(dateValue); | |
console.log(date1 == date2); // false (different instances) | |
console.log(date1 === date2); // false (different instances) | |
console.log(date1 > date2); // false (date1 is not later than date2) | |
console.log(date1 < date2); // false (date1 is not earlier than date2) | |
console.log(date1 >= date2); // true (rofl) | |
console.log(date1 <= date2); // true (ahahahaha) |
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 Eminem | |
def spaghetti(options={}) | |
@spaghetti ||= {} | |
@spaghetti[options] ||= Spaghetti.new(options) | |
end | |
end | |
e = Eminem.new | |
e.spaghetti # Calculates |
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
centerMobileBanner = -> | |
$mobileBannerText = $('.mobile-banner span') | |
$mobileBannerText.css('left', ($(window).width() * 0.5) - $mobileBannerText.width() * 0.5) | |
$(document).ready(centerMobileBanner) | |
$(window).resize(centerMobileBanner) |
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
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
widgetPath: 'public/static/components', | |
relativeCoffeePath: '**/javascripts/**', | |
coffee: { | |
compile: { | |
files: [ | |
{ | |
expand: true, | |
cwd: '<%= widgetPath %>', |