Skip to content

Instantly share code, notes, and snippets.

@tpott
tpott / low-battery-level-detection-notification-for-all-battery-sensors-with-time-pattern.yaml Home Assistant Blueprint: Low battery level detection & notification for all battery sensors with Time Pattern
blueprint:
name: Low battery level detection & notification for all battery sensors with Time Pattern Detection
description: Regularly test all sensors with 'battery' device-class for crossing
a certain battery level threshold and if so execute an action. Modified version to allow for Time-Pattern based detection.
domain: automation
input:
threshold:
name: Battery warning level threshold
description: Battery sensors below threshold are assumed to be low-battery (as
well as binary battery sensors with value 'on').
$ python rosetta.py 5000000 | shuf -n2
1099489
4113097
$ calc '1099489*4113097'
4522304907433
$ pypy easy_primes.py -f 4522304907433 -t 1100000 -v
Largest prime 1100009
Searching for factors of 4522304907433 up to 2126572 (except not really)
import math
import numpy as np
import matplotlib.pyplot as plt
data = np.loadtxt('some_wav_to_tsv.tsv')
func = np.vectorize(lambda x: math.log(max(0.001, abs(x))))
# skip column 1, row number, and column 2, max_i
plt.pcolormesh(func(data[:,2:].T))
plt.show()
@tpott
tpott / url safe base64.py
Created January 1, 2016 16:29
whats the diff
import os
import base64
def helper():
while True:
s = os.urandom(16)
a = base64.b64encode(s)
b = base64.urlsafe_b64encode(s)
if a != b:
print (a, b)

Keybase proof

I hereby claim:

  • I am tpott on github.
  • I am tpott (https://keybase.io/tpott) on keybase.
  • I have a public key whose fingerprint is 9DE6 0FDA 3441 3358 87E4 C083 842F 1E54 61E3 4AF9

To claim this, I am signing this object:

@tpott
tpott / pubcert
Created November 9, 2014 22:15
github ssl cert
Certificate:
Data:
Version: 3 (0x2)
Serial Number:
0c:00:93:10:d2:06:db:e3:37:55:35:80:11:8d:dc:87
Signature Algorithm: sha256WithRSAEncryption
Issuer: C=US, O=DigiCert Inc, OU=www.digicert.com, CN=DigiCert SHA2 Extended Validation Server CA
Validity
Not Before: Apr 8 00:00:00 2014 GMT
Not After : Apr 12 12:00:00 2016 GMT
@tpott
tpott / self_parsing.go
Created May 26, 2014 16:48
simple go parser
// self_parsing.go
// Mon May 26 09:47:10 PDT 2014
package main
import (
"os"
"fmt"
"reflect"
"go/ast"
@tpott
tpott / nhands.py
Last active August 29, 2015 13:57
# nhands.py
# Trevor Pottinger
# Fri Mar 14 22:23:19 PDT 2014
import time
from random import random
def my_cmp(x,y):
if x[1] > y[1]:
return -1
@tpott
tpott / vidcopy.py
Created March 13, 2014 17:52
video processing, take one
# vidcopy.py
# Trevor Pottinger
# Thu Mar 6 17:18:22 PST 2014
import numpy as np
# lets try reading in a file and then writing it out
from moviepy.video.io.ffmpeg_reader import FFMPEG_VideoReader as reader
from moviepy.video.io.ffmpeg_writer import FFMPEG_VideoWriter as writer
# nhands.py
# Trevor Pottinger
# Fri Mar 14 22:23:19 PDT 2014
from random import random
def counts2deck(ccounts):
"""Converts the card counts to a list of sorted cards"""
deck = []
for letter in ccounts: