Skip to content

Instantly share code, notes, and snippets.

View Elwell's full-sized avatar

Andrew Elwell Elwell

View GitHub Profile
@Elwell
Elwell / get_sunrise.py
Created May 22, 2015 14:43
Sunrise / Sunset calculation
andrew@mythic:~$ cat bin/get_sunrise.py
#!/usr/bin/python
# calculate sunrise/sunset times for location
# Andrew Elwell <Andrew.Elwell@gmail.com> 2013-09-02
import ephem
import ConfigParser
import paho.mqtt.client as mqtt
@Elwell
Elwell / publish.ino
Last active August 29, 2015 14:21
testcase for pubsubclient retained
// Reed Switch to MQTT publisher for home
// Andrew Elwell, May 2015
#include <SPI.h>
#include <Ethernet.h>
#include <PubSubClient.h>
byte mac[] = { 0x00, 0x04, 0xA3, 0x2C, 0x1D, 0xF1 };
byte server[] = { 10, 1, 1, 251 };
@Elwell
Elwell / gist:35dea60bf32e02ed9fcf
Created May 16, 2015 07:43
Arduino Ethernet to MQTT publisher
// Reed Switch to MQTT publisher for home
// Andrew Elwell, May 2015
#include <SPI.h>
#include <Ethernet.h>
#include <PubSubClient.h>
byte mac[] = { 0x00, 0x04, 0xA3, 0x2C, 0x1D, 0xF1 };
byte server[] = { 10, 1, 1, 251 };

Keybase proof

I hereby claim:

  • I am Elwell on github.
  • I am elwell (https://keybase.io/elwell) on keybase.
  • I have a public key whose fingerprint is 86FE 807B 075D 6A0E 9D02 A0DE B252 F8D8 F822 3247

To claim this, I am signing this object:

@Elwell
Elwell / log
Created May 11, 2014 13:21
nanode uip
#include <UIPEthernet.h>
EthernetClient client;
signed long next;
int led = 6;
void setup() {
pinMode(led, OUTPUT);
digitalWrite(led, HIGH);
Serial.begin(115200);
--- issue.item.html-orig 2011-03-20 00:24:03.049357938 +0800
+++ issue.item.html 2014-04-15 01:41:32.974950437 +0800
@@ -74,7 +74,16 @@
<tr>
<th i18n:translate="">Assigned To</th>
- <td tal:content="structure context/assignedto/menu">assignedto menu</td>
+ <td>
+ <select name="assignedto">
+ <option value="-1">- no selection -</option>
@Elwell
Elwell / gist:6505599
Created September 10, 2013 06:14
mosquitto debugging
read_pv was failing when publishing (hangs after publish), so knocked up a dummy test client with static dictionary
andrew@guruplug:~$ ./debug_mqtt.py
{'AC_Hz': 2925, 'PV_A': 11, 'Out_W': 3428, 'PV_W': 3355, 'PV_V': 3014, 'kWh_Total': 1851, 'timestamp': 1378793395.40962, 'pid': 6573, 'kWh_today': 17, 'AC_V': 11}
loop start
^C
^C
^Z
[2]+ Stopped ./debug_mqtt.py
andrew@guruplug:~$ killall debug_mqtt.py
@Elwell
Elwell / read_values.py
Last active February 8, 2020 01:06
simple test script to poll serial modbus
#!/usr/bin/python
# script to poll growatt PV inverter and spit out values
# Andrew Elwell <Andrew.Elwell@gmail.com> 2013-09-01
from pymodbus.client.sync import ModbusSerialClient as ModbusClient
import time
import sys
start = int(sys.argv[1])
@Elwell
Elwell / gist:5663508
Created May 28, 2013 15:16
BDII query
ldapsearch -LLL -x -h localhost -p 2170 -b GLUE2GroupID=grid,o=glue '(&(objectClass=GLUE2ComputingShare)(GLUE2ComputingShareMaxCPUTime=999999999))' | perl -p00e 's/\r?\n //g' | grep dn: | cut -d"=" -f5 | cut -d"," -f1 | sort | uniq
@Elwell
Elwell / ow_parsename.c.patch
Created May 8, 2013 14:42
bugfix for owfs
diff -u -r1.220 ow_parsename.c
--- ../../..//owlib/src/c/ow_parsename.c 24 Jul 2012 01:47:31 -0000 1.220
+++ ../../..//owlib/src/c/ow_parsename.c 8 May 2013 14:39:46 -0000
@@ -343,11 +343,11 @@
return parse_nonreal;
} else if (strcasecmp(pathnow, "text") == 0) {
- pn->state |= ePS_json;
+ pn->state |= ePS_text;
return parse_first;