This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| name: organize-file | |
| description: Organize or structurally refactor an existing Swift source file for clarity without changing behavior, with limited support for Objective-C files. Use when asked to tidy, reorder, group, section, or reorganize a file; move private implementation below its visible API; or assess whether cohesive responsibilities should be extracted into separate files. | |
| --- | |
| # Organize File | |
| Reorganize structure, not behavior. Preserve the file's public contract and keep the diff easy to verify. | |
| ## Workflow |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import argparse | |
| import json | |
| import os | |
| import re | |
| import sqlite3 | |
| import sys | |
| from dataclasses import dataclass | |
| from datetime import datetime | |
| from pathlib import Path |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/zsh | |
| set -euo pipefail | |
| SCRIPT_NAME="$(basename "$0")" | |
| usage() { | |
| cat <<EOF | |
| Usage: | |
| sudo $SCRIPT_NAME start |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/zsh | |
| set -euo pipefail | |
| SCRIPT_NAME="$(basename "$0")" | |
| usage() { | |
| cat <<EOF | |
| Usage: | |
| sudo $SCRIPT_NAME start |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Dan's Focus Hack | |
| // @namespace http://tampermonkey.net/ | |
| // @version 2024-06-19 | |
| // @description try to take over the world! | |
| // @author You | |
| // @match https://chatgpt.com/* | |
| // @icon https://www.google.com/s2/favicons?sz=64&domain=chatgpt.com | |
| // @grant none | |
| // @downloadURL Find me at https://gist.github.com/drosenstark/713b8e22f9692405b46e973d9bc5246c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| # | |
| # Make255Values-RolandNibbleEncoding | |
| # See https://mididesigner.com/qa/10040/roland-tr-8s-sysex-whats-what for what's what | |
| import csv | |
| # Convert decimal value to MSB and LSB hexadecimal values | |
| def to_msb_lsb(value): | |
| msb = value // 16 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*! | |
| * -------------------------------------------------------------------------- | |
| * CSS Style Sheet by Dan Rosenstark | |
| * -------------------------------------------------------------------------- | |
| * | |
| * Author: Dan Rosenstark | |
| * Gist URL: https://gist.github.com/drosenstark/2f505257df4c71f64cccb79aeda87746 | |
| * | |
| * Description: | |
| * This CSS file is designed to enhance and customize the appearance of web pages. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import os | |
| import json | |
| import re | |
| import fnmatch | |
| from pathlib import Path | |
| ##################### |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // thanks to this thing! | |
| // https://www.macstories.net/ios/fs-bookmarks-a-shortcut-to-reopen-files-and-folders-directly-in-the-files-app/ | |
| extension URL { | |
| func openParentDirectoryInFilesApp() { | |
| guard var components = URLComponents(url: self.deletingLastPathComponent(), resolvingAgainstBaseURL: false) else { return } | |
| components.scheme = "shareddocuments" | |
| guard let newURL = components.url else { return } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| /* | |
| * Prompt: | |
| * I want a Swift object that will sit on an object (let's call that object A) which will allow other objects (B, C, D) to subscribe to changes in A on a certain variable. | |
| * | |
| * So the Swift class/object that you're making allows subscribers to provide a block to be executed based on the changes in that variable. The variable could be a Bool, but if you have to box it as an NSNumber, that's fine. | |
| * | |
| * Response: | |
| * You can achieve this behavior in Swift using a closure (or block in Objective-C terminology) for notifying changes. Here's a simple example with a Publisher class that wraps an object and allows other classes to subscribe for changes: |
NewerOlder