Skip to content

Instantly share code, notes, and snippets.

Avatar
🤖

Andre LaBranche dreness

🤖
View GitHub Profile
@dreness
dreness / xplot.rb
Created Sep 11, 2021
A slight tweak to sra's xplot formula for homebrew
View xplot.rb
# Based on https://git.hactrn.net/sra/Homebrew-Tap/raw/master/xplot.rb
# Updated by dre for macOS 11.5.3
# - prepended `autoconf` and `autoupdate`, which are really living up
# to their names. The *newest* part of xplot is from 1996.
# Documentation: https://docs.brew.sh/Formula-Cookbook
# http://www.rubydoc.info/github/Homebrew/brew/master/Formula
class Xplot < Formula
desc "xplot"
homepage "http://www.xplot.org"
@dreness
dreness / logfreq.sh
Created Sep 7, 2021
macOS log haystack needler
View logfreq.sh
#!/bin/zsh
# set -x
# Reference: https://dreness.com/blog/archives/155773
usage() {
print "$1: Use histograms to explore os_log data.
Usage: $1 [-k logKey] [-l logtime] [-h] [predicate]
-k Calculate frequency of unique values of this log attribute.
@dreness
dreness / basic_compute.xml
Created Jul 28, 2021
basic compute kernel Kodelife project XML
View basic_compute.xml
<?xml version='1.0' encoding='UTF-8'?>
<klxml v='16' a='MTL'>
<document><properties><creator><![CDATA[net.hexler.KodeLife]]></creator><creatorVersion><![CDATA[1.0.1.153]]></creatorVersion><versionMajor>1</versionMajor><versionMinor>1</versionMinor><versionPatch>1</versionPatch><author><![CDATA[]]></author><comment><![CDATA[]]></comment><enabled>1</enabled><size><x>500</x><y>500</y></size><clearColor><x>0</x><y>0</y><z>0</z><w>1</w></clearColor><selectedRenderPassIndex>1</selectedRenderPassIndex><selectedKontrolPanelIndex>0</selectedKontrolPanelIndex><uiExpandedPreviewDocument>0</uiExpandedPreviewDocument><uiExpandedPreviewRenderPass>1</uiExpandedPreviewRenderPass><uiExpandedProperties>1</uiExpandedProperties></properties><params><uiExpanded>1</uiExpanded><param type='CLOCK'><displayName><![CDATA[Clock]]></displayName><variableName><![CDATA[time]]></variableName><uiExpanded>0</uiExpanded><running>1</running><direction>1</direction><speed>1</speed><loop>0</loop><loopStart>0</loopStart><loopEnd>6.28319</loopEnd>
@dreness
dreness / no_lc_rpath.txt
Created Jun 14, 2021
AMD forgot LC_RPATH in the sample code for their own SDK!
View no_lc_rpath.txt
andre@boop RadeonProRenderSDK % file tutorials/Bin/01_camera_setup64
tutorials/Bin/01_camera_setup64: Mach-O 64-bit executable x86_64
andre@boop RadeonProRenderSDK % ./tutorials/Bin/01_camera_setup64
dyld: Library not loaded: @rpath/libRadeonProRender64.dylib
Referenced from: /Users/andre/work/RadeonProRenderSDK/./tutorials/Bin/01_camera_setup64
Reason: image not found
zsh: abort ./tutorials/Bin/01_camera_setup64
andre@boop RadeonProRenderSDK % otool -L tutorials/Bin/01_camera_setup64
@dreness
dreness / bg_remove.sh
Created Apr 30, 2021
Maybe the same thing as Imagemagick's "bg_removal.sh"
View bg_remove.sh
#!/bin/zsh
# an image that looks like the background
WHITE=/Users/andre/Desktop/white.png
# output directory
OUT=/Users/andre/Pictures/mugshots_no_bg
# maybe run us like this:
# find ... -name '*.jpg' | xargs -n 100 -P 4 -J % ~/bin/bg_remove.sh %
@dreness
dreness / svg2pdf.sh
Last active Apr 1, 2021
Batch convert SVGs to PDF using Inkscape
View svg2pdf.sh
#!/bin/zsh
IMAGE_DIR=$1
INK="/Applications/Inkscape.app/Contents/MacOS/inkscape"
SCRIPT="inkscript"
COUNT=0
# If gdate is available (brew install coreutils), we can show precise timing info
type -a gdate &> /dev/null && HAS_GDATE=1
@dreness
dreness / ifsocket.sh
Created Feb 7, 2021
Realtime graph from WebSocket data
View ifsocket.sh
#!/bin/zsh
D=$(date "+%Y-%m-%d")
#D=$(date "+%s")
ifstat -t -n -i en0 \
| sed -l '1d;2d' \
| while read -A IFSTAT
do
echo -n "{"
echo -n "\"Time\": \"${D} ${IFSTAT[1]}\", "
#echo -n "\"Time\": \"${IFSTAT[1]}\", "
@dreness
dreness / lscap.py
Created Dec 5, 2020
Reformat tcpdump output for logstalgia on macOS
View lscap.py
# /usr/bin/env python -u
from colorhash import ColorHash
from pprint import pprint as pp
from pcapng import FileScanner
import asyncio
import sys
import re
cmd = "tcpdump --immediate-mode -l -g -k -n -i pktap,en0 ip or udp"
@dreness
dreness / stargazer-repos.graphql
Created Nov 25, 2020
Enumerate pinned items owned by stargazers of a repository with given owner and name
View stargazer-repos.graphql
query ($owner: String!, $name: String!, $gazers: Int, $items: Int) {
repository(owner: $owner, name: $name) {
name
description
resourcePath
id
stargazers(last: $gazers, orderBy: {field: STARRED_AT, direction: DESC}) {
edges {
starredAt
node {
@dreness
dreness / websizer.py
Created Oct 9, 2020
Sum Content-Lengths of a bunch of HTTP resources on servers that might not return Content-Length in HEAD responses.
View websizer.py
#!/usr/bin/env/ python
import requests
import fileinput
import sys
from humanfriendly import format_size
f = open("/Users/andre/Desktop/urls.txt", "r")
s = requests.session()