Skip to content

Instantly share code, notes, and snippets.

@bef
bef / checkarch.sh
Created June 15, 2023 08:17
Check architecture of MacOS binary or Application bundle
#!/bin/bash
## Check architecture of MacOS binary or Application bundle
## // Ben Fuhrmannek 2023-06-15
for i in "$@"; do
if [[ ! -e "$i" ]]; then
echo "ERROR: $i: not found"
continue
fi
if [[ -d "$i" && -f "$i/Contents/Info.plist" ]]; then
@bef
bef / rename-images-from-exif-datetime.sh
Created December 10, 2020 14:23
Luminar 4 better filename after export hack/workaround
#!/bin/bash
## 2020-12-10 - BeF
## rename image files from exif data the way I like them: including original filename and date
if [[ $# -eq 0 ]]; then
echo "$0 <file> ..."
exit 1
fi
for fn in "$@"; do
if [[ "$fn" =~ [0-9]\ at\ [0-9] ]]; then
echo "$fn not changed."
@bef
bef / brew github token.md
Created February 28, 2020 09:48
How to securely handle Github auth tokens with homebrew or avoid them entirely

Problem

Homebrew likely needs a Github API auth token to work correctly, at least with 2FA enabled Github accounts. The Internet - e.g. https://gist.github.com/willgarcia/7347306870779bfa664e - suggests to add the token to your environment via .bashrc, which is generally a bad idea and gives every started program access to your github account.

Solution 1: Shell wrapper

  1. Generate access token via https://github.com/settings/tokens
  2. Wrap your Access token in a shell script, e.g. ~/bin/brew, or whatever is in your path before the actual brew path:
#!/bin/bash
HOMEBREW_GITHUB_API_TOKEN=xxxx /usr/local/bin/brew "$@"
#!/usr/bin/env python2
from zbase32 import zbase32
import hashlib
import sys
input = sys.argv[1]
print "hashing " + input
m = hashlib.sha1()
m.update(input)

Keybase proof

I hereby claim:

  • I am bef on github.
  • I am bef (https://keybase.io/bef) on keybase.
  • I have a public key ASBK5T8Fc-J7-WcrNX-XRh71Hq3Io2zGA5Dvw-wcP7HVsAo

To claim this, I am signing this object:

....
<dict>
<key>name</key>
<string>Variable</string>
<key>scope</key>
<string>variable.language, variable.other</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#0206EE</string>