Skip to content

Instantly share code, notes, and snippets.

@bwg
bwg / protected.php
Created March 18, 2014 15:33
how does Bar call test() on Foo if its defined as protected?
<?php
abstract class Base {
protected static function test() {
echo get_called_class()."\n";
}
}
class Foo extends Base {
protected static function test2(){
@bwg
bwg / selection.js
Last active December 18, 2015 15:39
cross browser double click selection/range fun
// Browsers behave differently when dbl clicking to select
// a range.
//
// Chrome and IE use the text node that contains the selected text
// as the startContainer with an offset to exclude any whitespace
// characters at the start of the node.
//
// Firefox will use a text node *before* the selected text
// as the startContainer, with a positive offset set to the end
// of the node. If there is no previous sibling of the selected text
@bwg
bwg / dnsmasqresolv.sh
Created June 1, 2012 17:30
Shell script for updating resolv.dnsmasq.conf in OS X
#!/bin/bash
# updates resolv.dnsmasq.conf with DHCP provided DNS servers for the
# currently active network interface on OS X
# the location of the dnsmasq resolv file
RESOLV=/etc/resolv.dnsmasq.conf
# get the list of active services from scutil
SERVICES=$(echo 'show Setup:/Network/Global/IPv4' | scutil | grep -e '[[:digit:]] :' | awk '{print $3}')
@bwg
bwg / widget-parent-renderqueue.js
Created January 24, 2011 16:02
plugin for widgetparent that uses an async-queue to render children
YUI.add('sm-widget-parent-renderqueue', function(Y) {
/**
* Plugin for WidgetParent that uses an async-queue to render children
*
* @module widget-parent-render-queue
*/
var NAME = 'renderqueue',
HOST = 'host',