Skip to content

Instantly share code, notes, and snippets.

@errkk
errkk / forms.py
Created July 29, 2014 12:33
Data Display for solar panel data
from django import forms
from .models import Temperature, PumpEvent
class TemperatureForm(forms.ModelForm):
class Meta:
model = Temperature
exclude = ('timestamp', )
@errkk
errkk / gist:9297516
Last active August 29, 2015 13:56
Ultrasound distance, lazy version without wiring into power pins
/*
HC-SR04 Ping distance sensor:
VCC to arduino 5v
GND to arduino GND
Echo to Arduino pin 7
Trig to Arduino pin 8
This sketch originates from Virtualmix: http://goo.gl/kJ8Gl
Has been modified by Winkle ink here: http://winkleink.blogspot.com.au/2012/05/arduino-hc-sr04-ultrasonic-distance.html
And modified further by ScottC here: http://arduinobasics.blogspot.com.au/2012/11/arduinobasics-hc-sr04-ultrasonic-sensor.html
// readCapacitivePin
// Input: Arduino pin number
// Output: A number, from 0 to 17 expressing
// how much capacitance is on the pin
// When you touch the pin, or whatever you have
// attached to it, the number will get higher
uint8_t readCapacitivePin(int pinToMeasure) {
// Variables used to translate from Arduino to AVR pin naming
volatile uint8_t* port;
@errkk
errkk / gist:7412982
Created November 11, 2013 13:11
cooking bad
eyJzdiI6eyJjIjoiMzFkNjMiLCJjcyI6ImkyYmwiLCJ3IjoiY2Y5IiwiY2wiOiJjMTowfGMyOjF8YzM6MHxjNDoxfGM1OjF8YzY6MSIsInNsIjoiczE6MnxzMjozfHMzOjF8czQ6NXxzNToyfHM2OjF8czc6MCIsImJuIjoiYjE6MHxiMjozfGIzOjJ8YjQ6MnxiNTowIiwidSI6InUwMXx1MDJ8dTAzfHUwNHx1MDV8dTA2fHUwN3x1MDl8dTEwfHUxMXx1MTJ8dTEzfHUxNHx1MTV8dTE2fHUxN3x1MjZ8dTI3fHUyOHx1Mjl8dTMwfHUzMXx1MzJ8dTMzfHUzNHx1MzV8dTM2fHUzN3x1MzgiLCJzIjoic2VsbGVyX3JwczoxODd8Y2xpY2tlcl9ycHM6MTIyfGJhbmtfcnBzOjVnY3xjaGVhdGVkX3dpZGdldHM6MHxjaGVhdGVkX2Nhc2g6MHxoYW5kX21hZGVfd2lkZ2V0czpmNjU0fG1hZGVfd2lkZ2V0czoxZGJjai5mazNrM2JhM2cwaXxzb2xkX3dpZGdldHM6MWNtbGEuYjBuMG4wNjdlZzN8aGFuZF9zb2xkX3dpZGdldHM6NWNiYy5uMG4wbjEwODI5MjZ8c2Vjb25kc19wbGF5ZWQ6NWFofGJvdWdodF91cGdyYWRlczoxNXx0b3RhbF9jYXNoOjEyaGprbi5rOWU5ZWNoZGx8c3RhcnRfdGltZTpjZGoxZ2RoZGYifSwiYWMiOiJhMDF8YTAyfGEwM3xhMDR8YTA3fGEwOHxhMTR8YTE4fGEyMnxhMjMifQ
@errkk
errkk / RadioSwitch.ino
Last active December 27, 2015 04:19
RadioSwitch
// See http://www.fanjita.org/serendipity/archives/53-Interfacing-with-radio-controlled-mains-sockets-part-2.html
#define PAYLOAD_SIZE 48
#define DATA_PIN A4
#define VCC_PIN A5
#define GND_PIN A3
#define LED_PIN 13
#define CHANNEL 1
#define TURNON 1
@errkk
errkk / gist:7006532
Created October 16, 2013 11:52
Pusher Parrot
#include <SPI.h>
#include <Ethernet.h>
#include <PusherClient.h>
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
PusherClient client;
IPAddress ip(192,168,1,101);
const int parrot = 3;
@errkk
errkk / gist:6279024
Last active December 21, 2015 08:38
Composite a PNG over an input video frame by frame
avconv -i input.mp4 -f image2 frames/f_%00d.jpg
for F in $(ls frames/)
do
composite -compose atop -gravity SouthWest overlay_frame.png frames/$F out/$F
done
avconv -f image2 -i out/f_%00d.jpg out.mpeg -b 2400kb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@errkk
errkk / gist:5690962
Last active December 17, 2015 23:39
Downloads latest frames from the Pi, updates the frame list, makes them into a video, and plays it!
rsync -avz pi@192.168.1.117:/home/pi/mnt/ ~/Desktop/stills/ && find . -name '*.jpg' -size 0 -print0 | xargs -0 rm && ls *.jpg > stills.txt && mencoder -nosound -ovc lavc -lavcopts vcodec=mpeg4:aspect=16/9:vbitrate=8000000 -vf scale=1080:768 -o ~/Desktop/tl_london1.avi -mf type=jpeg:fps=48 mf://@stills.txt && mplayer ../tl_london1.avi
@errkk
errkk / gist:5237693
Last active December 15, 2015 09:19
How to find cat gifs when under comedy time pressure

Right click Chrome "Omnibar" and go to Edit Search Engines

Imgur

Add https://www.google.co.uk/search?tbm=isch&tbs=itp:animated&q=%s and call it a keyword like Gif Search and make sure its added to "Default Search Engines"

Quick need cat gif

Type gif then tab then your search terms