Skip to content

Instantly share code, notes, and snippets.

View danbeam's full-sized avatar
🚲

Dan Beam danbeam

🚲
  • Los Angeles, CA
View GitHub Profile
@danbeam
danbeam / unmaxed.sh
Created August 26, 2011 08:07
remove Firefox extension maxVersion
#!/bin/bash
usage() {
cat >&2 <<EOT
Usage: $(basename $0) <a_url_to_a_ff_ext.xpi>
EOT
exit 1;
}
if [ "$#" -lt "1" ]; then
@danbeam
danbeam / say-hello.js
Created August 16, 2011 23:44
say hello!
function say() {
var slice = Array.prototype.slice;
var concat = Array.prototype.concat;
var strs = slice.call(arguments);
var func = function() {
strs = concat.call(strs, slice.call(arguments));
return func;
};
func.toString = function() {
return strs.join(' ');
@danbeam
danbeam / the_answer_to_life_the_universe_and_everything.sh
Created July 10, 2011 03:28
The shell file that calculates the answer to life the universe and everything
#!/bin/sh
answer() { echo -e "\n\nAnswer: 42\n"; exit; }
trap answer TRAP INT HUP;
while [ 1 ]; do head -10 /dev/urandom | hexdump -C | head -3 | egrep --color=auto '[a-f][0-9a-f]'; sleep .1; done
# to run -
# curl https://raw.github.com/gist/1074226/the_answer_to_life_the_universe_and_everything.sh | sh
@danbeam
danbeam / git-man-entries.txt
Created June 22, 2011 03:38
Damn, that's a lot to git!
cmd-list.made
endnote
git
git-add
git-am
git-annotate
git-apply
git-archimport
git-archive
gitattributes
@danbeam
danbeam / make-min.sh
Created June 14, 2011 23:36
Only $19 if you order today!
#!/bin/bash
DIR=${1:-.};
if [ -z "$YUI" -o ! -r "$YUI" ]; then
echo "You need the path to YUI Compressor as env var \$YUI";
exit 1;
fi
for CSS in `find $DIR -type f -name *.css`; do
@danbeam
danbeam / get-css21-color-min-candidates.js
Created June 9, 2011 09:16
Get the colors that can be optimized on the w3's CSS2.1 color page
// on http://www.w3.org/TR/CSS21/syndata.html
Array.prototype.forEach.call(document.querySelectorAll('span.colorsquare'), function(square) {
var name = square.childNodes[0].innerText,
hex = square.childNodes[1].data.trim();
if (hex[1] === hex[2] && hex[3] === hex[4] && hex[5] === hex[6]) {
hex = '#' + hex[1]+hex[3]+hex[5];
}
if (hex.length > name.length) {
console.log(hex, '->', name);
}
@danbeam
danbeam / get-css3-color-min-candidates.js
Created June 9, 2011 09:11
Get the colors that can be optimized on the w3's CSS3 color page
// on http://www.w3.org/TR/css3-color/
Array.prototype.forEach.call(document.querySelectorAll('table.colortable')[1].querySelectorAll('td:not(.c)'), function(td) {
var name = td.innerText,
hex = td.nextSibling.innerText;
if (hex[1] === hex[2] && hex[3] === hex[4] && hex[5] === hex[6]) {
hex = '#' + hex[1]+hex[3]+hex[5];
}
if (hex.length > name.length) {
console.log(hex, '->', name);
}
@danbeam
danbeam / gist:1013629
Created June 8, 2011 01:55
make-money.html
<!doctype html>
<html>
<body>
<ol>
<li>Work at Yahoo!</li>
<li>???</li>
<li>PROFIT!!!</li>
</ol>
</body>
</html>
flab =
function () {
var s = Array.prototype.slice,
a = [s.call(arguments)],
b = function () {
b._calls = a
a.push(s.call(arguments))
return b
}
b.toString = function () {
# lets you do echo 'lol' | todata
# or cat filename | todata
# and it'll spit out a nice data URI
todata() {
if [ ! -t 0 ]; then
php -r "echo 'data:text/plain;base64,'.base64_encode(file_get_contents('php://stdin')); }" && echo;
fi
}