Skip to content

Instantly share code, notes, and snippets.

View bulletmark's full-sized avatar

Mark Blakeney bulletmark

  • Brisbane Australia
View GitHub Profile
@bulletmark
bulletmark / ftpd-topfield patch
Created March 28, 2011 22:12
Makes ftpd-topfield clean up closed socket correctly, even when lost ungracefully from vlc >v0.9.
diff --git a/ftpd-topfield/ftpd.c b/ftpd-topfield/ftpd.c
index db0b67b..f6d3458 100644
--- a/ftpd-topfield/ftpd.c
+++ b/ftpd-topfield/ftpd.c
@@ -932,6 +932,7 @@ reboot_topfield (void)
void
retrieve (const char *cmd, const char *name)
{
+ static int in_get;
FILE *dout = 0;
@bulletmark
bulletmark / hotot-gtk3
Last active December 26, 2015 20:29
Hotot startup wrapper.
#!/bin/bash
#
# Simple bash wrapper to ensure hotot app only runs once. Name this
# script "hotot", "hotot-gtk3", or "hotot-qt5", etc as appropriate for you and
# put early in your PATH, e.g. in your $HOME/bin/.
#
# Author: Mark Blakeney.
prog=$(basename $0)
real=/usr/bin/$prog
#!/usr/bin/env python
import time, threading
import pifaceio
# Pressing a Piface board input pin starts a sequence of output pins + delays.
# Define output sequences here. Format is:
# in_pin: ((out_pin1, on_time), (out_pin2, on_time), [ .. ])
# if out_pin = -1 then delay for on_time only.
# It's up to you to define/use output sequences that don't conflict.
#!/usr/bin/env python
import time, threading
import pifaceio
# Width and number of output pulses in sequence
PULSE_ON = 2 # secs
PULSE_OFF = 1 # secs
PULSE_NUM = 3 # count of ON pulses in sequence
PIN_TRANSITIONS = PULSE_NUM * 2
@bulletmark
bulletmark / gist:5e9843fec479b74b293c
Created October 30, 2014 23:13
Simple piface program to toggle outputs and keep state over restart
#!/usr/bin/env python
import os, time, pickle, pifaceio
filename = os.path.join(os.path.expanduser('~'), '.' +
os.path.basename(__file__) + '.init')
pf = pifaceio.PiFace()
# Read stored last states
@bulletmark
bulletmark / gs-extract.sh
Last active September 1, 2023 00:50
Bash script to extract GNOME shell javascript files
#!/bin/bash
if [[ $# -ne 1 ]]; then
echo "usage $0 dir" >&2
exit 1
fi
dir="$1"
if [[ -e $dir ]]; then
echo "Error: $dir already exists" >&2
@bulletmark
bulletmark / sumbench.sh
Created July 4, 2018 07:39
Script to run given first argument command across given machines
!/bin/bash
# Run given first argument command across given machines
# M.Blakeney, Jul 2018.
script=$1
shift
hosts=$*
bscript=$(basename $script)
for h in $hosts; do
rsync -a $script $h:/tmp/
@bulletmark
bulletmark / sumbench
Created July 4, 2018 07:53
Program to benchmark set of checksum commands
#!/usr/bin/python3
'Program to benchmark set of checksum commands.'
# Author: M.Blakeney, Jul 2018.
import os, argparse, time, tempfile, subprocess, statistics
import collections, platform
# Default set of commands to execute
CMDS = 'md5sum,sha1sum,sha256sum'
@bulletmark
bulletmark / wifi-switcher
Last active January 2, 2024 03:06
Small program to switch wifi off/on when wired connection goes on/off
#!/usr/bin/env python3
# If you are using Linux NetworkManager then this program toggles your
# wifi connection off->ON whenever your wired connection goes ON->off,
# and vice-versa. Simply copy this to
# /etc/NetworkManager/dispatcher.d/99-wifi and ensure it is executable.
# No configuration is required. Get the latest version from
# https://gist.github.com/bulletmark/8e051a0a9ffdce689d86988c528e7764
# Author: Mark Blakeney, Jun 2020.
from __future__ import annotations
import subprocess
@bulletmark
bulletmark / PKGBUILD
Last active August 21, 2022 05:20
borg-standalone-bin
# Maintainer: mark.blakeney at bullet-systems dot net
pkgname=borg-standalone-bin
pkgver=1.2.2
pkgrel=1
pkgdesc="Borg backup - prebuilt standalone binary"
url="https://borgbackup.readthedocs.io/en/stable/installation.html#standalone-binary"
license=("BSD")
arch=("x86_64" "i686")
replaces=("borg-bin")
provides=("borg" "borgbackup")