Skip to content

Instantly share code, notes, and snippets.

View doobry's full-sized avatar

Chris Beswick doobry

View GitHub Profile
@doobry
doobry / British - PC.keylayout
Created January 25, 2012 20:34
British Keyboard Layout for Mac OS X
<?XML version="1.1" encoding="UTF-8"?>
<!DOCTYPE keyboard PUBLIC "" "file://localhost/System/Library/DTDs/KeyboardLayout.dtd">
<!--Last edited by Ukelele version 2.1.10 on 2012-05-10 at 19:14 (BST)-->
<keyboard group="0" id="13361" name="British - PC" maxout="1">
<layouts>
<layout first="0" last="0" modifiers="Modifiers" mapSet="ANSI"/>
</layouts>
<modifierMap id="Modifiers" defaultIndex="0">
<keyMapSelect mapIndex="0">
<modifier keys=""/>
@doobry
doobry / avs2pipe.c
Created August 2, 2011 22:02
An argument for inline comments...
/*
* Copyright (C) 2010-2011 Chris Beswick <chris.beswick@gmail.com>
*
* This file is part of avs2pipe.
*
* avs2pipe is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
@doobry
doobry / dsmodel.php
Created August 1, 2011 15:50
Database Model Layer thingy idea for Dr4g
<?php
abstract class PPI_Model
{
protected $_dsName = 'default';
protected function __construct()
{
$this->_connection = PPI_DataSources::get($this->_dsName);
}
@doobry
doobry / nginx.conf
Created August 1, 2011 10:48
nginx php-fpm config
worker_processes 1;
events {
worker_connections 1024;
use epoll;
}
http {
include mime.types;
default_type application/octet-stream;
@doobry
doobry / users.sql
Created July 26, 2011 13:15
MySQL user auth with stored procedures
/*
Possible SHA1 values 2^160 = 1.46150164 × 10^48
RAND() returns a float from 0 to 1 ~= 10^16
CONCAT(RAND(), RAND(), RAND())
*/
@doobry
doobry / route_speed.php
Created July 21, 2011 23:44
Route::compilePatterns speed comparison
<?php
function compilePatterns($pattern) {
$repl = array();
$replace = function($value) use (&$repl) {
$key = ':::' . count($repl) . ':::';
$repl[$key] = $value[0];
return $key;
};
$pattern = preg_replace_callback('/\{[0-9,]+\}/', $replace, $pattern);
@doobry
doobry / gist:1086358
Created July 16, 2011 13:30
Enforced unified constructor
<?php
namespace lambent\core;
use ReflectionClass;
class Object
{
protected static $_defaults = array(
'_config' => true,
@doobry
doobry / gist:1084732
Created July 15, 2011 13:52
Soddy static registry...
<?php
class Registry_Compat {
private $_imp;
public function __construct($imp)
{
$this->_imp = $imp;
}
@doobry
doobry / Password Update done badly
Created July 4, 2011 09:59
Password Update done badly for Smiley
#!/bin/bash
function update_user {
local user=$1
local email=$2
local pass=$3
local wiki_pass=$(htpasswd -nb $user $pass)
local email_pass=$(md5pass $user)
@doobry
doobry / stats.php
Created June 11, 2011 20:24
God AWEFULL PHP for edit_21
<html>
<head>
<title>Carlsberg don't do websites, so we got this pap instead</title>
<meta http-equiv="refresh" content="1">
</head>
<body>
<?php
$db = new mysqli( 'localhost', 'user', 'password', 'weatherdb');