Skip to content

Instantly share code, notes, and snippets.

@dbernheisel
dbernheisel / scrape-owned-nintendo-ps-games.js
Created September 7, 2025 18:11
Scrape your owned Nintendo and Playstation games
// Copy and paste when browsing your collection
// https://www.nintendo.com/us/orders/
// https://library.playstation.com/recently-purchased/1
//
// A textarea will be appended to the page that will have a list of your games
// ready for copy/paste into a spreadsheet program; the columns are:
// Title, System, isPhysical, isDigital, isReproduction, isSubscriptionOnly
// isSubscriptionOnly may not be accurate, because you may also own it physically, but it also is availble on Playstation Plus.
// isReproduction is always false
// isPhysical is always false
@dbernheisel
dbernheisel / otel_process_propagator_wrapper_check.ex
Created July 7, 2025 19:38
OpentelemetryProcessPropagator credo check
defmodule MyApp.Checks.OtelTaskPropagator do
use Credo.Check,
base_priority: :high,
category: :warning,
explanations: [
check:
"Prefer OpentelemetryProcessPropagator wrappers of `Task` and `Task.Supervisor` so that telemetry tracing can correlate these spawned processes"
]
@impl Credo.Check
@dbernheisel
dbernheisel / req_wrapper.ex
Last active November 18, 2023 13:43
Req adapter that raises while in MIX_ENV=test
defmodule MyApp.Req do
@moduledoc """
Wrapper around Req to apply defaults. See [Req](https://hexdocs.pm/req)
This will also protect from external requests running while MIX_ENV=test.
To set the adapter in controller or integration tests, you may configure
your mock with `Process.put(:req_adapter, my_mock)`.
You must specify `external_service` and `request_name` telemetry tags
@dbernheisel
dbernheisel / earmark-for-with-mermaid.ex
Last active August 22, 2023 17:28
How to handle switching themes in Mermaid
# keep the src around for mermaid for re-renders.
def maybe_rewrite_mermaid(
{"pre", _attrs, [{"code", [{"class", "mermaid"}], inner, meta}], pre_meta}
) do
{"div",
[
{"phx-update", "ignore"}
],
[
@dbernheisel
dbernheisel / footer.html.heex
Last active November 2, 2022 02:16
Theme Chooser in Phoenix and JavaScript
@dbernheisel
dbernheisel / fzf-mix.vim
Created February 23, 2022 17:57
Use fzf.vim to fuzzy-find available mix commands
function! g:MixRun(selection) abort
if !empty(a:selection)
execute "!mix ".a:selection
endif
endfunction
function! g:MixFzf(selection = '') abort
if empty(a:selection)
call fzf#run(fzf#wrap({
\ 'source': 'mix help --names',
@dbernheisel
dbernheisel / rename_phx.sh
Last active February 14, 2021 06:58
Rename a Phoenix project
export FROM="petal"
export FROM_MOD="Petal"
export TO="elixir_stream"
export TO_MOD="ElixirStream"
cp -R "$FROM" "$TO"
cd "$TO"
git ls-files -z | xargs -0 perl -p -i -e "s/$FROM/$TO/g; s/$FROM_MOD/$TO_MOD/g;"
mv "lib/${FROM}" "lib/$TO"
mv "lib/${FROM}.ex" "lib/${TO}.ex"
@dbernheisel
dbernheisel / default.pa
Created October 20, 2020 14:48
Pulseaudio Focusrite 6i6 config
# Put this at the bottom
## Remap Scarlett input 1 separately
load-module module-remap-source source_name=scarlett-xlr-1 source_properties="device.description='Focusrite Scarlett 6i6 XLR 1'" master=alsa_input.usb-Focusrite_Scarlett_6i6_USB_00074100-00.multichannel-input remix=no channels=2 master_channel_map=front-left,front-left channel_map=left,right
### Remap Scarlett input 2 separately
load-module module-remap-source source_name=scarlett-xlr-2 source_properties="device.description='Focusrite Scarlett 6i6 XLR 2'" master=alsa_input.usb-Focusrite_Scarlett_6i6_USB_00074100-00.multichannel-input remix=no channels=2 master_channel_map=front-right,front-right channel_map=left,right
### Remap Scarlett inputs 3&4 separately
load-module module-remap-source source_name=scarlett-inputs-3-4 source_properties="device.description='Focusrite Scarlett 6i6 3/4'" master=alsa_input.usb-Focusrite_Scarlett_6i6_USB_00074100-00.multichannel-input remix=no channels=2 master_channel_map=front-center,lfe channel_map=left,right
@dbernheisel
dbernheisel / employer-test.md
Created February 24, 2020 14:37
Employer Test

employer-test

A list of questions to ask potential employers.

Work Style

Ownership

  • Does one single person own a unit of work (task, project, product, etc)?
  • Can that single person's manager override the decisions made by that person on that unit of work?
@dbernheisel
dbernheisel / mass-expire-redis.sh
Last active October 8, 2019 17:34
Expire redis keys en-masse
#!/bin/bash
# Mass expire Redis keys using the SCAN command so it doesn't block or overwhelm
# memory
# Usage example: ./mass-expire-redis.sh "127.0.0.1" "6379" "mykey:*" "300"
# Logs to ./filename.ext.log
if [ $# -ne 4 ]; then
echo "Usage: $0 <host> <port> <pattern> <expiration>"
exit 1