Skip to content

Instantly share code, notes, and snippets.

#! /usr/bin/env bash
# Script to install NixOS from the Hetzner Cloud NixOS bootable ISO image.
# (tested with Hetzner's `NixOS 20.03 (amd64/minimal)` ISO image).
#
# This script wipes the disk of the server!
#
# Instructions:
#
# 1. Mount the above mentioned ISO image from the Hetzner Cloud GUI
#!/bin/bash
name=$1
cluster=$2
td_json=$(aws ecs describe-task-definition --task-definition ${cluster}-${name} | jq 'map({family, networkMode, containerDefinitions, volumes})' | jq '.[0]')
aws ecs register-task-definition --cli-input-json $td_json
aws ecs update-service --service ${cluster}-${name} --task-definition ${cluster}-${name} --region eu-west-1 --cluster ${cluster}
defmacro defbang({ name, _, args }) do
unless args |> is_list do
args = []
end
quote bind_quoted: [name: Macro.escape(name), args: Macro.escape(args)] do
def unquote(to_string(name) <> "!" |> String.to_atom)(unquote_splicing(args)) do
case unquote(name)(unquote_splicing(args)) do
:ok ->
:ok
@Reimerei
Reimerei / gist:9e3bf2a00b3f57e7184d
Last active October 23, 2015 09:35
Postgres jsonb: remove key from all entries
# Function
CREATE FUNCTION jsonb_merge(JSONB, JSONB)
RETURNS JSONB AS $$
WITH json_union AS (
SELECT * FROM JSONB_EACH($1)
UNION ALL
SELECT * FROM JSONB_EACH($2)
) SELECT JSON_OBJECT_AGG(key, value)::JSONB FROM json_union;
$$ LANGUAGE SQL;
@Reimerei
Reimerei / gist:16c654ae83dca9993014
Last active August 29, 2015 14:23
Profiling Exlixir

get fproxf

https://github.com/talko/fprofx

compile fproxf

erlc src/fprofx.erl

copy beam file to project

path: _build/dev/lib/fprofx/ebin/

open project console

iex -S mix

profile a function

  • :fprofx.apply(SBS, :config, ["fooo"], [{:procs, :erlang.processes -- [:erlang.whereis(:fprofx_server)]}])