Skip to content

Instantly share code, notes, and snippets.

@bjorne
bjorne / LICENSE.txt
Created June 4, 2011 21:13 — forked from bytespider/LICENSE.txt
140byt.es -- convert string to array of UTF-8 bytes
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@bjorne
bjorne / LICENSE.txt
Created June 20, 2011 14:35 — forked from 140bytes/LICENSE.txt
140byt.es -- Click ↑↑ fork ↑↑ to play!
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@bjorne
bjorne / throw.js
Created November 30, 2011 08:59
Internet Explorer Gotcha
window.a = function() {
throw new Error("expected");
};
try {
window.a();
} catch (ex) {
alert(ex.message);
}
@bjorne
bjorne / beautydiff
Created June 15, 2012 08:04
Diff compressed Javascript files by beautifying them first
#!/bin/bash
UGLIFY=`which uglifyjs`
ARGS="--beautify"
F1=/tmp/$RANDOM
F2=/tmp/$RANDOM
cat $1 | $UGLIFY $ARGS > $F1
cat $2 | $UGLIFY $ARGS > $F2
@bjorne
bjorne / take-photo.sh
Created July 13, 2012 10:55
Take a photo using Cinema Display camera if present, built-in otherwise
#!/bin/bash
dir="$HOME/Documents/commit-photos"
if [[ ! -d $dir ]]; then
mkdir -p $dir
fi
f=`echo \`date "+%Y%m%d-%H%M%S"\``
device=`imagesnap -l | grep -v "Video Devices:" | head -n 1`
@bjorne
bjorne / free-keys.el
Created September 27, 2012 21:35
Show free key bindings in Emacs (for the current mode)
(setq free-keys-modifiers (list "C" "M" "C-M"))
(setq free-keys-keys "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.,/§1234567890-=[];'\\`±!@#$%^&*()_+}{:\"|?><~")
(defun free-keys ()
(interactive)
(let ((buf (get-buffer-create "*Free keys*")))
(display-buffer buf)
(with-current-buffer buf
(erase-buffer)
(mapc (lambda (modifier)
@bjorne
bjorne / angular-snippet.js
Created April 23, 2013 19:27
angular source code pearl
// Performance optimization: http://jsperf.com/apply-vs-call-vs-invoke
switch (self ? -1 : args.length) {
case 0: return fn();
case 1: return fn(args[0]);
case 2: return fn(args[0], args[1]);
case 3: return fn(args[0], args[1], args[2]);
case 4: return fn(args[0], args[1], args[2], args[3]);
case 5: return fn(args[0], args[1], args[2], args[3], args[4]);
case 6: return fn(args[0], args[1], args[2], args[3], args[4], args[5]);
case 7: return fn(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
@bjorne
bjorne / README.md
Last active December 16, 2015 16:28
Node April Fools Proxy

April Fools Proxy

A vanilla node proxy that gives webpages a treat.

Clone this gist and simply run node index.js. Then configure 127.0.0.1:8484 as a proxy and you're good to go.

Have fun and be sure to report any pranks!

@bjorne
bjorne / widen-github.js
Created September 24, 2015 09:49
Widen Github Diffs. Useful when violators of 80 character lines are in action.
// ==UserScript==
// @name Widen Github
// @namespace http://use.i.E.your.homepage/
// @version 0.1
// @description enter something useful
// @match https://github.com/*
// @copyright 2012+, You
// ==/UserScript==
var containerWidth = $('.container').css('width');
@bjorne
bjorne / cycle.as
Created October 22, 2015 09:16
Cycle Safari Windows
tell application "Safari"
set theWindows to windows
set win1 to item 1 of theWindows
set win2 to item 2 of theWindows
repeat
tell win1
set index to 1
set visible to false
set visible to true
end tell