Skip to content

Instantly share code, notes, and snippets.

Avatar

Eric Sandeen sandeen

View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am sandeen on github.
  • I am sandeen (https://keybase.io/sandeen) on keybase.
  • I have a public key ASDPNrc7zb-rDVzrofuoAdxYcssOCFH5LI85AIcGZL-jyAo

To claim this, I am signing this object:

View gist:b42802f38385fa43fbc995f4fc6aa6be
+--------------+---------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
View gist:7957d37892e602d3b5766fb9a1a32b67
+--------------+---------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@sandeen
sandeen / gist:7f7451edb99d6c7a55fe575e9f87d634
Created Jan 25, 2018
MISO data export from influxdb in json
View gist:7f7451edb99d6c7a55fe575e9f87d634
JSON:
{"results":[{"series":[{"name":"miso","columns":["time","Coal","NaturalGas","Nuclear","Other","Total","Wind"],"values":[[1516908600,43641,12475,12292,871,72382,3103],[1516908900,43462,12146,12293,869,71966,3196],[1516909200,43316,12128,12300,871,71896,3281],[1516909800,43022,11858,12281,870,71508,3478],[1516910400,42879,11976,12284,860,71707,3709],[1516910700,42982,12253,12289,863,72167,3780],[1516911000,43066,11975,12295,866,72092,3890],[1516911300,43009,11823,12282,875,71950,3961],[1516911600,42905,11739,12286,873,71895,4092]]}]}]}
Pretty:
{
"results": [
{
"series": [
@sandeen
sandeen / gist:4df597da69c4a292b8ea89ec85bf6258
Created Jan 20, 2018
Influxdb example of combining multiple measurements with separate keys into single measurement with multiple keys using CQ
View gist:4df597da69c4a292b8ea89ec85bf6258
I was trying to solve the problem where I'd like to separate DHW firings
from space heating firings, to more accurately calculate heat loss, efficiency,
etc.
Right now, the way collectd sends measurements to influxdb, it's separate
measurements:
> select * from modbus_value where time > now() - 2m
name: modbus_value
time host instance type type_instance value
@sandeen
sandeen / gist:823ceb55083dacd2d9bc
Created Jan 6, 2015
fix for non-8-bit-multiples
View gist:823ceb55083dacd2d9bc
// Packet is 1 bit per byte, pack to 8-bits per byte.
for pIdx := 0; pIdx < len(d.pkt)*8; pIdx++ {
d.pkt[pIdx>>3] <<= 1
if pIdx < d.Cfg.PacketSymbols {
d.pkt[pIdx>>3] |= d.Quantized[qIdx+(pIdx*d.Cfg.SymbolLength2)]
} else { // zero out last bits past PacketSymbols
d.pkt[pIdx>>3] |= 0
}
}
View gist:7bab652509d58192bfe6
@@ -265,6 +259,15 @@ func (d Decoder) Decode(input []byte) (pkts [][]byte) {
d.pkt[pIdx>>3] |= d.Quantized[qIdx+(pIdx*d.Cfg.SymbolLength2)]
}
+ // Left over bits?
+ r := (8 - (d.Cfg.PacketSymbols % 8))
+ if r > 0 {
+ for pIdx := 0; pIdx < r; pIdx++ {
+ d.pkt[(d.Cfg.PacketSymbols-1)>>3] <<= 1
+ d.pkt[(d.Cfg.PacketSymbols-1)>>3] |= 0