RSSAmplifier

Blog

Nudin's Blog

Blog by Michael F. Schönitzer

schoenitzer.deRSS feed ↗38 posts

Latest posts

Writing a GIMP 3.0 Plugin – Ressources and Notes

Writing a GIMP 3.0 Plugin – Resources and Notes GIMP 3.0 is almost out, and I'm thrilled. Not only will this version bring new features and improvements, but it finally modernizes the technology stack in two important ways: It will use GTK 3 It will use Python 3 This will make it easier and more sustainable to develop plugins for GIMP. The old Python 2 plugins will not work anymore, but the new…

Shorter Hacks 23: Bash previous folder

Shorter Hacks 23: Bash previous folder In bash you can not only cd into the last directory with cd - , but also use tilde-dash with any other command. For example: ls ~- will show the files in the previous directory.

Shorter Hacks 22: Systemd-analyze calendar

Shorter Hacks 22: systemd-analyse calendar Compared to cron, systemd timers have their own, alternative time specification format. This is more human readable than the old cron specification – but a "new" format means new possibilities to screw up. Luckily systemd has a feature to check if a time specification is sound and really means what you intend: $ systemd-analyze calendar "Mon,Tue *-01..04…

Shorter Hacks 21: Git push previous commit

Shorter Hacks 21: Git push previous commit You can not only push the current state of a branch to its remote branch, you can push any commits to any remote branch. This way you can for example push all your commit except the latest with: git push remotename @~:branchname I regularly use this when my current commit is not finished yet, but I want to push the already finished work done in previous…

Shorter Hacks 20: IPython history

Shorter Hacks 20: IPython history In IPython you can print all commands of the current session with (in a copy-paste able version) by %hist . If you want to display the history of the previous time you used IPython you can do that by %hist ~1/ . To search the full history for a keyword, use %hist -g foobar .

Shorter Hacks 19: Terminate hanging ssh sessions

Shorter Hacks 19: Terminate hanging ssh sessions When the network connection breaks while you work in an ssh session or the ssh server terminates – maybe due to a reboot – the ssh session freezes and stays frozen for a long time. There is an ssh keybinding to stop such a frozen session: First press return , then ~ and finally . – this will immediately terminate the connection and exit the client.

Shorter Hacks 18: Filter lines in less

Shorter Hacks: Filter lines in less The pager less has an option to filter displayed lines by regex pattern. Basically a built-in grep. Press & and then type your filter and only matching lines will be shown. A ! at the start of the pattern or Ctr+N instead of the ampersand will turn it to an inverse filter.

Shorter Hacks 17: SSH Purge host from known_hosts file

SSH Purge host from known_hosts file When the host key of a computer you want to ssh to has changed for a valid reason, ssh will block attempts to connect to it to avoid man-in-the-middle attacks. Deleting the key from the known_hosts file with an editor can be annoying, especially if the files is "hashed". Therefore, ssh-keygen offers a feature to do that: ssh-keygen -R hostname

Shorter Hacks 16: IPython Autoreload

Shorter Hacks 16: IPython Autoreload When developing some python code and testing it in IPython, I love the autoreload feature of IPython. When enabled it will reload imported modules automatically. So you will always use the newest version of your code. It even patches modifications on class methods into existing class instances. To enable it first load it with %load_ext autoreload , then enable…

Shorter Hacks 15: Dig output format

Dig output format You probably use dig to query dns records. The default output of dig is rather verbose, but you can configure it. Try the following for a succinct output: dig +nostats +nocomments +nocmd +noquestion +identify +multiline @1.1.1.1 schoenitzer.de You can set this as default output by adding the options to the file ~/.digrc .

Shorter Hacks 14: Get external IP behind NAT

Shorter Hacks 14: Get external IP You are behind a NAT and need your "outer" IP address? You can use curl with one of several handy websites: For example: curl icanhazip.com or curl ifconfig.me . If you want to self-host such a service with nginx it's as simple as: location / { default_type text/plain; return 200 "$remote_addr\n"; }

Shorter Hacks 13: Git exclude files

Shorter Hacks 13: git exclude files If you want to ignore a file without putting it into the public .gitignore you can list it in .git/info/exclude – works the same way but is local to you computer and not version controlled.

Shorter Hacks 12: Open editor from within less

Shorter Hacks 12: open editor from within less Opened a file in less but then realise you have to edit it. The key v (as in vim ?) opens up your editor, as defined in EDITOR or VISUAL .

Shorter Hacks 10: disown

Shorter Hacks 10: disown Some long running command is still active in your ssh session and you need to leave; but you don't want to stop it and therefore regret that you didn't execute it in screen/tmux or with nohup? You can still use disown. Stop the process by <C-Z>, unpause it in the background with bg and run disown so that you can end you ssh session without killing it.

Shorter Hacks 11: journalctl list boots

Shorter Hacks 11: journalctl list boots journalctl --list-boots list your last boots with start and shutdown date, as far as the journal dates back. You can use journalctl -b num to view the logs of previous boots. Beside that I sometimes use it to check "at what time did I went to bed yesterday?"

Shorter Hacks 9: git autostash

Shorter Hacks 9: Git autostash You want to rebase, merge or pull but have uncommitted changes? Use the option --autostash . Example: git pull --autostash is equivalent to `git stash; git pull; git stash pop`

Shorter Hacks 8: limit strace to syscalls with files

Shorter Hacks 8: limit strace to syscalls with files I often use strace to see which files a program uses and often even more interesting: wich (non-existing) files it fails to open. With the flag -y strace will decode file descriptors, so you see the path of the files and with -e %file strace will only print syscalls that operate on a file: open , stat , chmod , unlink , … Please note that this…

Shorter Hacks 7: better search in man pages

Shorter Hacks 7: better search in man pages I love the man page system on Linux/Unix and frequently look something up. But one thing drove me crazy: Since the description of flags is written in a new line below the flag, most of the time you have to scroll up again after every search to see the flag you've been searching for. If you don't understand what I mean, search for "symbolic link" in the…

Shorter Hacks 6: pipe stderr

Shorter Hacks 6: pipe stderr Normal pipes in bash/zsh only redirect stdout to the target process. If you, for example want to grep the output of strace you need to also redirect stderr to the target. You can do this by strace ls |& grep open . On older versions of bash you need the less handy strace ls 2>&1 | grep open .

Shorter Hacks 5: git word diff

Shorter Hacks 5: git word diff If a diff is hard to read because the changes are small, try `git diff --word-diff`. While the default diffing algorithm works line wise, this will show you changes within a line.

Shorter Hacks 4: strace failed-only

Shorter Hacks 4: Strace only failed syscalls Want to see why some program is failing? Strace often has the information, but the output is too much to read. You can use the option -Z to limit output to failed syscalls only. -z on the other hand limits to successful syscalls.

Shorter Hacks 3: grep ps

Shorter Hacks 3: grep ps I was always annoyed that if you grep the output of ps you will always also get the process of grep itself. Then I found this trick: ps aux | grep [h]top

Shorter Hacks 2: get local ip with hostname

Shorter Hacks 2: get ip using hostname To get the hosts ip address I used to use ip addr – but the output is noisy and the address hard to spot. Use hostname -i instead, to get exactly what you need.

Shorter Hacks 1: git dash

Shorter Hacks 1: git dash You probably know cd - to move back into the previous directory. Git offers the same handy shortcut to refer to the last checked-out branch. So, you can conveniently switch between two branches by git checkout - , or merge the previous branch by git merge - , etc.

Arch Packages You Might Want to Install

Arch Packages You Might Want to Install After installing a fresh Arch, the system ist pretty bare and you might spend a long time thinking about which packages you might need. But even after installing all packages you came up with, the installation is likely followed by a long period where you regularly discover missing tools. To help to speed things up, here is a opinionated list of arch…

Audio volume in Anki

Audio volume in Anki TL;DR: Install mpv and put volume=80 into ~/.local/share/Anki2/mpv.conf to set the audio volume of Anki to 80%. Audio volume handling is pretty high in my list of "annoying things I can't believe are still an issue". Whenever I listen to music or watch video there's a high chance, I have to either turn up the volume to hear something. Not much later some other application…

A better button for my Tomu

A better button for my Tomu A while ago I ordered a Tomu . More specific an "original" Tomu. And not only one but 60… but not all of them for myself. ;) Until recently I used my Tomus only sparely. The mayor issue that prevented me so far was that the "button" that has to be pressed at every authorisation was pretty hard to touch. The origin of that problem is that the buttons are just two tiny…

Arbitary virtual memory usage with numpy

Arbitrary virtual memory usage with numpy When recently hacking on htop, there was a bug about large memory sizes being displayed wrong. But to test for it you need a process that uses 98GiB of memory. Luckily any type of memory – so virtual memory is enough. How to get a process to have an fixed, arbitrary large amount of virtual? Sure I could write a few lines of C to do it, but with numpy…

Javascript: Country Code to Flag

Javascript: Country Code to Flag Here's a fun little Javascript function: function getflag(langcode) { var first = langcode.charCodeAt(0) + 127397; var second = langcode.charCodeAt(1) + 127397; var flag=`&#${first};&#${second};`; return flag; } getflag("DJ") // 🇩🇯 getflag("DE") // 🇩🇪 getflag("SE") // 🇸🇪 How does this work? Instead of adding the flags of every country to the Unicode standard,…

So Much Nothing

So Much Nothing If you know about sparse files, this is of no relevance for you, but might still amuse you. If you don't know about sparse files, I recommend changing that because they are not only fun, but also very useful — for example when handling filesystem images. $ dd if=/dev/null of=hugeemptyfile bs=4M count=0 seek=2000G $ ls -l hugeemptyfile -rw-r--r-- 1 michi users 7,9E 11. Mai 01:45…

Convert images to PDF with ImageMagic

Convert images to PDF with ImageMagic I often have to join multiple images into one PDF file. My way to do this was always to convert the images to PDF files using ImageMagick and then concatenate the PDF files with pdftk. Lately this failed with the following error: convert: attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAuthorized/408. The…

Asking Gender in Surveys – doing it right

Asking Gender in Surveys — doing it right When taking surveys or registering for events I often get annoyed by the “gender-question”. It's pretty easy to do it properly but people still come up with surprisingly many ways of doing it wrong. So here I want to present you how not to do it and how to do it. Let's start with the worst form that you can probably find: Gender: * Male Female This form…

How to read a vimscript stacktrace

Reading vimscript stacktraces When you get an ERROR in vimscript, vim will show you a stacktrace, as you might also know it from other languages. But reading them is not trivial and I haven't found any documentation of it so far. When you see them the first time, you might interpret them wrong and search the error at the wrong location. Let's look at a stacktrace from vimwiki: Error detected while…

Introducing Hewa

Introducing Hewa While reading, typos and spelling mistakes in texts can be annoying. I myself make a lot of typos and spelling mistakes — but that doesn't mean that they annoy me any less when I stumble over one while reading. I personally already use vims built in spell checker as well as LanguageTool to check my texts — but that doesn't find everything. Asking someone to proofread every text…

Linux Raw Sockets

Linux Raw Sockets Recently I did a userspace implementation of the Host Identity Protokoll (HIPv2, RFC 7401) with the upcoming Diet Exchange (HIP DEX, IETF draft 6) . Doing so, I've learnt a lot about raw socktet programing under Linux and here I want to share a few things with you. So, I assume you have already worked with network sockets before – if not, don't fear, it's not that hard and there…

Awesome way to debug python

Awesome way to debug python This it so awesome. The probably most foolproof method to debug python after printf-debugging: import code code.interact(local=dict(globals(), **locals())) You can add this at any position in your code you like. Whenever the second line is executed the python-read-evaluate-print-loop (REPL) is started and you can interact with your program live: you can check the values…

Up2date softwareversions for Wikidata

Up2date software versions for Wikidata I'm a supporter of Wikidata and free Software. So naturally I care about Wikidata's items about free software. There are at least 17.000 of them and their quality is (as always on Wikis) very different. Lots of them came due to corresponding Wikipedia-articles, but others were created by imports from for example Gentoo's Portage. One aspect where Wikidata…

Vim revelation of the day: wildmode

Vim revelation of the day: wildmode How often had I been annoyed by Vims command and file autocompletion. I was sure I had looked into this in the past – was that just imagination or was I searching the wrong terms? Now I finally stumbled over the right options: set wildmenu set wildmode=longest:full set wildignore+=*.a,*.o,*.hi set wildignore+=*.pdf,*.gz,*.aux,*.out,*.nav,*.snm,*.vrb Wildmenu…