Skip to content

Instantly share code, notes, and snippets.

View dave1010's full-sized avatar

Dave Hulbert dave1010

View GitHub Profile
@dave1010
dave1010 / cowsay.txt
Created June 10, 2011 08:48
for i in `ls /usr/share/cowsay/cows`; do echo $i && cowsay -f $i hi; done > cowsay.txt
apt.cow
____
< hi >
----
\ (__)
(oo)
/------\/
/ | ||
* /\---/\
~~ ~~
@dave1010
dave1010 / google-analytics-eu-cookie.js
Created May 26, 2011 08:37
Google Analytics loading script that complies with the new EU cookie legislation
@dave1010
dave1010 / autoload.php
Created May 25, 2011 12:53
PHP 5.3 autoloader
<?php
// PHP Standards Working Group PSR-0
function autoload($className)
{
$className = ltrim($className, '\\');
$fileName = '';
$namespace = '';
if ($lastNsPos = strripos($className, '\\')) {
$namespace = substr($className, 0, $lastNsPos);
@dave1010
dave1010 / .htaccess
Created May 24, 2011 13:32
mod_rewrite filename-123.css to filename.css
# only for files / directories that don't exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# remove "-" and any digits preceding a file extension
RewriteRule ^(.*)\-[0-9]+(\.[a-z]+)$ $1$2 [L]
# works for CSS, JS, images, etc.
# means you can set far-future expires headers (so browsers cache files lots)
# whilst being able to easily invalidate the cache, just by changing the version number
@dave1010
dave1010 / LICENSE.txt
Created May 18, 2011 12:22 — forked from 140bytes/LICENSE.txt
Load jQuery - all 31kB of it
Copyright (c) 2011 YOUR_NAME_HERE, YOUR_URL_HERE
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
@dave1010
dave1010 / .htaccess
Created May 11, 2011 13:21
PHPUnit config
deny from all
# put this in your tests and test-reports folders if you don't want the world seeing them
@dave1010
dave1010 / wp-cli.php
Created April 26, 2011 16:01
Load WordPress from a CLI not in the global scope
<?php
// When loading WP from phpunit, phpunit doesn't run WP in the global scope.
// This breaks WP. This is an attempt to fix it.
function de_globalize_wp() {
// pretend this is apache
// I use $_SERVER['HTTP_HOST'] or a file called "host" to get the right DB settings
$_SERVER['HTTP_HOST'] = trim(file_get_contents(__DIR__ . '/host'));
@dave1010
dave1010 / id_rsa.pub
Last active September 25, 2015 13:48
My (work) public key
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAsOGRyFXbKTod3h39XAK0HESYf4SFbHVIpBfWgWF+AwahzYX43ZOSK2wubLOCmGdo2D/hDrS+f0cV4Wjc7/6sNqQz1BSs+G3hIm3K9O2aeUuRqamplze/ecXzAhDyhNT3jZ3tuJ43hWJ2pHthrwehf0q6qW0Z/swFZMBucZek9fgHkIdLzJgRJX7YNQ/fmDdYNeXn0o/RnzMNm5YqCwQ/h7gMUIjfg7kS8zmOK9VEc8nyAnc/CAzFPefEdBEF6fUczNuDI+0KQ+BgfnI3zlLJsOjyT13ycyNbK4o2RIA2o8tsOwSFs6zweIiB0+LEObDMnlnkSLI5FDx3AqwU0URTXw== dave@wearebase.com
@dave1010
dave1010 / web-server-headers-research.php
Created April 11, 2011 12:04
See what web server a site is using and add it to a DB table
<?php
ob_start();
passthru('curl -I http://www.reddit.com | grep Server | sed "s/Server: //"');
$server = ob_get_clean();
// http://xkcd.com/327/
mysql_query("INSERT INTO servertypes (server) VALUES '$server'");
@dave1010
dave1010 / os-error-codes.sh
Created April 1, 2011 14:51
os-error-codes.sh
for i in `seq 0 132`; do python -c "import os; print '$i ' + os.strerror($i)"; done