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
$.fn.duplicate = function(count, cloneEvents, callback) { | |
var stack = [], el; | |
while(count--) { | |
el = this.clone( cloneEvents ); | |
callback && callback.call(el); | |
stack.push( el.get()[0] ); | |
} | |
return this.pushStack( stack ); | |
}; |
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
// what does this do?: | |
(function(){ | |
var i = 5; | |
}()); | |
// What this does is create an anonymous function then assigns a local variable 'i' | |
// with an integer value of 5 to it. Then it runs the function. |
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 | |
# Downloads and installs the latest version of Chromium onto your Mac OS X. | |
# Requires curl, unzip, and rsync. | |
set -eu | |
curl="/usr/bin/curl" | |
unzip="/usr/bin/unzip" | |
rsync="/usr/bin/rsync" |
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
[user] | |
name = Your Name | |
email = your@email.com | |
[color] | |
status = auto | |
branch = auto | |
diff = auto | |
ui = auto | |
[color "branch"] | |
current = yellow reverse |
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 foldl(f, z, xs) { | |
return xs.length === 0 ? z : foldl(f, f(z, xs[0], xs.slice(1))); | |
} | |
function foldr(f, z, xs) { | |
return xs.length === 0 ? z : f(xs[0], foldr(f, z, xs.slice(1))); | |
} |
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
$('#something') | |
.queue(function(){ | |
$(this).addClass("turned-on"); | |
$(this).dequeue(); | |
}) | |
.delay(2000) | |
.queue(function(){ | |
$(this).removeClass("turned-on"); | |
$(this).dequeue(); | |
}) |
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
// I was bored. | |
// Sorry :( | |
function d(id){ return document.getElementById(id); } | |
window.onload = function(){ | |
var email_only = d('email_only'), | |
mail_only = d('mail_only'), | |
phone_only = d('phone_only'); | |
mail_only.style.display = phone_only.style.display = 'none'; | |
d('contact_us_stype_email').onclick = function () { |
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
The following Javascript finds the highest z-index in the page and changes the | |
background color to orange. | |
What I'm trying to do is find the DOM element with the highest z-index. I have | |
the following code, but I can't figure out how to do it without having the variable "high". | |
Can you figure out a better way? | |
Also, it doesn't seem to work in Safari. |
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 image magnifier; jdbartlett's rewrite of Chris Iufer's jLoupe | |
// $('<a href="bigimage.jpg"><img src="smallimg.jpg"></a>').loupe(); | |
// code: http://gist.github.com/252303 - demo: http://jsbin.com/olado3 | |
(function($) { | |
$.fn.loupe = function(options) { | |
if (!this.length) return this; | |
options = $.extend({ | |
loupe: 'loupe', | |
width: 200, | |
height: 150 |
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
(?xi) | |
\b | |
( # Capture 1: entire matched URL | |
(?: | |
[a-z][\w-]+: # URL protocol and colon | |
(?: | |
/{1,3} # 1-3 slashes | |
| # or | |
[a-z0-9%] # Single letter or digit or '%' | |
# (Trying not to match e.g. "URI::Escape") |