Skip to content

Instantly share code, notes, and snippets.

View gdunstone's full-sized avatar

Gwyn Dunstone gdunstone

View GitHub Profile
@gdunstone
gdunstone / filereader.py
Created May 18, 2017 07:11
A generator based file line reader, optimised for reading in order, with a list like interface.
def get_generator(fh):
while True:
data = fh.readline()
if not data:
break
yield data
class GenFileReader(object):
def __init__(self, fn):
self._fn = fn
# stolen from http://stackoverflow.com/questions/21810452/cv2-imshow-command-doesnt-work-properly-in-opencv-python
import cv2
img = cv2.imread("image.jpg")
cv2.startWindowThread()
cv2.namedWindow("preview")
cv2.imshow("preview", img)
@gdunstone
gdunstone / nginx_public_html
Created January 9, 2017 02:29
NGINX rule for public_html dir with basic auth
location ~* \~(.*)/(.*$) {
auth_basic "Restricted";
auth_basic_user_file /home/$1/public_html/.htpasswd;
alias /home/$1/public_html/$2;
}
# extract package data
pattern="Leap-2.*x64.deb"
files=( $pattern )
ar vx ${files[0]}
tar -xf data.tar.xz
# Initialisation
sudo rsync -avhP ./etc/init/leapd.conf /etc/
# Device rules
# Initialisation
sudo rsync -avhP ./etc/init/leapd.conf /etc/
# Device rules
sudo rsync -avhP ./lib/udev/rules.d/25-com-leapmotion-leap.rules /lib/udev/rules.d/
# Daemon
sudo rsync -ahvP ./usr/sbin/leapd /usr/sbin
# Executables
#!/bin/bash
if [ $# -lt 1 ]
then
echo "USAGE: $0 <block device>"
exit 1
fi
read -p "About to format $1, Are you sure (y/N)?" -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
#!/bin/bash
if [ $# -lt 1 ]
then
echo "USAGE: $0 <block device> $1 <name>"
exit 1
fi
tmp=/tmp/SPC-OS_rename-$RANDOM
mkdir -p $tmp/root
#!/bin/bash
if [ $# -lt 1 ]
then
echo "USAGE: $0 <block device>"
exit 1
fi
devs=($1*)
WITH 16 CORES
Command being timed: "bash -xe generate_gigapan.sh ./ test1 16"
User time (seconds): 1913.30
System time (seconds): 1.43
Percent of CPU this job got: 111%
Elapsed (wall clock) time (h:mm:ss or m:ss): 28:39.25
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Command being timed: "bash -xe generate_gigapan.sh ./ test1 16"
User time (seconds): 1913.30
System time (seconds): 1.43
Percent of CPU this job got: 111%
Elapsed (wall clock) time (h:mm:ss or m:ss): 28:39.25
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 402464