Skip to content

Instantly share code, notes, and snippets.

View shanesveller's full-sized avatar
💭
I may be slow to respond.

Shane Sveller shanesveller

💭
I may be slow to respond.
View GitHub Profile
@shanesveller
shanesveller / adapter_dispatch.exs
Last active August 18, 2024 17:21
Benchmark different techniques to decide a callable module at runtime
# Inspired by https://engineering.tripping.com/blazing-fast-elixir-configuration-475aca10011d
# Updated with more options, including persistent_term and process locals
Mix.install([{:benchee, "~> 1.0"}])
Application.put_env(:fast_config, :adapter, TargetModule)
:persistent_term.put({:fast_config, :adapter}, TargetModule)
defmodule TargetModule do
def run, do: :ok
@ChrisPenner
ChrisPenner / Optics Cheatsheet.md
Last active April 12, 2024 14:24
Optics Cheatsheet
@rhnonose
rhnonose / absinthe_collector.ex
Created October 18, 2019 17:57
Absinthe Collector
defmodule AbsintheCollector do
@moduledoc """
Module to collect absinthe telemetry events
"""
use Prometheus.Metric
require Prometheus.Contrib.HTTP
@events [
[:absinthe, :resolve, :field, :start],
[:absinthe, :resolve, :field],
@slashdotdash
slashdotdash / aggregate_case.ex
Last active August 8, 2019 11:47
Commanded aggregate ExUnit case template
defmodule AggregateCase do
@moduledoc """
Defines a test case to be used by aggregate tests.
"""
use ExUnit.CaseTemplate
alias Commanded.Aggregate.Multi
using opts do
@peterc
peterc / get_sizes.sql
Last active February 2, 2021 02:52
Get the size of different tables and other relations in a PostgreSQL database
SELECT
schema_name, rel_name, table_size,
pg_size_pretty(table_size) AS size
FROM (
SELECT
nspname AS schema_name,
relname AS rel_name,
pg_table_size(pg_class.oid) AS table_size
FROM pg_class, pg_namespace
WHERE pg_class.relnamespace = pg_namespace.oid

Nix Flake MVP

Goals

  • To provide Nix repositories with an easy and standard way to reference other Nix repositories.

  • To allow such references to be queried and updated automatically.

  • To provide a replacement for nix-channel, NIX_PATH and Hydra

@ejpcmac
ejpcmac / shell.nix
Last active February 12, 2024 18:03
Example shell.nix for Elixir projects using a preversion
{ pkgs ? import <nixpkgs> {} }:
with pkgs;
let
elixir_1_7_0_rc_1 = { mkDerivation }:
mkDerivation rec {
version = "1.7.0-rc.1";
# Use `nix-prefetch-github --rev <version> elixir-lang elixir` to update.
sha256 = "1hp1zdscq7h2qcgcfbzw5dx1wxy05bqlrxvv5kcl8414c69inx8g";
@edolstra
edolstra / nix-lang.md
Last active October 30, 2024 00:36
Nix language changes

This document contains some ideas for additions to the Nix language.

Motivation

The Nix package manager, Nixpkgs and NixOS currently have several problems:

  • Poor discoverability of package options. Package functions have function arguments like enableFoo, but there is no way for the Nix UI to discover them, let alone to provide programmatic ways to
@josevalim
josevalim / watcher.sh
Last active May 22, 2024 10:06
A 1LOC bash script for re-running tests whenever a lib/ or test/ file changes keeping the same VM instance
# You will need fswatch installed (available in homebrew and friends)
# The command below will run tests and wait until fswatch writes something.
# The --stale flag will only run stale entries, it requires Elixir v1.3.
fswatch lib/ test/ | mix test --stale --listen-on-stdin
@jhoblitt
jhoblitt / kubernetes.groovy
Created April 18, 2016 19:20
configuring the kubernetes jenkins plugin via groovy
import org.csanchez.jenkins.plugins.kubernetes.*
import jenkins.model.*
def j = Jenkins.getInstance()
def k = new KubernetesCloud(
'jenkins-test',
null,
'https://130.211.146.130',
'default',