diff --git a/_config.yml b/_config.yml index bf1a83d..c847b06 100644 --- a/_config.yml +++ b/_config.yml @@ -27,19 +27,7 @@ defaults: values: permalink: til/:title/ category: til - layout: til-post - -jekyll-archives: - enabled: - - categories - - tags - layouts: - category: category - tag: tag - permalinks: - category: "/blog/category/:name/" - tag: "/blog/tag/:name/" + layout: post feed: - categories: - - til \ No newline at end of file + category: til \ No newline at end of file diff --git a/_data/categories.yml b/_data/categories.yml deleted file mode 100644 index 26e09d8..0000000 --- a/_data/categories.yml +++ /dev/null @@ -1,12 +0,0 @@ -til: - backColor: "#ed0" - textColor: black -thoughts: - backColor: "#4d8" - textColor: black -quotes: - backColor: "#c66" - textColor: black -links: - backColor: "#36b" - textColor: black \ No newline at end of file diff --git a/_data/nav.yml b/_data/nav.yml index 84db8f9..91660a7 100644 --- a/_data/nav.yml +++ b/_data/nav.yml @@ -1,9 +1,11 @@ -- name: about +- name: ABOUT link: / -- name: blog +- name: BLOG link: /blog -- name: til +- name: TIL link: /til -- name: photos↗ +- name: PROJECTS + link: /projects +- name: PHOTOS↗ link: http://andrewconlinphotography.co.uk diff --git a/_posts/blog/2023-01-14-musings-on-the-cinema.md b/_drafts/blog/2023-01-14-musings-on-the-cinema.md similarity index 100% rename from _posts/blog/2023-01-14-musings-on-the-cinema.md rename to _drafts/blog/2023-01-14-musings-on-the-cinema.md diff --git a/_posts/blog/2023-03-05-yuri-felsen-on-love.md b/_drafts/blog/2023-03-05-yuri-felsen-on-love.md similarity index 100% rename from _posts/blog/2023-03-05-yuri-felsen-on-love.md rename to _drafts/blog/2023-03-05-yuri-felsen-on-love.md diff --git a/_posts/blog/2023-04-29-links-arent-performances.md b/_drafts/blog/2023-04-29-links-arent-performances.md similarity index 100% rename from _posts/blog/2023-04-29-links-arent-performances.md rename to _drafts/blog/2023-04-29-links-arent-performances.md diff --git a/_includes/nav.html b/_includes/nav.html index d2f1616..4d1e092 100644 --- a/_includes/nav.html +++ b/_includes/nav.html @@ -1,15 +1,9 @@ -{% assign primaryCategory = site.data.categories[include.a] %} - -
+
{{ page.date | date_to_string }} - | + | {{ content | reading_time | pluralize: "minute" }} - | - {{ categories.first }} - | - - {% for tag in tags %} - {{ tag }} - {% if tag != tags.last %} - , - {% endif %} - {% endfor %}
- {{ page.date | date_to_string }} - | - {{ content | reading_time | pluralize: "minute" }} - | - {{ categories.first }} - | - - {% for tag in tags %} - {{ tag }} - {% if tag != tags.last %} - , - {% endif %} - {% endfor %} -
-- -
- - - - - - - -- 14 Jan 2023 - | - 1 minute - | - thoughts - | - - - journal - - , - - - cinema - - , - - - film - - -
-I’ve realised that going to the cinema makes me sad; a quiet, contemplative melancholy. Ennui. No matter the film, something about the cinema experience is meditative for me. I always look at things differently in the aftermath; like my perception is temporarily knocked off balance. No, more like a fog is lifted for a while. I especially enjoy that time immediately after, the cycle home. I notice so many little details, scenes of beauty and of strange nostalgia. Like I’m finally seeing the world how it is, or rather, I begin to see rather than look, listen rather than hear. I feel as though these moments, however brief, are when I am truly in touch with myself. My soul, my inner essence. This is why I love the cinema. These moments of private melancholy, of temporary clarity. It is a feeling I cannot replicate anywhere else in my life.
- - -- -
- - - - - - - -- 05 Mar 2023 - | - 1 minute - | - quotes - | - - - yuri felsen - - , - - - love - - -
-“Like everyone, I have my own, maybe obsessive futile, maybe in some way authentic, vision: all of a sudden, I will imagine the entire homogenous world as it is revealed to us-the streets, the cities, the rooms, those intelligent beasts of a sad and predatory nature, who have learn to stand on their hind legs, who have built all this but are fated to disappear, who, despite this, still try to cling to something solid and lasting, still try to ward off the inevitability of death, who dreamt up fairy tales and, now that these stories have been disproved, are disconsolate - and for me the only means of defending myself from our terrible fate is love, my love - Lyolya. Without love we fall into a stupor or despair, it covers our naked animal essence; with the fear of death, with deliberate attempts to grab hold of some kind of eternity, one that is at once a mystery to us and yet devised by us, even the remains of love, even its very echo in music, imbues us with a semblance of fearlessness, dignity and the spiritual range to disregard death. Only by loving, by knowing about love, hoping for love, are we inspired and meaningfully engaged in life, able to banish the sovereignty of petty day-to-day cares, to stop waiting for the end to come”
- -- Yuri Felsen (trans. Bryan Karetnyk)
- -From ‘Deceit’, first published in 1930 and translated to English in 2022.
- - -- - - - - - - -
+
10 Mar 2023 - | + | 2 minutes - | - thoughts - | - - - html - - , - - - css - - , - - - bootstrap - - , - - - jekyll - - , - - - webdev - -
- -
- - - - - - - -- 29 Apr 2023 - | - 1 minute - | - links - | - - - copyright - - , - - - law - - , - - - pluralistic - - -
-“For starters, it finds that publishing a link can be a “performance” of a copyrighted work, which meant that when Linkletter linked to the world-viewable Youtube files that Proctorio had posted, he infringed on copyright.
- -This is a perverse, even surreal take on copyright. The court rejects Linkletter’s argument that even Youtube’s terms of service warned Proctorio that publishing world-viewable material on its site constituted permission for people to link to and watch that material.”
- -Via: Pluralistic
- - -all the posts, in reverse chronological. there is an atom feed above. @@ -121,37 +107,13 @@ -
This is a perverse, even surreal take on copyright. The court rejects Linkletter’s argument that even Youtube’s terms of service warned Proctorio that publishing world-viewable material on its site constituted permission for people to link to and watch that material.”
- -Via: Pluralistic
]]>I loved this idea, and thought it would be no problem to get a Python script up and running periodically on my Raspberry Pi home server using cron
. However, I ran into various issues along the way (some of which were not so easy to resolve), so I’m collating all the configuration changes I made in the hopes that it will be useful to someone one day. You can find the full repo for this project here, and I have also included my Dockerfile, docker-compose.yml and crontab at the end of this TIL.
How easily can I translate what I am thinking about into a working setup?
@@ -118,11 +114,7 @@ PYTHONPATH=/usr/bin/local/python3These are usually a direct tradeoff, with ease typically preferred over options. This tends to frustrate me, as I want full control of all those little configurations.
-The solution to this, at least for me, are frameworks such as Bootstrap and Jekyll. They put a layer between the user and the options; essentially translating and simplying all the little configurations into something much easier to work with. Columns in Bootstrap make page layouts simple; markdown-to-html parsing in Jekyll makes text formatting a breeze. But, most importantly of all, these frameworks don’t sacrifice on the possibilities. They make it easier to apply complex setups, but if you want to go in and tweak absolutely everything to your liking, go right ahead. By providing the user with simpler ways of doing the same things as before, they manage to bridge the gap between Can I do everything I want to? and How easy is it?. And I think that is beautiful.
]]>- Yuri Felsen (trans. Bryan Karetnyk)
- -From ‘Deceit’, first published in 1930 and translated to English in 2022.
]]>php
errors.
+The solution to this, at least for me, are frameworks such as Bootstrap and Jekyll. They put a layer between the user and the options; essentially translating and simplying all the little configurations into something much easier to work with. Columns in Bootstrap make page layouts simple; markdown-to-html parsing in Jekyll makes text formatting a breeze. But, most importantly of all, these frameworks don’t sacrifice on the possibilities. They make it easier to apply complex setups, but if you want to go in and tweak absolutely everything to your liking, go right ahead. By providing the user with simpler ways of doing the same things as before, they manage to bridge the gap between Can I do everything I want to? and How easy is it?. And I think that is beautiful.
]]>php
errors.
….aaaaaand, voila! The command runs, the files are scanned and everything is up to date.
-I loved this idea, and thought it would be no problem to get a Python script up and running periodically on my Raspberry Pi home server using cron
. However, I ran into various issues along the way (some of which were not so easy to resolve), so I’m collating all the configuration changes I made in the hopes that it will be useful to someone one day. You can find the full repo for this project here, and I have also included my Dockerfile, docker-compose.yml and crontab at the end of this TIL.
A lot of problems with cron
come down to user privileges. Each user has their own crontab
, and then there is the system-wide root crontab
. The first issue I ran into with creating a cron
job inside a container was that Docker created the crontab as a non-root user. This issue presented itself to me when I tried to run the following command, to list the current cronjobs in the Docker container:
docker-compose exec container-name crontab -l
-
This returned the following output:
-no crontab for root
-
Now, it is not necessarily a problem to have non-root cron
jobs, but just make absolutely certain that you are creating the jobs with the user you expect. For me, I wanted to run as root
, so I added to following line to my docker-compose.yml:
user: root
-
Now, the root
user will be used when building your Docker image and the created crontab
will be where you expect.
When cron
calls your Python script, you may run into issues with ModuleNotFoundError
or ImportError
, where Python cannot find your installed packages. This is because cron
does not have access to your system environment variables, including the Python path. You can resolve most of these errors with imports by adding the PYTHONPATH
environment variable to your crontab
. This should be the path to your site-packages
folder, something like this:
PYTHONPATH=/usr/bin/local/python3
-
You may also need to add a shebang (#!
) to your Python script to direct cron
to the correct version. You can find the Python location with one of the following commands:
which python
-which py
-which python3
-
NOTE: These commands must be performed in your Docker container when it is up and running. In docker-compose
syntax this would be the following (with the name of your container instead of container-name
):
docker-compose exec container-name which python3
-
You can then add this to the top of your Python script, as follows:
-#!/usr/bin/local/python3
-
Some modules will still run into errors even when the PYTHONPATH variable has been set. In particular, I ran into problems with reportlab
and Pillow/PIL
:
ImportError: cannot import name '_imaging' from 'PIL'
-
This was solved by adding the system PATH to the crontab
as well. The system path is included in the default crontab
that is created when you first run crontab -e
:
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
-
Therefore, it is a good idea to include it if you are making a new crontab
to make sure cron
can find everything it needs to.
By default, cron
runs from the default root path. Therefore, both your call to Python in your crontab
and the filepaths within Python should either be relative to root
(i.e /main.py
rather than main.py
) or just use full paths instead.
This error is related to Python inside a Docker container rather than cron
. However, someone might still find it useful. When you install your requirements.txt
, you may encounter errors such as
legacy-install-failure
-error: command '/usr/bin/gcc' failed with exit code 1
-fatal error: Python.h: No such file or directory
-
I was able to resolve these by adding python3-dev
, wheel
and Cmake
to my requirements.txt
. These are sometimes required when packages include other binaries or need to compile other code when installed.
cron
syntaxI hope this helped you resolve some errors! I’ve included my Dockerfile, docker-compose.yml and crontab below if you want to set up a similar project or adjust your own files. The full repo is also available here.
- -Dockerfile:
-FROM python:3
-
-COPY . .
-RUN python3.11 -m pip install --no-cache-dir -r requirements.txt
-
-RUN touch /var/log/cron.log
-
-RUN apt-get update \
-&& apt-get install cron -y
-
-RUN chmod +x main.py
-
-RUN crontab crontab
-
-CMD cron -f
-
docker-compose.yml:
-version: "2.4"
-
-services:
- watchman:
- platform: "linux/arm64/v8"
- image: watchman:latest
- container_name: watchman
- restart: always
- user: root
- build:
- context: build
- dockerfile: Dockerfile
-
crontab:
-PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
-PYTHONPATH=/usr/bin/local/python3
-15 7 * * * python3 /main.py >> /var/log/cron.log 2>&1
-
-
php
errors.
-
-I was trying using the following syntax to call occ
and scan the files:
sudo -u www-data php /path/to/nextcloud/occ files:scan --all
-
but I kept running into a PHP error. Specifically this error:
- -Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: could not find driver in /path/to/nextcloud/lib/private/DB/Connection.php:139
-
followed by a long, verbose stack trace.
- -It took me a decent amount of time to diagnose the exact issue, but eventually I found this list of required PHP modules in the Nextcloud admin manual.
- -Running php -m
will print out the list of currently installed PHP modules. I noticed I was missing quite a few of the required modules, but the one that was causing my issue was the missing pdo_mysql
module.
-This can be installed by running:
sudo apt-get install php7.4-mysql
-
Note: This command will change based on your OS, PHP version and database type
- -This resolved the error! However (as is always the case), this only meant I got a shiny new error instead:
- -Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known in /path/to/nextcloud/lib/private/DB/Connection.php:139
-
From first glance, this looks like something wrong in the DNS name resolution. This sent me a long way down the wrong path, changing a whole bunch of things in my docker-compose.yml file.
-Eventually however, after a long and perilous journey over the high seas of Nextcloud forums and StackOverflow, I found this example of running php occ
in a docker-compose configuration.
-This led me to running this command:
docker-compose exec -u www-data nextcloud-app php occ files:scan --all
-
Note: replace nextcloud-app with the name of your Nextcloud container. Also, this command must be run from the directory of your Nextcloud docker-compose.yml
- -….aaaaaand, voila! The command runs, the files are scanned and everything is up to date.
- -
@@ -128,7 +114,7 @@ My main hobbies are film photography and running. I love Simon Willison, I also post my TIL series here. Any time I run into a weird error while programming, I post the full error message and the fix that I found, to hopefully help someone down the line.
-
my collection of tils (today-i-learned). i use this mainly to collect solutions to weird errors i have faced, and detail the little projects that i work on. this has its own atom feed (above) as they are typically very different from my other posts. all tils are blog posts but not all blog posts are tils. @@ -121,16 +107,10 @@ - - - - -
- - - - - -
+
01 Mar 2023 - | + | 2 minutes - | - til - | - - - php - - , - - - nextcloud - - , - - - docker - - , - - - docker-compose - -
- - - - - -
+
19 Apr 2023 - | + | 3 minutes - | - til - | - - - cron - - , - - - python - - , - - - docker - - , - - - docker-compose - - , - - - kindle - -