Skip to content

Instantly share code, notes, and snippets.

@chockenberry
chockenberry / tot.sh
Last active March 9, 2025 22:28
A shell script for Tot
#!/bin/sh
basename=`basename $0`
if [ -z "$*" ]; then
echo "usage: ${basename} <dot> [ -o | -r | <file> | - ]"
echo ""
echo "options:"
echo " -o open dot in window with keyboard focus"
echo " -r read contents of dot"
@chockenberry
chockenberry / ScreenRecordingDetection.m
Created November 21, 2019 22:38
Detecting Screen Recording Permission in macOS Catalina
BOOL canRecordScreen = YES;
if (@available(macOS 10.15, *)) {
canRecordScreen = NO;
NSRunningApplication *runningApplication = NSRunningApplication.currentApplication;
NSNumber *ourProcessIdentifier = [NSNumber numberWithInteger:runningApplication.processIdentifier];
CFArrayRef windowList = CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly, kCGNullWindowID);
NSUInteger numberOfWindows = CFArrayGetCount(windowList);
for (int index = 0; index < numberOfWindows; index++) {
// get information for each window
@chockenberry
chockenberry / Slack Formatting Bar Feedback.txt
Last active October 22, 2020 19:26
Slack Formatting Bar Feedback
There are a couple of problems with the new formatting bar:
1) The icon to turn it on/off doesn't make sense. It's a toolbar, and the "Aa" doesn't get that concept across. It's in a strange place, next to "@" and ":-)", icons that cause an element to come up over the text field without changing it. A lot of smart folks aren't figuring this out (and let's face it, no one reads the fricken' manual.) Don't believe me, check out the replies to this tweet:
https://twitter.com/chockenberry/status/1196992017143779328
2) Once you have the epiphany to turn it off, it doesn't turn off the functionality. I've been using Markdown since it was just a glint in John Gruber's eye, and it's actually easier for me to _read_ text *like this* even when it contains `code`.
If I opt out of the formatting bar, it feels like I should be opting out the fancy completion stuff, too.
@chockenberry
chockenberry / Debug.swift
Last active April 11, 2024 13:22
Debug and release logging in Swift that's reminiscent of NSLog()
//
// Debug.swift
//
// Created by Craig Hockenberry on 3/15/17.
// Updated by Craig Hockenberry on 2/20/24.
// Usage:
//
// SplineReticulationManager.swift:
//
@Jabarabo
Jabarabo / githubpull.md
Last active April 2, 2025 08:15
Gist of a stolen gist
#!/bin/bash
xdotool mousemove 100 100
xdotool click 1
for i in `rand -M 3 -N 1000`; do
echo -n "Play $i "
case "$i" in
"0")
@jarbro
jarbro / symantec-vip-access-totp.md
Last active April 2, 2025 07:13
Generate Symantec VIP Access Token as TOTP

Generate Symantec VIP Access Token as OTP

Recently I came across a web service that required two-factor authentication using the Symantec VIP Access App. I already manage all of my OTP tokens in a different app (If you are on iOS I highly recommend using OTP Auth by Roland Moers.) and did not want to have to use yet another app to generate the TOTP.

There is a way to generate a Symantec VIP Access compatible token very easily if you have access to an environment which can run Python PIP. I happen to have Ubuntu Windows Subsystem Linux running on my machine. (If you are running Windows 10 and don't have this you should really check it out.) Let's get started...

hello

Instructions

Here we install python3-pip and qrencode so we can generate our secret, I

@ixdy
ixdy / yubikey4-ssh-macos.md
Last active February 9, 2025 12:12
Setting up ssh public key authentication on macOS using a YubiKey 4

Setting up ssh public key authentication on macOS using a YubiKey 4

I largely followed Florin's blog post, but have a few notes to add regarding issues I encountered:

Basic setup notes

  1. I used a YubiKey 4, while the blog describes using a YubiKey NEO. I'm sure a YubiKey 5 would also work. I'm also running macOS 10.13.6.
  2. I installed GPGTools as recommended. However, as I'll note later, it seems that gpg-agent only automatically starts when gpg is used; for ssh, you'll need to ensure it's running.
  3. Before generating your keys, decide what key size you want to use. If you run the list command inside gpg --edit-card, look for the Key attributes line to see what is currently selected. On my YubiKey 4, it defaulted to 2048 bits for all keys:
Key attributes ...: rsa2048 rsa2048 rsa2048
@pamolloy
pamolloy / README.md
Last active October 16, 2024 20:40
Ubiquiti USG configuration for Wireguard

Download the latest ugw3 package from https://github.com/Lochnair/vyatta-wireguard/releases and install it on your USG using dpkg -i wireguard-ugw3-<version>.deb.

cd /config/auth
umask 077
mkdir wireguard
cd wireguard
wg genkey > wg_private.key
wg pubkey < wg_private.key > wg_public.key
@dlzi
dlzi / remove-python-macos.md
Last active March 4, 2025 13:21
How to uninstall Python 3.x on a macOS

1. DO NOT attempt to remove any Apple-supplied system Python which are in /System/Library and /usr/bin.
2. Multiple Python versions can coexist pacifically on macOS. So, uninstalling Python is purely optional.

To remove a different version, change 3.7 to the Python version you want to remove.

sudo rm -rf /Library/Frameworks/Python.framework/Versions/3.7
sudo rm -rf "/Applications/Python 3.7"
sudo find /usr/local/bin -lname '../../../Library/Frameworks/Python.framework/Versions/3.7/*' -delete