Stan's blog Thanks for stopping by.
Posts with the tag web-dev:

Adding native image lazy-loading to Ghost with a Cloudflare Worker

In my recent post about Street Photography in South Korea, I embedded many high-res pictures. The total size of the page is about 40 MB, which is a bit much to load right away.

Adding syntax highlighting to Ghost with highlight.js

After my recent relooking, I finally took the time to add syntax highlighting for code snippets.

While Ghost doesn’t support code syntax highlighting out the box, it lays down the groundwork for it.

Deploying an Angular app on Heroku

I am currently working on a school project that involves an API made with NestJS and a front-end made with Angular 9. I wanted to properly set up auto-deployments from GitHub to a serverless hosting provider, so I turned to my old friend, Heroku. Heroku can host a bunch of software projects like NodeJS, Rails, Django, and more. An app deployed on Heroku has to be able to listen and answer HTTP requests.

Easy web deployments with Ansistrano

At my previous work we’ve been using Capistrano for years and it’s not particularly great. It does work well, but it really feels like messy Ruby scripting with messy documentation. We use Capistrano for a specific kind of projects which are usually PHP or Node deployed on multiple non-autoscaled webservers. Recently for school I had two Laravel projects to make. One of the requirements was to deploy them on a real webserver with a valid domain name, HTTPS, etc.

Ansible 2.8 + snapcraft: my first big FOSS contribution!

About a year ago, I started to manage my laptop via Ansible (as much as I could, at least). I had some software installed via snapcraft, a new package manager from Canonical. There was no Ansible module for snaps at the time, which was pretty surprising considering snapcraft has been getting quite some traction in the past few years. I assume it’s mostly used on desktops, and Ansible is mostly used on servers, hence the missing module.

Debug PHP in Docker using Xdebug with VS Code or PhpStorm

I’m tired of reading countless of tutorials about this, many of which include a lot of unnecessary steps and do not work on all platform. To put an end to this, I published a repo: php-xdebug-docker with everything that is necessary to get Xdebug to work with VS Code and PhpStorm when running the PHP code inside a Docker container, including a tutorial for both editors. The Dockerfile is based on the php:7-apache image.

How to compare a bcrypt hash between PHP and Node.js

I’m in a situation where a Node app and a PHP app are sharing a database. The PHP app handles the user registration and hashes the password using password_hash(). The password_hash() function uses the bcrypt algorithm if you specify PASSWORD_DEFAULT or PASSWORD_BCRYPT. With Node, the bcrypt NPM module can be used to compare the hash and the plain password, with a little gotcha. There are multiple versions of bcrypt: https://en.wikipedia.org/wiki/Bcrypt#Versioning_history

Node.js: Easily check code coverage with istanbul.js/nyc

In 2019, doing Test Driven Development is the norm. Your project probably has tests, but do you know how much of your code is executed when the tests are ran? That’s what code coverage is about. It’s a very useful measure to know which parts of the code are not reached by the tests. It’s not an absolute measure though, only an indicator. Parts of the code can be tested but still have bugs if the tests are not extensive enough.