This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
try: | |
import simplejson as json #python <2.6 | |
except(ImportError): | |
import json as json #python 2.6+ | |
import urllib | |
trends = json.load(urllib.urlopen('http://api.twitter.com/1/trends/23424975.json'))[0] | |
trendlist = trends[trends.keys()[0]] | |
for trend in trendlist: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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. |
NewerOlder