Skip to content

Instantly share code, notes, and snippets.

@mgurov
mgurov / .zshrc.zsh
Last active March 6, 2025 18:25
.zshrc
PROMPT='%10~ %# '
alias gitline='git log -n 1 --format=%s | xargs echo refs/heads/mykola | tr " :." _ | xargs git check-ref-format --normalize | xargs -I {} git push -f origin -o merge_request.create HEAD:{} || echo something went wrong'
alias drm='docker rm -f $(docker ps -aq)'
alias dcup='docker-compose up'
bindkey "^[^[[C" forward-word
bindkey "^[^[[D" backward-word
bindkey "^[[H" beginning-of-line
@mgurov
mgurov / SpringApplicationTracker.kt
Last active January 12, 2023 14:18
tracking the cost of the application start/stop in
private val maxInstancesAllowed = System.getProperty("payment-testing.spring.max-instances-allowed", "-1").toInt()
private val instancesRegistered = AtomicInteger(0)
// + class name in src/test/resources/META-INF/spring.factories
// e.g. org.springframework.boot.SpringApplicationRunListener=x.x.x.SpringApplicationTracker
class SpringApplicationTracker(
val application: SpringApplication,
val args: Array<String>,
) : SpringApplicationRunListener {
@mgurov
mgurov / Friendly-tech-chats-teaser-1-OST.rb
Created July 14, 2021 18:45
Friendly tech chats teaser 1 OST source code
# Welcome to Sonic Pi
synth :prophet, note: :c1, release: 8, cutoff: 80
sleep 8
synth :prophet, note: :d1, release: 8, cutoff: 80
sleep 8
@mgurov
mgurov / gitline.alias.sh
Last active December 3, 2021 14:34
gitline - a shell alias to derive a git branch name from the last commit subject and push to origin
alias gitline='git log -n 1 --format=''%s'' | xargs echo refs/heads/mykola | tr " :" _ | xargs git check-ref-format --normalize | xargs -I {} git push origin HEAD:{} || echo something went wrong'
gitline() {
git log -n 1 --format='%s' | tr " :.'" _ | xargs -I {} echo refs/heads/mykola_{} | xargs git check-ref-format --normalize | xargs -I {} git push origin HEAD:{} || echo something went wrong
}
@mgurov
mgurov / sonic-pi-morse.rb
Last active March 19, 2021 17:24
quick'n'dirty morse player for sonic-pi
unit = 0.1 # as in time unit
note = 80
message = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui.'
define :play_morse do |str|
words = string_to_words str
for word in words do
letters = wor
G4 F4
I thought that I heard you laughing,
Dm2 G2 Am/A2 Am/B2 Am/C2 Am/D
I thought that I heard you sing.
Am/E F4 Dm2 G2 Am4 G2
I think I thought I saw you try.
# as per https://sonic-pi.net/tutorial.html#section-A-2
if true
with_fx :reverb, room: 1 do
live_loop :time do
synth :prophet, release: 8, note: :e1, cutoff: 90, amp: 3
sleep 8
end
end
end
@mgurov
mgurov / pgctl
Created May 28, 2019 12:29
connect to a postgres instance behind kubectl
#!/bin/bash -eux
CONTEXT=pro
APP=purple
exec 3< <(
pgid=$!
echo "kill $pgid"
kubectl --context=${CONTEXT} --namespace=${APP} port-forward ${APP}-${APP}-db-0 :5432
)
select
nspname || '.' || relname as "relation",
pg_size_pretty(
pg_relation_size(C.oid)
) as "size",
to_char(round( pg_relation_size(C.oid) /(
select
sum( pg_relation_size( C.oid ) ) as "totalsize"
from
pg_class C
#!/bin/bash -eux
shopt -s nullglob
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
while true; do
files=( x* )
if (( ${#files[@]} )); then
echo file found: $files