diff --git a/_includes/header.html b/_includes/header.html index b9eb77b..6fbcc83 100644 --- a/_includes/header.html +++ b/_includes/header.html @@ -1,10 +1,4 @@ -andrewconl.in is CSSing
- - blog - til - projects - meta - feed - [archive] +andrewconl.in is CSSing
+blog til projects meta feed [archive]

diff --git a/_layouts/post.html b/_layouts/post.html index b77e537..6ed4107 100644 --- a/_layouts/post.html +++ b/_layouts/post.html @@ -1,9 +1,9 @@ --- layout: default --- -~ / {{page.category}} / {{page.title}} - - {{ page.date | date: "%Y-%m-%d" }} | +~ / {{page.category}} / {{page.title}}
+ + {{ page.date | date: "%Y-%m-%d" }}
{{ content | reading_time | pluralize: "minute" }}

diff --git a/_posts/blog/2024-02-28-microzig-display-driver.md b/_posts/blog/2024-02-28-microzig-display-driver.md index 31c50da..40a8311 100644 --- a/_posts/blog/2024-02-28-microzig-display-driver.md +++ b/_posts/blog/2024-02-28-microzig-display-driver.md @@ -35,7 +35,7 @@ But where is the fun in that?! Something about this project wouldn't let me just I started out by trying to just send commands to the screen. I knew the default address of the device from the datasheet (0x3C), and started firing commands over I2C to try and provoke any sort of reaction. The MicroZig driver allowed me to this super easily. Just setup the I2C device, and then send data using the `write_blocking` function. I put the sending code inside a little function to make things easier to parse: -```zig +``` const i2c0 = i2c.num(0); _ = i2c0.apply(.{ .clock_config = rp2040.clock_config, @@ -44,7 +44,7 @@ _ = i2c0.apply(.{ .baud_rate = 400000, }); ``` -```zig +``` pub fn send(bytes: []const u8) !void { const a: i2c.Address = @enumFromInt(0x3C); _ = i2c0.write_blocking(a, bytes) catch { @@ -57,7 +57,7 @@ The SSD1306, stood firm, resolutely denying me even a single pixel. There is no It was at this point that I became really impressed with Zig's compilation, and in particular the caching. As part of this process, I was messing around a lot with my code, and then building and loading onto the Pico with the following command: -```bash +``` zig build; picotool load -x zig-out/firmware/pico_i2c.uf2 ``` @@ -83,7 +83,7 @@ Surely I was almost there? Well, almost yes, but not quite. Matiasus's commands The thing that made the breakthrough for me was [this holy grail of a blog post](https://nnarain.github.io/2020/12/01/SSD1306-OLED-Display-Driver-using-I2C.html). Just exactly what I needed at exactly the right time. It calmly and thoroughly explains the process of communicating with the display, as well as the initialisation. I was mostly right in what I interpreted from the datasheet, but it is always nice to have things confirmed by someone who clearly understands this better than you. This led me to the following initialisation commands: -```zig +``` const INIT = [_]u8{ CONTROL_COMMAND, 0xAE, CONTROL_COMMAND, 0xA8, 0x1F, diff --git a/_posts/til/2023-03-01-nextcloud-php-errors.md b/_posts/til/2023-03-01-nextcloud-php-errors.md index a4c3a6b..2461de9 100644 --- a/_posts/til/2023-03-01-nextcloud-php-errors.md +++ b/_posts/til/2023-03-01-nextcloud-php-errors.md @@ -1,7 +1,7 @@ --- title: Fixing php errors in a Nextcloud docker-compose configuration -category: til -layout: post +categories: +- til tags: - php - nextcloud @@ -15,7 +15,7 @@ I was trying to rescan the files in my Nextcloud server (running on Raspberry Pi I was trying using the following syntax to call `occ` and scan the files: -```bash +``` sudo -u www-data php /path/to/nextcloud/occ files:scan --all ``` @@ -32,7 +32,7 @@ It took me a decent amount of time to diagnose the exact issue, but eventually I 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: -```bash +``` sudo apt-get install php7.4-mysql ``` **Note: This command will change based on your OS, PHP version and database type** @@ -49,7 +49,7 @@ From first glance, this looks like something wrong in the DNS name resolution. T Eventually however, after a long and perilous journey over the high seas of Nextcloud forums and StackOverflow, I found [this example](https://techoverflow.net/2020/07/17/how-to-run-nextcloud-php-occ-in-a-docker-compose-configuration/) of running `php occ` in a docker-compose configuration. This led me to running this command: -```bash +``` 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** diff --git a/_posts/til/2023-04-19-running-python-in-cron-in-docker.md b/_posts/til/2023-04-19-running-python-in-cron-in-docker.md index 4e25893..0e8ef95 100644 --- a/_posts/til/2023-04-19-running-python-in-cron-in-docker.md +++ b/_posts/til/2023-04-19-running-python-in-cron-in-docker.md @@ -1,7 +1,6 @@ --- title: Running a Python script periodically in a Docker container using cron category: til -layout: post --- Recently, my partner gave a great idea for utilising my old Kindle: generate a "newspaper" each morning from a bunch of RSS feeds, and email it to the Kindle using "Send-to-Kindle" feature (a blog post about this project is in the works). @@ -11,7 +10,7 @@ I loved this idea, and thought it would be no problem to get a Python script up ## 1. Double check the user 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: -```bash +``` docker-compose exec container-name crontab -l ``` This returned the following output: @@ -19,24 +18,24 @@ 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: -```yaml +``` user: root ``` Now, the `root` user will be used when building your Docker image and the created `crontab` will be where you expect. ## 2. Missing dependencies 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: -```bash +``` 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: -```bash +``` 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`): -```bash +``` docker-compose exec container-name which python3 ``` You can then add this to the top of your Python script, as follows: @@ -45,11 +44,11 @@ You can then add this to the top of your Python script, as follows: ``` ## 3. Still missing dependencies 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`: -```python +``` 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`: -```bash +``` 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. @@ -73,7 +72,7 @@ I was able to resolve these by adding `python3-dev`, `wheel` and `Cmake` to my ` I 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](https://github.com/andrwcnln/watchman). Dockerfile: -```docker +``` FROM python:3 COPY . . @@ -91,7 +90,7 @@ RUN crontab crontab CMD cron -f ``` docker-compose.yml: -```yaml +``` version: "2.4" services: @@ -106,9 +105,9 @@ services: dockerfile: Dockerfile ``` crontab: -```cron +``` 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 -``` +``` \ No newline at end of file diff --git a/_posts/til/2024-01-10-using-rvm-with-alacritty.md b/_posts/til/2024-01-10-using-rvm-with-alacritty.md index 68b743b..ce969c0 100644 --- a/_posts/til/2024-01-10-using-rvm-with-alacritty.md +++ b/_posts/til/2024-01-10-using-rvm-with-alacritty.md @@ -25,11 +25,11 @@ Please visit https://rvm.io/integration/gnome-terminal/ for an example. So, we need to be in a login shell. Unfortunately, Alacritty does not have a settings GUI [like gnome-terminal](https://rvm.io/integration/gnome-terminal) and similar, and after thorough investigation I couldn't find a way to set this up through Alacritty. We need a different solution. Luckily, this is possible through the shell itself. You can open a login shell by running the following command (press Ctrl+D to return to the interactive shell): -```bash +``` bash --login ``` This also works with `zsh`, or Z-shell: -```bash +``` zsh --login ``` Unfortunately for all you fishers out there, I couldn't find a way to to this with `fish`. If you know how, [send me an email!](mailto:andrew@andrewconl.in) diff --git a/assets/css/default.css b/assets/css/default.css index 4fdc940..9e8e69a 100644 --- a/assets/css/default.css +++ b/assets/css/default.css @@ -1,5 +1,3 @@ -@import "gruvbox.css"; - @font-face { font-family: 'Geist'; src: url('/assets/fonts/Geist-Regular.otf') format('opentype'); @@ -7,13 +5,6 @@ font-style: normal; } -@font-face { - font-family: 'Geist Black'; - src: url('/assets/fonts/Geist-Black.otf') format('opentype'); - font-weight: normal; - font-style: normal; -} - @font-face { font-family: 'Geist Mono'; src: url('/assets/fonts/GeistMonoNerdFont-Regular.otf') format('opentype'); @@ -107,10 +98,6 @@ a:hover { text-decoration: none; border-bottom: 2px solid #FABD2F; border-radius: 1px; - - img { - filter: brightness(0) saturate(100%); - } } img { diff --git a/assets/css/gruvbox.css b/assets/css/gruvbox.css deleted file mode 100644 index c0af0cb..0000000 --- a/assets/css/gruvbox.css +++ /dev/null @@ -1,73 +0,0 @@ -.highlight .hll { background-color: #ffffcc } -.highlight { background: #282828; color: #ebdbb2; background-color: #282828 } -.highlight .c { color: #928374; font-style: italic; background-color: #282828 } /* Comment */ -.highlight .err { color: #ebdbb2; background-color: #282828 } /* Error */ -.highlight .esc { color: #ebdbb2; background-color: #282828 } /* Escape */ -.highlight .g { color: #ebdbb2; background-color: #282828 } /* Generic */ -.highlight .k { color: #fe8019; background-color: #282828 } /* Keyword */ -.highlight .l { color: #ebdbb2; background-color: #282828 } /* Literal */ -.highlight .n { color: #ebdbb2; background-color: #282828 } /* Name */ -.highlight .o { color: #fe8019; background-color: #282828 } /* Operator */ -.highlight .x { color: #ebdbb2; background-color: #282828 } /* Other */ -.highlight .p { color: #ebdbb2; background-color: #282828 } /* Punctuation */ -.highlight .ch { color: #928374; font-style: italic; background-color: #282828 } /* Comment.Hashbang */ -.highlight .cm { color: #928374; font-style: italic; background-color: #282828 } /* Comment.Multiline */ -.highlight .cp { color: #8ec07c; background-color: #282828 } /* Comment.Preproc */ -.highlight .c1 { color: #928374; font-style: italic; background-color: #282828 } /* Comment.Single */ -.highlight .cs { color: #928374; font-style: italic; background-color: #282828 } /* Comment.Special */ -.highlight .gd { color: #282828; background-color: #fb4934 } /* Generic.Deleted */ -.highlight .ge { color: #83a598; text-decoration: underline; background-color: #282828 } /* Generic.Emph */ -.highlight .gr { color: #ebdbb2; font-weight: bold; background-color: #fb4934 } /* Generic.Error */ -.highlight .gh { color: #b8bb26; font-weight: bold; background-color: #282828 } /* Generic.Heading */ -.highlight .gi { color: #282828; background-color: #b8bb26 } /* Generic.Inserted */ -.highlight .go { color: #504945; background-color: #282828 } /* Generic.Output */ -.highlight .gp { color: #ebdbb2; background-color: #282828 } /* Generic.Prompt */ -.highlight .gs { color: #ebdbb2; background-color: #282828 } /* Generic.Strong */ -.highlight .gu { color: #b8bb26; font-weight: bold; background-color: #282828 } /* Generic.Subheading */ -.highlight .gt { color: #ebdbb2; font-weight: bold; background-color: #fb4934 } /* Generic.Traceback */ -.highlight .kc { color: #fe8019; background-color: #282828 } /* Keyword.Constant */ -.highlight .kd { color: #fe8019; background-color: #282828 } /* Keyword.Declaration */ -.highlight .kn { color: #fe8019; background-color: #282828 } /* Keyword.Namespace */ -.highlight .kp { color: #fe8019; background-color: #282828 } /* Keyword.Pseudo */ -.highlight .kr { color: #fe8019; background-color: #282828 } /* Keyword.Reserved */ -.highlight .kt { color: #fabd2f; background-color: #282828 } /* Keyword.Type */ -.highlight .ld { color: #ebdbb2; background-color: #282828 } /* Literal.Date */ -.highlight .m { color: #d3869b; background-color: #282828 } /* Literal.Number */ -.highlight .s { color: #b8bb26; background-color: #282828 } /* Literal.String */ -.highlight .na { color: #b8bb26; font-weight: bold; background-color: #282828 } /* Name.Attribute */ -.highlight .nb { color: #fabd2f; background-color: #282828 } /* Name.Builtin */ -.highlight .nc { color: #ebdbb2; background-color: #282828 } /* Name.Class */ -.highlight .no { color: #d3869b; background-color: #282828 } /* Name.Constant */ -.highlight .nd { color: #ebdbb2; background-color: #282828 } /* Name.Decorator */ -.highlight .ni { color: #fabd2f; background-color: #282828 } /* Name.Entity */ -.highlight .ne { color: #fb4934; background-color: #282828 } /* Name.Exception */ -.highlight .nf { color: #fabd2f; background-color: #282828 } /* Name.Function */ -.highlight .nl { color: #fb4934; background-color: #282828 } /* Name.Label */ -.highlight .nn { color: #ebdbb2; background-color: #282828 } /* Name.Namespace */ -.highlight .nx { color: #ebdbb2; background-color: #282828 } /* Name.Other */ -.highlight .py { color: #ebdbb2; background-color: #282828 } /* Name.Property */ -.highlight .nt { color: #fb4934; background-color: #282828 } /* Name.Tag */ -.highlight .nv { color: #ebdbb2; background-color: #282828 } /* Name.Variable */ -.highlight .ow { color: #fe8019; background-color: #282828 } /* Operator.Word */ -.highlight .w { color: #ebdbb2; background-color: #282828 } /* Text.Whitespace */ -.highlight .mb { color: #d3869b; background-color: #282828 } /* Literal.Number.Bin */ -.highlight .mf { color: #d3869b; background-color: #282828 } /* Literal.Number.Float */ -.highlight .mh { color: #d3869b; background-color: #282828 } /* Literal.Number.Hex */ -.highlight .mi { color: #d3869b; background-color: #282828 } /* Literal.Number.Integer */ -.highlight .mo { color: #d3869b; background-color: #282828 } /* Literal.Number.Oct */ -.highlight .sb { color: #b8bb26; background-color: #282828 } /* Literal.String.Backtick */ -.highlight .sc { color: #b8bb26; background-color: #282828 } /* Literal.String.Char */ -.highlight .sd { color: #b8bb26; background-color: #282828 } /* Literal.String.Doc */ -.highlight .s2 { color: #b8bb26; background-color: #282828 } /* Literal.String.Double */ -.highlight .se { color: #b8bb26; background-color: #282828 } /* Literal.String.Escape */ -.highlight .sh { color: #b8bb26; background-color: #282828 } /* Literal.String.Heredoc */ -.highlight .si { color: #b8bb26; background-color: #282828 } /* Literal.String.Interpol */ -.highlight .sx { color: #b8bb26; background-color: #282828 } /* Literal.String.Other */ -.highlight .sr { color: #b8bb26; background-color: #282828 } /* Literal.String.Regex */ -.highlight .s1 { color: #b8bb26; background-color: #282828 } /* Literal.String.Single */ -.highlight .ss { color: #83a598; background-color: #282828 } /* Literal.String.Symbol */ -.highlight .bp { color: #fabd2f; background-color: #282828 } /* Name.Builtin.Pseudo */ -.highlight .vc { color: #ebdbb2; background-color: #282828 } /* Name.Variable.Class */ -.highlight .vg { color: #ebdbb2; background-color: #282828 } /* Name.Variable.Global */ -.highlight .vi { color: #ebdbb2; background-color: #282828 } /* Name.Variable.Instance */ -.highlight .il { color: #d3869b; background-color: #282828 } /* Literal.Number.Integer.Long */ diff --git a/assets/fonts/Geist-Black.otf b/assets/fonts/Geist-Black.otf deleted file mode 100644 index c1489de..0000000 Binary files a/assets/fonts/Geist-Black.otf and /dev/null differ diff --git a/assets/images/icons/rss.svg b/assets/images/icons/rss.svg deleted file mode 100644 index 54759f9..0000000 --- a/assets/images/icons/rss.svg +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - rss [#1028] Created with Sketch. - \ No newline at end of file