Dugan Chen's Homepage

Various Things


Go-Style Error Handing in Modern C++

There’s a lot of discussion these days about how to handle errors in C++ without using exceptions, or more specifically, the best currently-usable alternative to std::expected. Do you use a boost::outcome? An abseil::StatusOr? An std::variant? These are all ways to return a single value containing both a result and its error information, which may be […]

The Simplest Autojump Implementation for Zsh

This is the simplest autojump implementation for Zsh: As you can see, all it does is set up “cdr’, which is included with Zsh (see the “zshcontrib” manpage) and alias it to “j”, which is the command that would be installed by autojump. Now, when you “cd” around, Zsh keeps the history and allows you […]

Quetzalcoatl 2.0 Released.

I have finally completed version 2.0 of the Quetzalcoatl MPD client. It’s at the the old GitHub page: https://github.com/duganchen/quetzalcoatl Previous versions have moved here: https://github.com/duganchen/quetzalcoatl-legacy The master branch of the legacy repository is the first release, and the experimental branch is the rewrite that I eventually developed into this one. Why An MPD Client? I […]

Bootstrap Directory Index Skins for Apache and Ngnix

This is how you can get nicer directory indexes in Apache and Nginx. First, have you ever used h5ai? I have. It’s great. But now, I want something lighter. I want a solution that does not defer to a CGI, an application server, or equivalent. I want something that uses only the web server itself. […]

A PyQt implementation of JQuery’s Promises and Deferreds

I tried to implement jQuery’s Promises and Deferreds in PyQt. I was moderately successful. The use case here is chaining QNetworkAccessManager calls. When you have the name of an artist, it takes two calls to fetch the artist’s photo from last.fm. The first call fetches a reply that has the image URL. The second call […]

PyQt Implementation of MSDN’s MVP Example

I had a look at Microsoft’s Model View Presenter example, and I couldn’t resist blogging a PyQt version. For the PyQt version, we’ll have a dropdown list of music artists. When one artist is selected, its bio is retrieved from Last.FM and loaded into the UI. I only loosely skimmed the article and its source […]

MVP with PyQt. With a Model layer.

Some of the peer feedback I received on my MVP for Qt (PyQt and PySide) made good points. Pushing all the complexity to a single monolithic Presenter class simply moves the problem; you still have to subdivide that complexity, or the Presenter will be huge. Furthermore, if you have a tabbed layout, there are benefits […]

MVP for Qt (PyQt and PySide)

I took my PyQt implementation of Michael Feather’s Humble Dialog box example, and I refactored it into a Model View Presenter implementation that fits PyQt and PySide better. I’ll show you the code first, and then I’ll discuss it: The code, filter_chain.py The code itself is PyQt, but the discussion below also applies to PySide. […]

Qt, Python, AsyncIO. And Quetzalcoatl.

I’ve know I’ve said this before, but I’m at work on the next version of Quetzalcoatl, my Qt-based MPD client for KDE, written in Python. PyQt and PySide I did not say “PyQt-based”, because PySide compatibility is on the table. Normalizing PyQt for API-compatibility with PySide is easy. If you’re importing PyQt, you set its […]

LEMP on Slackware

I’ve gotten to really like the nginx web server. Here’s how to set it up on Slackware. Nginx Just install the nginx SlackBuild from SlackBuilds.org. Then make nginx’s startup script executable, and start it. Browse to http://localhost/, and you should see nginx’s start page. Add the following to /etc/rc.d/rc.local, so that nginx is started on […]


Next Page »