Skip to content

Instantly share code, notes, and snippets.

@mludvig
mludvig / audio_helper.py
Last active March 13, 2019 07:25
Sample code for using AWS Polly in Python
#!/usr/bin/env python3
# audio_helper.py - simple PyGame audio player
# Author Michael Ludvig
import io
import pygame
# PyGame initialisation - upon module loading
pygame.init()
# startup script for python to enable saving of interpreter history and
# enabling name completion
# import needed modules
import atexit
import os
import readline
import rlcompleter
# where is history saved
#!/bin/bash
# Save as /etc/profile.d/local.sh or as your local ~/.bash_profile
# By Michael Ludvig <mludvig@logix.net.nz>
umask 022
if [ $(id -u) = "0" ]; then
# Prompt is RED for root
_PS1COLOUR=31
else
@mludvig
mludvig / dropbox-rename.py
Created October 17, 2016 23:44
Rename images in DropBox folder to facilitate sorting by date
#!/usr/bin/env python
# Rename files in DropBox folder to allow easy sorting by date.
# If a JPG files contains EXIF data recognised by DropBox we
# rename it from e.g. "IMG_1234.JPG" to "2016-01-01 10:20:30 IMG_1234.JPG"
# Requires access token obtained from DropBox API page.
# By Michael Ludvig <mludvig@logix.net.nz>
# License Public Domain (it's too simple a script to deserve any licensing protection :)
@mludvig
mludvig / virtualenv-init.sh
Created August 15, 2016 03:20
Initialise Python VirtualEnv and show it's name in $PS1
#!/bin/bash
# virtualenv init.sh - Initialise Python VirtualEnv and show it in $PS1
# By Michael Ludvig <mludvig@logix.net.nz>
# Usage
# 1) copy this file as 'init.sh' to your 'virtualenv' project's folder
# 2) run it, e.g. ~/whatever/init.sh (where 'whatever' is the project)
if [ -z "${_MY_DIR}" ]; then
@mludvig
mludvig / split-image.sh
Created September 28, 2011 05:04
split-image.sh - Split a large image into same-size tiles
#!/bin/bash -e
## split-image.sh - Split a large image into same-size tiles
## Split a large image into same-size tiles
## and optionally convert to a print-ready PDF document
##
## For example split a huge A1-size banner into 8x A4 tiles
## and create a single PDF ready for print.
@mludvig
mludvig / scan2pdf.sh
Created April 22, 2011 13:48
scan2pdf.sh - Linux command-line scan-to-pdf script
#!/bin/bash -e
## Put your sane-detected device name here.
#DEVICE="snapscan"
## For network scanners use
#DEVICE="net:sane.example.org:snapscan"
DEVICE='brother4:net1;dev0'
## See scanimage --device $(DEVICE) --help
SOURCES[0]="FlatBed"