Skip to content

Instantly share code, notes, and snippets.

View deeuu's full-sized avatar

Dominic Ward deeuu

View GitHub Profile
@deeuu
deeuu / rclone_empty_dirs.xsh
Last active August 8, 2018 16:43
xonsh script to list all directories on a remote that do not contain files (but may contain folders), via rclone
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
deeuu / num_rows.py
Created July 17, 2018 07:34
SQLAlchemy: number of rows
# https://stackoverflow.com/questions/10822635/get-the-number-of-rows-in-table-using-sqlalchemy
num_rows = session.query(MyTable).count()
@deeuu
deeuu / wav_to_flac.sh
Last active May 4, 2018 10:21
Traverse a directory tree, converting all wav files (which will be deleted) to flac
find $1 -name "*.wav" -exec sh -c 'sox "$1" --bits 16 "${1%.*}.flac"; rm "$1"' _ {} \;
@deeuu
deeuu / getbibs.py
Created June 7, 2017 22:03 — forked from wcaleb/getbibs.py
The Pandoc filter and shell script I use to make a bibliography file from my BibTeX note files. See http://wcm1.web.rice.edu/plain-text-citations.html
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Pandoc filter that grabs the BibTeX code block from each note file
# and then uses bibtexparser to add a "short title" entry in the "note" field,
# appending finished BibTeX entry to a bibliography file.
from pandocfilters import toJSONFilter, CodeBlock
# https://github.com/sciunto/python-bibtexparser
import bibtexparser