Write a program that connects to a Postgres database and stores contact information in a table.
Sample input:
$ go run .
First name: John
Last name: Smith
#!/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 |
#!/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 :/ |
escape = fn str -> | |
str | |
|> Base.encode16() | |
|> String.replace_prefix("", "&#x") | |
|> String.replace_suffix("", ";") | |
end | |
String.replace(string, ~r/\W/, escape) |
#!/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 |
#!/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 |
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() |
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 |
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 |
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. |