Skip to content

Instantly share code, notes, and snippets.

@bkyle
bkyle / unheader.py
Created October 10, 2023 12:56 — forked from omots/unheader.py
SNES unheadering tool
#!/usr/bin/env python3
# unheader.py - Portable commandline SNES ROM unheading tool
# By oldmanoftheSEA (omotss@twitter, omots@github)
# THIS UTILITY COMES WITH NO WARRANTY EXPRESSED OR IMPLIED
# Backups are ALWAYS a good idea.
# Principles & support:
# This tool is generally conservative when it comes to making modifications.
@bkyle
bkyle / dismiss-notifications
Created January 15, 2022 15:50
Applescript to dismiss all "drive not ejected properly" notifications. This can be run as a script at the terminal, setup as a cronjob, run through Alfred, etc.
#!/usr/bin/osascript
tell application "System Events"
tell process "NotificationCenter"
set vWindowCount to (count windows)
if vWindowCount is 0 then
return
end if
set vWindow to window 1
set vNotificationContainer to (UI element 1 of scroll area 1 of vWindow)
@bkyle
bkyle / mdNotes.js
Last active June 8, 2021 13:54
mdNotes
(function() {
function highlight(span) {
const dataAnnotationContent = decodeURIComponent(span.getAttribute("data-annotation"))
const dataAnnotation = JSON.parse(dataAnnotationContent)
const citationItem = dataAnnotation.citationItem
const uri = dataAnnotation.uri
const id = uri.split("/").pop()
const text = dataAnnotation.text
const position = dataAnnotation.position
const pageIndex = position.pageIndex + 1
@bkyle
bkyle / .dir-locals.el
Created March 20, 2021 23:00
.dir-locals.el for Obsidian Vaults
;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")
((markdown-mode . ((visual-fill-column-width . 100)
(mode . visual-fill-column)
(mode . visual-line)
(markdown-hide-markup . nil)
(markdown-header-scaling . t)
(markdown-wiki-link-search-parent-directories . t)
(markdown-wiki-link-search-subdirectories . t)
@bkyle
bkyle / docker-backup.sh
Created March 8, 2021 15:13
Backup the contents of docker images
container=""
bindings=$(docker inspect ${container} | jq -r '.[].HostConfig.Binds[]')
echo ${bindings} | while read bind; do
volume=${bind/:*/}
mount_point=${bind/*:/}
echo "docker run --volumes-from ${CONTAINER} -it --rm -v $(pwd)/backups:/backups busybox tar -czvf /backups/${volume}.tar.gz \"${mount_point}\""
done
@bkyle
bkyle / jd.sh
Last active February 28, 2021 16:02
Functions for the bash shell to support johnny.decimal indexes
JOHNNY_ROOT="..."
function jfind() {
(cd "${JOHNNY_ROOT}"; find [1234567890][1234567890]* $@)
}
function jls() {
(cd "${JOHNNY_ROOT}"; ls -1d [1234567890][1234567890]-*/[1234567890][1234567890]\ */[1234567890][1234567890].[1234567890][1234567890]*)
}
@bkyle
bkyle / jd.py
Created February 27, 2021 01:27
Alfred Script Filter to list Johnny.Decimal index
from __future__ import print_function
import json
import os
import subprocess
import sys
def ls(wd):
"""Returns a list of directories under ``wd`` that match the johnny.decimal
pattern. The directories returned will be related to the passed working directory."""
pattern = "[1234567890][1234567890]-*/[1234567890][1234567890]\ */[1234567890][1234567890].[1234567890][1234567890]*"
/* Localized versions of Info.plist keys */
@bkyle
bkyle / NSArray+Globbing.h
Created February 3, 2010 20:02
NSArray+Globbing
#import <Foundation/Foundation.h>
@interface NSArray (Globbing)
+ (NSArray*) arrayWithFilesMatchingPattern: (NSString*) pattern inDirectory: (NSString*) directory;
@end
@bkyle
bkyle / NSOutlineView-DMExtensions.h
Created January 17, 2010 05:24
Wil Shipley's NSOutlineView (DMExtensions)
// NSOutlineView-DMExtensions.h
// Library
//
// Created by William Shipley on 3/10/06.
// Copyright 2006 Delicious Monster Software, LLC. Some rights reserved,
// see Creative Commons license on wilshipley.com
#import <Cocoa/Cocoa.h>
@interface NSOutlineView (DMExtensions)