Skip to content

Instantly share code, notes, and snippets.

View rasathus's full-sized avatar

Chris Fane rasathus

View GitHub Profile
@rasathus
rasathus / avg.py
Created September 24, 2012 21:28
Sonar averaging wrapper
#/bin/python
import subprocess
sonar = subprocess.Popen(['./sonar'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = sonar.communicate()
split_output = out.split('\n')
results_list = []
for line in split_output:
# -*- coding: utf-8 -*-
from __future__ import with_statement
import os
import time
import logging
import shutil
import tempfile
import Queue
@rasathus
rasathus / LightInABox-controlmypi
Created March 27, 2013 11:14
The control my pi elements of LightsInABox
from controlmypi import ControlMyPi
jabber_id = 'Jabber ID'
password = 'password'
panel_id = 'circMan'
panel_name = 'Lights In A Box'
panel_status = 'pub'
def controlmypi_callback(connection, key, value):
logging.info("Got message from controlmypi.com key : %s Value : %s" % (key, value))
if controlmypi_connection.start_control():
capture_service.say_cheese()
try:
while True:
logging.info("Queue length is : %d" % snap_queue.qsize())
rgb = snap_queue.get(block=True)
led_setter.set(rgb)
capture_service.say_cheese()
capture_service.spring_cleaning()
except KeyboardInterrupt:
class Capture_Upload:
def __init__(self, controlmypi):
self.image_id = 0
self.controlmypi = controlmypi
self.storage_bucket = 'image-store'
self.uri = boto.storage_uri(self.storage_bucket, 'gs')
self.temp_dir = tempfile.mkdtemp(prefix='googlestorage')
temp_uuid = str(uuid4())
self.entr = temp_uuid[0:8]
@rasathus
rasathus / gist:5467290
Last active December 16, 2015 16:59
Sleekxmpp : Failed to import _strptime because the import lockis held by another thread
INFO:sleekxmpp.xmlstream.xmlstream:Negotiating TLS
INFO:sleekxmpp.xmlstream.xmlstream:Using SSL version: 3
ERROR:sleekxmpp.xmlstream.xmlstream:Connection error.
ERROR:sleekxmpp.basexmpp:Failed to import _strptime because the import lockis held by another thread.
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/sleekxmpp/xmlstream/xmlstream.py", line 1441, in _process
if not self.__read_xml():
File "/usr/local/lib/python2.7/dist-packages/sleekxmpp/xmlstream/xmlstream.py", line 1509, in __read_xml
self.__spawn_event(xml)
File "/usr/local/lib/python2.7/dist-packages/sleekxmpp/xmlstream/xmlstream.py", line 1577, in __spawn_event
@rasathus
rasathus / gist:b46207391c0ee41a08e1
Created October 29, 2014 18:42
elasticsearch append to array
"script": "ctx._source.Tracking += Tracking",
"params": {
"Tracking": [ { "Timestamp": datetime.datetime.now(), "Entry": tracking['Entry'], "SystemId": system_id} ]
}
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
green='\033[0;32m'
@rasathus
rasathus / gist:6b63f12bdf4f8d90b1e5
Last active April 26, 2017 18:10
saltstack/salt #18302 Test Output
Using salt package 2014.7.0+ds-2trusty1
vagrant@vagrant-ubuntu-trusty-64:~$ sudo salt-call --local grains.items
local:
----------
SSDs:
biosreleasedate:
12/01/2006
biosversion:
VirtualBox
@rasathus
rasathus / gist:e8bbf6c48c7f89f2b4d2
Last active August 29, 2015 14:26
Vagrant Salt Provision failure since moving to 1.7.4
Non working Vagrant 1.7.4 Version
==> default: Running provisioner: salt...
INFO environment: Running hook: provisioner_run
INFO runner: Preparing hooks for middleware sequence...
INFO runner: 3 hooks defined.
INFO runner: Running action: provisioner_run #<Method: Vagrant::Action::Builtin::Provision#run_provisioner>
INFO warden: Calling IN action: #<Proc:0x000001027d4c60@/opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:94 (lambda)>
INFO interface: info: Copying salt minion config to vm.
Copying salt minion config to vm.