Skip to content

Instantly share code, notes, and snippets.

@dreness
dreness / notes.md
Last active December 18, 2019 21:52
#Windows advice

Preamble

I run a fair amount of *nix software on my Windows machine - not because it's easy, but because it has become apparent that this die-hard Mac user needs a more diverse portfolio (for personal reasons; I have successfully avoided Windows for my entire career to date). In fact, it's quite difficult compared to running the same software on macOS, which isn't too surprising since macOS is generally considered to be a member of the *nix family, while Windows is not.

This document contains a random bag of things that will cut you as you attempt to cross the streams, and also the occasional tip or trick.

Condensced wisdom

  • There are many choices of 'environments' for building / running things, such as: MSYS2, Cygwin, Anaconda, VCPKG, WSL. They can be used concurrently (with important caveats; keep reading), and the correct one to use for a given task likely depends on compatability requirements of the software you're making or using.
  • path handling is a mess (WSL purports to ease this pain some
@dreness
dreness / shadowhash.sh
Last active March 17, 2018 00:04
Examine shadowhash data from a DSLocal account record in macOS
#!/bin/bash
if [ -z $1 ]
then
echo "Requires a username as the first and only argument."
exit 1
fi
readShadowhash() {
u=$1
@dreness
dreness / funcs.sh
Created February 11, 2018 01:44
a few bash techniques for error handling
#!/usr/bin/bash
trap "echo inner ERR" ERR
trap "echo inner EXIT" EXIT
aThunk()
{
unsurprisingly
}
@dreness
dreness / VLCxcallbacker.py
Last active February 15, 2023 16:46
VLCxcallbacker: generate and host a web page of vlc-x-callback links to every video file in a given directory (for #VLC clients on iOS)
# -*- 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
@dreness
dreness / schmoVids.py
Last active December 17, 2017 00:44
Somebody asked what their second-longest video is :)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import isodate
import time
import math
import json
import sys
import os
from ytdata import YTData
from datetime import datetime
@dreness
dreness / owl.py
Last active January 12, 2018 06:37
Reveal OverwatchLeague video URLs
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
Work in progress. For now, just show URLs to m3u8 files of match videos.
To use, first do:
pip install -r requirements.txt
TODO: pre-season VODs were split out by game; season1 VODs contain all games in a match
"""
@dreness
dreness / LSFileInfo example
Last active October 17, 2022 17:51
Interrogate LaunchServices using #PyObjC to query file paths for default app handler, all possible app handlers, and the UTI
xomg% python LSFileInfo.py dylib-map.sqlite
('\n', u'/Users/andre/bin/dylib-map.sqlite')
('UTI: ', u'dyn.ah62d4rv4ge81g6pqrf4gn')
('default app: ', file:///Applications/DB%20Browser%20for%20SQLite.app/)
('all apps: ', (
"file:///Applications/DB%20Browser%20for%20SQLite.app/"
))
@dreness
dreness / watch_file.d
Last active July 16, 2020 22:29
Try to find out who is opening, reading from, writing to, deleting a file
#!/usr/sbin/dtrace -s
#pragma D option quiet
#pragma D option switchrate=10hz
/* pass the filename to watch for as the only cli argument */
dtrace:::BEGIN
{
/* double dollar sign to stringify cli arg */
@dreness
dreness / ShoutCast-polling.md
Last active July 3, 2017 14:04
A tentative analysis of why Shoutcast is spinning a full CPU core

A Shoutcast process (called sc_serv25, with PID 10213) is using way more CPU than expected for the workload - specifically, 100% of a CPU core. Let's investigate.

$ sudo strace -p 10213 -o ~/sc_serv25_strace.txt -f -t -tt -T
(control-c after a few seconds)

Looking at sc_serv25_strace.txt for weirdness, we notice thread 10221 is very hot. Here's an excerpt:

$ grep 10221 ~/sc_serv25_strace.txt
...
10221 1499065013.244010 poll([{fd=14, events=POLLIN}, {fd=75, events=POLLIN}], 2, 0) = 0 (Timeout) <0.000009>
@dreness
dreness / symfind.py
Last active September 13, 2017 20:57 — forked from pudquick/symfind.py
Automatic symbol definition discovery for OS X binaries and their linked shared libraries
#!/usr/bin/python
"""Usage: symfind BINARY_PATH SEARCH_STR
symfind automates the usage of otool and nm to attempt to find out which
binary a symbol is defined in that's used within BINARY_PATH's code.
"""
import subprocess, os.path, sys, getopt