Resources for learning web design & front-end development:
ONLINE
Design
// Define function. | |
function waitForDeps(obj, list) { | |
// Expose promise. | |
return new Promise((resolve) => { | |
// Start polling. | |
const interval = setInterval(() => { | |
// Get missing. | |
const listMissing = list.filter(key => !obj[key]); | |
// All clear? |
/** | |
* Gets the median for a list of numbers. | |
* | |
* @param {number[]} [listSorted=[]] | |
* @returns {number} | |
*/ | |
const getMedian = (listSorted = []) => { | |
// Get count. | |
const listCount = listSorted.length; |
Resources for learning web design & front-end development:
ONLINE
Design
# Route extension-less URLs to the equivalent *.html file. | |
# For instance: example.com/about = example.com/about.html | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteRule ^([^\.]+)$ $1.html [NC,L] | |
</IfModule> |
export type IJson = IJsonArray | IJsonObject | boolean | number | null | string; | |
export type IJsonArray = IJson[]; | |
/* | |
===== | |
NOTE: | |
===== | |
This is an `interface` because the reference |
// ====== | |
// Types. | |
// ====== | |
type DeepReadonly<T> = { | |
readonly [K in keyof T]: T[K] extends Record<PropertyKey, unknown> ? DeepReadonly<T[K]> : T[K]; | |
}; | |
// =========================== | |
// Helper: deep freeze object. |
/* | |
===== | |
NOTE: | |
===== | |
This works with LinkedIn's current markup, as of 2024-02-23. | |
Run it via the dev tools console, while on your "following" page. | |
https://linkedin.com/mynetwork/network-manager/people-follow/followers | |
*/ |
I came across some code awhile ago that, though I can't share exactly, I wanted to document as a "footgun."
You should never have a class
that can be used both as a singleton with helper methods and can be instantiated.
Even if you did, there should never be static
and public methods — by the same name — that do different things.
/*
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<meta http-equiv="x-ua-compatible" content="ie=edge" /> | |
<meta | |
name="viewport" | |
content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1" | |
/> | |
<title> |