Skip to content

Instantly share code, notes, and snippets.

View diafour's full-sized avatar

Ivan Mikheykin diafour

View GitHub Profile
@diafour
diafour / cluster-23.sh
Created June 9, 2023 12:38
Run kind cluster with access to local registry
#!/usr/bin/env bash
# A helper for kind to create and delete clusters with untrusted local registry.
# Based on https://kind.sigs.k8s.io/docs/user/local-registry/
#
# Note: kind 0.17.0
set -Eeo pipefail
# Settings for kind cluster
@diafour
diafour / gist:d601a5f5adfc02549a47e12815f40964
Created January 7, 2021 08:36
python psycopg2 fetchall
cur = self.conn.cursor()
cur.execute(
"""
SELECT
user_id
FROM
user_state
"""
)
user_ids = cur.fetchall()
@diafour
diafour / logrus_test.go
Created December 12, 2020 14:24
logrus with short caller and caller only for some levels
import (
"fmt"
"runtime"
"testing"
"github.com/sirupsen/logrus"
)
type MyFormatter struct {
@diafour
diafour / jq.test
Created March 31, 2020 18:14
jq fromjson or tostring problem
try (tonumber) catch ("Should catch error")
"a20"
"Should catch error"
# Tests are groups of three lines: program, input, expected output
# Blank lines and lines starting with # are ignored
#
# Simple value tests to check parser. Input is irrelevant
#
@diafour
diafour / cluster-19.sh
Last active March 27, 2024 10:00
Run kind cluster with access to local registry
#!/usr/bin/env bash
# A helper for kind to create and delete clusters with untrusted local registry.
# Based on https://kind.sigs.k8s.io/docs/user/local-registry/
#
# Note: kind 0.10.0
# Settings for kind cluster
CLUSTER_NAME="kube-19"
KIND_NODE_IMAGE="kindest/node:v1.19.7"
@diafour
diafour / gist:4ece0ee1157615bde5ed351e2e09a17d
Created April 16, 2019 10:22
tda2000.ru highlight M positions
(function() { var countM = 0; var countRows = $("table.catalog-item-list tr").each(function() { var t = $(this).find("td.catalog-item-nal div.catalog-item-nal-yes span b").text(); if (t == 'М') { $(this).css('background-color','pink'); countM++; } ; if (t!='М') {$(this).css('visibility', 'collapse')} } ).length; return {'M':countM, 'All':countRows}; })()
@diafour
diafour / gist:ab3cb34859de4e0c8d17c839548a9b31
Created December 19, 2017 18:51
Commiters stats from git repository
git log --shortstat --pretty="%cE" | sed 's/\(.*\)@.*/\1/' | grep -v "^$" | awk 'BEGIN { line=""; } !/^ / { if (line=="" || !match(line, $0)) {line = $0 "," line }} /^ / { print line " # " $0; line=""}' | sort | sed -E 's/# //;s/ files? changed,//;s/([0-9]+) ([0-9]+ deletion)/\1 0 insertions\(+\), \2/;s/\(\+\)$/\(\+\), 0 deletions\(-\)/;s/insertions?\(\+\), //;s/ deletions?\(-\)//' | awk 'BEGIN {name=""; files=0; insertions=0; deletions=0;} {if ($1 != name && name != "") { print name ": " files " files changed, " insertions " insertions(+), " deletions " deletions(-), " insertions-deletions " net"; files=0; insertions=0; deletions=0; name=$1; } name=$1; files+=$2; insertions+=$3; deletions+=$4} END {print name ": " files " files changed, " insertions " insertions(+), " deletions " deletions(-), " insertions-deletions " net";}'
git log --all --graph --date="format:%d.%m.%Y %H:%M" --pretty="%C(auto,yellow)%h %C(green)%an <%ae> %Cblue%ad %C(auto)%d %C(reset)%s"
@diafour
diafour / redis-sidecar.sh
Last active October 3, 2017 14:21
Get rid of kubectl in redis sidecar
#!/usr/bin/env bash
# https://github.com/CommercialTribe/kube-redis/blob/develop/sidecar.sh
KUBE_TOKEN=$(</var/run/secrets/kubernetes.io/serviceaccount/token)
KUBE_CA=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt
KUBE_NS=$(</var/run/secrets/kubernetes.io/serviceaccount/namespace)
KUBE_URL="https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_SERVICE_PORT_HTTPS"
@diafour
diafour / gist:5d8fe1622d6c9f43e522508897eac0e4
Created August 16, 2017 09:10
Symfony-demo build change composer.json
$ dapp dimg build
symfony-demo-app
From [USING CACHE]
signature: dimgstage-symfony-demo:8b7e283d4662405e7892470334daca9bd156310554d1115ddf982a31a53adfaf
date: 2017-08-16 04:08:13 +0000
size: 120.0 MB
Before install [USING CACHE]
signature: dimgstage-symfony-demo:b9be46d38198f06783edfa7b1494d8037a68e445d0611d7bf9db277b2735012c
date: 2017-08-16 04:13:41 +0000
difference: 109.0 MB