Skip to content

Instantly share code, notes, and snippets.

@boriska70
boriska70 / redis-in-shell
Last active May 14, 2023 21:20
Redis client usage from shell
##### Get values by pattern and group by
export keys=""
for key in $(redis-cli -h hostname.com keys "pat:tern:*"); do
keys="$keys"" ""$key"
done
redis-cli -h hostname.com mget $(echo $keys) > values_1405
cat values_1405 | sort | uniq -c
@boriska70
boriska70 / ruby helpers
Last active February 16, 2020 08:41
(One or few)-liners in ruby
##### single column strings CSV to comma-separated interges list (example: export data from DB and use as "in" clause in different DB)
arr = []
data = File.readlines 'drivers_202002161000.csv'
#data.kind_of?(Array)
data.each do |el|
arr.push el.to_i
end
str = arr.join(',')
### List local images sorted by size:
docker image ls | grep -v 'TAG' | tr -d 'MB' | tr -d 'GB' | sort -k 7
### Remove all containers, including stopped ones
docker ps -aq | xargs docker container rm
@boriska70
boriska70 / postgres_analyze.txt
Last active April 23, 2022 18:36
Useful Postgres analysis queries
Title: Postgres DDL blocking and non-blocking operations
URL: https://leopard.in.ua/2016/09/20/safe-and-unsafe-operations-postgresql#.YmRFt5NByDU
============================================================
Title: Postgres size functions (and many others)
URL: https://www.postgresql.org/docs/current/functions-admin.html#FUNCTIONS-ADMIN-DBSIZE
============================================================
@boriska70
boriska70 / check_coverage.sh
Created February 4, 2018 08:15
Create coverage report from multiple coverage.txt files (Go)
#!/usr/bin/env bash
# This should run after executing tests with coverage, for example:
# APP_ENV=test APP_CONF_PATH=$(pwd)/conf ginkgo -r --race -compilers=2 --cover --coverprofile=coverage.txt --coverpkg=<path-to-package1>,<path-to-package2>
echo "mode: atomic" > ./output.txt; find . -name coverage.txt -exec grep -h -v "^mode" {} + >> ./output.txt
go tool cover -func=./output.txt
go tool cover -html=./output.txt
@boriska70
boriska70 / findReposWithBranch.sh
Last active December 24, 2016 20:09
Find GitHub repositories owned by an organization by branch name
#/bin/bash
ORGANIZATION=$1
BRANCH_NAME=$2
TOKEN=$3
FIRST_URL="https://api.github.com/orgs/$ORGANIZATION/repos?page=1"
TEMP_FILE="./all_repos.txt"
RESULTS_FILE="./repos_with_"$BRANCH_NAME".txt"