Skip to content

Instantly share code, notes, and snippets.

## put this file in ~
[working-directory: '/Users/frenata/src/nix-darwin-config']
rebuild:
darwin-rebuild switch --flake .#roar
@frenata
frenata / evil.py
Created December 12, 2024 15:19
abuse python decorators + default mutable args
import functools
import datetime as dt
def capture():
def decorator(func):
@functools.wraps(func)
def wrapper(*args, ctx=[], **kwargs):
if len(ctx) > 0:
print(f"this function was last called at {ctx[-1][0]}")
ctx.append((dt.datetime.now(), args, kwargs))
@frenata
frenata / Justfile-for-docker.md
Created November 27, 2024 02:07 — forked from fdmysterious/Justfile-for-docker.md
Justfile for docker

Justfile for docker

This gist shows how to use the just command runner for a docker based project. The trick is to give the ability to call the recipes inside or outside the container, making it compatible for example with pipelines, or Devcontainers.

image_name := env_var_or_default("IMAGE_NAME", "buildenv:componentTesting")

# https://stackoverflow.com/questions/23513045/how-to-check-if-a-process-is-running-inside-docker-container
@frenata
frenata / Alacritty.command
Last active January 8, 2024 21:12
OSX reset nix commands
# ~/Desktop/Alacritty.command
~/reset-nix.sh
alacritty &
exit
# ~/.config/nixpkgs/config.nix
# use like: nix-env -iA nixpkgs.tools
{
packageOverrides = pkgs: with pkgs; {
tools = pkgs.buildEnv {
name = "standard";
paths = [
httpie
tmux
@frenata
frenata / .cshrc
Last active October 19, 2023 14:14
freebsd setup
eval `ssh-agent`
-- 0. create and install OpenBSD on QEMU
host$ qemu-img create openbsd.img 10G
host$ qemu-system-x86_64.exe -hda .\openbsd.img -boot d -cdrom .\<BSD_INSTALL_IMG>.iso -m 1024
bsd$ <INSTALL BSD AND THEN HALT>
host$ qemu-system-x86_64.exe -drive file=openbsd.img,if=virtio,format=raw -boot c -m 1024 -net nic -net user,hostfwd=tcp::2222-:22 -nographic -monitor telnet::45454,server,nowait -serial mon:stdio
host$ ssh <USER>@localhost -p 2222
-- 1. configure doas
bsd$ su
bsd# echo permit :wheel > /etc/doas.conf
@frenata
frenata / allowlist
Last active January 5, 2023 19:27
blocklist bypass
twitter
twimg
linkedin
licdn
t.co
__foo = None
class Foo:
def __init__(self, x):
self.x = x
def init_global_foo(x):
global __foo
__foo = Foo(x)
@frenata
frenata / with_handlers.yaml
Last active April 1, 2022 20:09
conditionally restart systemd unit files via ansible, two styles
tasks:
- name: specify a systemd unit file
become: true
copy:
src: foo.service
dest: /etc/systemd/system
notify: restart foo
- name: enable the systemd unit file
become: true