Skip to content

Instantly share code, notes, and snippets.

View lox's full-sized avatar

Lachlan Donald lox

View GitHub Profile
@lox
lox / contests-worker.sh
Created October 1, 2010 05:15
init.d script for contests-worker
#!/bin/sh -e
### BEGIN INIT INFO
# Provides: contests-worker
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Queue worker for Contests
# Description: Queue worker for Contests
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
<?php
/*
Ergo benefits:
- Bare bones: basic MVC, routing, templates, error handling
- Build on PHP 5.3: closures, namespaces, late static binding
- Designed for building RESTful systems, quickly
*/
@lox
lox / loggly.conf
Created October 27, 2010 02:56
syslog-ng configuration for loggly
# loggly
source s_all {
file ("/proc/kmsg" log_prefix("kernel: "));
unix-stream ("/dev/log");
internal();
file("/mnt/log/apache2/error.log" follow_freq(1) flags(no-parse));
};
destination d_loggly {
tcp("logs.loggly.com" port(14791));
--- src/protocols/ec_tcp.c.orig 2009-09-08 17:04:47.000000000 +0200
+++ src/protocols/ec_tcp.c 2009-09-08 17:06:15.000000000 +0200
@@ -116,7 +116,7 @@
tcp = (struct tcp_header *)DECODE_DATA;
opt_start = (u_char *)(tcp + 1);
- opt_end = (u_char *)((int)tcp + tcp->off * 4);
+ opt_end = (u_char *)((u_char *)tcp + tcp->off * 4);
DECODED_LEN = (u_int32)(tcp->off * 4);
--- pcaputil.c.orig Sun Mar 14 14:12:11 2004
+++ pcaputil.c Sun Mar 14 14:12:34 2004
@@ -16,6 +16,7 @@
#include <pcap.h>
#ifdef BSD
#include <pcap-int.h>
+#define BIOCIMMEDIATE _IOW('B',112, u_int)
#endif
#include "pcaputil.h"
<?php
use \Pheasant;
use \Pheasant\Types;
class Post extends Pheasant\DomainObject
{
public function properties()
{
return array(
@lox
lox / phark_proposal.md
Created November 23, 2010 04:03
A proposal for a sane php package manager

Proposal for Phark, a sane php package manager

As it stands PEAR sucks. It's complicated, clumsy and is full of utter garbage (sorry).

PHP is rapidly dying because we don't have any decent way of writing code that can easily build on the work of others. What we need is a simple, open package management system like rubygems.

We now have decent support for namespaces, class autoloading and archives. I propose we abandon

@lox
lox / watch.rb
Created April 19, 2011 20:00
Synchronize two directories via fsevents and sftp
#!/usr/bin/env ruby
require 'rubygems'
require 'rb-fsevent'
require 'net/sftp'
remote_host = 'host.goes.here'
remote_user = 'ubuntu'
Net::SFTP.start(remote_host, remote_user) do |sftp|
@lox
lox / install_jenkins.sh
Created April 20, 2011 18:18
A script for installing Jenkins on Ubuntu 10.04
#!/bin/bash
# install the beast
sudo aptitude install openjdk-6-jre git-core
# update rubygems
wget http://production.cf.rubygems.org/rubygems/rubygems-1.7.2.zip
tar xzvf rubygems-1.7.2.tgz
cd rubygems-1.7.2
sudo ruby setup.rb
@lox
lox / JUnitReporter.php
Created April 21, 2011 18:57
A SimpleTest Reporter that outputs JUnit compatible XML
<?php
/**
* A reporter that writes jUnit xml files
*/
class JUnitReporter extends SimpleReporter
{
private $_dom;
private $_tests=array();
private $_test;