Skip to content

Instantly share code, notes, and snippets.

View joanllenas's full-sized avatar
👾

Joan Llenas joanllenas

👾
View GitHub Profile
@jacobrask
jacobrask / test.js
Last active December 21, 2022 13:50
JavaScript unit testing in the console
function test (name, fn) {
console.group(name);
var args = [ console.assert.bind(console) ];
// Async
if (fn.length > 1) {
var timeout = setTimeout(function(){ console.error(name+' timed out'); }, 2000);
args.push(clearTimeout.bind(null, timeout));
}
fn.apply(null, args);
console.groupEnd();
@TBonnin
TBonnin / git-remove-branches
Last active May 27, 2023 14:44
Safely remove local fully merged branches
#!/bin/bash
# This has to be run from master
git checkout master
# Update our list of remotes
git fetch
git remote prune origin
# Remove local fully merged branches
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"