Skip to content

Instantly share code, notes, and snippets.

View ljharb's full-sized avatar
🔜
working on that thing you asked about

Jordan Harband ljharb

🔜
working on that thing you asked about
View GitHub Profile
$ history | grep git | awk '{print $3}' | sort | uniq -c | sort -rn | head
127 st
53 dif
46 add
33 co
23 commit
16 push
12 pull
12 merge
10 br
@iedemam
iedemam / gist:9830045
Created March 28, 2014 10:50
Automatically manipulate .gitmodules so Travis CI pulls submodules from public URL instead of SSH URL.
#
# I use SSH URLs in my submodules for convenience. However, Travis CI is unable to
# clone from those URLs even though the repositories are public. To fix this, I'm
# simply manipulating the .gitmodules file with sed so it points to the public
# URLs before initializing the submodules.
#
# Hope it saves you some frustration!
#
# disable the default submodule logic

RegExp.escape(string)

Computes a new version of a String value in which certain characters have been escaped, so that the regular expression engine will interpret any metacharacters that it may contain as character literals.

When the escape function is called with one argument string, the following steps are taken:

  1. Let string be ToString(string).
  2. ReturnIfAbrupt(string).
  3. Let length be the number of characters in string.
  4. Let R be the empty string.
/*!
* jQuery JavaScript Library v2.1.1pre
* http://jquery.com/
*
* Includes Sizzle.js
* http://sizzlejs.com/
*
* Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
* Released under the MIT license
* http://jquery.org/license
@ljharb
ljharb / gist:8174372
Created December 29, 2013 20:20
Handling the results of multiple async ops with JS.
var promises = [
async1(),
async2(),
asyncN()
];
/* jQuery: warning, won't swallow exceptions */
var deferred = $.Deferred();
$.when.apply($, promises)
.done(function () { deferred.resolve(promises); })
@itod
itod / twitter_compose_undo_bug.md
Last active December 25, 2015 17:09
twitter.com "Compose" undo bug report

###SUMMARY: Twitter.com "compose" text area undo granularity is seriously broken (far too coarse-grained).

###CONTEXT: OS X 10.8.5

Any Browser of:

  • Chrome Version 31.0.1650.8 beta
  • Safari Version 6.0.5 (8536.30.1)
  • Firefox 24
@getify
getify / gist:5297595
Created April 3, 2013 00:55
"polymorphism" w/ JS? sorta. kinda. maybe. comes from: https://gist.github.com/getify/5253319
// a sort-of-polyfill for `currentThis` as proposed in: https://gist.github.com/getify/5253319
function lookupFn(oThis,fn) {
var ptr = oThis, i, keys;
while (ptr) {
keys = Object.keys(ptr);
for (i=0; i<keys.length; i++) {
if (ptr[keys[i]] === fn) {
return ptr;
}
}
@WebReflection
WebReflection / writeInGithub.js
Last active January 13, 2021 04:33
a silly script to write in your github timeline
/**
* so here the thing ... you go in your github page
* as example I go here: https://github.com/WebReflection
* you open your console
* you copy and paste this shit
* then you write and execute in the console
* write("Hi There!");
* NOTE: Pixel Font from a 2006 project of mine :-) http://devpro.it/pixelfont/
*/
function write(text, color, start) {
anonymous
anonymous / dict-ie.js
Created December 28, 2012 07:12
old IE shim for creating empty dict objects
// pre-ES5 IE version
var dict = (function() {
var PROPERTY_KEYS = [
"hasOwnProperty",
"isPrototypeOf",
"propertyIsEnumerable"
"valueOf",
"toString",
"toLocaleString",
"constructor"
@domenic
domenic / promises.md
Last active April 1, 2025 01:54
You're Missing the Point of Promises

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
 // the rest of your code goes here.