opengeodata.de

Best of Bash 7

2018-08-08

Long time no see, but how does a wise person said once? “If you see a stranger, follow him.” Let’s follow…

Sometimes we need to increase the size of the tmp folder to install something big. ertseyhan shared a way:

sudo mount -o remount,size=10G,noatime /tmp
echo "Done. Please use 'df -h' to make sure folder size is increased."

Using that sweet pomodore technique to annoy the breaks right outta ya? Termdown got you covered - a very nice Python tool. I use it with xdotool to minimize every window. After this a minimal log is written to be able to track back my usage.

termdown 25m --no-figlet -W && xdotool key ctrl+alt+d && echo $(date) > pomodoro.log

People are averse to new workflows which is why a neatly constructed CSV file, containing business related info, sent to multiple people for analysis, ended up being printed as TXT. (╯▅╰) So PDF to the rescue (a sentence never said before, I assume).

iconv -f ISO-8859-1 -t UTF-8 the_data.csv -o the_data_utf-8.csv
csvtomd the_data_utf-8.csv > the_data.md
sed -i '2s/'$(head -n 2 the_data.md | tail -n 1 | awk -F "|" 'BEGIN{OFS="|"}{ print }')'/'$(head -n 2 the_data.md | tail -n 1 | awk -F "|" 'BEGIN{OFS="|"}{ $2 = $5; print }')'/' the_data.md
pandoc -s the_data.md -V geometry:landscape --variable geometry:margin=0.5in -o the_data.pdf

First command will convert to UTF8 (this is of course not obligatory). Second line will use csvtomd to get these sweet MD files which pandoc loves so much. The third line will make sure the second column of data will not be rendered too large. csvtomd uses the max length of any column to detemine how many hypens - it will insert. This is agreeable on the editor level, yet pandoc will routinely f* up the rendering since the column width in the PDF is determined by the number of hyphens. So … if you have a lot of text in column 2 it will always end up destroying the table layout. The command just equals the number of hyphens in the 2nd column with those in 5th column (a column where I have a restricted number of characters/words per se). Finally pandoc renders a nice landscape PDF for everyone to open. Pandoc uses an extensive amount of LaTeX libraries which is why it is okay to cry a bit (20 Kb CSV + 2 hours work + ~1GB of TeX stuff -> 40 Kb PDF).

Ah, yes and…

ffmpeg -ss 00:02:48.3 -i input_video.webm -c copy output_video.webm

Need to cut a video real quick? This is how (from timestamp to end in this case).

Love? Nah…

The last thing is a slack CLI client named sclack built with rage by haskellcamargo. Good thing to turn frustration into something this nice.