This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Prisma } from "@prisma/client"; | |
import { Buffer } from "buffer"; | |
import _ from "lodash"; | |
export interface CastOptions { | |
trimStrings?: boolean; | |
} | |
export enum Types { | |
Integer, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MyAppWeb.Api.Macros do | |
@moduledoc """ | |
Not actual Absinthe middleware. | |
""" | |
use Absinthe.Schema.Notation | |
@doc """ | |
Macro to reuse the common pattern of preloading associations using | |
a batch function using `id` as the key. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Gg.Application do | |
# See https://hexdocs.pm/elixir/Application.html | |
# for more information on OTP Applications | |
@moduledoc false | |
@migrator if Mix.env() in [:prod, :staging], do: [MyApp.Migrator], else: [] | |
use Application | |
@impl true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule UnnestHelpers do | |
@doc """ | |
Converts an arbitrarily nested map of translations to a flat map | |
with all key levels combined to period-separated strings. | |
Useful when you want to convert a nested structure like Rails | |
i18n YAML translation files into a flat structure, like an Excel | |
spreadsheet. | |
## Examples |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule UnterEats.Paginatable do | |
@callback base_query() :: Ecto.Queryable.t() | |
@callback filter_by_params({atom(), term()}, Ecto.Queryable.t()) :: Ecto.Queryable.t() | |
@optional_callbacks filter_by_params: 2 | |
alias UnterEats.Repo | |
def filter_and_paginate_resource(module, params) when is_atom(module) do | |
query = module.base_query() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Implies that AWS_PROFILE and AWS_REGION are set | |
aws ecr list-images --repository-name $1 \ | |
| jq -r '.imageIds[].imageTag' \ | |
| xargs printf -- 'imageTag=%s\n' \ | |
| xargs aws ecr batch-delete-image --repository-name $1 --image-ids |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ "$1" = "" ]; then | |
echo "No input file!" | |
exit 1 | |
fi | |
cat $1 | \ | |
jq -S 'del(.compatibilities, .registeredAt, .registeredBy, .requiresAttributes, .revision, .status, .taskDefinitionArn)' | \ | |
sponge $1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
escape = fn str -> | |
str | |
|> Base.encode16() | |
|> String.replace_prefix("", "&#x") | |
|> String.replace_suffix("", ";") | |
end | |
String.replace(string, ~r/\W/, escape) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
SAMPLES_PATH="$(pwd)/samples.csv" | |
uname="$(uname)" | |
# When on Windows, you need to pass the path as c:/path/to/file | |
# rather than /c/path/to/file (as expected by PostgreSQL). | |
if [[ "$uname" != "Linux" && "$uname" != "Darwin" ]]; then | |
# remove the leading slash and replace the second slash with :/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env -S bash -e | |
if [[ "$1" = "" ]]; then | |
echo "Usage: ./calculate_time.sh FILE.csv" | |
exit 1 | |
fi | |
FILE="$(realpath $1)" | |
if [[ ! -f "$FILE" ]]; then |