Skip to content

Instantly share code, notes, and snippets.

@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
@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
<?php
/**
* @file
* drush command.
*/
/**
* Implementation of hook_drush_command().
*
@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]
@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 / ws_joystick.html
Last active May 31, 2022 16:02
Websocket with the virtual joystick Uses WebSocket-for-Python (CherryPy) & https://github.com/jeromeetienne/virtualjoystick.js
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<script type='application/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js'></script>
<script type='application/javascript'>
$(document).ready(function() {
@theapi
theapi / pygamesound.py
Created November 13, 2013 13:46
Play sounds with pygame without a GUI with the sounds being chosen by key presses.
import os
os.environ['SDL_VIDEODRIVER'] = 'dummy'
import pygame
import curses
# -----------------------------------------------------------------------------
class curses_screen:
def __enter__(self):
@theapi
theapi / doorbell.ino
Created November 25, 2013 17:04
Very hacky listen to the wireless doorbell
int i, good, k, j, incoming;
int inPin = 3;
int led = 13;
int steps = 8;
int on = 0;
byte data_in;
void setup()
/* DoorbellReceiver.ino - Detects signal from wireless doorbell.
Modified sketch (unknown licence) from Riva, to be found at
http://forum.arduino.cc/index.php?topic=110662.msg1094167#msg1094167
DBAD Public Licence (http://www.dbad-license.org/)
crutzen.eu - July 2013
Modified by Peter Clarke https://github.com/theapi
@theapi
theapi / motor_ir_alpha.ino
Last active December 30, 2015 04:49
tmp ir noticing (sillyness)
#define LED_LEFT_PIN 4
#define LED_RIGHT_PIN 3
#define PIR_LEFT_PIN 12
#define PIR_RIGHT_PIN 11
#define MOTOR_LEFT_PIN 6
#define MOTOR_RIGHT_PIN 5