Skip to content

Instantly share code, notes, and snippets.

View treffynnon's full-sized avatar
🧟

Simon Holywell treffynnon

🧟
View GitHub Profile
@treffynnon
treffynnon / LegacyIncludes.php
Created November 26, 2010 21:58
Legacy class code loader
<?php
$dir = 'classes/';
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if($file != '.' && $file != '..' && !is_dir($dir.$file)){
require_once($dir.$file);
}
}
closedir($dh);
@treffynnon
treffynnon / LazyLoadingProxy.php
Created December 1, 2010 22:03
A simple example of using a Lazy Loading Proxy object in PHP. It is useful when attempting to work with legacy code for logging and memory savings when working with global objects..
<?php
/**
* @author Simon Holywell <treffynnon@php.net>
*/
class LazyLoadingProxy {
/**
* Where the instance of the actual class is stored.
* @var $instance object
*/
private $instance = null;
@treffynnon
treffynnon / .bash_logout
Created April 26, 2011 09:17 — forked from bobthecow/.gitconfig
dot files
# stuff to add at end of ~/.bash_logout
if ((agent_started)); then
echo "Killing ssh agent"
ssh-agent -k
fi
# File: ~/.bash_profile
# source ~/.profile, if available
if [[ -r ~/.profile ]]; then
. ~/.profile
fi
# start agent and set environment variables, if needed
agent_started=0
if ! env | grep -q SSH_AGENT_PID >/dev/null; then
@treffynnon
treffynnon / gist:1031709
Created June 17, 2011 16:04
Disable weekends on a jQuery Tools DateInput
var dateinput = $('input[type="date"]').dateinput({
"onShow": function(event) {
var calendar = this.getCalendar();
var conf = this.getConf();
var classes = conf.css.off + ' ' + conf.css.disabled;
function disableWeekends() {
var weeks = calendar.find('.calweek');
weeks.find('a:first, a:last').addClass(classes);
}
calendar.find('#calprev, #calnext').click(disableWeekends);
@treffynnon
treffynnon / xorg.conf
Created June 22, 2011 20:19
X11 config for Dell Inspiron on Ubuntu and Linux Mint where maximum screen resolution is only 800x600 you can add 1024x768 by using this configuration file.
# Install:
#
# On Mint 6 Fluxbox edition this file goes in /etc/X11/xorg.conf
# On Mint 10 LXDE edition this file goes in /usr/share/X11/xorg.conf.d/20-screen.conf
# This config will also work for versions of Ubuntu of course in /etc/X11/xorg.conf
#
# Don't forget to back up your original xorg.conf file before adding this one.
#
# You'll need to restart your machine to see the effect.
@treffynnon
treffynnon / ExampleUsage.php
Created July 11, 2011 13:05
A prototype/alpha pure PHP wrapper for the ssdeep binary (tested with version 2.4).
<?php
/**
* Some examples of how to use this prototype. I highly recommend that you use
* the PHP PECL extension I wrote instead though. It is better in every way.
* For more information see http://php.net/ssdeep and http://pecl.php.net/ssdeep
*/
// Get a hash via a supplied file path
$SsDeep = new SsDeep();
$hash_string = $SsDeep->getHash($file);
@treffynnon
treffynnon / gist:1295904
Created October 18, 2011 16:45
My current tumblr theme - http://blog.simonholywell.com
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<!--
Vacant Modified - 1.7
Designed by Sam Stefan samstefan.co.uk
Modified by Simon Holywell simonholywell.com
-->
@treffynnon
treffynnon / server.js
Created October 21, 2011 13:53
Connect to an IrisCouch database from Node.js, save a new document and retrieve it back again.
var http = require('http');
http.createServer(function (req, http_res) {
http_res.writeHead(200, {'Content-Type': 'text/plain'});
var response = '';
var cradle = require('cradle');
var connection = new(cradle.Connection)('https://subdomain.iriscouch.com', 443, {
auth: { username: 'username', password: 'password' }
});
@treffynnon
treffynnon / install.sh
Created June 6, 2012 11:40 — forked from derek-watson/tumblr.rb
Tumblr to Hakyll (Markdown and reStructuredText) migration
#!/usr/bin/env bash
echo "This script will download and install the tumblr migration script"
echo "script and its dependencies on Debian systems."
echo " "
read -p "Install dependencies from apt-get? [Yn] "
if [ "$REPLY" == "" -o "$REPLY" == "y" -o "$REPLY" == "Y" ]; then
echo "Installing the dependencies..."
echo " "
sudo apt-get install libxslt-dev libxml2-dev ruby rubygems pandoc