Skip to content

Instantly share code, notes, and snippets.

@TylerOderkirk
TylerOderkirk / fake_ap.py
Created May 4, 2018 03:41
dreamproxy hg r2
# from https://forum.micropython.org/viewtopic.php?p=19988&sid=7aaeff853648d6cd65371661708c1fba#p19988
import network
import time
import uos
from machine import Pin
led = Pin(2, Pin.OUT)
led.off() # actually turns it on
sta_if = network.WLAN(network.STA_IF)
sta_if.active(True)
@TylerOderkirk
TylerOderkirk / tontec_console_click_hack.sh
Created July 21, 2015 02:46
Switching tmux windows on ADS7846 touch events
#!/bin/bash
while :; do # until forever...
if ! evtest --query /dev/input/event2 EV_KEY BTN_TOUCH; then # if somebody is pressing their finger on the touchscreen...
echo BTN_TOUCH!
tmux next-window -t 0 # tell un-named tmux session #0 to switch to its next window
sleep .1s # avoid doing this twice for a single touch
fi
sleep .05s
done
@TylerOderkirk
TylerOderkirk / bluelog_stdout_parser.py
Last active August 17, 2016 10:52
bluelog_stdout_parser.py
#!/usr/bin/env python
import subprocess, time, os, sys
#TODO: kill any already-running bluelog instances
cmd = ['./bluelog', '-m', '-t', '-f', '-a0', '-n', '-v']
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
mru_macs = []
@TylerOderkirk
TylerOderkirk / bluelog_1.1.2_stdout_flush.patch
Created July 1, 2015 01:49
bluelog.c STDOUT "-v" flush
diff -r d8638b19d99d bluelog.c
--- a/bluelog.c Tue Jun 30 21:44:06 2015 -0400
+++ b/bluelog.c Tue Jun 30 21:48:00 2015 -0400
@@ -911,7 +911,7 @@
{
if (friendlyclass)
{
- printf("[%s] %s,%s,%s,(%s)\n",\
+ printf("%s,%s,%s,%s,(%s)\n",\
dev_cache[ri].time, dev_cache[ri].addr,\
@TylerOderkirk
TylerOderkirk / panstamp_modem_softserial.ino
Created June 16, 2015 00:59
The Panstamp 'modem' sketch ported to use SoftwareSerial on an Uno
/*
* modem.pde
*
* Copyright (c) 2014 panStamp <contact@panstamp.com>
*
* This file is part of the panStamp project.
*
* panStamp is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@TylerOderkirk
TylerOderkirk / make_slip_connections
Created June 14, 2015 17:22
[dirt simple comms] make a SLIP connection over a socat-provided pty which is conected to https://gist.github.com/TylerOderkirk/c8510292cc86648074b5
#!/bin/bash
socat -ddd -ddd PTY,raw,echo=0 "EXEC:'python /home/tz/proj/dsc/stdinout_tofrom_named_pipe.py that',pty,raw,echo=0" &
SOCAT_PID1=${!}
echo
read -p 'Enter PTY number (eg "12"): ' PTY1
sudo slattach -dv -p slip /dev/pts/${PTY1} &
SLATTACH_PID1=${!}
echo
read -p 'Enter interface name (eg "sl0"): ' IFACE1
# create a pty and attach it to python app's stdin/out
socat -ddd -ddd PTY,raw,echo=0 "EXEC:'python /home/tz/proj/dsc/stdinout_tofrom_named_pipe.py that',pty,raw,echo=0"
# create a second pty and attach it to python app's stdin/out
socat -ddd -ddd PTY,raw,echo=0 "EXEC:'python /home/tz/proj/dsc/stdinout_tofrom_named_pipe.py other',pty,raw,echo=0"
# write some binary data into the first pty (where '7' is what's printed by socat)
cat /bin/true > /dev/pts/7
# read some binary data from the second pty (where '11' is what's printed by socat)
@TylerOderkirk
TylerOderkirk / stdinout_tofrom_named_pipe.py
Last active August 29, 2015 14:23
[dirt simple comms] read bytes from stdin and write them to a named pipe. read bytes from another named pipe and write them to stdout.
#!/usr/bin/env python
import thread, sys, time
if sys.argv[1] == "other":
fifo_w = open('/tmp/south', 'wb')
fifo_r = open('/tmp/north', 'rb')
log = open('/tmp/serial_log_southbound', 'wb')
else:
fifo_r = open('/tmp/south', 'rb')
fifo_w = open('/tmp/north', 'wb')
@TylerOderkirk
TylerOderkirk / time_warner_channel_listings.py
Created November 1, 2014 15:23
A script to scrape the data from Time Warner Cable's channel listings
#!/usr/bin/python
import json, sys
# convert time warner cable's json channel listing to csv
# http://www.timewarnercable.com/northeast/support/clu/clu.ashx?CLUID=476&Zip=14534&Embedded=true
# 1. use chrome's "network" tab in "developer tools" to obtain a curl command line to retrieve the listing (http://www.timewarnercable.com/CustomerService/Clu/CluJson.ashx?[..])
# 2. retrieve the listing w/ curl
# 3. nuke the non-ascii bytes perl -i.bak -pe 's/[^[:ascii:]]//g' time_warner_channel_listings.json
@TylerOderkirk
TylerOderkirk / dump_AT45DB041B.py
Last active December 6, 2022 17:42
A script to dump an Atmel AT45DB041B 4Mbit SPI Flash part's contents to disk using a Bus Pirate.
#!/usr/bin/env python
# dump the contents of an atmel AT45DB041B flash part to 'data.bin'
# usage: ./dump_AT45DB041B.py /dev/ttyUSB0
# tested w/ https://github.com/audiohacked/pyBusPirate ac19e00b53, Bus Pirate Hardware labelled v3.6, Firmware: "Bus Pirate v3b, Firmware v5.10 (r559), Bootloader v4.4"
# bugs: slow. as in... dozens of hours :/