Skip to content

Instantly share code, notes, and snippets.

View darrenpmeyer's full-sized avatar

Darren P Meyer darrenpmeyer

View GitHub Profile
@darrenpmeyer
darrenpmeyer / pyenv_most_recent.sh
Created July 25, 2018 21:09
Install most recent stable Python with pyenv
#!/usr/bin/env bash
# Get most recent version number of CPython, excluding rc, dev, pypy, etc.
pyver=$(pyenv install --list | grep -v '[^0-9. ]' | sort -r | head -n1 | awk '{print $1}')
# install it
pyenv install $pyver
@darrenpmeyer
darrenpmeyer / fix wemos_d1_mini mac_os crash.md
Created October 17, 2018 18:41
FIX - Wemos D1 mini crashes macOS 10.13 High Sierra when plugged in via USB

tl;dr: the D1 mini's usbserial interface is a little sketchy and macOS doesn't cope well. You need to install the driver from wch.cn. direct link to CH341SER_MAC.ZIP

SHA-512 sum (copy whole line, run pbpaste | shasum -c in your download directory to check):

efb25faeb87d66a10e284629231fad7ebfbdbf2c2a50ed9b35f8dd9793398ff79df3da3312367dbc497dc62103195bc4eaf6399f8084f442bb1d1a7a51551eac *CH341SER_MAC.ZIP
@darrenpmeyer
darrenpmeyer / umake-pycharm-pro.sh
Last active December 16, 2018 15:44
Installing PyCharm Professional on Ubunutu
#!/usr/bin/env bash
## this script installs PyCharm Professional via umake on Ubuntu systems
## You can also use `snap install pycharm-professional` if you don't mind snap
# install umake if it doesn't yet exist
if ! which umake
then
# add the ubuntu-make (umake) repo and update local package caches
sudo add-apt-repository ppa:ubuntu-desktop/ubuntu-make
sudo apt-get update
@darrenpmeyer
darrenpmeyer / darkproxies.pac
Last active May 28, 2021 06:16
PAC file for I2P, Tor, etc. proxy configs
function FindProxyForURL(url, host) {
if (dnsDomainIs(host, ".i2p")) { return "HTTP localhost:4444"; }
if (dnsDomainIs(host, ".onion")) { return "SOCKS localhost:9050"; }
return "DIRECT";
}
@darrenpmeyer
darrenpmeyer / darren-sources-bionic.list
Last active April 12, 2019 13:14
Favorite APT repos for Ubuntu 18.04 LTS (bionic)
#KEY https://download.sublimetext.com/sublimehq-pub.gpg
deb https://download.sublimetext.com/ apt/stable/
@darrenpmeyer
darrenpmeyer / openvpn-ubuntu-install.sh
Created June 5, 2019 17:01
Install an OpenVPN Server on Ubuntu (tested with 18.04 Bionic Beaver)
#!/usr/bin/env bash
git clone https://github.com/Nyr/openvpn-install.git
cd openvpn-install/
chmod +x openvpn-install.sh
# interactive! But also logs stdout/stderr to a log file for later review
sudo ./openvpn-install.sh 2>&1 |tee openvpn-install.log
@darrenpmeyer
darrenpmeyer / svg2png.sh
Created July 2, 2019 21:31
One-liner: convert an SVG to a PNG
# requires: brew install librsvg
# inspired by: https://superuser.com/a/723031
# change 1.0 to a zoom factor you want for clean zoom. Exact pixels possible, read man page
rsvg-convert -z 1.0 file.svg > file.png
@darrenpmeyer
darrenpmeyer / is_unicode.py
Created July 26, 2019 15:27
Python2 and Python3 compatible "is this a unicode string" check
from __future__ import print_function
# the string to check is in 'candidate'
if isinstance(candidate, type(u"")):
print("This is a unicode string")
else:
# if it's a Py2 'str' or a Py3 'bytes' object, this will convert
# otherwise it'll raise an exception
candidate = candidate.decode('utf8')
-- in iTerm2, create a profile named 'Alfred' with the settings you want
-- this script will create a new bash login environment using that profile and run the Alfred commands
-- in Alfred's preferences, go to Terminal, select Custom, and paste this script in
on alfred_script(q)
set text item delimiters to " "
set cmdline to q as text
tell application "iTerm"
create window with profile "Alfred" command "bash -lc " & quoted form of cmdline
@darrenpmeyer
darrenpmeyer / setchime.sh
Last active March 5, 2020 15:20
Control macOS startup chime
#!/usr/bin/env bash
set -eu -o pipefail
## based on work by Mr. Macintosh: https://mrmacintosh.com/how-to-enable-the-mac-startup-chime-on-your-2016-macbook-pro/
## hattip DaringFireball: https://daringfireball.net/linked/2020/02/25/mac-startup-chime
##========================================================================
## To the extent possible under law, Darren Meyer has waived all copyright
## and related or neighboring rights to setchime.sh
##========================================================================