Skip to content

Instantly share code, notes, and snippets.

View davidfraser's full-sized avatar

David Fraser davidfraser

View GitHub Profile
@davidfraser
davidfraser / scientific-training-in-undergrad-compsci.rst
Created October 11, 2013 15:35
A rationale for teaching source control and testing practice in undergraduate Computer Science

Scientific Training in Undergraduate Computer Science

Background

This document was formed out of the consensus of leaders in software development companies in Cape Town, and proposes some changes to the undergraduate Computer Science curriculum, in order to improve the level of understanding and effectiveness of students, both in order to increase their relevant skills on graduation,

@davidfraser
davidfraser / venv_link.py
Last active February 9, 2025 22:04
Script to link Python system package into virtual environment from Nick Coghlan at https://bitbucket.org/ncoghlan/misc/raw/44341af0b2e4ac7f9580d5f907d8f49c7013b3b9/venv_link.py Modified to use system python to find the module, and pip to decide the link location
@davidfraser
davidfraser / merge_firefox_history.py
Created June 10, 2013 15:53
This is a (slightly-cleaned-up) script that I used to restore Firefox history when I'd lost it. Basically give it original.sqlite (the original places database you want to modify), backup.sqlite (an old backup with history that needs to be merged into the original database), and it should generate updated.sqlite which will contain the combinatio…
#!/usr/bin/env python
import sqlite3
import logging
import shutil
# copy
shutil.copy2("original.sqlite", "updated.sqlite")
original = sqlite3.connect("original.sqlite")
backup = sqlite3.connect("backup.sqlite")
@davidfraser
davidfraser / OfficeCleaner.py
Created March 19, 2013 08:24
Clean up XHTML by removing extraneous things - in particular those generated by copying and pasting out of Microsoft Office products
import cssutils
from xml.sax import saxutils
from lxml.html import tostring, fromstring, clean
from lxml import etree
import logging
class Cleaner(clean.Cleaner):
def clean_html(self, html):
if not isinstance(html, unicode):
#!/bin/bash
target_displays="$1"
VGA=VGA-0
LVDS=LVDS-0
if [[ "$target_displays" == "auto" || "$target_displays" == "" ]]
then
xrandr_output="`xrandr -q`"
vga_connected=`echo "$xrandr_output" | grep "^$VGA " | cut -d' ' -f2`
@davidfraser
davidfraser / raw_mismatches.py
Created September 15, 2012 06:31
Code to explore android sms corruption by comparing raw and sms tables in mmssms.db
#!/usr/bin/env python
import sqlite3
import pprint
import datetime
import time
# install from https://github.com/pmarti/python-messaging/tarball/master - built against 0.5.12
from messaging import sms
import pprint