Skip to content

Instantly share code, notes, and snippets.

@ryankennedy
ryankennedy / 00_README.md
Last active December 12, 2024 19:57
How to macOS sandbox a Go application

Sandboxing a Go program in macOS

This sample Go file shows how to use sandbox_init on macOS (now deprecated, but it still works) to prevent a Go application from accessing the network beyond localhost.

@raidendotai
raidendotai / vectorsearch.html
Last active March 12, 2025 06:35
In-browser, local vector similarity search, powered by pglite
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Semantic Search Demo</title>
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css"
rel="stylesheet"
/>
@lambrospetrou
lambrospetrou / deploy-ssh.sh
Created September 6, 2024 07:06
Simple deployment on a VPS, Hetzner, EC2 with zero downtime. Uses Caddy and systemd.
#!/usr/bin/env bash
# Inspired from:
# - https://blog.wesleyac.com/posts/simple-deploy-script
# - https://gist.github.com/WesleyAC/b3aaa0292579158ad566c140415c875d
# - https://caddyserver.com/docs/running#using-the-service
set -e
# cd $(dirname $0)
@mhart
mhart / functions-index.js
Last active June 26, 2024 02:42
PPR w/ CF Pages and HTMLRewriter
// functions/index.js
export async function onRequestGet({ request, env }) {
// Start getting something from "the DB"
const dbPromise = scheduler.wait(1000).then(() => new Date().toDateString());
// Fetch index.html from cache (body will stream below)
const staticShell = await env.ASSETS.fetch(request);
// The browser will immediately render up until the body closing tag,
// then we insert dom modification scripts as the data is resolved
#!/usr/bin/env bash
# Abort sign off on any error
set -e
# Start the benchmark timer
SECONDS=0
# Repository introspection
OWNER=$(gh repo view --json owner --jq .owner.login)
@boooeee
boooeee / team_ranking_example.R
Last active March 3, 2024 18:00
This code derives a schedule/home field adjusted team ranking for a randomly generated set of games. The randomly generated games can be replaced with actual teams and outcomes from the sport of our choice.
library(tidyverse)
n_games <- 100
# Define the teams
teams <- c("rock", "paper", "scissors")
# simulated home advantage #
home_adv<-2
# Generate the data frame
@rcrowley
rcrowley / example.tf
Created February 15, 2024 17:56
The simplest custom internal tool, protected by the Substrate Intranet, BYO functionality
data "archive_file" "example" {
output_file_mode = "0666" # before umask
output_path = "${path.module}/example.zip"
source_file = "${path.module}/example/index.js"
type = "zip"
}
data "aws_apigatewayv2_apis" "substrate" {
name = "Substrate"
protocol_type = "HTTP"
@surma
surma / .gitignore
Created February 1, 2023 15:48
Wasm GC
*.wasm
# Rails production setup via SQLite3 made durable by https://litestream.io/
# Copy this to Dockerfile on a fresh rails app. Deploy to fly.io or any other container engine.
#
# try locally: docker build . -t rails && docker run -p3000:3000 -it rails
#
# in production you might want to map /data to somewhere on the host,
# but you don't have to!
#
FROM ruby:3.0.2
@tgross
tgross / vmctl
Created July 27, 2021 19:27
Fircracker virtual machine control script
#!/usr/bin/env bash
set -euo pipefail
help() {
cat <<EOF
vmctl [COMMAND] [ARGS]
Launch firecracker VMs from configuration templates with networks
managed by CNI. VM configuration is stored in $VM_CONFIG_DIR
and network configuration is stored in $NET_CONFIG_DIR