Skip to content

Instantly share code, notes, and snippets.

🤖

Andre LaBranche dreness

🤖
Block or report user

Report or block dreness

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dreness
dreness / pre-commit
Last active Jul 12, 2019
git pre-commit hook to set commit email address based on the repo's remote domain(s)
View pre-commit
#!/bin/zsh
#
# Set repo's user.email to a default or alternate value based on remote domain.
# Because the in-flight commit info has already been set, if an email address
# change is needed, this commit is aborted. Retry the commit to use the new address.
#
# To automatically install custom hooks to new repos:
# 1) Add something like the following to ~/.gitconfig:
# [init]
# templatedir = ~/.git/templates
@dreness
dreness / manual-ocsp-check.txt
Created Feb 22, 2016
Manually check certificate revocation status using OCSP
View manual-ocsp-check.txt
# Assumes an Apple-like layout: leaf --> issuer --> CA in exactly 3 certs
# The last arg to codesign specifies the code to check, by bundle or executable path, or process ID
codesign -d -vv --extract-certificates=cert I-didnt-edit-my-config-file
for i in 0 1 2 ; do openssl x509 -inform der -in cert${i} -out cert${i}.pem ; done
openssl ocsp -CAfile cert2.pem -issuer cert1.pem -cert cert0.pem -url $(openssl x509 -in cert0.pem -ocsp_uri -noout)
Example:
╭─ andre@flux ~
@dreness
dreness / fix-aifc.sh
Last active May 26, 2019
Attempt to repair an interrupted QuickTime Player audio recording
View fix-aifc.sh
#!/bin/zsh
#set -e
#set -x
# dre@mac.com
#
# This script attempts to repair a partial AIFC recording generated by
# QuickTime Player. This happens when QTP is interrupted while recording.
# Look for partial files with:
@dreness
dreness / Uncloned.swift
Created May 1, 2019
Show something mumble mumble APFS cloned files mumble?
View Uncloned.swift
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
Created Apr 1, 2019
make a bunch of barcodes
View mkbarcodes.py
#!/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 / throttle.sh
Last active Feb 19, 2019
A script to apply bandwidth limits to specific traffic in OS X using pf and dummynet
View throttle.sh
#!/bin/bash
# Create a file such as /Users/you/Documents/pftable to hold a list of IPs or subnets to throttle.
# Example file contents:
# 1.2.3.4
# 2.3.4.5/16
# Reset dummynet to default config
dnctl -f flush
@dreness
dreness / LSFileInfo.py
Last active Feb 10, 2019
Interrogate LaunchServices to query file paths for default app handler, all possible app handlers, and the UTI
View LSFileInfo.py
#!/usr/bin/env python
import LaunchServices as ls
from Foundation import NSURL
from sys import argv
for arg in argv[1:]:
url = NSURL.fileURLWithPath_(arg)
if url == None: continue
print("\n", url.path())
@dreness
dreness / VLCxcallbacker.py
Last active Jan 6, 2019
Synthesize and host vlc-x-callback stream links
View VLCxcallbacker.py
# -*- coding: utf-8 -*-
from __future__ import print_function, unicode_literals
import os
import socket
from datetime import datetime
from urllib import parse
from klein import Klein
from twisted.web.static import File
from twisted.python.filepath import FilePath
View cc_southpark.py
#!/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-"
def seasonClips(URL):
VIDS = []
@dreness
dreness / mystery_routing.txt
Last active Dec 3, 2018
A routing puzzle for you
View mystery_routing.txt
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
You can’t perform that action at this time.