Skip to content

Instantly share code, notes, and snippets.

benfulton /
Created Feb 4, 2020
Extend the leaf branch lengths of a Newick tree so all the paths are the same length
from Bio import Phylo
from io import StringIO
import sys
treedata = sys.argv[1]
handle = StringIO(treedata)
tree =, "newick")
out = StringIO()
benfulton /
Last active Aug 29, 2015
Screen scraper to summarize grades for MyStudentsProgress
import requests
from lxml import html
# music 62531,
def grade(r):
return float(r[2][0])/float(r[2][1])
except ValueError:
benfulton /
Created Jul 7, 2014
Launch the WaferSlim SLIM server from a source directory
import sys
import waferslim.server
import logging
#sys.argv = ['programname', '-iq', '-q', directory]
def start_server():
# This script reads a GIT directory and prints out the contents
# appropriately to be incorporated into a Google Visualization Treemap
import os
rootdir = "E:\\Git"
result = {}
for path, dirs, files in os.walk(rootdir):
key = os.path.basename(path)
benfulton /
Created Jan 16, 2014
Copy registered machines from a LinkSys router to a hosts file, by scraping a router web page
import urllib2
import base64
import re
request = urllib2.Request("")
base64string = base64.encodestring('%s:%s' % (USER, PASSWORD)).replace('\n', '')
request.add_header("Authorization", "Basic %s" % base64string)
lines = (re.findall(r"'(.*?)'", x, re.DOTALL) for x in urllib2.urlopen(request) if 'new AAA' in x)
q = dict((vv[0], vv[1]) for vv in lines if vv)
benfulton / WMPSongs.rb
Created Jul 17, 2012
Reading Windows Media Player songs in Ruby
View WMPSongs.rb
require 'win32ole'
class MediaPlayer
def initialize
@player ='WMPlayer.OCX')
def songs
s = @player.mediacollection.getByAttribute("MediaType","Audio")
benfulton / RavenHQ.rb
Created Jun 7, 2012
Connecting to RavenHQ in Ruby
View RavenHQ.rb
require 'httparty'
response = HTTParty.get('')
response = HTTParty.get(response.headers['oauth-source'], :headers => { "Api-Key" => ApiKey })
auth = "Bearer " + response.body
response = HTTParty.get('', :headers => { "Authorization" => auth })
puts response.body, response.code, response.message, response.headers.inspect
benfulton / Book2Calendar.rb
Created Mar 7, 2012
Create an iCal file for your books checked out of Monroe County Public Library
View Book2Calendar.rb
require "icalendar"
require "Mechanize"
include Icalendar
class Libry
def initialize
@agent =
You can’t perform that action at this time.