Skip to content

Instantly share code, notes, and snippets.

View jiphex's full-sized avatar

James Hannah jiphex

View GitHub Profile
/**
* Copyright 2006 Paul Querna
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
/**
* Copyright 2006 Paul Querna
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@jiphex
jiphex / testthrottle.sh
Created July 13, 2009 22:46
Script for Tomato Firmware based routers to detect Virgin Media (UK) traffic shaping, then trigger events such as LED switching and backend calling (e.g To Twitter)
#! /bin/sh
PINGHOST="212.58.226.77" # BBC news
THROTTLEFILE="/tmp/throttlestate"
PINGTIME=`ping -c 5 -q $PINGHOST | grep ^round | cut -d "/" -f 4 | cut -d "." -f 1`
WASTHROTTLED=`cat $THROTTLEFILE`
PINGISGT=`expr $PINGTIME \> 100`
if [ $PINGISGT -eq 1 ]; then
echo "I think I'm throttled (with a ping of $PINGTIME ms)"
THROTTLESTATE="yes"
else
@jiphex
jiphex / trends.py
Created April 19, 2009 19:52
Script to print the current twitter trends.
@jiphex
jiphex / bashrc.sh
Created November 24, 2008 20:27
My bash/vim/git environment
#! /bin/bash
# James Hannah - Bash Prompt.
# If no prompt, quit here.
[ -z "$PS1" ] && exit
# Get the important things sorted first
export EDITOR=vim
# Lets define some colors
@jiphex
jiphex / uniweek.php
Created July 26, 2008 10:33
Week calculator for Lancaster University
<?php
// The year start date...
define("YEARSTART", mktime(0, 0, 0, 10, 5, 2007), FALSE);
// Calculates the week number from the start of the year as set in the
// general configuration files. Returns an array containing the uni week
// number [0], the term name as a string [1] and a boolean if the current
// week is during a holiday [2]...
function universityWeek() {
BWPRICE = 0.045
COLPRICE = 0.12
unless ARGV[0] then
puts "Usage: #{$0} [#bwpages] [#colpages] [#copies] [binding-price/copy]"
exit 1
end
binding_price = ARGV[3].to_f
#! /usr/bin/env python
import sys, os
import httplib # JSON Retrieval
import simplejson # JSON Parsing
class Story(object):
"""
Class to represent a single Reddit story.