Skip to content

Instantly share code, notes, and snippets.

Dominic Ward deeuu

Block or report user

Report or block deeuu

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
deeuu / make_rclone_mount_service.xsh
Last active Jun 4, 2019
Script to create a systemd service for mounting an rclone remote
View make_rclone_mount_service.xsh
remote = $ARG1
mount_point = f'/mnt/{remote}'
print(f'Creating mount point for user `{$USER}`, (may require root permissions)')
sudo mkdir -p @(mount_point)
sudo chown $USER @(mount_point)
log = f'/tmp/rclone-mount-{remote}.log'
config = f'''[Unit]
deeuu /
Last active May 28, 2019
matplotlib + tkinter
import time
import random
import tkinter as tk
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from matplotlib.figure import Figure
class Window():
def __init__(self, root):
self.root = root
deeuu /
Last active May 29, 2019
JSON for quick config file
class JSONConfigParser():
import collections
Option = collections.namedtuple('Option', 'type is_required default')
def __init__(self):
self._expected = {}
def add_option(self, option, type, is_required=False, default=None):
self._expected[option] = self.Option(type, is_required, default)
deeuu / folders-to-gphotos-albums.xsh
Last active Mar 9, 2019
Xonsh script wrapper around upload-gphotos to upload all personal image/video folders to google-photo albums
View folders-to-gphotos-albums.xsh
# see
import argparse
import os
parser = argparse.ArgumentParser()
help='Folder of images. Can contain subdirectories')
parser.add_argument('--username', help='Your Google Photos username')
parser.add_argument('--password', help='Your Google Photos password')
parser.add_argument('--ftypes', nargs='+',
deeuu / auto_gopass.xsh
Created Dec 4, 2018
Gopass autocompletion for xonsh
View auto_gopass.xsh
sudo echo $(gopass completion bash) > /etc/bash_completion.d/gopass
deeuu / install_julia.xsh
Last active Feb 26, 2019
Install julia
View install_julia.xsh
version = "1.1.0"
major, minor, patch = version.split('.')
wget f"{major}.{minor}/julia-{version}-linux-x86_64.tar.gz"
tar -xvf f"julia-{version}-linux-x86_64.tar.gz"
cp -r f"julia-{version}" /opt/
ln -sf f"/opt/julia-{version}/bin/julia" /usr/local/bin/julia
rm -r f"julia-{version}-linux-x86_64.tar.gz" f"julia-{version}"
echo "Done: Type 'julia'"
deeuu / tag_version.xsh
Last active Dec 9, 2019
Xonsh script for tagging (and pushing the tag) the version of a python package as recorded in
View tag_version.xsh
about = {}
with open($(find . -d 2 -name '').strip()) as f:
exec(, about)
tag_version = f"v{about['__version__']}"
git tag @(tag_version)
git push origin @(tag_version)
deeuu /
Last active Sep 4, 2018
Python function to lower case all sub-directories and files in a directory
def lower_case_all(dirname):
import os
for dirpath, dirs, files in os.walk(dirname, topdown=False):
for filename in files:
os.rename(os.path.join(dirpath, filename),
os.path.join(dirpath, filename.lower()))
for adir in dirs:
deeuu / rclone_empty_dirs.xsh
Last active Aug 8, 2018
xonsh script to list all directories on a remote that do not contain files (but may contain folders), via rclone
View rclone_empty_dirs.xsh
import re
rclone_remote_path = 'drive:/temp'
dirs = re.findall('\d+:\d+:\d+\ +-1\ +(.*?)\n',
$(rclone lsd -R @(rclone_remote_path)))
file_dirs = re.findall('\d+\ +(.*\/?(?=\/))',
$(rclone ls @(rclone_remote_path)))
deeuu /
Created Jul 17, 2018
SQLAlchemy: number of rows
num_rows = session.query(MyTable).count()
You can’t perform that action at this time.