Skip to content

Instantly share code, notes, and snippets.

View assertchris's full-sized avatar

Christopher Pitt assertchris

View GitHub Profile
@assertchris
assertchris / load_vhosts.php
Created March 24, 2011 13:25
Apache2 dynamic config creator
<?php
# Change username, password and database to match your db details
#
# Set up the database table:
# CREATE TABLE IF NOT EXISTS `vhosts` (
# `id` int(11) NOT NULL AUTO_INCREMENT,
# `name` varchar(255) DEFAULT NULL,
# `aliases` text,
# `path` text,
@assertchris
assertchris / gist:910147
Created April 8, 2011 15:46
Simple Socket wrapper class for Objective-C
// simple socket wrapper class for objective-c
// SocketController.h
#import <Foundation/Foundation.h>
#import <netinet/in.h>
#import <sys/socket.h>
#import <arpa/inet.h>
@protocol SocketControllerDelegate
@assertchris
assertchris / gist:927843
Created April 19, 2011 13:51
JavaScript unified timeout/interval shim
// Based on the exceptional work of Arian Stolwijk (https://github.com/arian), https://gist.github.com/9286b06108b1dabae4d9
(function(global){
var defaults = {
'setTimeout': global.setTimeout,
'clearTimeout': global.clearTimeout,
'setInterval': global.setInterval,
'clearInterval': global.clearInterval
},
@assertchris
assertchris / gist:1024865
Created June 14, 2011 13:13
Mootools Event Proxy
//http://jsfiddle.net/sixtyseconds/HrKHp/
var Proxy = new Class({
'addDelegate': function(object, events) {
var self = this;
if (!self.delegates) {
self.delegates = [];
}
@assertchris
assertchris / gist:1039952
Created June 22, 2011 12:12
Slick (MooTools) custom selector for case-insensitive content matching
Slick.definePseudo('contains-ci', function(text) {
return (this.innerText || this.textContent || '').match(new RegExp(text, 'ig'));
});
@assertchris
assertchris / gist:1080435
Created July 13, 2011 14:47
Objective-c flipclock shape geometry
/*
* x1
* a-----------------------b
* r1/ \
* p c
* | |
* | l g |
* | / \ r2/ \ |y1
* | m k h f |
* | | | y3| | |
@assertchris
assertchris / gist:1168029
Created August 24, 2011 13:16
PHP Events callback methods
$callbacks = null;
function addEvent($type, $callback)
{
global $callbacks;
if (empty($callbacks))
{
$callbacks = array();
}
@assertchris
assertchris / gist:1241764
Created September 26, 2011 07:14
OSX showall/hideall hidden files.
alias showall='defaults write com.apple.finder AppleShowAllFiles TRUE;killall Finder'
alias hideall='defaults write com.apple.finder AppleShowAllFiles FALSE;killall Finder'
@assertchris
assertchris / gist:1244642
Created September 27, 2011 08:59
Recursive .svn folder delete
find ./ -type d -name '.svn' -print0 | xargs -0 rm -rdf
@assertchris
assertchris / gist:1299215
Created October 19, 2011 18:29
OSX sings to me...
say -v "Bad News" "dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum"