Skip to content

Instantly share code, notes, and snippets.

Avatar

Dan Beam danbeam

  • Los Angeles, CA
View GitHub Profile
View gist:519507
# screw with somebody (put in ~/.bashrc or ~/.bash_profile)
function uptime {
/usr/bin/uptime | sed -re 's/up[^,]+/up 99999 days/g';
}
View gist:571284
( cat <<EOT
anonymize () {
[ ! -z \$PS1 ] && export PS2=\$PS1;
export PS1='user@host:~\$ ';
}
unanonymize () {
[ ! -z \$PS2 ] && export PS1=\$PS2;
unset PS2;
View gist:572951
_______ _______ _ _________ _______
( ____ )( ___ )( ( /|\__ __/( ____ \
| ( )|| ( ) || \ ( | ) ( | ( \/
| (____)|| (___) || \ | | | | | |
| _____)| ___ || (\ \| | | | | |
| ( | ( ) || | \ | | | | |
| ) | ) ( || ) \ |___) (___| (____/\
|/ |/ \||/ )_)\_______/(_______/
YOUR TESTS FAILED
@danbeam
danbeam / CSS-micro-optimizations.md
Created Jan 22, 2011
A list of teeny-tiny optimizations you know of that you can do safely in CSS
View CSS-micro-optimizations.md

Things you can safely do:

Unary terms with 0 measurements:

margin-left: 0em;                      -> margin-left:0;
margin-left: 0ex;                      -> margin-left:0;
margin-left: 0cm;                      -> margin-left:0;
margin-left: 0mm;                      -> margin-left:0;
@danbeam
danbeam / chromium_update_manager_failures.md
Created Mar 9, 2011
the ppa I added to /etc/apt/sources.list is 404ing when using update manager to try to upgrade
View chromium_update_manager_failures.md

from my /etc/apt/sources.list

 # Google chrome
 deb http://ppa.launchpad.net/chromium-daily/ppa/ubuntu karmic main
 deb-src http://ppa.launchpad.net/chromium-daily/ppa/ubuntu karmic main

update manager's error output

View innerHTML faster than fast
// for everybody except IE
function replaceHtml(el, html) {
var oldEl = typeof el === "string" ? document.getElementById(el) : el;
var newEl = oldEl.cloneNode(false);
newEl.innerHTML = html;
oldEl.parentNode.replaceChild(newEl, oldEl);
/* Since we just removed the old element from the DOM, return a reference
to the new element, which can be used to restore variable references. */
return newEl;
};
@danbeam
danbeam / wtfjs
Created Mar 29, 2011
seriously, though, wtf js?
View wtfjs
(function (b) {
return 1<!--b;
}(1)); // what do I return?
@danbeam
danbeam / another wtf
Created Mar 29, 2011
seriously, you suck, JS
View another wtf
undefined === (function () {
return <!-- muhahah! you'll never evaluate me!
}()); // true
@danbeam
danbeam / text-overflow-ellipsis-feature-test.js
Created Apr 9, 2011
Feature test for text-overflow: ellipsis; with YUI3
View text-overflow-ellipsis-feature-test.js
YUI().use('gallery-ellipsis', function (Y) {
// must wait to append hidden node
Y.on('domready', function () {
// create a hidden node and try to style it
var cloned,
hidden = Y.Node.create('<div style="visibility:hidden;position:absolute;white-space:nowrap;overflow:hidden;"></div>'),
rules = ['textOverflow', 'OTextOverflow'];
@danbeam
danbeam / text-overflow-ellipsis-feature-test-jquery.js
Created Apr 9, 2011
A feature test to determine if text-overflow: ellipsis; works in the current browser (using jQuery)
View text-overflow-ellipsis-feature-test-jquery.js
(function ($) {
// innocent until proven guilty
$.extend({'ellipsis':{'nativeSupport' : false}});
// do a quick feature test to see if we're natively supported
$(function () {
// a hidden node we're testing and it's soon-to-be clone
var cloned, hidden = $('<div style="visibility:hidden;position:absolute;white-space:nowrap;overflow:hidden;"></div>'),