Skip to content

Instantly share code, notes, and snippets.

View zachallaun's full-sized avatar

Zach Allaun zachallaun

View GitHub Profile
@zachallaun
zachallaun / scratch.exs
Created September 23, 2023 18:45
CubDB Query helpers
Mix.install([
{:cubdb, "~> 2.0"}
])
{:ok, _} = CubDB.start_link(data_dir: "./cubdb", name: DB)
defmodule CubQuery do
@moduledoc """
Key and query utilities for CubDB
"""
Mix.install([
{:finch, path: "./finch"},
{:benchee, "~> 1.1.0"},
{:bandit, "~> 1.0.0-pre.5"},
{:plug, "~> 1.14.2"}
])
defmodule PlugServer do
import Plug.Conn
@zachallaun
zachallaun / req_stream.livemd
Last active April 23, 2023 20:48
Livebook notebook demonstrating how streaming responses might be implemented

Req Stream

local_req = Path.expand("~/dev/req")

Mix.install([
  {:req, path: local_req}
])
@zachallaun
zachallaun / graphing_example.livemd
Created April 16, 2023 18:41
Graphing example using Livebook and Kino.VegaLite

Graphing Example

Mix.install([
  {:kino_vega_lite, "~> 0.1.8"}
])

alias VegaLite, as: Vl
@zachallaun
zachallaun / open.sh
Created April 14, 2023 15:52
WSL: Open file in browser
# Usage: open some_file.html
# Open a file in browser
function open () {
explorer.exe $(wslpath -w $(realpath $1))
return 0
}
@zachallaun
zachallaun / wireguard_tailscale_wsl2.md
Last active February 2, 2023 15:20
Fixing Wireguard/Tailscale on WSL2

The default eth0 network interface on WSL2 has an MTU of 1280, which isn't sufficient for large packets sent over the Wireguard protocol.

You can confirm the issue by running ip a and seeing that the MTU of the eth0 interface is 1280.

To fix this, you need to set the MTU of the eth0 interface to 1500. This has to be done every time WSL starts.

Edit /etc/wsl.conf to include:

[boot]
@zachallaun
zachallaun / 0_rap_janus.md
Last active December 18, 2022 21:58
Implementation of an RAP system using the Janus library

RAP System using Janus

Update 12/18/22: "Part 2" notes/changes added at the bottom.

Based on this post by Peter Ullrich, adapted to use the experimental Janus authorization library.

Context

I've been working on an experimental authorization library over the last few days, and so was pleasantly surprised when Peter posted about building a Role and Permission System. I jumped at the opportunity to see how Janus could "slot in" to the architecture that he presented.

Kino.Process - Non-started Processes

Mix.install([
  # {:kino, "~> 0.6.2", override: true}
  {:kino, path: "./", override: true}
])
@zachallaun
zachallaun / autoplay.ex
Last active August 3, 2022 01:03
Code sketch: media player statechart for LiveBeats
defmodule MediaPlayer.AutoplayNext do
@moduledoc """
Helper statechart used to check whether the song is ending and communicate back to
the parent.
"""
use Protean
alias Protean.Action
alias LiveBeats.MediaLibrary

Keycult Raffle Info, Tips & Troubleshooting

Starting in August 2020, Keycult is using a new raffle system integrated with our Discord chat server. Important links:

The purpose of this document is to answer common questions and provide useful troubleshooting tips to those who might be having trouble.

General raffle rules