Skip to content

Instantly share code, notes, and snippets.

View lox's full-sized avatar

Lachlan Donald lox

View GitHub Profile
@lox
lox / gist:169617
Created August 18, 2009 08:34
Generic SPL class loader for PHP
<?php
/**
* Generic SPL class loader
* @license http://opensource.org/licenses/mit-license.php MIT License
* @author Lachlan Donald <lachlan@ljd.cc>
*/
class ClassLoader
{
private $_paths = array();
@lox
lox / gist:209677
Created October 13, 2009 23:50
git-recent-branches
#!/usr/bin/env php
<?php
## git-recent-branches: shows all branches, sorted by the most recently updated
## git-recent-branches Copyright 2009 Lachlan Donald <lachlan@ljd.cc>.
$verbose = in_array('-v',$argv);
$arg = in_array('-a',$argv) ? '-a' : '';
$branches = array();
@lox
lox / autoexec.cfg
Created November 15, 2009 22:27
Quake3 Config
// Lox's Quake3 Config
// copy into the baseq3 directory to use
seta r_customHeight "900"
seta r_customWidth "1440"
seta r_mode "-1"
seta cg_fov 120
seta r_detailtextures "1"
seta r_drawSun "1"
1) extract tracks from the mkv file
mkvextract tracks <source_file.mkv> 1: <source_file.h264> 2:<source_file.ac3>
2) convert video to be compliant with the ATV
ffmpeg -y -i <source_file.h264> -vcodec libx264 -b <bitrate> -maxrate <max_bitrate> -an -threads 4 -level 31 -g 250 -qmin 10 -qmax 51 -qdiff 4 -subq 6 -flags +loop -flags2 +mixed_refs+wpred -sc_threshold 40 -partitions +parti4x4+partp8x8+partb8x8 -refs 4 -bf 16 -keyint_min 25 -me_method umh -me_range 16 -i_qfactor 0.71 -cmp +chroma -b_strategy 1 -qcomp 0.6 -trellis 0 -rc_eq 'blurCplx^(1-qComp)' -f h264 <dest_file.h264>
3) convert audio to aac
ffmpeg -y -i <source_file.ac3> -vn -acodec libfaac -ab 160k -ar 48000 -ac 2 -async 50 -threads 4 -f aac <dest_file.aac>
4) join all the tracks together
@lox
lox / ts.php
Created May 11, 2010 23:49
Command-line script for manipulating timestamps
#!/usr/bin/env php
<?php
/**
* Command-line script for manipulating timestamps
*/
// parse options
$options = array('f'=>'r', 't'=>@date_default_timezone_get());
foreach(array_keys($options) as $arg)
@lox
lox / pheasant.php
Created May 16, 2010 05:18
Example code from Pheasant
<?php
/**
* A domain object using Pheasant for persistence
*/
class User extends DomainObject
{
public function __construct($firstname, $lastname)
{
<?php
// call looks like this:
sendgrid_send(array(
'from'=>'no-reply@justasktom.com',
'fromname'=>'JustAskTom.com',
'to'=>'lachlan@ljd.cc',
'subject'=>'Blargh.',
'text'=>'test',
@lox
lox / scribed
Created August 5, 2010 02:14
Init.d script for scribed for Ubuntu
#!/bin/sh
#
# scribed Start and Stop the scribe daemon
#
### BEGIN INIT INFO
# Provides: scribed
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
@lox
lox / install-scribed.sh
Created August 5, 2010 02:30
This is the process for installing Thrift, Scribed and the php extension on Ubuntu
#!/bin/bash
# This is the process for installing Thrift, Scribed and the php extension on Ubuntu
# lachlan@99designs.com
set -e
# install dependancies
aptitude install libboost1.40-dev libboost-filesystem1.40-dev libevent-dev build-essential flex bison libtool libevent-dev php5-dev pkg-config
# install thrift from source
cd /usr/local/src
@lox
lox / wordpress.vcl
Created August 29, 2010 07:36
Varnish configuration for Wordpress
## A varnish vcl file for WordPress, serves cached pages to not-logged in users
director apps random {
{ .backend = { .host = "127.0.0.1"; .port = "http"; } .weight = 1; }
}
acl purge {
"localhost";
}