Skip to content

Instantly share code, notes, and snippets.

defmodule Task do
defp await_one(tasks, timeout \\ 5_000) when is_list(tasks) do
awaiting =
Map.new(tasks, fn %Task{ref: ref, owner: owner} = task ->
if owner != self() do
raise ArgumentError, invalid_owner_error(task)
end
{ref, true}
end)
@thmsmlr
thmsmlr / elixir-coding-guidelines.mdc
Created May 25, 2025 15:05
My cursorrules for elixir coding styles
When writing Elixir code, perfer the following style guidlines:
1. Elixir developers tend to create many small functions in their modules. I DO NOT LIKE THIS. Instead create functions that fully capture a conceptual task, even if it makes that function longer. A good rule of thumb is, if a private function is only called once within a module, it should've been inlined.
For example:
DON'T DO THIS:
```elixir
@steipete
steipete / terminator.scpt
Last active May 22, 2025 08:21
Hasta la *vista, shell — the T-800 that babysits (and occasionally obliterates) your Terminal tabs. Built to kill hung jobs, not humans. Helps Cursor to keep the loop! Copy this into .cursor/scripts/terminator.scpt (or similar) and point Cursor/Windsurf to that file and prompt it with the comment below.
Moved to https://github.com/steipete/Terminator
@thmsmlr
thmsmlr / wait_for.ex
Created December 26, 2024 21:20
ExUnit helper function to wait up to a timeout to determine whether a set of assertions completes. Perfect for testing async code
@default_timeout 100
@check_interval 10
# Test Helpers
defp wait_for(fun, timeout \\ @default_timeout) do
start_time = System.monotonic_time(:millisecond)
ref = make_ref()
try do
Mix.install(
[
{:phoenix_playground, "~> 0.1.0"},
{:openai, "~> 0.6.1"},
{:makeup, "~> 1.1.2"},
{:makeup_elixir, "~> 0.14"}
],
config: [
openai: [
api_key: System.get_env("OPENAI_API_KEY"),
@nyku
nyku / resize_convert.sh
Last active August 1, 2024 22:38
Resize & Convert image -> webp
#!/bin/bash
# Usage:
# ./resize_and_convert.sh ~/Desktop/folder-with-images
# Check if the correct number of arguments is provided
if [ "$#" -ne 1 ]; then
echo "Usage: $0 source_path"
exit 1
fi
@aeons
aeons / config.exs
Last active April 1, 2025 00:33
Erlang 27 :json module in Phoenix
config :phoenix, :json_library, ErlJson
@rsms
rsms / macos-distribution.md
Last active June 8, 2025 23:21
macOS distribution — code signing, notarization, quarantine, distribution vehicles
#!/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)

LiveView Forms

Application.put_env(:sample, Example.Endpoint,
  http: [ip: {127, 0, 0, 1}, port: 5001],
  server: true,
  live_view: [signing_salt: "aaaaaaaa"],
  secret_key_base: String.duplicate("a", 64)
)