Skip to content

Instantly share code, notes, and snippets.

View bulletmark's full-sized avatar

Mark Blakeney bulletmark

  • Brisbane Australia
View GitHub Profile
#!/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 / 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
@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 / day04.py
Created December 5, 2021 01:47
AOC 2021 Day 4
#!/usr/bin/python3
import numpy as np
DATA = 'data/day04'
def total(board):
return np.sum(board[board > 0])
def main():
boards = []
@bulletmark
bulletmark / PKGBUILD
Last active February 25, 2022 02:58
borg-standalone-arm-bin
Maintainer: mark.blakeney at bullet-systems dot net
pkgname=borg-standalone-arm-bin
pkgver=1.2.0
pkgrel=1
pkgdesc="Borg backup - prebuilt standalone ARM binary"
url="https://borgbackup.readthedocs.io/en/stable/installation.html#standalone-binary"
license=("BSD")
arch=("armv8h" "armv7h" "armv6h" "armv5h")
replaces=("borg-arm-bin")
provides=("borg" "borgbackup")
@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")