Skip to main content

Senior Web Engineer. Open web / music. Remote DJ. Tall Dutch guy. #3million

micro.blog/sander

svandragt

mixcloud.com/cloudseer

 

If you send email using `noreply@` then think about why you're not having a human contact? Why are you sending email and missing out on starting a conversation? That's bad business. It also flags you as a potential spammer.

 

Looking for a way to checkout the same git repos on two machines. Moving the files into cloud sync causes trouble so maybe there’s a tool that export git repo definitions from a folder structure?

 

My server ran out of space, it turns out NextCloud was holding on to 30GB of trash! Fixed as per https://bayton.org/docs/nextcloud/nextcloud-hoarding-trash-how-to-force-automatic-removal-of-deleted...

 

elementaryOS is the comfy slippers of Linux distributions. If Apple ever ruins their privacy game, this is where I will end up.

 

Firefox's spelling checker wasn't working for me, and unfortunately it doesn't support the macOS default one, so I was seeing a lot of spelling errors. I fixed it by installing the recommended links at https://addons.mozilla.org/en-GB/firefox/language-tools/

 

Upgrade BookStack

I use the following script to run a daily upgrade on the instance:

#!/usr/bin/env bash
pushd /var/www/brain.vandragt.com
        git pull origin release && composer install --no-dev && php artisan migrate --force
popd

 

I’ve FINALLY setup a BookStack instance (trivial, once I sorted out a Let's Encrypt issue) for reference documentation. Find it at https://brain.vandragt.com. The ‘pages’ functionality for Known is pretty weak, and I think Bookstack will give me a good organisational structure by default, rather than hacking around in other systems. The Braindump will help me note down things I learn and collate my snippets.

I'll move my reference documentation from my site into it over time.

 

Installing PyInstaller on a Poetry project on MacOS

I'm looking to create a cross-platform executable of my commandline application. The application is using poetry as the package manager, and I'm running this on MacOS.

First we need to install PyInstaller:

$ poetry add pyinstaller --dev

Then it should be as simple as running the following:

$ poetry shell
$ pyinstaller --onefile app/app.py

Macho Libre

However, this resulted in the following error:

ModuleNotFoundError: No module named 'macholib'

macholib can be used to analyze and edit Mach-O headers, the executable format used by Mac OS X.

It’s typically used as a dependency analysis tool, and also to rewrite dylib references in Mach-O headers to be @executable_path relative.

Manually adding this dependency to the project addresses this:

$ poetry add macholib --dev

NLTK

However, now calling pyinstaller again throws up a new error:

Unable to find "nltk_data" when adding binary and data files.

NLTK is a leading platform for building Python programs to work with human language data. It provides easy-to-use interfaces to over 50 corpora and lexical resources such as WordNet, along with a suite of text processing libraries for classification, tokenization, stemming, tagging, parsing, and semantic reasoning, wrappers for industrial-strength NLP libraries [...].

Fortunately we can download the missing data as follows (from within the poetry shell):

$ python
>>> import nltk
>>> nltk.download()

Press the download button on the window that pops up and make sure the installation path matches the error message path.

Then fix the path to NLTK in PyInstaller according to this StackOverflow answer. To get to the right location, ask poetry:

$ poetry env list --full-path
$ cd <path>/lib/python3.7/site-packages/PyInstaller/hooks

Rerunning the pyinstaller command after this produced an executable! However it's 1.2GB, propably due to including the macholib library.

I will update this post when I've figured this out.

 

When a website looks good people will be drawn in; when the experience is good people will come back.

 

Hide Trackbacks 1.1.4

Hide Trackbacks is a WordPress plugin that hides pingbacks and trackbacks from your website comments.

The minimum supported WordPress version is now 5.0 and I've bumped up the version to indicate it is tested against the upcoming 5.4 release.

 

If you need a few minutes of calm in these worrying times, try listening to Ólafur Arnalds https://open.spotify.com/artist/7E3BRXV9ZbCt5lQTCXMTia?si=iqlvP-3NRQGqOAcZ93DUbw

 

Tip: when opening food containers write the DoO (Date of Opening) on the container with a sharpie. Never guess if something is in date!

 

Ready to give up on Python for cli tools and switch to nim or crystal or whatever. Creating and distibuting a standalone executable shouldn't be this hard.

 

I updated the "Auto-Update Nextcloud" post with a new version of the script to update the installed apps as well! https://vandragt.com/2020/auto-update-nextcloud

 

Fafi v0.1.5-alpha

I just released Fafi v0.1.5-alpha. Fafi is a console application that indexes and searches the page content of Firefox bookmarks.

Install via pipx install fafi

v0.1.5 stores the database into it's own application settings (using https://github.com/ActiveState/appdirs)

Source on Github

 

Auto-Update Nextcloud

I run my own Nextcloud server, and every other week there's an update to the server, or one of the plugins I've enabled. The following steps enable automatic updates to the Nextcloud server.

This assumes Nextcloud is installed under /var/www/nextcloud:

Add a scheduled task as the webserver user:

$ sudo -u www-data crontab -e

Add the following line to run the upgrade script once a day at 4:05am. Instead of running the upgrade process directly we run a script so that we can also run it from the shell if needed:

5     4  *  *  * cd /var/www/nextcloud && ./upgrade.sh

Now create the script and make it executable:

$ cd /var/www/nextcloud
$ nano upgrade.sh && sudo chmod +x upgrade.sh

The script itself runs the server updater, the no-interaction argument prevents prompting for questions, followed by the occ utility to update all installed apps.

  pushd $(dirname $0)/updater
/usr/bin/php updater.phar --no-interaction
cd ..; ./occ app:update --all
popd

 

All my local shops have run out of hand gel sanitizer, but still have bars of soap available. It’s very weird as the latter is more effective in getting rid of dirt and virus from your hands.

 

Introducing Faff - Firefox bookmark indexing

Over the holidays I’ve build a little tool, Faff, to index and search the page contents of Firefox bookmarks. This allows searching using words that appear on the pages rather than in the bookmark title. It uses full-text-search with ranking / relevance and snippets, it’s quite WIP. More info at https://github.com/svandragt/faff/

Search query

It's written in Python command-line tool and uses SQLite's full-text search and Newspaper's text extraction, so a search over all my bookmarks takes only about 0.3 seconds although the indexing is certainly slow.

 

I've written up my thought on my bookmarking setup: https://vandragt.com/pages/bookmarking-tools

 

Cuttlefish v0.4 Released

Cuttlefish is a PHP based hackable blog framework -- with the goals of being fast, easily hackable, and easy to adopt. I've been working on it since 2012, when it was known as Carbon. It can generate a static HTML site for uploading anywhere, or run dynamically.

Version 0.4 licenses the code as MIT, so anyone can build on top of the project. Cuttlefish now has API documentation courtesy of PHPDox, which is updated whenever code is changed. I've changed the code style from 'WordPress-like' to the PHP community default of PSR12. The project now comes with a Docker container which means getting up and running is even easier.

Install Cuttlefish is easy using the instructions. For a fuller list of changes see https://github.com/svandragt/cuttlefish/releases/tag/v0.4.

Known issue:  I still have trouble getting Xdebug to work, if you're familiar with Docker Compose and Xdebug I could use your help.

For v0.5, now that the codebase is in a better state, I'm looking at adding more features again.