Skip to content

Instantly share code, notes, and snippets.

View karbassi's full-sized avatar
🌱

Ali Karbassi karbassi

🌱
View GitHub Profile
$.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 );
};
// 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.
#!/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"
[user]
name = Your Name
email = your@email.com
[color]
status = auto
branch = auto
diff = auto
ui = auto
[color "branch"]
current = yellow reverse
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)));
}
$('#something')
.queue(function(){
$(this).addClass("turned-on");
$(this).dequeue();
})
.delay(2000)
.queue(function(){
$(this).removeClass("turned-on");
$(this).dequeue();
})
// 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 () {
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.
// 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
(?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")