Skip to content

Instantly share code, notes, and snippets.

View SimonS's full-sized avatar

Simon Scarfe SimonS

View GitHub Profile
// test whether file is being called directly.
// define a class
if (strtoupper(__FILE__)==strtoupper($_SERVER['SCRIPT_FILENAME'])) {
// demonstrate class
}
<!-- this is awesome. typing: -->
div.news-item*3>h2+div.date+p+p+a.link-cta
<!-- followed by ctrl+e in coda generates the following mark-up -->
<div class="news-item">
<h2></h2>
<div class="date"></div>
<p></p>
@SimonS
SimonS / gSpreddit.py
Last active September 27, 2015 02:38
Google Spreadsheet-generated CSV -> Reddit Flair Python script
#!/usr/bin/python
# This is the script we used to use to manage the flair on /r/bjj. It's now useless due to
# reddit doing flair assignment, but left it up for posterity or just in case someone wants
# a working example of reading from a CSV.
import csv, re, time
from urllib2 import urlopen
from redditclient import RedditClient
@SimonS
SimonS / wp_create.sh
Created March 8, 2012 11:02
quick start wordpress script
DEST=$1
WP='http://wordpress.org/latest.tar.gz'
wget $WP
tar zxvf latest.tar.gz
mv wordpress $DEST
rm latest.tar.gz
cd $DEST
@SimonS
SimonS / gist:2000649
Created March 8, 2012 11:47
Simple autoloader, customised the Zend autoloader to work with wordpress parent & child themes. Tries Parent and then fallsback to child. Could easily be reversed.
function __autoload($class_name) {
$parent_path = realpath(dirname(__FILE__).'/'.str_replace("_", "/", $class_name).'.php');
if(file_exists($parent_path)) {
require_once $parent_path;
}
$child_path = realpath( get_stylesheet_directory() . '/class/'. str_replace("_", "/", $class_name).'.php' );
if(file_exists($child_path)) {
require_once $child_path;
}
@SimonS
SimonS / gist:2001962
Created March 8, 2012 16:35
Minimal reponsive javascript framework
(function($){
var previous_state = '',
state;
$(function(){
// Resize event
var resizeTimer = null; /* use resizeTimer to minimise lag */
$(window).resize( function(){
@SimonS
SimonS / mentions.action
Created December 21, 2012 12:22
Use Growl to allow notifications in DMDirc on OS X
# pre-requisites:
# growlnotify (found as part of the Extras folder in the Growl distribution)
# DMDirc redirect plugin
# DMDirc exec plugin
# This section indicates which sections below take key/value
# pairs, rather than a simple list. It should be placed above
# any sections that take key/values.
keysections:
condition 0
@SimonS
SimonS / streak_stats.php
Last active January 1, 2016 19:28
Hacking around my streak with the dailymile API
<?php
require 'vendor/autoload.php';
$client = new DailymilePHP\Client;
$entries = $client->getEntries(['username' => 'simons', 'page' => 'all', 'since' => '1325462400']);
echo 'Entries: ' . count($entries). "\n";
$runningEntries = array_filter($entries, function($entry) {
@SimonS
SimonS / .block
Created October 3, 2017 23:01
fresh block
license: mit
@SimonS
SimonS / .block
Last active October 3, 2017 23:16
fresh block
license: mit