Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View darrenpmeyer's full-sized avatar

Darren P Meyer darrenpmeyer

View GitHub Profile
@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
-- 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 / unix_dates.scpt
Created August 31, 2015 21:04
Convert AppleScript date objects to UNIX timestamp or POSIX date format
-- convert an AppleScript Date object to a POSIX date CCYYMMDDHHmm.SS
on posixDate(datetime)
-- date -j -f "%A, %B %e, %Y at %I:%M:%S %p" "Tuesday, September 1, 2015 at 11:00:00 AM" +%Y%m%d%H%M
set command to "date -j -f '%A, %B %e, %Y at %I:%M:%S %p' '" & datetime & "'"
set command to command & " +%Y%m%d%H%M.%S"
set thePosixDate to do shell script command
return thePosixDate
end posixDate
@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
##========================================================================
@darrenpmeyer
darrenpmeyer / autobuild-openconnect-7-ubuntu.sh
Last active June 10, 2020 16:22
Autobuild script for OpenConnect 7 (Ubuntu 14/15/16 trusty/vivid/xenial)
#!/usr/bin/env bash
## NOTE! OpenConnect is now on Version 8, and this is only for historical use
## See https://gist.github.com/darrenpmeyer/1a56d0d4817352998fe9d7cfe5a79684 for new script
oc_ver="7.08"
echo "Autobuild OpenConnect $oc_ver"
echo " "
echo "This script uses apt-get and make install via sudo rights"
echo "To simplify this, we're going to use sudo -v to pre-authenticate you"
@darrenpmeyer
darrenpmeyer / openconnect-7-ubuntu-build.md
Last active June 10, 2020 16:24
Building OpenConnect 7 on Ubuntu 14 (trusty), 15 (vivid), and 16 (xenial)
@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')
@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 / big-sur-crontab.md
Created November 8, 2021 17:01
Setting up user cron jobs on macOS 11.6 Big Sur

NOTE the cron command scheduler is considered deprecated by Apple, in favor of using Launch Agents along with launchd. There is a decent launchd tutorial at launchd.info if you want to do that instead.

Give cron full disk access

Cron jobs usually need to work outside of the macOS "sandbox", accessing scripts and files across the filesystem. macOS supports Unix filesystem permissions, but there's an additional safety gate that's evaluated