Skip to content

Instantly share code, notes, and snippets.

View diafour's full-sized avatar

Ivan Mikheykin diafour

View GitHub Profile
@diafour
diafour / __usage
Last active September 24, 2024 14:01
d8-virtualization debug report for module
curl -sLo - https://gist.github.com/diafour/ede2238e6d7fbec9e5dff527f1b71788/raw/75e1aa6ef98f9ab8e83b866a6837047ff8293dfe/debug-report-module.sh | bash -s
@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 June 5, 2024 11:31
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"