August 13, 2020How Can You Inject the Language as String Into a Jinja TemplateI created a multilingual project using Flask with the help of Flask-Babel. While the translation mechanism via GNU gettext itself is pretty straightforward, I did not know how to inject the actual language into the Jinja template, so I can use it to set <html lang="xxx">. While it is odd that this is not mentioned in the documentation, once again StackOverflow offered solutions. solution one Just translate the language! <html lang="{{ _('en') }}"> That was too simple to think of :-)...
August 10, 2020How to View Log Entries Using SystemdUntil very recently I was lucky enough to have real log files, but now I have to use systemd’s way to view logs. show all log entries journalctl show nginx’ log entries journalctl -u nginx directly jump to the latest entries journalctl -e -u nginx
August 10, 2020How to Remove a File From a Git Repository but Keep It LocallyFor a video project, I have a video folder with videos and subtitle files. Obviously, I do not want to have hundreds of megabytes in my git repository, so I git ignored them - but I committed the subtitles. Now, the videos and the subtitles will be served by nginx from a media directory, outside of the project. In order to delete the subtitles from the git repository, but keep them locally, I have to…...
August 10, 2020How to Fix an Old Git Commit… which you do not have pushed to a remote repository. git add <my fixed files> git commit --fixup=OLDCOMMIT git rebase --interactive --autosquash OLDCOMMIT^ via https://twitter.com/nnja/status/796876898005417984?s=03 via https://stackoverflow.com/questions/2719579/how-to-add-a-changed-file-to-an-older-not-last-commit-in-git/27721031#27721031
July 23, 2020Why Is Setuptools a Runtime Dependency… or in other words… Why is this snippet part of setup.py in all Zope projects? install_requires = 'setuptools', This sounds weird at first, but there is good reason. setuptools provides pkg_resources, and the latter is used in __init__.py, in order to declare a namespace package. __import__('pkg_resources').declare_namespace(__name__) Still confused? While pkg_resources-style namespace packages are no longer recommended for new projects, this approach was used to split large packages, and retrieve the contents from more than one location....
July 22, 2020How to Audit and Harden an SSH ClientYou probably know how to harden an SSH server, or at least heard of it. e.g. do not offer weak ciphers, or do not allow root login… But did you know you can and also should harden your SSH client? step 1 - auditing your SSH client terminal 1 git clone https://github.com/jtesta/ssh-audit cd ssh-audit python3.8 ssh-audit.py -c # c = client audit; this starts a ssh server on port 2222 terminal 2 ssh localhost -p 2222 Now, switch back to terminal 1 and have a look at the output - it all should be green - but it won’t....
July 15, 2020How to Find Nginx Config File on a Nixos VmNixos… hm, a dream for my web hosting company, but a nightmare as a casual user :-D Compared to other Linux distributions, there are so many differences. For a start… where the heck is my nginx.conf? Hint - it is not in /etc/nginx/nginx.conf systemctl cat nginx ... X-CheckConfigCmd=/nix/store/xxx-nginx-1.14.2/bin/nginx -t -c /nix/store/xxx-nginx.conf -p /var/spool/nginx X-ConfigFile=/nix/store/xxx-nginx.conf In order to show the configuration, FlyingCircus (my hosting company) created a custom command nginx-show-config | less ....
July 13, 2020How to Access Name Based Servers in Development SetupThe problem You run a web application via nginx and you dispatch the requests based on the server name. And maybe the server name header only gets set via a proxy or an URL, which is currently or permanent not available in your dev setup. The solution curl -- header "Host: example.com" http://localhost Further information Blog post by the maintainer of curl: https://daniel.haxx.se/blog/2018/04/05/curl-another-host/
July 13, 2020How to List Packages Which Can Be UpgradedHave you ever logged into your Ubuntu machine and you get greeted with xxx packages can be updated? Do you want to know which packages can be updated before running apt upgrade? This is for you (and me): apt list --upgradable
July 10, 2020How to Install Release CandidatesHow to install release candidates Today on Twitter, one of the core maintainers of pytest announced the release of pytest 6.0.0rc1, and also asked to install and run it, and report if there are any problems. https://twitter.com/nicoddemus/status/1281385522422784005 Ok, but how do you install a release candidate? If you just do a pip install pytest, the current latest release gets installed, which is 5.4.3 as the time of writing. Turns out, there are a couple of options…...