Skip to content

Instantly share code, notes, and snippets.

View pkuczynski's full-sized avatar

Piotr Kuczynski pkuczynski

View GitHub Profile
@pkuczynski
pkuczynski / delete.sh
Last active August 29, 2024 21:19
delete github actions workflows
gh run list --all -w "NAME GOES HERE" --json databaseId --jq '.[].databaseId' | xargs -I {id} gh run delete {id}
@pkuczynski
pkuczynski / react-intl-default-message.ts
Last active March 8, 2023 12:31
Sets react-intl defaultMessage based on existing translation file
// Requires `npm i jscodeshift @types/jscodeshift`
// Run: `npx jscodeshift -t react-intl-default-message.ts src/**/*.ts`
import en from './src/i18n/locales/en.json'
export const parser = 'tsx'
export default function transformer(file, api) {
const j = api.jscodeshift

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@pkuczynski
pkuczynski / status.sh
Created October 16, 2017 14:33
Kubectl get pods with colorful output
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 February 12, 2014 16:18
List files with their numerical chmod permissions
#
# 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 / LICENSE
Last active December 10, 2024 17:09
Read YAML file from Bash script
MIT License
Copyright (c) 2014 Piotr Kuczynski
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWAR
@pkuczynski
pkuczynski / db.rake
Created January 28, 2014 10:23
Loading data from SQL file in rake task
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 December 6, 2013 13:10
Renames multiple tags using regexp. Usage: git_rename_tags.sh $frompattern $topattern
#!/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 December 6, 2013 11:13
MusicBrainz Picard: converts album date from yyyy-mm-dd to simply yyyy
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 April 27, 2018 14:01
Remove all git tags matching pattern passed as parameter
#!/bin/sh
for tag in $(git tag -l $1)
do
git tag -d $tag
git push origin :refs/tags/$tag
git push --tags
done