Skip to content

Instantly share code, notes, and snippets.

@theapi
theapi / knock.py
Last active November 27, 2018 01:11
Simple demo to detect knocking from a piezo sensor on the Raspberry Pi.
#!/usr/bin/python
import time, signal, sys
from Adafruit_ADS1x15 import ADS1x15
def signal_handler(signal, frame):
print 'You pressed Ctrl+C!'
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
#print 'Press Ctrl+C to exit'
@theapi
theapi / stepper.py
Last active December 22, 2015 09:59
Very basic script that rotates a stepper motor with a Raspberry Pi.
#!/usr/bin/env python
# Thanks to http://www.youtube.com/watch?v=Dc16mKFA7Fo
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
ControlPin = [18,22,24,26]
<?php
/**
* @file
* drush command.
*/
/**
* Implementation of hook_drush_command().
*
@theapi
theapi / mux_cctv_video.sh
Created April 26, 2013 22:25
Watch the samba share for new videos with the .264 extension then mux them into a .mkv file playable by video players.
#!/bin/sh
# apt-get install inotify-tools
# apt-get install mkvtoolnix
WATCHED_DIR="/mnt/sda1/cctv/videos"
echo "Watching directory: $WATCHED_DIR for new files"
inotifywait -m -q -e create -r "$WATCHED_DIR" --format "%w%f" |
while read file
@theapi
theapi / gist:5447951
Created April 23, 2013 22:27
Convert raw .264 video file from cctv dvr
mkvmerge -o output.mkv --forced-track 0:no -d 0 -A -S -T --no-global-tags --no-chapters input.264 --track-order 0:0