Skip to content

Instantly share code, notes, and snippets.

View oubiwann's full-sized avatar
💭
🌌

Duncan McGreggor oubiwann

💭
🌌
View GitHub Profile
@oubiwann
oubiwann / devstack.rb
Created February 15, 2012 21:24 — forked from termie/devstack.rb
Vagrant script for devstack
Vagrant::Config.run do |config|
sshdir = "#{ENV['HOME']}/.ssh/"
checkout = (ENV['COOKBOOKS'] or "#{ENV['HOME']}/lab/OpenStack/openstack-cookbooks")
ip_prefix = (ENV['IP_PREFIX'] or "10.0.5.")
mac_prefix = (ENV['MAC_PREFIX'] or "080027027")
suffix = "100"
ip = "#{ip_prefix}#{suffix}"
config.vm.box = "oneiric"
config.vm.box_url = "http://images.ansolabs.com/vagrant/oneiric64.box"
config.vm.customize ['modifyvm', :id, '--memory', '350']
@oubiwann
oubiwann / openstack_foundation_affiliations.py
Created August 1, 2012 18:18
A quick hack to tally OpenStack Member affiliations
from pprint import pprint
from urllib2 import urlopen
from bs4 import BeautifulSoup
soup = BeautifulSoup(urlopen("http://www.openstack.org/community/members/").read())
bullets = soup.find_all("li")
affiliations = [x.text.split("(")[1].split(")")[0].lower().strip()
for x in bullets if "(" in x.text]
@oubiwann
oubiwann / gist:3381472
Created August 17, 2012 18:44 — forked from lentil/gist:810399
Unit tests, PEP8, PyFlakes pre-commit hook in Python (with interactive support!)
#!/usr/bin/env python3
import os
import re
import shutil
import subprocess
import sys
import tempfile
def system(*args, **kwargs):
@oubiwann
oubiwann / list_queues.txt
Created October 5, 2012 23:18
A Kombu send/receive example
Listing queues ...
hipri 5
lopri 0
midpri 0
...done.
@oubiwann
oubiwann / basepages.py
Created October 7, 2012 03:24
Rendering ReST with Twisted Templates
import const, fragments, renderer
class ContentPage(BasePage):
"""
Note that the BasePage class is not included in this
example. It and its parent class manage template
loading, slot-filling, etc.
"""
contentType = const.contentTypes["rst"]
@oubiwann
oubiwann / config.py
Created October 10, 2012 21:16
Memcache, Twisted Templates, and the Klein Mirco-webframework
"""
A simple configuration file.
"""
cache = True
debug = True
@oubiwann
oubiwann / 01-deferred-list.py
Created October 13, 2012 21:01
Async Batching with Twisted: A Walkthrough
from twisted.internet import defer, reactor
from twisted.web.client import getPage
def listCallback(results):
print results
def finish(ign):
reactor.stop()
def test():
@oubiwann
oubiwann / convert.py
Created October 14, 2012 01:27
WMA to MP3 Conversion for Mac OS X
#!/usr/bin/python
import os
import re
import subprocess
import sys
# script configuration
if sys.platform == "darwin":
MPLAYER_PATH = os.path.join(
@oubiwann
oubiwann / pingfm.py
Created October 14, 2012 01:30
Twisted Ping.fm Client
#!/usr/bin/python
import sys
from ConfigParser import SafeConfigParser
from twisted.internet import reactor
from pyngfm.client import PingFMAsyncClient
def checkMessage(message):
@oubiwann
oubiwann / attempt1.py
Created October 14, 2012 01:34
Python and Rhythmbox
source_list = shell.get_property("sourcelist")
library, playlists = source_list.get_property("model")
for child in library.iterchildren():
x1, pixbuf, name, source, pango_attrs, x2, x3, enum = child
if name == "Import Errors":
import_errors = source
elif name == "Missing Files":
missing_files = source
fh = open("/tmp/missing_files.txt", "w+")