Skip to content

Instantly share code, notes, and snippets.

View sirleech's full-sized avatar

Christopher Lee sirleech

  • Canberra, Australia
View GitHub Profile
@sirleech
sirleech / gist:3213543
Created July 31, 2012 04:13
Install W3c Validator on Ubuntu 11
sudo apt-get install w3c-markup-validator
nano /etc/w3c/validator.conf
# Whether private RFC1918 addresses are allowed.
Allow Private IPs = yes
<VirtualHost *:81>
ServerAdmin [email protected]
DocumentRoot /usr/share/w3c-markup-validator/html/
@sirleech
sirleech / gist:2821987
Created May 29, 2012 01:09
Trigger jQuery UI Autocomplete with Javascript. Good for Selenium
function fireEvent(element,event){
if (document.createEventObject){
// dispatch for IE
var evt = document.createEventObject();
return element.fireEvent('on'+event,evt)
}
else{
// dispatch for firefox + others
var evt = document.createEvent("HTMLEvents");
evt.initEvent(event, true, true ); // event type,bubbling,cancelable
@sirleech
sirleech / gist:2660189
Created May 11, 2012 14:42
Python Read JSON from HTTP Request of URL
# Load Json into a Python object
import urllib2
import json
req = urllib2.Request("http://localhost:81/sensors/temperature.json")
opener = urllib2.build_opener()
f = opener.open(req)
json = json.loads(f.read())
print json
print json['unit']
@sirleech
sirleech / gist:2592215
Created May 4, 2012 05:19
RRDdata Temperature Database Example

Use this command to get the UNIX time

date +%s

Create a gauge RRD with a 60 second heartbeat

rrdtool create temperature.rrd --step 60 \
  DS:temp:GAUGE:600:-273:5000 \
 RRA:AVERAGE:0.5:1:1200 \
@sirleech
sirleech / gist:2583622
Created May 3, 2012 05:55
Get the UNIX Time Stamp
date +%s
@sirleech
sirleech / gist:2583166
Created May 3, 2012 04:26
RRDTool with Python on Ubuntu 11.10
@sirleech
sirleech / gist:2289568
Created April 3, 2012 05:42
Imagemagick make thumbnails
convert -resize 133x100 -extent 133x100 -gravity center annualClimateSummary2011.jpg
convert -resize 300x225 -extent 300x225 -gravity center annualClimateSummary2011.jpg
@sirleech
sirleech / gist:2128590
Created March 19, 2012 23:50
Git Graph
git config --global alias.graph 'log --graph --all --oneline --decorate --color --date-order'
git graph
@sirleech
sirleech / gist:2091521
Created March 19, 2012 02:39
Numato Relay Linux Quick Start
Open a terminal window after plugging the Numato device into your usb port.
> screen /dev/ttyACM0
> relay on 0
> relay off 0