Use USB drive as apt-get cache for frequent Raspberry PI reinstalls

I work on a configuration script for a Raspberry Pi, and as I debug it, more often than not I need to run reinstall over and over. On a metered connection it may be a problem, as not only it’s slow, it also uses your data plan. A way around this would be having a… Continue reading Use USB drive as apt-get cache for frequent Raspberry PI reinstalls

Custom file extensions (e.g. .env): routing and rendering serialized responses

It is fairly common to add json handler to a CakePHP route and have it automatically respond with formatted JSON. Consider this example. In your route: $routes->prefix(‘Api’, function (RouteBuilder $routes) { $routes->setExtensions([‘json’]); $routes->fallbacks(DashedRoute::class); }); In your controller: public function initialize(): void { parent::initialize(); $this->addViewClasses([\Cake\View\JsonView::class]); $this->viewBuilder()->setOption(‘serialize’, true); } So now when you request actions in that… Continue reading Custom file extensions (e.g. .env): routing and rendering serialized responses

Deploying a simple CakePHP app to Render.com using Docker

Render doesn’t have a ā€œnative PHP runtimeā€ like it does for Node/Python, but it does have Docker. So we can use a Docker image that will set up the PHP runtime for us. To make it happen, we will have to add these two files to our application: Dockerfile that imports and uses a prebuilt… Continue reading Deploying a simple CakePHP app to Render.com using Docker

Connection to Sqlite not established, unable to open database file

The problem You created a new CakePHP application and you try to visit its homepage. You get a database error. Missing Database Connection Cake\Database\Exception\MissingConnectionException Connection to Sqlite could not be established: SQLSTATE[HY000] [14] unable to open database file The (potential) reason Check your composer.json and see if your application uses cakephp/debug_kit: “require-dev”: { … “cakephp/debug_kit”:… Continue reading Connection to Sqlite not established, unable to open database file

Using peewee with mysql-connector-python

The problem You already import mysql.connector in your project and you want to use peewee, only problem is: peewee.ImproperlyConfigured: MySQL driver not installed! It’s a known issue since 2018: Why does not peewee support mysql-connector-python? Ā· Issue #1501 Ā· coleifer/peewee. The advice is to: either install pymysql or implement a proxy driver for the mysql.connector… Continue reading Using peewee with mysql-connector-python

Creating API credentials for certbot-dns-oci

The setup You want to generate Letsencrypt certificates using DNS-01 challenge (e.g. wildcard certificates) and you host your domain on Oracle Cloud. Your code is in Python and you want to use certbot-dns-oci for updating the TXT DNS records for the DNS-01 challenge. The problem You need to provide some OCI credentials to certbot-dns-oci and… Continue reading Creating API credentials for certbot-dns-oci

Debugging cron environment on Azure Web App Service

I wrote a service script in Python and I wanted it to run daily on Azure Web App Service. The catch? Same script will run differently when launched manually via SSH and when triggered with cron. Most notably, it will be missing all your environment variables. So how do you know what actually is in… Continue reading Debugging cron environment on Azure Web App Service