Found all these from nix-repl. Use builtins.fetchTarball for nixpkgs pinning!

View flow_optional_parameters.js
// undefined | string
function optionalF (optional?: string) {
console.log(typeof optional);
// undefined | null | string
function maybeF (maybe: ?string) {
console.log(typeof maybe);
View isPrefixOf.js
// this is fully tail recursive
// also note that isPrefixOf([], []) is true
function isPrefixOf ([head1, ...tail1], [head2, ...tail2], prefixEquality = true) {
if (!prefixEquality) return false;
if (head1 === undefined) return true;
if (head2 === undefined) return false;
return isPrefixOf(tail1, tail2, head1 === head2);

Error and Exception Handling Techniques

Reposting here for safe keeping.

Error Codes

One of the return values is the error. Use when the goal is to cover-your-ass by ensuring that error handling is possible, even though you know any error handling or recovery would clutter the happy-path and thus ensure programmers are reluctant to admit to their existence at all.

View shift_timezone.php
// remember that timezones are a political-social thing
// they can change at any time
// this means you want a globally updated source of timezones
// this is usually provided by iana
// PHP distributions usually packages the latest timezone db at thier release
// but they can be outdated
// to update your version you need to download these:
// this is why you must always store datetime as UTC in your single source of truth

Isolated MySQL Environment

The advantage of this, is that you can work on multiple independent MySQL servers at the same time.

Further more you won't use global sockets, only filesystem unix domain sockets, which means you will not have to deal with port conflicts. Also this is much lower overhead than using something like Docker.

# first we create our isolated project directory
View get_privileges.sql
SELECT * FROM mysql.user
View get_lock.sql
-- when creating events on MySQL,
-- you probably don't want the events to run simultaneously
-- if the execution of a event takes too long
-- this shows you to use GET_LOCK and RELEASE_LOCK with events
-- note that GET_LOCK and RELEASE_LOCK unlike many other MySQL commands
-- do not automatically namespace themselves within the currently used database
-- so we have to use this CONCAT_WS technique
-- note that unlike cron, mysql events when scheduled as recurring without a designated start date
-- will immediately execute upon creation
-- you can confirm this with SELECT * FROM\G