Skip to content

Instantly share code, notes, and snippets.

@fragmede
fragmede / threader.py
Created August 14, 2016 17:20
basic threading example
import threading
import time
class Continuous(threading.Thread):
def __init__(self):
super(Continuous, self).__init__()
self.die = False
self.info = 0
def run(self):
from diffusers import StableDiffusionPipeline
pipe = StableDiffusionPipeline.from_pretrained(
"CompVis/stable-diffusion-v1-4",
use_auth_token=True
).to("mps")
prompt = "a photo of an astronaut riding a horse on mars"
image = pipe(prompt)["sample"][0]
image.save("astronaut_rides_horse.png")
@fragmede
fragmede / init.lua
Created April 18, 2023 11:28
Hammerspoon script that creates a new Space/virtual desktop and sticks a new Chrome window into it with ⌘⌃⌥N
-- Grab the ID for the last desktop, which is assumed to be the most recently create one
function getLargestDesktopKey()
rawSpaceNames = hs.spaces.missionControlSpaceNames()
for key, value in pairs(rawSpaceNames) do
uuid = key
end
spaceNames = rawSpaceNames[uuid]
for _, nested_table in pairs(rawSpaceNames) do
for __, value in pairs(nested_table) do
local desktopNum = string.match(value, "Desktop (%d+)")
@fragmede
fragmede / AGENTS.md
Last active December 19, 2025 21:07
Simple agents.md for codex to commit to git, save as ~/.codex/AGENTS.md

Important Instructions

ALWAYS commit changes to git after completing any task. After making any code changes, modifications, or additions, run:

# If not in a git repository, initialize it first:
git init

# Then commit changes:
git add .
git commit -m "Description of changes"
@fragmede
fragmede / rm
Last active December 23, 2025 01:25
save this as rm, make it executable, and put it somewhere that's earlier in your PATH than /bin/rm
#!/usr/bin/env sh
# save this as rm, make it executable, and put it
# in a directory that your user can't write to,
# and is earlier in your PATH than /bin.
# But don't just put it in ~/bin and move that up
# in your path. That means an attacker could manage to
# put a file called sudo in ~/bin/ and you'd give it your
# password and the attacker could turn around and elevate
# privileges = bad. :(