Skip to content

Instantly share code, notes, and snippets.

dukechem /
Created Mar 14, 2021
Inadvertent middle-button on touchpad closes browser tabs, pastes in terminal. Add lines below to .bashrc to Disable mouse middle button emulation by touchpad
# Disable mouse middle button emulation by touchpad
# Add these lines to your .bashrc on linux. Tested with debian
# You may need to change $5 to $6 as explained here:
# Ref:
# xinput --set-prop (your id number) (your libinput Middle Emulation Enabled number) 1
# That is, setting "Emulation Enabled" to "1" actually disables emulation (confusingly).
# If `xinput not found` then `sudo apt install xinput` or alternatively
# `brew install xinput`
# XINP="/home/linuxbrew/.linuxbrew/bin/xinput"
dukechem /
Created Jan 16, 2021
Low battery warning by audio and notification for macos laptops
#! /usr/bin/env sh
# When battery has less than 25%, pops up notifier counting down integer % of battery left 24, 23, 22, 21 ...
# When battery is less than 15% also announces "Low Battery" verbal warning.
# INSTALL: Put this file in /Users/Shared/ folder on your mac laptop, then chmod a+x *.sh
# And put (below) in ~/Library/LaunchAgents/ (or /Library/LaunchAgents/ for every user).
# This file is run by whenever charger is disconnected
# When charger is unplugged, the date of this file changes: Library/Preferences/
## See also
dukechem / gist:f25dc3934f23a0097b5cff2d9225ada7
Created Sep 23, 2020
Easy way to get csv list of files with each md5-sum using free TREESIZE.EXE from
View gist:f25dc3934f23a0097b5cff2d9225ada7
cd <path to parent folder of the files>
echo "Do not open c:\temp\filelist-with-md5.csv until you see current time displayed"
filelist /md5 > c:\temp\filelist-with-md5.csv
time /t
dukechem /
Last active Jun 19, 2020
Download full macos installers with curl --limit-rate and can resume partial downloads
# encoding: utf-8
# Copyright 2017 Greg Neagle.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
dukechem /
Created Feb 10, 2020
Fix for no/broken login screen when vnc to remote mojave macos... connects to existing console session I think? See URL for more...
sudo defaults write /Library/Preferences/ VNCAlwaysStartOnConsole -bool true
dukechem / batch-conv-portfolio-pdf
Created Feb 4, 2020
View batch-conv-portfolio-pdf
Unlike ordinary pdf files, portfolio.pdf files cannot be viewed on tablets or phones, and most software that can open them is available only on windows or mac, not on linux (until recently). They really should have a different extension like .pdfp or similar. Google finds lots of folks looking to batch convert portfolios to individual files, as the portfolio breaks *lots* of automated workflows, especially if you upload them to systems that can't handle them. If you try to open them in other viewers, like a link in a browser, you'll see a misleading messages ending in "get adobe reader now!", like:
You get that brain-dead message even if you already have adobe-reader. The work-around is to download the pdf then open in some awful adobe-reader or acrobat software (version 10 or newer is needed, I believe).
If you have a bunch of such pdfs, this is a place folder for upcoming script to batch convert portfolio pdf files.
dukechem / rdate-windows-howto.txt
Last active Aug 5, 2020
howto have older windows (not on internet) just get the right date from newer windows on internet. In this example winXP/7/8 uses psrdatesvc to get datetime on private non-internet network without NTP from a windows or linux pc serving RFC868 time (default port 37).
View rdate-windows-howto.txt
In example scenario below, the "XP" box can also be vista/win7-8-8.1 (maybe even 10), 32 or 64 bit.
How to keep XP on minimally on network, but not internet, using network only to update time and push files via scp/sftp.
Both old XP and Server are kept safe by closing all ports on XP, and allow that XP computer to connect only to port 37 on a (rfc868 aka "rdate") time-server. The device providing TIME service on port37 should get its own time from internet/intranet (by ntp, etc).
(The time-server does not have run a server-os: it can be almost any linux device, or even a windows-pc.)
With all ports closed on XP, the time-server cannot infect XP. If XP is infected, such as by a usb-key, it cannot spread over
network to time-server (unless time-server has vulnerability known to virus. Turn off smb1 on time-server (if windows)!
On XP/7/8/8.1, rdatesvc.exe (= prdatesvc = PermaSoft Rdate service) safely keeps system time and date correct by periodically from
port 37 on a specified time SerVeR, such time.nist.go
dukechem / python.rb
Last active Feb 11, 2020 — forked from SamuelMarks/python.rb
python3.6.9 brew formula. Proof of concept that generally fails: brew switch python3 does not really work right: i.e. pip3 fails. Use pyenv/miniconda instead.
View python.rb
class Python < Formula
desc "Interpreted, interactive, object-oriented programming language"
homepage ""
url ""
sha256 "5e2f5f554e3f8f7f0296f7e73d8600c4e9acbaee6b2555b83206edf5153870da"
revision 1
bottle do
sha256 "1bc5a2d3f0a8602bf2f46de7c43fcb6dde4f110c0f4518d4e802cb1f733a43de" => :high_sierra
sha256 "131d39120ac6ca2f21bf231de7414c08916cea472bc5219e0bcb49541f77cb9f" => :sierra
dukechem /
Last active Feb 10, 2020 displays how many rows & cols, and shows first 2 rows of csv file(s). Bash/sh script using head, tail, wc, and awk.
if [ $# -eq 0 ]
bnam=$(basename "$0")
echo "Usage: $bnam *.csv (displays how many rows & cols, and shows first 2 rows of csv file(s))"; exit
# Total Rows Words Size = 76 76 5587 foobar.csv
# Line 2 has 20 Cols = 391.43,6,0,4.54,4,71.33,3.22,4,2,4,4,2,2,2,0.27,1,576.35,0.13,-1,538.32