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
| // testing |
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
| FROM node:8.9.0-alpine as builder | |
| RUN apk add --no-cache cmake make gcc g++ libc-dev linux-headers git | |
| RUN npm install taglib2 -g |
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
| # setup Elixir aliases | |
| export ELIXIRROOT="$HOME/elixir" | |
| if [ ! -d "$ELIXIRROOT" ]; then | |
| mkdir -p $ELIXIRROOT | |
| fi | |
| export MIXPATH="/root/.mix" | |
| export HEXPATH="/root/.hex" | |
| export ELIXIR_VOLUMES="-v ${ELIXIRROOT}/.mix:${MIXPATH} -v ${ELIXIRROOT}/.hex:${HEXPATH} --workdir /src" | |
| alias iex='docker run -it ${ELIXIR_VOLUMES} -v ${PWD}:/src --rm --network=host elixir' | |
| alias iexm='docker run -it ${ELIXIR_VOLUMES} -v ${PWD}:/src --rm --network=host elixir iex -S mix' |
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 | |
| GOPATH=$(which go) | |
| if [ -n "$GOPATH" ]; then | |
| echo "Go installed: $GOPATH" | |
| go version | |
| exit 1 | |
| fi | |
| VERSION=1.15.2 | |
| PKG_NAME="go${VERSION}.linux-amd64.tar.gz" |
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
| # .env | |
| # POSTGRES_PASSWORD= | |
| # PGADMIN_DEFAULT_EMAIL=admin@localhost | |
| # PGADMIN_DEFAULT_PASSWORD= | |
| version: "3.3" | |
| services: | |
| pgsql: | |
| image: postgres:11-alpine | |
| restart: always | |
| volumes: |
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 App.Posts do | |
| # ref. https://amandasposito.com/elixir/ecto/macro/2021/01/22/macro-ecto-custom-on-conflict.html | |
| # ref. https://elixirforum.com/t/upsert-conditional-update-e-g-update-only-when-existing-data-is-outdated/55503/2 | |
| defmacro custom_on_conflict_update_replace_all(queryable) do | |
| values = | |
| :fields | |
| |> Post.__schema__() | |
| |> Enum.map(fn f -> | |
| {f, quote(do: fragment(unquote("EXCLUDED.#{f}")))} |
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
| Finch.start_link(name: MyFinch) | |
| url = "https://horizon.stellar.org/accounts/GAFNBDOZBFUKHB4ZY5ANCQ25PM33YLTMWQKW25J7LXNZM3YSHRH3BELY/transactions?limit=200&cursor=119456526699307008&include_failed=true" | |
| Finch.build(:get, url, [{"Accept", "text/event-stream"}]) | |
| |> Finch.stream(MyFinch, nil, fn | |
| {:status, status}, _acc -> | |
| IO.inspect(status) | |
| {:headers, headers}, _acc -> | |
| IO.inspect(headers) |
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
| SELECT pg_terminate_backend(pg_stat_activity.pid) | |
| FROM pg_stat_activity | |
| WHERE pg_stat_activity.datname = 'TARGET_DB' | |
| AND pid <> pg_backend_pid(); |
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
| # user <1---*> playlist <1---*> playlist_song | |
| (from p in Playlist, | |
| join: u in assoc(p, :user), | |
| left_join: ps in assoc(p, :songs), | |
| where: p.id == ^1 and u.id == ^1, | |
| group_by: p.id, | |
| select: %{ | |
| playlist_id: p.id, | |
| song_count: count(ps.id) | |
| } |
OlderNewer