Skip to content

Instantly share code, notes, and snippets.

View bassdread's full-sized avatar

bassdread

  • UK
View GitHub Profile
import subprocess
import signal
import platform
class RaidMonitor:
def __init__(self, agentConfig, checksLogger, rawConfig):
self.agentConfig = agentConfig
self.checksLogger = checksLogger
self.rawConfig = rawConfig
# removes any Filesystem with Filesystem of none in df
from fabric.api import *
import fabric
env.hosts=["ec2-23-22-191-90.compute-1.amazonaws.com"]
env.user="ec2-user"
def hostname_check(): # hostname_check is just a task name, replace with anything
run("hostname")
def install_agent(key, url):
# Connect to an Arduino attached to a moisture sensor. The code below is
for the Arduino
"""
const int pin = A0; // Analog input pin
unsigned long duration;
void setup()
{
Serial.begin(9600); // initialize serial communications at 9600 bps
pinMode(pin, INPUT);
import webapp2
import cgi
from google.appengine.api import urlfetch
import json
import logging
class MainHandler(webapp2.RequestHandler):
red = 'http://www.blinkstick.com/d/<ID>/red.json'
green = 'http://www.blinkstick.com/d/<ID>/green.json'
http://bildr.org/2011/07/ds18b20-arduino/ - Temperature sensor
http://bildr.org/2012/11/photoresistor-arduino/ - Light sensor
http://www.ebay.co.uk/itm/Soil-Hygrometer-Detection-Buzzer-Alarm-Module-Moisture-Sensor-Cable-For-Arduino-/390643155171?pt=UK_BOI_Industrial_Automation_Control_ET&hash=item5af42580e3 - In analog mode just read straight from the analog input
www.maplin.co.uk/amazing-h2o-pump-228295 - Water pump
http://www.ebay.co.uk/itm/360626244581?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649 - Irrigation system
http://www.ebay.co.uk/itm/Nano-V3-0-ATmega328P-Arduino-Compatible-/171078373098?pt=LH_DefaultDomain_0&hash=item27d510ceea - Nano
pi@neptr ~ $ uname -a
Linux neptr 3.6.11+ #538 PREEMPT Fri Aug 30 20:42:08 BST 2013 armv6l GNU/Linux
pi@neptr ~ $ curl -O http://nodejs.org/dist/v0.11.7/node-v0.11.7-linux-arm-pi.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 4843k 100 4843k 0 0 816k 0 0:00:05 0:00:05 --:--:-- 939k
pi@neptr ~ $ tar zxf node-v0.11.7-linux-arm-pi.tar.gz
pi@neptr ~ $ node-v0.11.7-linux-arm-pi/bin/node -e 'console.log("hello")'
-su: node-v0.11.7-linux-arm-pi/bin/node: No such file or directory
pi@neptr ~ $ ldd node-v0.11.7-linux-arm-pi/bin/node
execve("node-v0.11.7-linux-arm-pi/bin/node", ["node-v0.11.7-linux-arm-pi/bin/no"...], [/* 17 vars */]) = -1 ENOENT (No such file or directory)
dup(2) = 3
fcntl64(3, F_GETFL) = 0x20002 (flags O_RDWR|O_LARGEFILE)
fstat64(3, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f07000
_llseek(3, 0, 0xbead3308, SEEK_CUR) = -1 ESPIPE (Illegal seek)
write(3, "strace: exec: No such file or di"..., 40strace: exec: No such file or directory
) = 40
close(3) = 0
munmap(0xb6f07000, 4096) = 0
@bassdread
bassdread / gist:7589445
Created November 21, 2013 20:54
npm install i2c
$ npm install i2c
npm http GET https://registry.npmjs.org/i2c
npm http 304 https://registry.npmjs.org/i2c
npm http GET https://registry.npmjs.org/bindings
npm http GET https://registry.npmjs.org/underscore/1.2.4
npm http GET https://registry.npmjs.org/coffee-script/1.3.3
npm http GET https://registry.npmjs.org/repl/0.1.3
npm http 304 https://registry.npmjs.org/coffee-script/1.3.3
npm http 304 https://registry.npmjs.org/bindings
npm http 304 https://registry.npmjs.org/underscore/1.2.4
var BMP085 = require('bmp085'),
barometer = new BMP085(
{
'mode' : 0,
'address': 0x77,
'device': '/dev/i2c-0'
}
);
barometer.read(function (data) {
console.log("Temperature:", data.temperature);
@bassdread
bassdread / gist:8032083
Last active December 31, 2015 19:09
Code for make blink sticks talk to cheer lights. More info at http://www.cheerlights.com/subscribe-to-cheerlights-feed and blinkstick.com
#!/usr/bin/python
"""
Download this script and run it as
```
python thenameofthefile.py
```
or