Skip to content

Instantly share code, notes, and snippets.

@woylie
woylie / check_missing_translations.sh
Last active October 20, 2023 03:17
Shell script for checking gettext .po files for missing translations
#!/bin/bash
# Script generated by ChatGPT, no edits
# Example: ./check_missing_translations.sh apps/my_app_web/priv/gettext/ja
# Ensure the script is given an argument (the folder to check)
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <locale_folder>"
exit 1
fi
@woylie
woylie / list_to_typespec.ex
Last active June 29, 2023 04:17
Convert list of values to type specification in Elixir
@doc """
Converts a list of values into an AST for defining a type.
Source: https://elixirforum.com/t/dynamically-generate-typespecs-from-module-attribute-list/7078/16
## Usage
@categories [:one, :two, :three]
@type category :: unquote(list_to_typespec(@categories))
@woylie
woylie / git_horoscope.sh
Last active June 15, 2023 12:29
Generates your daily horoscope based on your Git commits of the last week using the OpenAI API
#!/bin/bash -e
# File: git_horoscope.sh
# Description: This script uses the OpenAI API to generate your daily horoscope
# based on your Git commits of the last seven days.
# Requirements:
# - https://github.com/openai/openai-python installed and in the $PATH
# - configured OpenAI API key (export OPENAI_API_KEY=abc)
# - Github CLI installed and configured
# Usage: ./git_horoscope.sh author
@woylie
woylie / .pa11yci
Created October 20, 2022 00:43
Basic pa11y-ci config
{
"defaults": {
"reporters": [
"pa11y-ci-reporter-html"
],
"runners": ["axe", "htmlcs"],
"includeNotices": false,
"includeWarnings": true,
"standard": "WCAG2AAA"
}
@woylie
woylie / repo_fetch.ex
Last active January 25, 2022 02:52
Repo.fetch
defmodule MyApp.Repo do
use Ecto.Repo,
otp_app: :my_app,
adapter: Ecto.Adapters.Postgres
alias Ecto.Queryable
alias Ecto.Schema
@doc """
Fetches a single struct from the data store where the primary key matches the
@woylie
woylie / absinthe_enums_from_ecto_enums.ex
Last active November 8, 2021 09:27
Absinthe enums from Ecto enums
@doc """
Takes a list of Ecto.Enum fields and converts them into Absinthe enum
types.
## Usage
The list consists of tuples with the name of the GraphQL enum, the Ecto schema
module and the schema field using `Ecto.Enum`.
use Absinthe.Schema.Notation
@woylie
woylie / notation.ex
Created November 14, 2020 10:58
Absinthe enum from EctoEnum
@doc """
Defines an enum in your Absinthe schema from an enum defined with `EctoEnum`.
## Example
If you defined an enum with `EctoEnum` like this:
defmodule MyApp.Enums do
import EctoEnum
### Keybase proof
I hereby claim:
* I am woylie on github.
* I am woylie (https://keybase.io/woylie) on keybase.
* I have a public key ASDwF_R5sK547hgF8evUJkY9byG-zuI6mcNnJWjX-Ew_jQo
To claim this, I am signing this object: