Skip to content

Instantly share code, notes, and snippets.

@BrechtDeMan
BrechtDeMan / check-submissions.py
Last active May 2, 2016 09:34
Heuristically check submissions to the AES Student Recording Competition comply with the rules.
# -*- coding: UTF-8 -*-
# Copyright 2015 Brecht De Man
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@BrechtDeMan
BrechtDeMan / hyperfootnote.tex
Created January 20, 2016 15:00
Clickable hyperlink in footnote
\usepackage{hyperref}
% Make clickable footnote
\newcommand{\hyperfootnote}[1][]{\def\ArgI{{#1}}\hyperfootnoteRelay}
% relay to new command to make extra optional command possible
\newcommand\hyperfootnoteRelay[2][]{\href{#1#2}{\ArgI}\footnote{\href{#1#2}{#2}}}
% the first optional argument is now in \ArgI, the second is in #1
% Takes at most 3 parameters (see http://www.tex.ac.uk/FAQ-twooptarg.html for info on multiple optional parameters)
% If first parameter isn't given, it's value is '' (empty string in text before footnote reference)
@BrechtDeMan
BrechtDeMan / batchrename.py
Created December 28, 2015 11:19
Rename multiple files at once with list of original file names and list of corresponding resulting file names (for easy renaming using a text editor like Sublime Text)
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os # for getting files from directory
import sys # for accessing command line arguments
# Command line arguments
assert len(sys.argv)<4, "batchrename takes at most 1 command line argument\n"+\
"Use: python batchrename.py [folder_name]"
@BrechtDeMan
BrechtDeMan / png2pdf.sh
Created November 24, 2015 12:35
Convert PNG files to separate PDFs (install ImageMagick 'sudo brew install imagemagick'/'sudo port install ImageMagick')
#!/usr/bin/env
for f in *.png; do
convert ./"$f" ./pdf/"${f%.png}.pdf"
echo "Converting "$f" to ""${f%.png}.pdf"
done
@BrechtDeMan
BrechtDeMan / audio_files_info.py
Created October 12, 2015 15:25
Recursively get information of all files in specified directory and subdirectories (esp. WAV file properties) and write to text file.
import os # walking through file system
import sys # command lines arguments
import wave # for reading .wav files
# Turn number of seconds (int) to '[minutes] min [seconds] s' (string)
def seconds2timestr(time_in_seconds):
if time_in_seconds is not None:
time_in_minutes = int(time_in_seconds/60)
remaining_seconds = int(time_in_seconds%60)
return str(time_in_minutes) + "min " + str(remaining_seconds) + "s"
@BrechtDeMan
BrechtDeMan / toggle_highlights_LaTeX
Last active October 22, 2022 21:48
LaTeX tip: easily enable/disable highlight in a file (e.g. to highlight modifications or important sections)
\usepackage{color, soul}
% allow highlighting reference
\soulregister\cite7
\soulregister\ref7
\soulregister\pageref7
% comment out one of the two:
\newcommand{\markasnew}[1]{\hl{#1}} % highlight
%\newcommand{\markasnew}[1]{{#1}} % don't highlight