Skip to content

Instantly share code, notes, and snippets.

View davidfraser's full-sized avatar

David Fraser davidfraser

View GitHub Profile
@davidfraser
davidfraser / Google Drive Sync Wine Scripting.md
Last active February 11, 2025 10:31
Google Drive Sync Wine Scripting

Google Drive Sync Wine Scripting

This is a set of scripts that help running Google Drive Backup and Sync under Wine, with multiple Google accounts.

Each account is given its own Wine prefix (a separate wine configuration).

To install, run install-gdrive-sync google_account

List the accounts set up in ~/.config/gdrive-accounts

@davidfraser
davidfraser / make_yaml_decoder_module.py
Last active August 1, 2017 20:29
Script for making cut-down version of pyyaml that is a single-file yaml loader
#!/usr/bin/env python
"""Command-line utility to combine the necessary modules to make a single-file yaml_decoder.py"""
import shutil
import os
from os.path import abspath, dirname, exists, join
include_modules = 'loader reader parser scanner composer constructor resolver nodes events tokens error'.split()
# this should be placed in the pyyaml source tree
@davidfraser
davidfraser / reduce_mbsync_journal.py
Last active May 29, 2017 19:58
A simple script to remove superfluous entries from a mbsync internal .journal file
#!/usr/bin/env python
"""This is a script for internal use when doing large mail migrations with mbsync
See http://isync.sourceforge.net/mbsync.html for more information on the product
If IMAP disconnects occur on a large mailbox, the internal .journal file that tracks progress
can grow very large in size, though much of the information is not needed
This script can be used to reduce the file in size
NB: This should be used with caution, and never while mbsync is running
It does not replace the file, but can be used to produce a new journal file,
@davidfraser
davidfraser / hang_coloredlogs.py
Last active May 18, 2017 14:27
Demonstration of hang when coloredlogs in one thread and import in other thread does logging
#!/usr/bin/env python
import logging
import time
import threading
import coloredlogs
# configured notices that will be displayed with styling by coloredlogs
NOTICE = 25
logging.addLevelName(25, 'notice')
@davidfraser
davidfraser / list-vbox-snapshots.sh
Last active May 15, 2018 15:19
List VirtualBox snapshots and disk usage in a tree
#!/bin/bash
vmname="$1"
[ "$vmname" == "" ] && { echo syntax $0 vmname >&2 ; exit 1 ; }
vmdir="$HOME/virtualbox/machines/$vmname"
sndir="$vmdir/Snapshots/"
vboxtmp="`tempfile -p vbox-$vmname --suffix='-list.txt'`"
vboxsed="`tempfile -p vbox-$vmname --suffix='-list.sed'`"
vboxmanage snapshot "$vmname" list > "$vboxtmp"
for uuid in `grep "UUID:" "$vboxtmp" | sed 's%^.*(UUID: \([0-9a-f-]*\)).*$%\1%'`
do
@davidfraser
davidfraser / imap-pass
Created August 7, 2015 06:51
Simple script to get and set passwords in keyring, from tutorial on mbsync at http://bloerg.net/2013/10/09/syncing-mails-with-mbsync-instead-of-offlineimap.html
#!/usr/bin/env python
import argparse
import keyring
import getpass
if __name__ == '__main__':
SERVICE = 'mbsync'
parser = argparse.ArgumentParser()
@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"
REM ***** BASIC *****
Sub Main
End Sub
Sub NavigateNextFootnote
Dim document as object
Dim dispatcher as object
@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
@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.…