If you deploy a Python (or any) app to Azure App Service for Linux, you may find that cron jobs in /etc/cron.d/ silently stop working. This is because App Service runs your app through a custom container with a startup.sh as PID 1, and the cron daemon is never started. Even if the cron package… Continue reading Cron not working on Azure App Service (Linux)
Category: Development
Debugging a 3rd party library in Python
You use a 3rd party library in your Python project and at one point you want to see exactly what it does. For example, you want to see what Yahoo Finance API URLs does yahooquery call internally. It uses a _get_data() function that uses some other function to build the URL and you just want… Continue reading Debugging a 3rd party library in Python
Oracle Cloud FreeBSD: LaunchInstance NotAuthorizedOrNotFound
I created an instance configuration on Oracle Cloud based on FreeBSD-14.2-RELEASE-arm64-ufs image (could have been any other FreeBSD). When launching an instance from this configuration, I got: Error returned by LaunchInstance operation in Compute service.(404, NotAuthorizedOrNotFound, false) Authorization failed or requested resource not found. The likely problem is some value is missing in the instance… Continue reading Oracle Cloud FreeBSD: LaunchInstance NotAuthorizedOrNotFound
Recovering an Oracle Cloud instance
Use case: you have an Oracle Cloud instance but lost SSH access to it. To recover access, you need to know which pubkey you used on it, or which port SSH is listening on. Or, you don’t want to terminate it before you make sure it doesn’t contain important data. Solution: you will have to… Continue reading Recovering an Oracle Cloud instance
Deploying a Python bot to Azure Web App Service (Free Tier)
Run a Python bot for free on Azure Web App Service Pre-requisite: have a bot. You can use mehov/bot-clock as an example. It works with Telegram, so you will need TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID – see the bot’s readme for more info. Create a new Web App Go to Azure Portal → App Services and create… Continue reading Deploying a Python bot to Azure Web App Service (Free Tier)
Python doesn’t print logs on Render.com
When you deploy a Python Web Service to Render.com, your print statements may not work. They may appear later if they get buffered, but in most cases you want them to be put out immediately in the console. Render logs everything output to STDOUT. So you’ll need to make sure you configure your logging library… Continue reading Python doesn’t print logs on Render.com
Reading and writing geospatial in CakePHP 5.1+
CakePHP 5.1.0 introduced support for geospatial types, but for now it’s limited. Here’s how you can read and write these values easily.
“Authentication is required to continue” when loading Authentication component
If you use cakedc/users or cakephp/authentication and want to programmatically log in a newly created user, you will have to use setIdentity() on Authentication component, and for that you will have to load it into your controller. But if you do it wrong, you will get this error: Authentication is required to continue Authentication\Authenticator\UnauthenticatedException To… Continue reading “Authentication is required to continue” when loading Authentication component
Optional parameter in named routes
Let’s say you want to make a named CakePHP route which may or may not have an argument. For example, you want to return WHOIS information for an IP address: /whois/1.1.1.1 returns WHOIS information for 1.1.1.1 which is specifically passed in the URL; /whois will return WHOIS information for the visitor’s IP address. When doing… Continue reading Optional parameter in named routes
Changing request IP address for debugging in CakePHP
If you’re working on a feature that acts differently based on the request IP address, you would be wanting to test it continuously. For that, you may have to have your application think you’re accessing it from a specific/different IP address. The easiest way would be to just store the IP in a variable and… Continue reading Changing request IP address for debugging in CakePHP