Skip to content

Instantly share code, notes, and snippets.

@Munksgaard
Munksgaard / 2025_06_08_libtailscale_elixir.md
Created June 9, 2025 14:36
Your Phoenix application, directly on your Tailnet

Your Phoenix application, directly on your Tailnet

I've spent way too much time building an Elixir-wrapper for libtailscale and an accompanying chat app, because Elixir and libtailscale seem meant for each other.

I've been following Tailscale for a while now. Obviously, they're darlings of HN, their business strategy appeals to me and the product is great. I'm using it both for my personal servers and for managing

@Munksgaard
Munksgaard / phoenix-nix-tailwind.md
Created May 16, 2025 07:20
Building phoenix release using nix (the tailwind parts)

In general, follow the guides in the nixpkgs manual.

# config/config.exs
# Configure tailwind (the version is required)
config :tailwind,
  version: "3.4.12",
  # Use MIX_TAILWIND_PATH to find the tailwind binary
  path: System.get_env("MIX_TAILWIND_PATH"),
 default: [
defmodule(Math.Foo, [{:do, [@foo(3), def(foo(b), [{:do, @foo + b}]), def(add(b), [{:do, @foo + b}])]}]); alias(Math.Foo); IO.puts(Foo.add(2))
@Munksgaard
Munksgaard / flake.nix
Created February 14, 2024 18:33
elixir 1.17-dev
{
description = "elixir";
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {

Futlixir

Mix.install([
  {:nx, "~> 0.6"},
  {:exla, "~> 0.6"}
])

Nx.global_default_backend(EXLA.Backend)
# Change this according to your device
################
# Variables
################
# Date and time
date_and_week=$(date "+%Y/%m/%d (w%V)")
current_time=$(date "+%H:%M:%S")
#############
@reserved_characters ~c":/?#[]@!$&'()*+,;="
@spec is_char_reserved(byte) :: boolean
defguard is_char_reserved(character) when character in @reserved_characters
MIX_ENV=prod mix run bench.exs
Operating System: Linux
CPU Information: Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz
Number of Available Cores: 8
Available memory: 15.30 GB
Elixir 1.14.3
Erlang 25.3
Benchmark suite executing with the following configuration:
warmup: 2 s
// Generated by Futhark 0.25.0 (prerelease - include info below when reporting bugs)
// git: 6a2e6e1 (Sun Apr 30 19:03:19 2023 +0200) [modified]
// We need to define _GNU_SOURCE before
// _any_ headers files are imported to get
// the usage statistics of a thread (i.e. have RUSAGE_THREAD) on GNU/Linux
// https://manpages.courier-mta.org/htmlman2/getrusage.2.html
#ifndef _GNU_SOURCE // Avoid possible double-definition warning.
#define _GNU_SOURCE
#endif
def cap [n] (xs: [n]f64) =
map (\x -> x / f64.maximum xs) xs
def comb' [n] (delay: i64) (intensity: f64) (xs: [n]f64): [n]f64 =
loop xs = copy xs for i in delay..<n do
let xs[i] = xs[i] + intensity * xs[i - delay]
in xs
entry comb delay intensity = map (cap <-< comb' delay intensity)