Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python3
import time
import json
import urllib.request
raw = urllib.request.urlopen("http://api.openweathermap.org/data/2.5/forecast?q=Pardubice").read()
js = json.loads(raw.decode("UTF-8"))
future = [x for x in js["list"] if x["dt"] > time.time()]
@atx
atx / mqttirc.py
Created August 16, 2014 12:19
mqttirc.py
#!/usr/bin/python3
import mosquitto
import select
import socket
import time
import os
IRC_HOST = "192.168.66.1"
IRC_PORT = 6667
NICK = "HomeBot"
import numpy
import scipy.io.wavfile
import sys
rate, inp = scipy.io.wavfile.read(sys.argv[1])
inp = [x[0] for x in inp]
print("Loaded...")
lowpass = numpy.convolve(inp, [1 / 20] * 20, mode="same")
@atx
atx / demod.py
Created September 20, 2014 12:55
import scipy.io.wavfile
import sys
for fname in sys.argv[1:]:
rate, data = scipy.io.wavfile.read(fname)
silence = 0
for x in data:
if x and silence:
print(silence)
silence = 0
#! /usr/bin/python3
import struct
import sys
def to_int(l, signed=False):
ret = 0
for x in l[1:] if signed else l:
ret = (ret << 1) | x
if signed and l[0]:
@atx
atx / build-orangepipc-gentoo.py
Last active November 17, 2023 19:41
Script for building a Gentoo image for the Allwinner H3, use at your own risk
#! /bin/bash
# This script builds a Gentoo image for the Allwinner H3
# Based on http://linux-sunxi.org/H3_Manual_build_howto
# Tested on Orange Pi PC
set -e
function green {
echo -e '\033[0;32m'$@'\033[0m'
@atx
atx / README.md
Last active January 27, 2018 19:24 — forked from anonymous/README.md
Script for KBT Pure Pro firmware flashing

kbtflash

Some time ago, I reversed the protocol used by KBT Pure Pro for flashing its firmware in a hope of being able to flash a custom firmware (or do some BadUSB demonstration). This script is able to upload a firmware binary onto the keyboard.

The binary is obfuscated (already solved on SE) However, the firmware has a 32-bit checksum (at the end of the image), which does not seem to be any of the commonly used ones (there is this) (EDIT: Actually turned out to be a standard one, see edit below). If the uploaded firmware checksum does not match, the keyboard stays in the bootloader.

@atx
atx / upload.py
Created December 5, 2017 21:58
Quick hacky way to get Gadgetbridge exported data to InfluxDB
#! /usr/bin/env python3
import argparse
import datetime
import influxdb
import sqlite3
if __name__ == "__main__":
parser = argparse.ArgumentParser()
@atx
atx / fixchiselvcd.py
Last active June 30, 2018 16:08
Script that filters VCD files produced by chisel in order to make it load in PulseView (EDIT: This does not seem necessary for the newest git version of sigrok)
#! /usr/bin/env python3
import argparse
import pathlib
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-i", "--input", type=pathlib.Path, required=True)
parser.add_argument("-o", "--output", type=pathlib.Path, required=True)
@atx
atx / spiceresize.sh
Created July 13, 2018 14:12
Hacky script to support automatic screen resize with virt-manager VMs with arbitrary window manager (see https://bugzilla.redhat.com/show_bug.cgi?id=1352226 for details )
#! /bin/bash
if ! pgrep -u $(whoami) spice-vdagent; then
echo "Starting vdagent"
spice-vdagent
fi
INTERVAL=1
while true; do