Skip to content

Instantly share code, notes, and snippets.

View rchrd2's full-sized avatar

Richard Caceres rchrd2

View GitHub Profile
@rchrd2
rchrd2 / confirm.swift
Last active May 20, 2023 19:08
Swift shell script with native confirm dialog
import AppKit
import Foundation
import SwiftUI
extension NSApplication {
public func run<V: View>(@ViewBuilder view: () -> V) {
let appDelegate = AppDelegate(view())
NSApp.setActivationPolicy(.regular)
delegate = appDelegate
@rchrd2
rchrd2 / sketch.java
Created March 25, 2022 20:58
Processing sketch to convert midi sustain pedal to a bass drum midi note trigger
import themidibus.*; //Import the library
MidiBus myBus; // The MidiBus
int NOTE_NUMBER = 36;
int NOTE_VELOCITY = 50;
int NOTE_CHANNEL = 9;
String MIDI_DEVICE_IN = "GO:KEYS";
String MIDI_DEVICE_OUT = "GO:KEYS";
@rchrd2
rchrd2 / using-details-summary-github.md
Created January 8, 2022 02:12 — forked from scmx/using-details-summary-github.md
Using <details> <summary> expandable content on GitHub with Markdown #details #summary #markdown #gfm #html

How to use <details> <summary> expandable content on GitHub with Markdown

Firstly, what is <details> <summary>?

The HTML Details Element (<details>) creates a disclosure widget in which information is visible only when the widget is toggled into an "open" state. A summary or label can be provided using the <summary> element. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details.

Example

@rchrd2
rchrd2 / proxy.js
Created November 4, 2020 01:12
Cloudflare worker CORS proxy
// forked from: https://github.com/chebyrash/cors
addEventListener("fetch", event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
try {
const url = new URL(request.url);
if (url.pathname === "/") {
@rchrd2
rchrd2 / .bashrc
Last active November 25, 2020 04:27
archive files based on creation date
archive() {
if [ ! -d "$1" ]; then echo Missing base; return 1; fi
local BASE=$1
for f in "${@:2:$#-1}"; do
if [ -d "$f" ]; then continue; fi;
local DATE=`date -r "$f" "+%Y-%m-%d"`
local YEAR=`date -r "$f" "+%Y"`
local TARGET_DIR="$BASE/$YEAR/$DATE"
mkdir -p $TARGET_DIR
echo cp -iv "$f" "$TARGET_DIR/"
@rchrd2
rchrd2 / stash.py
Last active October 7, 2020 21:59
stash.py
#!/usr/bin/python3
"""
The idea is to take stdin, and write it to a new unique log file
php myscript.php | newlog filename
"""
import os
import sys
@rchrd2
rchrd2 / download.sh
Created October 20, 2019 02:08
wget example to download the decentralizedweb.net website
#!/bin/bash
wget --no-verbose --mirror --convert-links --directory-prefix=dwebsummit-download --no-host-directories https://decentralizedweb.net
rsync -vv --recursive --links --perms --checksum --ignore-times --exclude={.dat,dat.json} dwebsummit-download/ dwebsummit-dat/
@rchrd2
rchrd2 / extra.plist
Created July 3, 2018 05:14
electron-packager associate with file type (support drag)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>txt</string>
@rchrd2
rchrd2 / freeway-2600.asm
Last active October 20, 2017 06:50
Honking & collision sound are redacted
; Disassembly of roms/Freeway (1981) (Activision).a26
; Disassembled Thu Oct 19 22:17:47 2017
; Using DiStella v3.01a
;
; Command Line: ./binaries/osx/distella -pafs roms/Freeway (1981) (Activision).a26
;
processor 6502
VSYNC = $00
VBLANK = $01
@rchrd2
rchrd2 / sshuttle.sh
Last active April 5, 2018 22:31
BitBar + sshuttle
#!/bin/bash
#
# Easily start/stop sshuttle
#
# <bitbar.title>sshuttle</bitbar.title>
# <bitbar.version>v1.0</bitbar.version>
# <bitbar.author>richard@archive.org</bitbar.author>
# <bitbar.author.github>rchrd2</bitbar.author.github>
# <bitbar.desc>Easily start/stop a background shhuttle.</bitbar.desc>
# <bitbar.image></bitbar.image>