Skip to content

Instantly share code, notes, and snippets.

@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
@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:5a19dcb0f4ab71757a99
Created December 16, 2014 11:08
Vagrant looses suspended VM

Run VBoxManage list vms you can see your VMs and the ID

Paste that into .vagrant/machines/default/virtualbox/id

@errkk
errkk / gist:5b7a2ad83f4701407292
Created December 16, 2014 11:22
Salt Bootstrap Fail 2014.7

When Vagrant Upping, and you get this error:

ImportError: No module named requests


Stderr from the command:

stdin: is not a tty

SSH onto the box

@errkk
errkk / fadecandy.json
Created December 16, 2014 22:18
fadecandy.json
{
"listen": ["0.0.0.0", 7890],
"verbose": true,
"color": {
"gamma": 2.5,
"whitepoint": [0.4, 0.4, 0.4]
},
"devices": [
@errkk
errkk / gist:981b51761e7ac8f1541e
Created April 20, 2015 16:07
Print just the temperature from a DS18B20
# Print the number in degrees
awk -F'=' '/ t=/ { print $NF/1000 }' /sys/bus/w1/devices/$DEVICE_ID/w1_slave
# For Curling
curl $URL --data "value=$(awk -F'=' '/ t=/ { print $NF/1000 }' /sys/bus/w1/devices/$DEVICE_ID/w1_slave)" --compressed;
@errkk
errkk / gist:3763626
Created September 21, 2012 20:10
Term - taxonomy relationship SQL join for WP
SELECT * FROM wp_posts p
LEFT JOIN wp_term_relationships tr ON tr.object_id = p.ID
LEFT JOIN wp_term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id
LEFT JOIN wp_terms t ON t.term_id = tt.term_id
#include <Manchester.h>
#define RX_PIN 0
#define RELAY_PIN 1
uint8_t data;
uint8_t id;
void setup() {
@errkk
errkk / gist:4706383
Created February 4, 2013 12:08
Move a WordPress blog from one host to another, so the permalinks work
SET @uri_from = 'www.devurl.local';
SET @uri_to = 'www.liveurl.net';
UPDATE wp_options SET `option_value` = REPLACE(`option_value`, @uri_from, @uri_to)
WHERE `option_value` LIKE CONCAT( "%", @uri_from, "%" );
UPDATE wp_posts SET `guid` = REPLACE(`guid`, @uri_from, @uri_to);
UPDATE wp_posts SET `post_content` = REPLACE(`post_content`, @uri_from, @uri_to);
@errkk
errkk / gist:4986422
Created February 19, 2013 14:33
Prep repo for pushing from Fabric
git init && git config receive.denyCurrentBranch ignore