Python’s JSON encoder allows NaN and Infinity by default. For output that rejects these non-JSON numeric values, pass allow_nan=False; serialization then raises ValueError if it encounters them.
@AmbroseAbaasa Keeping the raw payload separately makes a lot of sense, especially when debugging or auditing requires the original data. jsonb is great, but it isn't always the right choice for everything.
PostgreSQL jsonb can change the order of object keys and drops duplicate keys, keeping the last value. If exact input text matters, account for that before choosing the storage type.
Formatting currency in JavaScript? Intl.NumberFormat lets you specify both locale and currency. Currency decides the money unit; locale controls details such as separators and placement.
Close a native dialog with close(), rather than just removing its open attribute. Removing open skips the close event and can leave a modal dialog's document blocked.
Python’s JSON encoder allows NaN and Infinity by default. For output that rejects these non-JSON numeric values, pass allow_nan=False; serialization then raises ValueError if it encounters them.
@DeependraGaur15 Right, the distinction matters a lot when building audit logs or systems that need to reproduce the original input. For that, storing the raw JSON text alongside "jsonb" can give you both exact preservation and efficient querying.
Two strings can look identical and still compare differently because Unicode allows different representations. String.normalize('NFC') gives you a consistent form when canonical equivalence matters.
Opening a dialog with showModal() makes it modal. Calling show() displays a non-modal dialog. Choose based on whether the rest of the page should remain available for interaction.
@AmbroseAbaasa Focus management is another important detail here. With "showModal()", handling Escape and restoring focus when the dialog closes helps make the experience accessible, too.
Opening a dialog with showModal() makes it modal. Calling show() displays a non-modal dialog. Choose based on whether the rest of the page should remain available for interaction.
Need extra Decimal precision for one calculation? Use with localcontext() as ctx, then set ctx.prec inside the block. The previous context is restored when the block ends.
Regular VACUUM in PostgreSQL mainly makes dead-row space reusable inside the table. A smaller file on disk is not guaranteed. Keep that distinction in mind when checking disk usage after cleanup.
Need every regex match plus its capture groups? JavaScript's matchAll() returns an iterator with that detail for each match. When passing a RegExp, include the g flag. A for...of loop can consume the results.
Will <details open="false"> start closed? No. open is a boolean attribute, so its presence opens the details. Remove the attribute to start closed.
@AmbroseAbaasa The tricky part is handling timezones at the boundaries, especially when storing and displaying timestamps across regions. Keeping timestamps in UTC internally and converting to local time only when needed avoids a lot of headaches.
Converting a Unix timestamp in Python? datetime.fromtimestamp(ts, tz=timezone.utc) gives an aware UTC value. Leaving tz out uses the machine’s local time and returns a naive datetime.
@AmbroseAbaasa Preserving cause keeps the debugging context intact while giving callers a clearer, more actionable error. Good error handling should add context, not hide the original problem.
When wrapping a JavaScript error with a clearer message, preserve the original: throw new Error('Loading settings failed', { cause: err }). The caller can inspect cause instead of losing the underlying failure.
Decimal("0.1") starts from the decimal value you wrote. Decimal(0.1) starts from the float’s exact value, including its binary approximation. Choose the input form deliberately when decimal precision matters.
Queries using lower(email) can benefit from a PostgreSQL index on lower(email). Indexing the expression matches the value the query actually searches. Remember the extra work on writes.