Skip to content

Instantly share code, notes, and snippets.

View jimwhitfield's full-sized avatar

Jim Whitfield jimwhitfield

  • Silicon Valley, California
View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
i_sig = jsondecode('{"I_BALL":[1964,2012,2018,1962,1853,1766,1766,1754,1777,1792,1726,1572,1485,1491,1606,1672,1707,1717,1680,1677,1728,1848,1961,2037,2065,1967,1920,1903,1955,2009,2044,2001,1881,1781,1666,1663,1718,1767,1753,1765,1698,1628,1605,1738,1856,1858,1759,1638,1669,1844,2076,2236,2192,2049,1948,1902,1878,1876,1981,2092,2075,1970,1844,1718,1654,1572,1535,1690,1838,1792,1659,1600,1610,1713,1749,1756,1783,1962,2130,2097,1851,1754,1895,2001,1977,1920,1920,2009,2034,1826,1592,1598,1746,1786,1654,1590,1734,1865,1796,1621,1549,1693,1905,1909,1770,1827,2049,2028,1833,1640,1763,2005,2065,1873,1750,1928,2026,1830,1528,1504,1776,1934,1768,1561,1644,1865,1865,1536,1384,1678,1989,1916,1601,1518,1773,1986,1755,1443,1536,1955,2081,1758,1488,1670,1950,1920,1570,1465,1841,2180,1997,1522,1438,1753,1832,1555,1302,1573,2052,2122,1682,1398,1651,1981,1841,1490,1563,2098,2412,2045,1538,1570,1963,2000,1610,1374,1812,2298,2118,1529,1316,1679,1995,1719,1351,1557,2177,2384,1886,1489,1722,2202,2126,1628,1514,2030,2456,2188,154
% sudo udevadm monitor
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent
KERNEL[101.778427] add /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5 (usb)
KERNEL[101.778735] add /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5:1.0 (usb)
KERNEL[101.778948] add /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5:1.1 (usb)
KERNEL[101.779325] bind /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5 (usb)
UDEV [101.831018] add /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5 (usb)
@jimwhitfield
jimwhitfield / gist:7a93571da2e41088aeba757b8572f100
Created February 2, 2021 21:16
cron entry to back up (by tar) list a list of files every 10 minutes
5,15,25,35,45,55 * * * * tar -C / -cvf $HOME/backup/files-`/bin/date +\%Y-\%m-\%d-\%H\%M`.tar --files-from=$HOME/backup/files.list
@jimwhitfield
jimwhitfield / Node-Red RasPi linux dashboard
Last active January 10, 2020 02:30
Node-Red export of working dashboard for OPS24x on RasPi
[
{
"id": "38ae5584.60dc7a",
"type": "tab",
"label": "OPS24--A",
"disabled": false,
"info": ""
},
{
"id": "f22dee6b.be4d4",
@jimwhitfield
jimwhitfield / NodeRed-raspi-OP24--A
Created January 8, 2020 21:38
NodeRed flow to use ttyACM0 and play a sound on data swing
[
{
"id": "6bf977c3.4c5c68",
"type": "tab",
"label": "OPS24--A",
"disabled": false,
"info": ""
},
{
"id": "6b995d18.2cd584",
@jimwhitfield
jimwhitfield / RadarSensorLCD
Created March 7, 2019 19:32
Arduino code (beware..uses 'Serial1') for running the OmniPreSense RadarSensor on an LCD responding to a 9481 LCD driver
#include <MCUFRIEND_kbv.h>
#include <Adafruit_GFX.h> // Core graphics library
// wiring with UNO or Mega2560:
//--------------POWER Pins--------------------------------
// 5V connects to DC 5V
// GND connects to Ground
// 3V3 do not need to connect(NC)
//--------------LCD Display Pins--------------------------
// LCD_RD connects to Analog pin A0
@jimwhitfield
jimwhitfield / verydumbterm.py
Last active August 24, 2018 21:18
python USB (/dev/ttyACM0) serial terminal that works over ssh. reads from stdin, mingles the echo with whatever arrives from serial
#!/usr/bin/env python3
import serial
from serial.serialutil import SerialException
import sys
import select
import tty
import termios
def key_available():
@jimwhitfield
jimwhitfield / print_json_posts.py
Last active August 9, 2018 18:02
Web server to accept JSON-formatted HTTP POSTs and pretty-print the payload
#!/usr/bin/python2
# Derived from https://gist.github.com/bradmontgomery/2219997#file-dummy-web-server-py-L26
# Added the feature to read the post body and print it to console.
# Not useful if the post body isn't json
# Usage::
# ./print_json_posts.py [<port>]
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
import SocketServer
import json
#!/usr/bin/python
"""
Copyright (c) 2017, Ubiquity Robotics
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,