You deploy your Node.js code to Azure Web Apps. In your code, you want to know the latest deployment commit ID/hash. Since Azure does not keep the information in environment variables, we will need to call a custom script on each build from package.json.
Category: Development
Deploying a Node.JS application to Azure Web App Service
If you deployed your Node.JS app to Azure and you can’t get it to run, a common gotcha is the port number your app is listening on. When troubleshooting, you may be reading that Azure allows incoming connections only to ports 80 and 443. So you make your app listen to 80 or 443, but… Continue reading Deploying a Node.JS application to Azure Web App Service
Searching for code snippets in a given directory
One thing that saved me lots of time and potential bugs is using grep for a given string in a given directory. Imagine you decided to rename a function and you now need to update every piece of code that calls it. No chance you will remember all places where you used it, and manually… Continue reading Searching for code snippets in a given directory
CRUD View: _getIndexTitleField() must be of type string, array returned
Setup You’re using CakePHP with CRUD plugin installed. You baked some models from the database. Problem You visit the index page for a given model and you get the following error: CrudView\Listener\ViewListener::_getIndexTitleField(): Return value must be of type string, array returned Solution Make sure the model has a display field. You can always try using… Continue reading CRUD View: _getIndexTitleField() must be of type string, array returned
Complex CASE-THEN-WHEN expressions as columns in select queries
(Below has been tested on CakePHP 5, but should work on 3+.) Say you’re working on a query that may have to do some currency conversion on the go if user’s currency is different from the currency in your database. To make it worse, your site may use a third currency as a base currency… Continue reading Complex CASE-THEN-WHEN expressions as columns in select queries
Getting started with Paginator: a minimal example
The built-in pagination changed in more recent CakePHP versions (4 and 5), it is now a view helper and no longer a controller component. MVP In your Controller where you want to use pagination, load the helper: public function initialize(): void { parent::initialize(); $this->viewBuilder()->addHelper(‘Paginator’); } Paginate your query results before passing them to the view… Continue reading Getting started with Paginator: a minimal example
Containing threaded association
CakePHP has find('threaded') which lets you fetch records recursively. A good example is threaded comments. Say, you have Articles hasMany Comments, and each comment can have a parent, linked via parent_comment_id. You define your association as usual. Then in the Comments table add the following: public function beforeFind($event, $query, $options, $primary) { $query->find('threaded', [ 'parentField'… Continue reading Containing threaded association
Datasource class could not be found
Let’s say you defined a new connection example-connection in your config/app_local.php: ‘example-connection’ => [ ‘host’ => ‘localhost’, ‘username’ => ‘my_username’, ‘password’ => ‘my_password’, ‘database’ => ‘my_database_name’, ‘url’ => env(‘DATABASE_URL’, null), ], If you don’t specify className and driver, you may be getting a MissingDatasourceException error. [Cake\Datasource\Exception\MissingDatasourceException] Datasource class example-connection could not be found. To fix,… Continue reading Datasource class could not be found
oracle-free-tier-compute-instance-vps-install-debian-10-buster-image
Post moved to https://faxmodem.eu/blog/development/cloud-serverless/oracle-free-tier-compute-instance-vps-install-debian-image/
Android Studio Virtual Device: Installing and Gotchas, pre-Android 7
Android 7+ introduces certificate pinning that makes it more difficult to debug the requests the device makes. This covers the pre-certificate-pinning Android versions. Install Download and install. Here’s the archive with all available versions: https://developer.android.com/studio/archive. I will be installing 2023.2.1.25. First Launch; Choosing SDK If Android Studio crashes every time you try to open it,… Continue reading Android Studio Virtual Device: Installing and Gotchas, pre-Android 7