Skip to content

Instantly share code, notes, and snippets.

View bartelemi's full-sized avatar
power on.

Bartłomiej Szostek bartelemi

power on.
View GitHub Profile
@bartelemi
bartelemi / profiler.py
Last active February 15, 2021 15:48
A Python CPU profiler decorator.
import typing as t
from cProfile import Profile
from functools import wraps
from pstats import SortKey, Stats
def profile(
user_function: t.Optional[t.Callable] = None,
*,
output: t.Optional[str] = None,
@bartelemi
bartelemi / gitchanges.sh
Last active July 12, 2021 16:56
Get commits between last annotated tag and HEAD.
function gitchanges () {
# Get commits between last annotated tag and HEAD.
if [ ! -d ".git" ]
then
echo "ERROR! You have to be in a root of a git repo to run this script!"
return -1
fi
git fetch --tags
last_tag=$(git describe --tags --abbrev=0)
branch=$(git rev-parse --abbrev-ref HEAD)
@bartelemi
bartelemi / NewSemVer.ps1
Last active January 3, 2022 18:23
Create annotated git tag in SemVer format with prepopulated release notes.
#
# Increment SemVer git tags without mistakes.
#
# For SemVer, check https://semver.org/.
#
function New-SemVer() {
# Create annotated git tag in SemVer format.
# Based on first argument, appropriate version part will be increased by one.
#
@bartelemi
bartelemi / db-disk-usage.sql
Last active May 23, 2019 12:19
PostgreSQL: Get disk usage statistics about all tables in all schemas.
-- Get disk usage statistics about all tables in all schemas.
-- Tables with high bytes/row ratio can be good candidates for normalization
--
-- Database Engine: PostgreSQL
SELECT *,
pg_size_pretty(total_bytes) AS "total",
pg_size_pretty(index_bytes) AS "index",
pg_size_pretty(toast_bytes) AS "toast",
pg_size_pretty(table_bytes) AS "table",