Skip to content

Instantly share code, notes, and snippets.

Piotr Kuczynski pkuczynski

Block or report user

Report or block pkuczynski

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@pkuczynski
pkuczynski / status.sh
Created Oct 16, 2017
Kubectl get pods with colorful output
View status.sh
kubectl get pods --all-namespaces \
| awk -v GREEN='\033[01;32m' \
-v NORMAL='\033[0m' \
-v YELLOW='\033[01;33m' \
-v RED='\033[01;31m' \
--field-separator='\s' '{
if (NR > 1) {
for (n=1; n<NF; n++) {
if (n == 3) {
split($n, ready, "/")
@pkuczynski
pkuczynski / gist:8958800
Created Feb 12, 2014
List files with their numerical chmod permissions
View gist:8958800
#
# Add following code to your ~/.bash_profile, and then you can list files using command:
# lsmod /path/to/file
#
lsmod() {
ls -l $1 | awk '{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/) *2^(8-i));if(k)printf("%0o ",k);print}'
}
@pkuczynski
pkuczynski / parse_yaml.sh
Last active Nov 8, 2019
Read YAML file from Bash script
View parse_yaml.sh
#!/bin/sh
parse_yaml() {
local prefix=$2
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
for (i in vname) {if (i > indent) {delete vname[i]}}
@pkuczynski
pkuczynski / db.rake
Created Jan 28, 2014
Loading data from SQL file in rake task
View db.rake
desc 'Load data from SQL file'
task :load_data => :environment do
puts 'Loading db/data.sql'
sql = File.read("#{Rails.root}/db/data.sql")
statements = sql.split(/;$/)
statements.pop # the last empty statement
statements.each do |statement|
ActiveRecord::Base.connection.execute(statement)
@pkuczynski
pkuczynski / git_rename_tags.sh
Created Dec 6, 2013
Renames multiple tags using regexp. Usage: git_rename_tags.sh $frompattern $topattern
View git_rename_tags.sh
#!/bin/sh
shopt -s extglob
for tag in $(git tag -l)
do
newtag=`echo "$tag" | sed -E "s/$1/$2/"`
if [[ $tag != $newtag ]]; then
git tag $newtag $tag
git tag -d $tag
git push origin :refs/tags/$tag
git push --tags
@pkuczynski
pkuczynski / musicbrainz_picard_simpledate.py
Created Dec 6, 2013
MusicBrainz Picard: converts album date from yyyy-mm-dd to simply yyyy
View musicbrainz_picard_simpledate.py
PLUGIN_NAME = 'Simple date'
PLUGIN_AUTHOR = 'Piotr Kuczynski'
PLUGIN_DESCRIPTION = 'Simplify album date to contain only year.'
PLUGIN_VERSION = "0.1"
PLUGIN_API_VERSIONS = ["0.9.0", "0.10", "0.15", "0.16"]
from picard.metadata import register_album_metadata_processor
import re
@pkuczynski
pkuczynski / git_remove_tags.sh
Last active Apr 27, 2018
Remove all git tags matching pattern passed as parameter
View git_remove_tags.sh
#!/bin/sh
for tag in $(git tag -l $1)
do
git tag -d $tag
git push origin :refs/tags/$tag
git push --tags
done
You can’t perform that action at this time.