Skip to content

Instantly share code, notes, and snippets.

View kouk's full-sized avatar

Konstantinos Koukopoulos kouk

View GitHub Profile
@kouk
kouk / Dockerfile
Created April 11, 2019 08:47
Run google meet in chrome via docker with user namespace
FROM jess/chrome
USER root
# Add chrome user
RUN groupadd -r -g 1001 kouk && useradd -r -g kouk -u 1001 -G audio,video kouk \
&& mkdir -p /home/kouk/Downloads && chown -R kouk:kouk /home/kouk
USER kouk
2018/09/25 14:14:32 [INFO] Terraform version: 0.11.7 41e50bd32a8825a84535e353c3674af8ce799161
2018/09/25 14:14:32 [INFO] Go runtime version: go1.10.1
2018/09/25 14:14:32 [INFO] CLI args: []string{"/bin/terraform", "apply"}
2018/09/25 14:14:32 [DEBUG] Attempting to open CLI config file: /home/ansible/.terraformrc
2018/09/25 14:14:32 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2018/09/25 14:14:32 [INFO] CLI command args: []string{"apply"}
2018/09/25 14:14:32 [INFO] command: empty terraform config, returning nil
2018/09/25 14:14:32 [DEBUG] command: no data state file found for backend config
2018/09/25 14:14:32 [DEBUG] New state was assigned lineage "2adf3ae4-aa99-0739-0027-8b17ae7c3762"
2018/09/25 14:14:32 [INFO] command: backend initialized: <nil>
@kouk
kouk / wale-delete-backups.sh
Last active June 12, 2019 17:29
wale-delete-backups.sh
#!/bin/sh -e
# cf. https://github.com/wal-e/wal-e/issues/206
cutoff=`date -u -d '1 month ago' +%s`
latest=`date -u +%s`
wal-e --terse backup-list | tail -n +2 | {
# find the oldest backup after the cutoff date
while IFS= read -r line; do
last_modified_date=`echo $line|awk '{print $2}'`
last_modified=`date -u -d "$last_modified_date" +%s`
if [ $last_modified -gt $cutoff -a $last_modified -lt $latest ]; then
@kouk
kouk / igrouper-test.py
Created November 11, 2016 15:13
Consume an iterable in chunks, skipping what's not needed. Similar to the "grouper" recipe in https://docs.python.org/2/library/itertools.html#recipes
from itertools import islice
from igrouper import igrouper
test = []
for batch in list(igrouper(range(24), 5)):
test.append(list(batch))
assert test == [[], [], [], [], []]
@kouk
kouk / wtf8.py
Last active February 17, 2022 00:14
Python codec for Wobbly Transformation Format - 8-bit (WTF-8)
# -*- coding: utf-8 -*-
# To the extent possible under law, the author of this work, Konstantinos
# Koukopoulos, has waived all copyright and related or neighboring rights to
# "Python codec for Wobbly Transformation Format - 8-bit (WTF-8)". It is
# dedicated to the public domain, as described in:
# http://creativecommons.org/publicdomain/zero/1.0/
# This work is published from Greece and is available here:
# https://gist.github.com/kouk/d4e1faababf14b09b27f
from __future__ import unicode_literals, print_function
import six
@kouk
kouk / How to add a submodule with shallow checkout and shallow clone
Last active April 17, 2024 20:16
.How to add a submodule with shallow checkout and shallow clone
If you have a huge repository (in size and in history) and want to add a subfolder
to your project as a submodule you can follow this example to save time and space
using git's shallow clone and shallow checkout feature. It is a bit more complicated
in this example because I assume that you want your submodule to track a non-default
branch, called `mybranch`, instead of the `master` branch. Things could probably get
a lot simpler when using the default branch. After following the commands in these
examples you can use `git submodule update` and `git submodule update --remote` as normal.
@kouk
kouk / tmxsync.sh
Last active April 6, 2023 20:52
tmux synchronize-windows
# tmxsync: bring all windows as panes into one window and activate the "synchronize-panes" option
# tmxunsync: split all panes into different windows and deactivate the "synchronize-panes" option.
# Licence:
# To the extent possible under law I, Konstantinos Koukopoulos, have waived all copyright and related or neighboring rights to tmxsync.sh, as describe by the CC0 document:
# http://creativecommons.org/publicdomain/zero/1.0/
# This work is published from: Greece.
tmxsync () {
export _TMUX_SYNC=1;
@kouk
kouk / Example health-check script with systemd socket activation
Last active March 13, 2023 16:42
Simple HTTP health-check by abusing systemd socket activation with shell scripts
$ curl --dump-header - localhost:12345
HTTP/1.0 404 Not Found
Content-Type: text/html
Content-Length: 43
Date: Fri, 05 Dec 2014 17:48:56 +0000
<html>
<body>
<h1>WUT</h1>
</html>
@kouk
kouk / connect-to-agent.sh
Last active August 29, 2015 14:08
connect with gpg-agent (with ssh) at all costs
# Tries to connect to a running gpg-agent or starts one itself. It tries connecting to:
# 1. the agent currently designated in the environment,
# 2. the agent designated in the $HOME/.gnupg/gpg-agent-info file,
# 3. the most recently started running gpg-agent process, or last
# 4. a new gpg-agent process, with ssh support and, if applicable, x11 support.
#
# Step no. 3 requires the "pgrep" and "sockstat" utilities (available on FreeBSD)
CONNECTGPG=$(which gpg-connect-agent)
if [ -x $CONNECTGPG ] ; then
$ python foo.py &
[1] 21377
$ gdb -p 21377
GNU gdb (GDB) Fedora 7.7.1-17.fc20
[... gdb loading messages ...]
0x00007f9a09af46e3 in __select_nocancel () at ../sysdeps/unix/syscall-template.S:81
81 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
(gdb) py-bt
#4 Frame 0x22d9c70, for file foo.py, line 12, in forever ()
sleep(1)