Stan's blog Thanks for stopping by.
Posts with the tag programming:

Using Firecracker and Go to run short-lived, untrusted code execution jobs

Note This post has been discussed on Hacker News This semester I have been working on a school project where the main requirement was that we needed to execute user-submitted code in one form or another. My team’s subject was a code benchmarking platform, where users could create benchmarks (eg: sort these two arrays as fast as possible) and then anyone could submit solutions to the benchmarks. In this post, I want to dive in the code execution part of the project, the approach I took and how I used Firecracker, with concrete code snippets.

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.

Migrating comments from Isso to Disqus

I’ve been using Isso since I launched this blog and it’s been working very well but I still much prefer the Disqus experience. I didn’t find anything on the web about migrating from Isso to Disqus, which is to be expected. So I made my own tool, and I’m happy to report it works! Isso stores comments in an SQLite database. To import our comments on Disqus, we will have to somehow generate a XML file that matches their custom XML format, which is based on the WXR (WordPress eXtended RSS) schema.

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:

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.