Skip to content

Instantly share code, notes, and snippets.

Dave Hulbert dave1010

Block or report user

Report or block dave1010

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
dave1010 / htaccess
Created Dec 14, 2011
HTTP Status Cats Apache (htaccess) config
View htaccess
# HTTP Status Cats
# Apache (htaccess) config created by @dave1010
# Licensed CC BY 2.0
# Images CC BY 2.0, from GirlieMac's photostream:
# Usage: copy save this file as .htaccess or add it to your httpd.conf
ErrorDocument 404 '<a href="" title="404 - Not Found by GirlieMac, on Flickr"><img src="" width="500" height="400" alt="404 - Not Found"></a>'
dave1010 / strip_word_html.php
Created Nov 12, 2010
Strip MS Word HTML. From
View strip_word_html.php
function strip_word_html($text, $allowed_tags = '<b><i><sup><sub><em><strong><u><br>')
//replace MS special characters first
$search = array('/&lsquo;/u', '/&rsquo;/u', '/&ldquo;/u', '/&rdquo;/u', '/&mdash;/u');
$replace = array('\'', '\'', '"', '"', '-');
$text = preg_replace($search, $replace, $text);
//make sure _all_ html entities are converted to the plain ascii equivalents - it appears
//in some MS headers, some html entities are encoded and some aren't
dave1010 /
Created Nov 30, 2010
# use ubuntu's notification system to let us know when there's something new in the apache error log
tail -n0 -f /var/log/apache2/error.log | while read line
body=`echo $line | cut -f 9- -d ' '`
notify-send -c im.received -i error "Apache / PHP error" "$body"
dave1010 / de-resolve-symlinks.php
Created Nov 5, 2013
De-resolve symlinks from PHP's __FILE__
View de-resolve-symlinks.php
View php-regex-router.php
// dangerously simple PHP regular expression URL router
// requires a mod_rewrite like "RewriteRule . /index.php [L]"
function get($url, $callback) {
$matches = array();
if (preg_match('~' . $url . '~', $_SERVER['REQUEST_URI'], $matches)) {
echo call_user_func_array($callback, $matches);
dave1010 / to-string.php
Created Jun 10, 2011
How to throw exceptions in a PHP class' __toString method
View to-string.php
class MyClass {
public function __toString() {
try {
return $this->render();
} catch(Exception $e) {
// the __toString method isn't allowed to throw exceptions
// so we turn them into an error instead
trigger_error($e->getMessage() . "\n" . $e->getTraceAsString(), E_USER_ERROR);
dave1010 / array-map-break-yield.php
Last active Sep 19, 2017
array_map in php, with break
View array-map-break-yield.php
class BreakOut extends Exception {}
function mapGenerator(array $arr, $callback)
$ret = [];
foreach ($arr as $val) {
try {
yield $callback($val);
# bamboo
mkdir /opt/atlassian
wget -O /opt/atlassian/bamboo.tar.gz
cd /opt/atlassian
tar xzf bamboo.tar.gz
mv atlassian* bamboo
mkdir /home/bamboo
from scapy.all import *
def arp_display(pkt):
if pkt[ARP].op == 1: #who-has (request)
if pkt[ARP].psrc == '': # ARP Probe
print "ARP Probe from: " + pkt[ARP].hwsrc
print sniff(prn=arp_display, filter="arp", store=0, count=10)
View cachebuster.php
interface CacheBuster
* @return string version
* @throws \NoVersionException
public function getVersion();
class MultipleCacheBuster
You can’t perform that action at this time.