Skip to content

Instantly share code, notes, and snippets.

View samstarling's full-sized avatar

Sam Starling samstarling

View GitHub Profile
@samstarling
samstarling / template-example.html
Created January 3, 2011 22:19
An example of an incredibly simple template.
<html>
<head>
<title>My Website</title>
</head>
<body>
<h1><?= the_title(); ?></h1>
<p><?= the_content(); ?></p>
</body>
</html>
# Without VPN
localhost:~ sam$ nslookup
> set type=srv
> 09580.c586.ce1.fm.radiodns.org
Server: 10.0.0.138
Address: 10.0.0.138#53
Non-authoritative answer:
*** Can't find 09580.c586.ce1.fm.radiodns.org: No answer
import dns.resolver
r = dns.resolver.get_default_resolver()
try:
ans = r.query('0.cec1.c189.ce1.dab.radiodns.org', 'CNAME')
print 'CNAME', ans[0].target
except NoAnswer:
print 'No answer'
@samstarling
samstarling / indefinite_article.php
Created February 21, 2011 22:14
Gets your a's/an's correct. Originally from http://james.cridland.net/code/
<?
// Usage:
echo "I have ".return_indefinitearticle("apple")." apple, and ".return_indefinitearticle("slice of bread")." slice of bread.";
function return_indefinitearticle($thing) {
return (preg_match('/^[aeiou]|s\z/i', strtolower($thing))) ? "an" : "a";
}
?>
@samstarling
samstarling / renew_jrul_books.py
Created March 20, 2011 21:54
Renew books at Manchester University Library.
import re
import mechanize
LIBRARY_CARD_NO = '12345678'
PIN_NO = '0000'
br = mechanize.Browser()
br.open("http://catalogue.library.manchester.ac.uk/")
br.follow_link(text="My Account", nr=1)
@samstarling
samstarling / stream_loudness.py
Created May 26, 2011 20:44
Measures the loudness of the MP3 streams passed in the 'stations' dictionary
# Requires pyechonest
import urllib
from pyechonest import config
from pyechonest import track
config.ECHO_NEST_API_KEY = "YOUR_API_KEY_HERE"
stations = {
'Fun Kids': 'http://media-ice.musicradio.com:80/FunKidsMP3Low',
require 'formula'
class Mysql51 < Formula
homepage 'http://dev.mysql.com/doc/refman/5.1/en/'
url 'http://mysql.mirrors.pair.com/Downloads/MySQL-5.1/mysql-5.1.58.tar.gz'
md5 'ae5aef506088e521e4b1cc4f668e96d2'
depends_on 'readline'
def options
@samstarling
samstarling / gist:1422580
Created December 2, 2011 09:53
Greasemonkey Hudson
// ==UserScript==
// @name Olympic Screen
// @namespace http://bbc.co.uk
// @include https://ci-app.int.bbc.co.uk/hudson/view/Olympics%202012%20Data%20Screen/
// ==/UserScript==
var $;
// Add jQuery
(function(){
@-moz-document domain("ci-app.int.bbc.co.uk") {
#navig, table#viewList, table#header, td#side-panel {
display: none;
}
}
@-moz-document domain("confluence.dev.bbc.co.uk") {
.menuminwidth0, .page-metadata, .ajs-menu-bar {
display: none !important;
}
@samstarling
samstarling / gist:2480233
Created April 24, 2012 14:51
Pretty `git log`
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative -n 20