Skip to content

Instantly share code, notes, and snippets.

View davidfraser's full-sized avatar

David Fraser davidfraser

View GitHub Profile
@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
#!/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 / 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):
@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 / venv_link.py
Last active June 2, 2017 20:30
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 / 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 / android_gnucash_account_link.py
Last active December 26, 2015 04:49
This is a script that will create online_id links for each account in a gnucash file, that correspond to the account ids generated by GnuCash for Android (https://github.com/codinguser/gnucash-android). It will alter the file in-place. After this, imports of OFX files exported by GnuCash for Android should automatically match accounts correctly.…
@davidfraser
davidfraser / uninstall-evernote-cleanup
Created December 29, 2014 09:26
Script to cleanup an Evernote installation under Wine, in order to allow reinstallation - see http://www.sgvulcan.com/evernote-under-wine-already-installed-by-another-user/
#!/bin/bash
echo first uninstall evernote using the wine uninstaller
wine uninstaller
echo now searching forregistry entry to remove
cd ~/.wine/drive_c/windows/profiles/$USER/temp
upgrade_code="`grep 'with upgrade code' EvernoteSetup.log | tail -n 1 | sed 's/^.*with upgrade code {\([A-Fa-f0-9-]*\).*$/\1/'`"
reverse_upgrade_code="`python -c "x='${upgrade_code}' ; y = x[:18].split('-') ; x = x.replace('-', '') ; z = [a+b for a, b in zip(x[16::2], x[17::2])] ; print ''.join(''.join(reversed(part)) for part in y+z).upper()"`"
echo please use regedit to navigate to '\HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\UpgradeCodes\' and remove the key "$reverse_upgrade_code"
wine regedit
REM ***** BASIC *****
Sub Main
End Sub
Sub NavigateNextFootnote
Dim document as object
Dim dispatcher as object
@davidfraser
davidfraser / fix-touchpad-bottom-edge.sh
Last active December 1, 2016 21:21
For Linux/X11 systems, adjusting setting on Lenovo Y50 (and possibly others) so that the button area of the touchpad is kept from also being regarded as a mouse movement area, preventing awkward dragging when trying to click.
#!/bin/bash
boundary="`synclient -l | grep RightButtonAreaTop | sed 's/RightButtonAreaTop//' | sed 's/[ =]//g'`"
echo Setting boundary to "$boundary"
synclient AreaBottomEdge="$boundary"