Skip to content

Instantly share code, notes, and snippets.

@Serneum
Serneum / MediaApplication.swift
Last active March 8, 2024 04:59
Swift media key event handling
import Cocoa
class MediaApplication: NSApplication {
override func sendEvent(event: NSEvent) {
if (event.type == .SystemDefined && event.subtype.rawValue == 8) {
let keyCode = ((event.data1 & 0xFFFF0000) >> 16)
let keyFlags = (event.data1 & 0x0000FFFF)
// Get the key state. 0xA is KeyDown, OxB is KeyUp
let keyState = (((keyFlags & 0xFF00) >> 8)) == 0xA
let keyRepeat = (keyFlags & 0x1)

Keybase proof

I hereby claim:

  • I am serneum on github.
  • I am serneum (https://keybase.io/serneum) on keybase.
  • I have a public key ASDA_k0BxFi3b4mBD6vz3mu3hH-6qT8ZbiD4ahvsh0VtGwo

To claim this, I am signing this object:

flowchart
  approved[PR Passes CI<br/>and<br/>Two PR Review Approvals] --->|Announce deployment 7 min<br/>ahead of planned deploy<br/>in #deployment| mergeRepoPR[Merge PR into repo at<br/>originally indicated deployment window]
  mergeRepoPR ---> prActions(GitHub action `create-release` is triggered<br/>tags branch for release<br/>creates release<br/>)
  prActions --->|notifies AppState of release| merge(AppState GitHub action creates deployment)
  merge ---> |Monitor the deploy as indicated<br/>in the AppState PR description| determine[Determine deployment outcome]
  determine --->|If unsuccessful| rollback[Perform a roll-forward, when possible]
  determine --->|On successfull deployment| announce[Announce successful deployment<br/>in the same #deployments thread] 
@Serneum
Serneum / shoko-copy-inotifywait.sh
Created April 4, 2024 22:47
Hardlink or clean up existing files when new files are detected
#!/bin/bash
inotifywait -m -r /data/media/Anime -e create -e moved_to -e delete --format "%w%f@%e" |
while read -r fullpathwithevent; do
ev="${fullpathwithevent##*@}"
echo "Event: $ev"
fullpath=$(echo $fullpathwithevent | sed 's/@.*//')
echo "Full path: $fullpath"