Skip to content

Instantly share code, notes, and snippets.

@dreness
dreness / extract_certs_from_pkg.py
Created November 2, 2019 08:27
Extract x509 certificates found in xar table of contents
#!/usr/bin/env python3
from xml.etree import ElementTree as ET
from os.path import abspath
from os import getenv
import subprocess
import textwrap
import zlib
import sys
@dreness
dreness / show_tcc_entries.sh
Created October 23, 2019 18:18
Show recent #TCC entries
#!/bin/sh
# ** NOTE: probably requires that SIP is disabled **
# To show all entries, remove "limit 10" from the queries.
echo "Recent user TCC entries:"
sqlite3 -line ~/Library/Application\ Support/com.apple.TCC/TCC.db "SELECT service, client, allowed, prompt_count, Datetime(last_modified, 'unixepoch') as modified FROM access order by modified desc limit 10;"
echo "\n-----------------------------------------\n"
@dreness
dreness / recent_notifications.sh
Created October 22, 2019 19:54
Display 10 most recent notification center #notifications
sqlite3 -line "$(getconf DARWIN_USER_DIR)/com.apple.notificationcenter/db2/db" "SELECT Datetime(delivered_date + 978328800, 'unixepoch', 'localtime') as delivered_at,
app.identifier,
record.presented,
record.style
FROM record
JOIN app
ON app.app_id = record.app_id
ORDER BY delivered_at DESC limit 10;"
@dreness
dreness / tickref.opy
Last active October 14, 2019 03:49
Displays overwatch instance stats: ticks dropped, ticks counted, ticks expected
#!define TICKS A
#!define COUNTING B
#!define NOW C
#!define STARTLAG D
#!define DROPPED E
#!define EXPECTED F
@Rule "fast assemble"
@Event global
if isAssemblingHeroes():
@dreness
dreness / heredoc-examples.md
Created October 8, 2019 08:20
Shell heredocs and related nestings

Zsh: Heredoc inside a command substitution

note the helpful indenting in the prompt

zsh% A=$(
cmdsubst> cat <<EOF
cmdsubst heredoc> boep boewp
cmdsubst heredoc> dootles
cmdsubst heredoc&gt; EOF
@dreness
dreness / new-trails.overscript
Last active February 28, 2020 21:54
#overwatch workshop code: trails occasionally buggy
#!define maxEffects N
#!define spawnEffects A
#!define effectDelay D
#!define effectScale S
#!define lastPosition Q
#!define editMode M
#!define editMutex J
#!define trails E
@Rule "fast setup"
@dreness
dreness / Uncloned.swift
Created May 1, 2019 06:33
Show something mumble mumble APFS cloned files mumble?
import Cocoa
// https://cocoa-dev.apple.narkive.com/Ciy40e20/is-cloning-the-same-as-copying-in-apfs#post8
func unclonedSize(of url: URL) throws -> off_t {
var list = attrlist(bitmapcount: UInt16(ATTR_BIT_MAP_COUNT),
reserved: 0,
commonattr: 0,
volattr: 0,
dirattr: 0,
fileattr: 0,
@dreness
dreness / mkbarcodes.py
Last active September 24, 2019 02:27
make a video of a bunch of generated barcodes using #ffmpeg
#!/usr/bin/env python3
# make some barcodes, then use ffmpeg to make a video from the individual frames,
# to see how fast FirebaseML can recognize barcodes through the camera.
# https://github.com/azamsharp/FirebaseML.git
# barcode types
# code128 code39 ean ean13 ean14 ean8 gs1
# gtin isbn isbn10 isbn13 issn itf jan pzn upc upca
@dreness
dreness / cc_southpark.py
Last active November 13, 2019 04:01
cc_southpark.py uses #BeautifulSoup to produce a list of links to #SouthPark episodes
#!/usr/bin/env python3
import json
from beautifulscraper import BeautifulScraper
from pprint import pprint as pp
URL = "http://southpark.cc.com/feeds/carousel/video/08f60a6f-24a8-4d88-88a3-eb5588494cbc/30/1/json/views/season-"
# a sample item:
'''
@dreness
dreness / mystery_routing.txt
Last active December 3, 2018 02:45
A routing puzzle for you
Question: is there ever a reason to ARP for an IP outside of any local subnets?
Update: I like @bmastenbrook's answer: https://twitter.com/bmastenbrook/status/1069415501296586752
# my subnet is a /24, and 10.0.10.10 is totally not on the same /24 as 10.0.0.42.
xomg% netstat -rn -f inet
Routing tables
Internet:
Destination Gateway Flags Refs Use Netif Expire
default 10.0.10.10 UGScI 3 0 en0