Skip to content

Instantly share code, notes, and snippets.

View gwpl's full-sized avatar

Grzegorz Wierzowiecki gwpl

  • Europe - usually: Zürich, Warsaw or Berlin
View GitHub Profile
@gwpl
gwpl / git-latexdiff
Created May 10, 2017 13:16
git-latexdiff # how to configure latexdiff in git
#!/bin/bash
# http://tex.stackexchange.com/a/1417/7128
TMPDIR=$(mktemp -d /tmp/git-latexdiff.XXXXXX)
latexdiff "$1" "$2" > $TMPDIR/diff.tex
pdflatex -interaction nonstopmode -output-directory $TMPDIR $TMPDIR/diff.tex
okular $TMPDIR/diff.pdf
rm -rf $TMPDIR
# Add to ~/.gitconfig
@gwpl
gwpl / inotify_exec_on_file_change.sh
Created May 16, 2017 23:01
inotifywait to exec specified command on each file change -> e.g. run "make", "pdflatex", or any other compile/upload or other command of choice! (Thanks https://superuser.com/a/181543/81861 ! )
#!/bin/bash
# Example usecase:
# inotify_exec_on_file_change.sh /path/phd paper.tex pdflatex paper.tex
dirn="$1"
filen="$2"
shift 2
echo "Watching directory $dirn for changes of file $filen . Watching directory insteaf of file to overcome behaviour of many text editors that replace file - Thanks to Giles and see his answer https://superuser.com/a/181543/81861 for more details. In case of matching even I execute:" $@
@gwpl
gwpl / gen_basic_files_metadata.csv.sh
Last active May 25, 2017 14:12
Generate .csv formatted basic metadata, fast to obtain, but allowing heuristics for syncing files or initial eastimation of backup/sync coverage. ( And yes, I know that this find command will not properly encode filenames containing quotes according to csv standard )
#!/bin/bash
# Generate .csv formatted basic metadata, fast to obtain, but allowing heuristics for syncing files or initial eastimation of backup/sync coverage.
fullpath="${1:-$PWD}"
dest="${2:-"$fullpath"/basic_files_metadata.csv.gz}"
hostname="${3:-"$(hostname)"}"
echo "find \"${fullpath}\" -type f -exec stat --format=\"%i,%Y,%s,%m,%n\" \"{}\" \\; > \"${dest}\""
echo "Progress in lines generated:"
(echo "inode,modification_ts,size,hostname,mount,path";
find "${fullpath}" -type f -exec stat --format="%i,%Y,%s,${hostname},%m,%n" "{}" \;
@gwpl
gwpl / ftfy_line_by_line.py
Created May 25, 2017 14:08
Line by line encoding fixing using ftfy to Mojibake and other corrections ( ftfy: https://github.com/LuminosoInsight/python-ftfy )
#!/usr/bin/env python3
import ftfy, sys
with open(sys.argv[1], mode='rt', encoding='utf8', errors='replace') as f:
for line in f:
sys.stdout.buffer.write(ftfy.fix_text(line).encode('utf8', 'replace'))
#print(ftfy.fix_text(line).rstrip().decode(encoding="utf-8", errors="replace"))
@gwpl
gwpl / .bashrc PS1 colorful prompt
Created May 27, 2017 18:27
.bashrc PS1 colorful prompt # playing with tput to make variables using it... ("SEA" color is unfortunate, I should find better name for this color)
alias ls='ls --color=auto'
#export PS1='[\u@\h \W]\$ '
#export PS1='\W\$ '
#export PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$'
#export PS1='\[\033[01;34m\]\u@\h\[\033[00m\]:\[\033[01;36m\]\w\[\033[00m\]\$'
#export PS1='\[\033[01;34m\]\u@\h\[\033[00m\]:\[\033[01;36m\]\w\[\033[01;37m\]\$\[\033[00m\]'
PROMPT_RED="\[$(tput setaf 1)\]"
PROMPT_GREEN="\[$(tput setaf 2)\]"
PROMPT_ORANGE="\[$(tput setaf 3)\]"
PROMPT_NAVY="\[$(tput setaf 4)\]"
@gwpl
gwpl / bash_test_rsync_options.sh
Last active August 27, 2017 15:19
./bash_test_rsync_options.sh # testing different rsync options and how outputs look like # TODO: extend with xattr test case and my favourite options combo 'rsync -aAXHzvR --progress' (# tweeted: https://twitter.com/GWierzowiecki/status/901825874416295936 )
#!/bin/bash
tmpdir="$(mktemp -d)"
function cleanup {
echo '@ cleanup {'
set -x
rm -r "$tmpdir"
set +x
echo '@ } end of cleanup'
}

Keybase proof

I hereby claim:

  • I am gwpl on github.
  • I am gwpl (https://keybase.io/gwpl) on keybase.
  • I have a public key ASCSgZW4fP-pVrJ8zG0GbajAW_pSNWHrZjkhXWCYxS2fZAo

To claim this, I am signing this object:

@gwpl
gwpl / NEW QGROUP!.md
Created December 15, 2017 18:21 — forked from mazgi/NEW QGROUP!.md
Btrfs subvolume quota
[root@btrfs-testdrive] # btrfs qgroup create 1/100 /mnt/btrfs
[root@btrfs-testdrive] # btrfs qgroup assign 0/276 1/100 /mnt/btrfs
[root@btrfs-testdrive] # btrfs qgroup show /mnt/btrfs
qgroupid rfer       excl       
-------- ----       ----       
0/5      16384      16384      
0/256    2864136192 2864136192 
0/258    833703936  833703936  
0/259    52510720   52510720   
@gwpl
gwpl / 2017-12-14-btrfs-try-to-btrfs-quota-qgroup.sh
Last active December 15, 2017 19:26
2017-12-14 Playing with BTRFS quota limits - Grzegorz Wierzowiecki
#!/bin/bash
# 2017-12-14 Playing with BTRFS quota limits - Grzegorz Wierzowiecki
# gist:
# Below script is prepared for easy experimentation, and should run copy-and-paste
# (you need permissions to create lvm groups, etc. therefore root)
# It
# * setup 128MiB btrfstest in selected volume group
# * setup quotas (32MiB and 64MiB) and test them
# * cleanup
# Helpful references:
@gwpl
gwpl / 2017-12-15-xattr-Semantic_Desktop_File_tagging.sh
Last active December 15, 2017 22:54
2017-12-15 xattr command line Semantic Desktop Style File Tagging
# 2017-12-15 xattr command line Semantic Desktop Style File Tagging
# this gist: https://gist.github.com/gwpl/a00e18bc150f1e3518335d13c5e46ad7
# Perform on xattr filesystem:
setfattr -n user.xdg.tags -v "foo,bar" file.png
setfattr -n user.xdg.comment -v "example comment" file.png
setfattr -n user.baloo.rating -v "10" file.png
getfattr -d file.png
# Screenshot how it looks like in Dolphin GUI : https://imgur.com/oguuJNm