Skip to content

Instantly share code, notes, and snippets.

@jalberto
jalberto / cf-ddns.sh
Created December 9, 2022 15:48
Cloudflare dyn DNS updater with curl & jq
AUTH_KEY='CF AUTH TOKEN KEY'
EMAIL_ADDRESS='CF email'
DNS_ZONE_NAME='domain.name'
DNS_RECORD_NAME="hola.domain.name"
DNS_ZONE=$(curl -sX GET "https://api.cloudflare.com/client/v4/zones?name=${DNS_ZONE_NAME}" -H "Content-Type:application/json" -H "Authorization:Bearer ${AUTH_KEY}" -H "X-Auth-Email:${EMAIL_ADDRESS}" | jq -r '.result[0].id')
DNS_RECORD=$(curl -sX GET "https://api.cloudflare.com/client/v4/zones/${DNS_ZONE}/dns_records?name=${DNS_RECORD_NAME}" -H "Content-Type:application/json" -H "Authorization:Bearer ${AUTH_KEY}" -H "X-Auth-Email:${EMAIL_ADDRESS}" | jq -r '.result[0].id')
CURRENT_DNS_VALUE=$(curl -sX GET "https://api.cloudflare.com/client/v4/zones/${DNS_ZONE}/dns_records/${DNS_RECORD}" -H "Content-Type:application/json" -H "Authorization:Bearer ${AUTH_KEY}" -H "X-Auth-Email:${EMAIL_ADDRESS}" | jq '.result["content"]')
CURRENT_IP_ADDRESS=$(curl -s ip.me)
@jalberto
jalberto / Dockerfile
Last active April 27, 2020 17:40
Elixir & Phoenix on Docker for development
FROM elixir:1.10
ENV \
PHX_VER=1.5.1 \
NODE_VER=12.x \
APP=/app HOME=/app \
PKGS="inotify-tools postgresql-client git"
RUN groupadd -g 1000 appuser \
&& useradd -r -u 1000 -g appuser appuser \
@jalberto
jalberto / map_utils.ex
Created November 21, 2018 10:04
Small util to transform Map keys into atoms or strings
defmodule MyApp.MapUtils do
@doc ~S"""
Transform keys in a Map to atoms
## Examples
iex> MyApp.Maputils.map_keys_to_atoms(%{"foo" => 1, "bar" => %{foo2: "2"}})
{bar: %{foo2: "2"}, foo: 1}
"""
def map_keys_to_atoms(map) when is_map(map) do
@jalberto
jalberto / grafana-memcached-pod.json
Created October 30, 2018 15:20
GRafana dashboard for memcached
{
"__inputs": [
{
"name": "DS_PROMETHEUS",
"label": "prometheus",
"description": "",
"type": "datasource",
"pluginId": "prometheus",
"pluginName": "Prometheus"
}
@jalberto
jalberto / grafana-pgbouncer-overview.json
Last active November 1, 2018 11:09
Grafana dashboard for pgbouncer (https://github.com/jbub/pgbouncer_exporter) (grafana ID #8711)
{
"__inputs": [
{
"name": "DS_PROMETHEUS",
"label": "prometheus",
"description": "",
"type": "datasource",
"pluginId": "prometheus",
"pluginName": "Prometheus"
}
@jalberto
jalberto / reindex.sh
Created August 30, 2018 13:29
Elasticsearch Reindex example
#!/bin/bash
SRC="http://foo:9200"
DST="http://localhost:9200"
curl -X POST "$DST/_reindex?pretty" -H 'Content-Type: application/json' -d'
{
"source": {
"remote": {
"host": "http://foo:9200"
#!/bin/sh
# Install Azure File Storage in a docker swarm from master
DRV_VER="v0.5.1"
AZURE_ACCOUNT="myaccount"
AZURE_KEY="mykey"
install_driver () {
sudo apt-get install -q -y cifs-utils
wget -q https://github.com/Azure/azurefile-dockervolumedriver/releases/download/${DRV_VER}/azurefile-dockervolumedriver
@jalberto
jalberto / shrc
Created August 31, 2017 09:35
Run azure cli using docker
az () {
docker run -v ${HOME}/.ssh:/root/.ssh azuresdk/azure-cli-python:latest az "$@"
}

Keybase proof

I hereby claim:

  • I am jalberto on github.
  • I am jasl (https://keybase.io/jasl) on keybase.
  • I have a public key whose fingerprint is 289E B9CE 63A1 8F8D C546 DA05 FA07 E62A 9716 EDDE

To claim this, I am signing this object:

@jalberto
jalberto / terminator_config
Created October 3, 2015 18:03
Terminator configuration. F12 to show/hide ~/.config/terminator/config
[global_config]
focus = mouse
suppress_multiple_term_dialog = True
title_transmit_bg_color = "#ffad00"
dbus = True
enabled_plugins = LaunchpadCodeURLHandler, APTURLHandler, LaunchpadBugURLHandler
always_on_top = True
tab_position = bottom
sticky = True
[keybindings]