Skip to content

Instantly share code, notes, and snippets.

@darrenpmeyer
darrenpmeyer / start-gocryptfs.sh
Created Jun 28, 2022
Encrypted Dropbox/Box/GoogleDrive folder on macOS using gocryptfs
View start-gocryptfs.sh
#!/usr/bin/env bash
set -euo pipefail
## encrypted files; script will create this. Put in a synced folder
ENCRYPTED_FOLDER="~/Dropbox/encrypted"
## mountpoint; script will create this. Should stay empty when not mounted!
## DO NOT PUT THIS IN A SYNCED FOLDER - DOING SO WILL SYNC UNENCRYPTED DATA
MOUNTPOINT="~/.local/cloudmount/Dropbox-Encrypted"
@darrenpmeyer
darrenpmeyer / ip4-alias.sh
Created Jun 10, 2022
Perl one-liner to get IP address from mDNS/DNS/Bonjour/whatever - works on any *nix that supports getHostByName
View ip4-alias.sh
# usage: `ip4 HOSTNAME`
alias ip4='perl -MSocket -e '\''$pack=gethostbyname($ARGV[0]); print inet_ntoa($pack)'\'''
@darrenpmeyer
darrenpmeyer / big-sur-crontab.md
Created Nov 8, 2021
Setting up user cron jobs on macOS 11.6 Big Sur
View big-sur-crontab.md

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

@darrenpmeyer
darrenpmeyer / decrypt-howto.md
Created Dec 23, 2020
Decrypt Unifi .unf backups
View decrypt-howto.md

NB: these instructions are for Ubuntu; they work under WSL on Windows 10 as well

Get the decrypt.sh file from here: https://github.com/zhangyoufu/unifi-backup-decrypt

Make sure prerequisites are installed:

sudo apt update && sudo apt install zip unzip openssl mongo-tools
@darrenpmeyer
darrenpmeyer / README.md
Created Nov 20, 2020
Automatically start a single instance of ssh-agent for all terminal sessions to share (bash)
View README.md

Installation

  1. mkdir -p ~/.config && touch ~/.config/ssh-agent.pid
  2. Paste the contents of ssh-agent-manage.sh into your .bashrc or .bash_profile or similar
  3. killall -9 ssh-agent
  4. Start a new terminal session (note: old sessions will not see ssh-agent, only new ones)

Details

This snippet, when included in .bashrc, will ensure that your session has a working ssh-agent with all your ssh keys loaded into it. It does this without creating separate ssh-agent processes by:

@darrenpmeyer
darrenpmeyer / burp-hidpi.md
Created Oct 19, 2020
Pixel Doubling / HiDPI display support for BurpSuite
View burp-hidpi.md

Running BurpSuite on a HiDPI display, and that makes the interface window tiny and unreadable?

Just set the _JAVA_OPTIONS environment variable so that it includes -Dsun.java2d.uiScale=2

On Linux, you can edit the BurpSuiteCommunity executable shell script wherever it's been installed, to include the following line near the top (below the #! line, though!):

export _JAVA_OPTIONS="-Dsun.java2d.uiScale=2"
@darrenpmeyer
darrenpmeyer / autobuild-openconnect-8-ubuntu.sh
Created Jun 10, 2020
Autobuild script for OpenConnect 8 (Ubuntu 18/19 bionic/eoan)
View autobuild-openconnect-8-ubuntu.sh
#!/usr/bin/env bash
oc_ver="8.10"
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"
sudo -k
sudo -v
@darrenpmeyer
darrenpmeyer / setchime.sh
Last active Mar 5, 2020
Control macOS startup chime
View setchime.sh
#!/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
##========================================================================
View iterm2-alfred-integration.scpt
-- 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 / is_unicode.py
Created Jul 26, 2019
Python2 and Python3 compatible "is this a unicode string" check
View is_unicode.py
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')