Skip to content

Instantly share code, notes, and snippets.

Avatar

Denis Andrejew seeekr

  • productioneer.io
  • Austria
View GitHub Profile
@seeekr
seeekr / docker_task.sh
Created Apr 27, 2019
run one off tasks in a docker swarm context
View docker_task.sh
#!/usr/bin/env bash
set -euo pipefail
svc=$1
replicas () {
docker service ls -f name=$svc --format '{{.Replicas}}'
}
@seeekr
seeekr / docker_exec.sh
Created Apr 27, 2019
`docker exec -it` equivalent in multi-node Docker Swarm context
View docker_exec.sh
#!/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 Jun 15, 2018
de-/serialize enums by ordinal with GSON
View GsonEnumByOrdinalSerializer.java
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 {
View render.json
{"http://localhost:8585":1}
@seeekr
seeekr / blockstack.txt
Created Dec 20, 2017
blockstack verification
View blockstack.txt
Verifying my Blockstack ID is secured with the address 1FBLBQvNBJAovcSncxafDXBpWPd2rgRSCc https://explorer.blockstack.org/address/1FBLBQvNBJAovcSncxafDXBpWPd2rgRSCc
@seeekr
seeekr / confix.ex
Last active Aug 14, 2017 — forked from jmglov/config.ex
Elixir: override Mix config with environment variables
View confix.ex
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
View keybase.md

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 Feb 27, 2016
fixing shariff custom post types on/off detection
View 0001-fixing-shariff-s-custom-post-handling-logic.patch
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 Nov 25, 2018
Using RAID with CoreOS (btrfs; RAID0, RAID1)
View setup-raid-coreos.sh
#!/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 Mar 30, 2021
enabling apache to serve WebP image files if accepted by browser (and .webp files available)
View apache-webp-rewrite.conf
## !! 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)