Skip to content

Instantly share code, notes, and snippets.

View seadowg's full-sized avatar

Callum Stott seadowg

View GitHub Profile
@seadowg
seadowg / rempdf
Created November 20, 2011 02:17
Delete pdfs from downloads folder on OSX
#!/bin/bash
rm /Users/$USER/Downloads/*.pdf
@seadowg
seadowg / install_buildr.sh
Created August 18, 2011 15:13
Install Buildr on OSX
gem install rjb -v 1.3.3 --platform ruby
gem install buildr
@seadowg
seadowg / build.xml
Created May 30, 2011 21:49
Scala ant build script (OS X with brew install of scala)
<project name="scalaIsAwesome" basedir="." default="build">
<property name="scala-compiler.jar"
value="/usr/local/Cellar/scala/2.8.1/libexec/lib/scala-compiler.jar"/>
<property name="scala-library.jar"
value="/usr/local/Cellar/scala/2.8.1/libexec/lib/scala-library.jar"/>
<path id="scala.classpath">
<pathelement location="${scala-compiler.jar}"/>
<pathelement location="${scala-library.jar}"/>
</path>
<taskdef resource="scala/tools/ant/antlib.xml">
@seadowg
seadowg / gensem.py
Created April 27, 2011 13:14
A general semaphore implementation
class Semaphore:
def init(self, n):
self.lock = BinSemaphore(1)
self.delay = BinSemaphore(0)
self.var = n
def wait(self):
self.lock.wait()
self.var = self.var - 1
if self.var < 0:
@seadowg
seadowg / poweroftwo.py
Created April 7, 2011 20:50
I once asked the fastest to calculate if a number was a power of two or not and I choked. Here is a nifty little way to do it.
import sys
def isapoweroftwo(n):
if n == 0:
return False
if n & (n - 1) == 0:
return True
@seadowg
seadowg / grav.py
Created March 3, 2011 21:33
Python script for setting your Ubuntu user pic as your Gravatar (command: 'python grav.py [email protected]')
import hashlib, urllib2, sys, os
class Gravatar:
def __init__(self, email):
self.email = email
self.hash = hashlib.md5(self.email.lower()).hexdigest()
def get(self):
try:
@seadowg
seadowg / tumble.html
Created February 28, 2011 00:05
Twitter/Flickr links in a list. Will style correctly in Tumblr Cargo theme. Quick paste for a mate.
<ul class="faint" id="links">
<li><a href="http://www.twitter.com" class="rounded">Twitter</a></li>
<li><a href="http://www.flickr.com"class="rounded">Flickr</a></li>
</ul>