My version of hygge is having friends come together for a dinner. When the dinner menu has just enough new flavors to make food interesting and just enough old favourites so that no one goes hungry. It’s about conversation that flows effortlessly, includes everyone, and makes us laugh. Most importantly, it’s about seeing my friends relaxed, cozy, and feeling at home – helping themselves to more food or a drink from the fridge and being happy in the moment.
In the process of learning how to deploy a Django webapp using Microsoft’s TFS build + release tools, I came across the need to convert several systemd services that used to be started by root user to systemd user services, so that they could be started and managed by a non-privileged user. Here is one of my original services that is used to run gunicorn (*** designates values that have been redacted):
Description=Gunicorn Service. Server: ***. App: ***. Environment: ***.
ExecStart=/bin/sh -c '/home/***/env/bin/gunicorn \
--pythonpath /home/***/app/ \
--chdir /home/***/app/ \
--log-file /home/***/logs/gunicorn.log \
--log-level info \
--pid /home/***/run/gunicorn.pid \
--name *** \
--workers 1 \
--bind=unix:///home/***/gunicorn.socket -m 000 \
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
I ran these steps to convert the original service to a user service:
user@server:~ cd /etc/systemd/system
user@server:~ sudo systemctl disable gunicorn.service
user@server:~ mkdir -p ~/.config/systemd/user
user@server:~ sudo mv gunicorn.service ~/.config/systemd/user/
user@server:~ sudo chown user:user ~/.config/systemd/user/gunicorn.service
user@server:~ systemctl --user enable gunicorn.service
user@server:~ systemctl --user start
To my surprise, that worked well and the service has started without complaints. However, I soon discovered two problems:
- The service no longer started automatically after server reboot
- The service only ran when I was SSHed into the server as the user who now managed the service
Turns out, the fix for both issue is relatively straight-forward, once you know what to do, which is the hard part. In order to fix the first problem, I ended up changing the service file:
It turns out that such thing as multi-user.target does not exist for systemd user services, but default.target does.
The second issue was a bit more interesting. Roughly speaking, systemd only runs user services when a user is logged in. When the user logs out, their services are promptly stopped. In order to overcome that, you need to indicate to the login manager that user needs to linger. On Ubuntu 16.04, the command to do so is:
sudo loginctl set-linger username
After applying both changes and rebooting, my systemd user services where chugging along happily without the need for manual intervention.
Here’s a take on Nectarine-Almond Oven Pancake from Williams-Sonoma Taste:
When you have a name that is hard for others to spell on their first attempt, you can get upset over it, or you can chuckle and start collecting your new aliases…
I built an Arduino nightlight that looks like a bunny.
I was inspired by this blog post on Sparkfun. However, I wanted to do something more complex in terms of lightning. The bunny shape was laser cut from acrylic and a simple circuit board was assembled to host two RGB LEDs that connected, along with a button, to an Arduno Nano board.
There are three modes for this nighlight:
- solid color (five colors pre-loaded; those can be rotated through by a short button press) The single button press controls the light mode:
- pulsating color (same five colors; those can also be rotated through by a short button press)
- crossfading light (uses the same five colors).
The long button press activates one of the sleep mode durations (turning the light off after 15 / 30 / 60 minutes). A short button press after the sleep mode was activated will cancel it.
This GitHub page contains the code and circuit design files.
From the Wikipedia article: Thousand Origami Cranes (千羽鶴 Senbazuru) is a group of one thousand origami paper cranes held together by strings. An ancient Japanese legend promises that anyone who folds a thousand origami cranes will be granted a wish by the Gods. Some stories believe you are granted eternal
good luck, instead of just one wish, such as long life or recovery from illness or injury.
It turns out that even if one has no particular skill at origami, if one folds something about 1000 and five times, one gets surprisingly good.
Here is some stats I’ve gathered on the process:
- The whole project has lasted for 252 days, I have only spent 41 days actually folding.
- On average, I made about 24 cranes at a time. There have been at least 10 days where I’ve made only 10 cranes and two very productive days where I’ve made 70. Further to this, I made 20 on 16 different occasions, 30 on 4 different occasions, 40 on 6 different occasions and 50 on 1 occasion.
- The longest streak was 9 days in March and the longest break was for 64 days.
Unfortunately I did not time myself, but I am pretty sure I can fold a crane in under a minute now. I recommend this project for everyone who feels guilty watching Netflix and not doing anything “useful” – now you can pretend you are being productive.
Update June 1, 2016: and here is the finished product…
Due to a change in the number of years you have been claims free, we are pleased to advise your premium has been reduced…
Um… thanks? It’s likely that the insurance company simply has not thought this scenario through but given that just a few months ago I got adjusted up by $20-30 because reasons, this looks facetious.
I am trying out the excellent DigitalOcean to host this blog along with a few other personal projects. This is my first time using a dedicated VPS for hosting and while it provides me with a great deal of control over my resources, one obvious down side is that I am also directly responsible for all system administration work. Instead of trying to install phpMyAdmin to administer my database or mocking with iptables, I’ve decided to use SSH tunneling and MySQL Workbench to do just that.
You can use the following command to tunnel the remote port 3306 of your VPS to the locally available port 8888:
ssh user@hostaddress -L 8888:127.0.0.1:3306
If all worked well, you will be logged into your remote machine and, while keeping that terminal window open, you will be able to use MySQL Workbench to connect to 127.0.0.1:8888 in order to access your database. By the way, you don’t have to use 8888 for your local port, I use 3306 locally as well, in which case the command becomes:
ssh user@hostaddress -L 3306:127.0.0.1:3306