Skip to content

Instantly share code, notes, and snippets.

View Pesticles's full-sized avatar

Luke Pascoe Pesticles

  • Auckland, New Zealand
View GitHub Profile
15:02:24 root@data:~# apt-key list
/etc/apt/trusted.gpg
--------------------
pub 2048R/BD33EEB8 2013-02-23
uid pkgr.io (http://pkgr.io) <support@pkgr.io>
pub 4096R/1F4C1BCE 2013-12-29
uid overviewer.org (Overviewer Build Key) <admin@overviewer.org>
/etc/apt/trusted.gpg.d/debian-archive-jessie-automatic.gpg
@Pesticles
Pesticles / gist:d16ad533a09927362a80
Created September 10, 2014 02:19
SD Card image shrinker
#!/bin/bash
IMG="$1"
if [[ -e $IMG ]]; then
P_START=$( fdisk -lu $IMG | grep Linux | awk '{print $2}' ) # Start of 2nd partition in 512 byte sectors
P_SIZE=$(( $( fdisk -lu $IMG | grep Linux | awk '{print $3}' ) * 1024 )) # Partition size in bytes
losetup /dev/loop2 $IMG -o $(($P_START * 512)) --sizelimit $P_SIZE
fsck -f /dev/loop2
resize2fs -M /dev/loop2 # Make the filesystem as small as possible
#!/usr/bin/python
import Image, ImageDraw, ImageFont
import sys, os, re
# FName assumed to be in YYYYMMDDHHMMSS.jpg format
fname = sys.argv[1]
assert fname
assert os.path.exists(fname)
#!/bin/bash
# The date is assumed to be today, but you can provide an override on the command line.
if [[ ! -z $1 ]]; then
DATE="$1"
DATE2=$( date -d $DATE +'%A %d %B %Y' )
else
DATE=$( date +'%Y%m%d')
DATE2=$( date +'%A %d %B %Y' )
fi
#!/bin/bash
#
# Checks the remote storage is mounted and tries to remount it if it's not.
# Once it's mounted, move any images waiting from the temporary local storage
# to the remote share.
# Is it mounted?
if ! mount | grep -q '/DATA'; then
# Try to mount
sudo mount -a
#!/bin/bash
#
# takes 3 pictures, 20 seconds apart.
function check {
# Certain conditions cause raspistill to lock up, primarily if it has trouble writing the image to storage.
# Since we store locally now (we didn't use to) it's not such a problem
# but if you're saving direct to NFS or CIFS these checks are important.
PID=$(ps ax | grep raspistill | grep -v grep | awk '{print $1}')
if [[ ! -z "$PID" ]]; then