Skip to content

Instantly share code, notes, and snippets.

@socketteer
socketteer / base_chat.py
Last active January 3, 2025 19:06
external_store
import anthropic
import sys
import os
import argparse
client = anthropic.Anthropic() # Will use ANTHROPIC_API_KEY from environment
DEFAULT_STORAGE_FILE = "/tmp/gist_files/continuation.txt"
def get_continuation(text):
@FeepingCreature
FeepingCreature / sonnet_is_fun.md
Created November 11, 2024 09:37
How to include sections from another Markdown file with Ruby (with AI)

Today at dayjob, my architect: "You should update the README as well. You know, I don't like having all the library environment variables copied into the service README. Can you just link to the submodule?"

Me, actually quite liking that all the variables are right there in the service README: "I wish there was an include directive for markdown."

Me, having access to Sonnet API via OpenRouter: "How hard is ad-hoc Markdown parsing anyway?"

"Hey Sonnet, can you..."

Hi! Need your help with a ruby/rake tool. I'm trying to ensure that my README includes environment variable snippets that are consistent with the submodules the service pulls in. Those have their own READMEs documenting their respective environment variables. So my idea is to throw in a very simple ruby markdown parser that just splits the file at sections (lines starting with #) and include directives (lines of the form [//] # (include path#section) and then just ensures that the text following the include directive matches the section in

@NoteAfterNote
NoteAfterNote / note-after-note-2024-may-19-termux-usbredirect-qemu.md
Last active January 7, 2025 11:16
Reading and writing a USB drive connected to a Linux server using Termux, termux-usb, usbredirect, and QEMU on a smartphone that is not rooted
@ctsrc
ctsrc / 00_install_fbsd_14_1_hetzner.md
Last active January 11, 2025 15:36
Install FreeBSD 14.1 on Hetzner

Install FreeBSD 14.1 on Hetzner server

Hetzner no longer offers direct install of FreeBSD, but we can do it ourselves. Here is how :)

Boot the server into rescue mode

Boot the Hetzner server in Hetzner Debian based rescue mode. ssh into it.

The Hetzner rescue image will tell you hardware details about the server in the login banner. For example, with one of my servers I see:

It appears that rasengan (Andrew Lee) of Private Internet Access believes that ownership of the company Freenode Ltd. gives him the right to unilaterally replace the current staff team.

We may have had our disagreements with staff, but freenode being run by a volunteer team, using servers provided by sponsors, is a key reason that we appreciate freenode.

As such, we do not believe that such a unilateral replacement by a corporate interest is appropriate.

If this attemped takeover by Andrew Lee continues, we will be advocating to move our communities elsewhere.

Context: Fuchs' leaked (not by him) draft resignation letter that caused Andrew Lee to come onto #freenode: https://fuchsnet.ch/privat/fn-resign-letter.txt

@m-radzikowski
m-radzikowski / script-template.sh
Last active January 13, 2025 20:14
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@cesarandreu
cesarandreu / sensible-defaults.css
Created June 2, 2018 10:04
Sensible css defaults taken from css-layout
div, span {
box-sizing: border-box;
position: relative;
display: flex;
flex-direction: column;
align-items: stretch;
flex-shrink: 0;
align-content: flex-start;
@bsedat
bsedat / Dockerfile
Last active August 8, 2023 05:56
Elixir Phoenix Umbrella App + Distillery Multistage Docker Build
FROM elixir:1.4.5 as asset-builder-mix-getter
ENV HOME=/opt/app
RUN mix do local.hex --force, local.rebar --force
# Cache elixir deps
COPY config/ $HOME/config/
COPY mix.exs mix.lock $HOME/
COPY apps/myproject_web/mix.exs $HOME/apps/myproject_web/
COPY apps/myproject_web/config/ $HOME/apps/myproject_web/config/
@maxwelleite
maxwelleite / ttf-ms-tahoma-installer.sh
Last active November 26, 2024 16:33
Script to install the original Microsoft Tahoma font on Ubuntu distros
#!/bin/bash
# Author: Maxwel Leite
# Website: http://needforbits.wordpress.com/
# Description: Script to install the original Microsoft Tahoma Regular and MS Tahoma Bold (both version 2.60) on Ubuntu distros.
# Dependencies: wget and cabextract
# Tested: Ubuntu Saucy/Trusty/Xenial/Bionic
output_dir="/usr/share/fonts/truetype/msttcorefonts/"
tmp_dir="/tmp/ttf-ms-tahoma-installer"
@antirez
antirez / lmdb.tcl
Created April 28, 2017 15:40
LMDB -- First version of Redis written in Tcl
# LVDB - LLOOGG Memory DB
# Copyriht (C) 2009 Salvatore Sanfilippo <antirez@gmail.com>
# All Rights Reserved
# TODO
# - cron with cleanup of timedout clients, automatic dump
# - the dump should use array startsearch to write it line by line
# and may just use gets to read element by element and load the whole state.
# - 'help','stopserver','saveandstopserver','save','load','reset','keys' commands.
# - ttl with milliseconds resolution 'ttl a 1000'. Check ttl in dump!