==========================
== Zhuo Hong Wei's Blog ==
==========================
Any and everything

Writing a Barebones Test Library

Here’s my latest experiment with Common Lisp, trying to write a small library for testing simple predicates. It runs a series of tests and report whether each test passed or failed, with a short summary at the end, (defmacro make-test (name predicate) `(lambda () (let ((p ,predicate)) (if p (format t "Test `~A` passed~%" ,name) (format t "Test `~A` failed~%" ,name)) p))) (defun run-tests (&rest tests) (let* ((score (lambda (p) (if p 1 0))) (run-test (lambda (test) (funcall test))) (scores (map 'list score (map 'list run-test tests))) (num-tests (length scores)) (num-passes (reduce #'+ scores))) (format t "~A out of ~A tests passed~%" num-passes num-tests))) To use it I do the following, Read more...

The Stateless Engineer

During a lunch conversation with my colleagues, the term Stateless Engineer was accidentally bornt. Imagine a future world where engineers are not defined by the team or product that they work on. Engineers are flexibly organized and re-organized into teams based on their skillsets to solve specific problems or work on products. Engineers are not tied to a fixed team or product for long periods of time. Engineers are not prevented from joining a new team because they do not have necessary context. Read more...

My First Common Lisp Macro

I have always been curious about Common Lisp macros and I finally dipped my toes into Common Lisp. Today I wrote my first macro to replicate ordered execution like (BEGIN expr1 expr2 …) in Scheme. (defmacro begin (&rest args) `(let ((ret ((lambda () ,@args)) )) ret))

A Review of Database Isolation Levels

There are some concepts that I have learnt in school but can’t seem to remember, revisiting wikipedia every few years. For example, database isolation levels. I wrote this simple post to help me reason and remember. There are four isolation levels, READ UNCOMMITTED, READ COMMITTED, REPEATABLE READS, and SERIALIZABLE. Imagine A and B are transactions. Read uncommitted A: select salary from employees where employee_id=5; // 1000 B: update employees set salary = 2000 where employee_id=5; //salary updated to 2000 A: select salary from employees where employee_id=5; // 2000 Read committed A: select salary from employees where employee_id=5; // 1000 B: update employees set salary = 2000 where employee_id=5; //salary updated to 2000 A: select salary from employees where employee_id=5; // 1000 B: * commit transaction * A: select salary from employees where employee_id=5; // 2000 Repeatable reads A: select salary from employees where employee_id=5; // 1000 B: update employees set salary = 2000 where employee_id=5; //salary updated to 2000 A: select salary from employees where employee_id=5; // 1000 B: * commit transaction * A: select salary from employees where employee_id=5; // 1000 Serializable A: select count(*) from employees; // 1 A locks selected records B needs to wait until A releases lock A: select count(*) from employees; // 1

2020 in Review

Personally, 2020 is definitely a year to remember. Here’s why: A full year of lockdown, work from home and restricted travel. I left my comfort zone after developing iOS applications for over 8 years. Transitioning into a full stack role, I had a lot of catch up to do for web and backend development. It was like a Rip Van Winkle moment, waking up to a radically different frontend and backend landscape. Read more...
Previous Page 3 of 3