Skip to content

Instantly share code, notes, and snippets.

View seeekr's full-sized avatar

Denis Andrejew seeekr

  • productioneer.io
  • Austria
View GitHub Profile
@seeekr
seeekr / docker_task.sh
Created April 27, 2019 12:53
run one off tasks in a docker swarm context
#!/usr/bin/env bash
set -euo pipefail
svc=$1
replicas () {
docker service ls -f name=$svc --format '{{.Replicas}}'
}
@seeekr
seeekr / docker_exec.sh
Created April 27, 2019 11:46
`docker exec -it` equivalent in multi-node Docker Swarm context
#!/usr/bin/env bash
docker_containerinfo() {
local taskid=$(docker service ps -f desired-state=running -q $1)
[[ -n "$taskid" ]] || { echo "no running task for service $1" >&2; return 1; }
local containerinfo=($(docker inspect --format '{{.NodeID}} {{.Status.ContainerStatus.ContainerID}}' $taskid))
local host=$(docker node ls -f id="${containerinfo[0]}" --format '{{.Hostname}}')
echo "$host ${containerinfo[1]}"
}
@seeekr
seeekr / GsonEnumByOrdinalSerializer.java
Created June 15, 2018 12:11
de-/serialize enums by ordinal with GSON
package com.denisandrejew.util;
import com.google.gson.*;
import lombok.experimental.var; // if java < 10
import java.lang.reflect.Type;
public class GsonEnumByOrdinalSerializer<T extends Enum> implements JsonSerializer<T>, JsonDeserializer<T> {
@Override
public T deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
{"http://localhost:8585":1}
@seeekr
seeekr / blockstack.txt
Created December 20, 2017 21:52
blockstack verification
Verifying my Blockstack ID is secured with the address 1FBLBQvNBJAovcSncxafDXBpWPd2rgRSCc https://explorer.blockstack.org/address/1FBLBQvNBJAovcSncxafDXBpWPd2rgRSCc
@seeekr
seeekr / confix.ex
Last active August 14, 2017 14:43 — forked from jmglov/config.ex
Elixir: override Mix config with environment variables
defmodule Confix do
defmacro __using__(app: app_name) do
quote do
import unquote(__MODULE__), only: :macros
@confix_app unquote(app_name)
end
end
defmacro cfg(key, type \\ :string) do

Keybase proof

I hereby claim:

  • I am seeekr on github.
  • I am seeekr (https://keybase.io/seeekr) on keybase.
  • I have a public key whose fingerprint is 7551 6CEC 6BBF CBC4 EACD 5602 7D16 0A7D B3C0 C44D

To claim this, I am signing this object:

@seeekr
seeekr / 0001-fixing-shariff-s-custom-post-handling-logic.patch
Created February 27, 2016 14:13
fixing shariff custom post types on/off detection
From 1531e3ed5393f28e1bcf8ef275cd6df0dbd1cefe Mon Sep 17 00:00:00 2001
From: Denis Andrejew <da.colonel@gmail.com>
Date: Thu, 25 Feb 2016 14:42:55 +0100
Subject: [PATCH] fixing shariff's custom post handling logic
---
shariff.php | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/shariff.php b/shariff.php
@seeekr
seeekr / setup-raid-coreos.sh
Last active April 24, 2022 21:58
Using RAID with CoreOS (btrfs; RAID0, RAID1)
#!/bin/sh
# replace with whatever your additional device is called
# /dev/sda should be where your CoreOS install lives right now
newdevice="/dev/sdb"
# 0 or 1
raidtype="0"
# make sure to download the single-partition.layout file as well
@seeekr
seeekr / apache-webp-rewrite.conf
Last active March 10, 2024 22:34
enabling apache to serve WebP image files if accepted by browser (and .webp files available)
## !! This snippet has been updated, but not tested in practice. It should work, please check / leave comments in case it doesn't. !! ##
# originally from https://groups.google.com/a/webmproject.org/group/webp-discuss/browse_thread/thread/196ac4ea705688d8
<IfModule mod_rewrite.c>
# TODO: don't forget to put
# AddType image/webp .webp
# in your mods-available/mime.conf
# (though this is optional because we're setting
# the mime type manually in the RewriteRule)