Skip to content

Instantly share code, notes, and snippets.

View zaygraveyard's full-sized avatar

Ziad El Khoury Hanna zaygraveyard

View GitHub Profile
@guest271314
guest271314 / compiling_standalone.md
Last active September 8, 2024 10:53
Compiling a standalone executable using modern JavaScript/TypeScript runtimes

Compiling a standalone executable using modern JavaScript/TypeScript runtimes

We have the same code working using node, deno, and bun.

E.g.,

bun run index.js

Welcome to the wacky world of almost 30 years of web

All of the following values for the <script type=" ••• "> will cause inline or external JavaScript to execute:

Value Note
"" The default value of script.type (eg: no type attribute present)
"text/javascript" The official JavaScript MIME type
"application/javascript" Legacy MIME type from when semantics mattered
"text/x-javascript" Legacy MIME type from before JavaScript was accepted as a valid MIME type
@pesterhazy
pesterhazy / indexeddb-problems.md
Last active September 9, 2024 23:30
The pain and anguish of using IndexedDB: problems, bugs and oddities

This gist lists challenges you run into when building offline-first applications based on IndexedDB, including open-source libraries like Firebase, pouchdb and AWS amplify (more).

Note that some of the following issues affect only Safari. Out of the major browsers, Chrome's IndexedDB implementation is the best.

Backing file on disk (WAL file) keeps growing (Safari)

When this bug occurs, every time you use the indexeddb, the WAL file grows. Garbage collection doesn't seem to be working, so after a while, you end up with gigabytes of data.

Random exceptions when working with a large number of indexeddb databases (Safari)

@IsaacXen
IsaacXen / README.md
Last active September 20, 2024 10:55
(Almost) Every WWDC videos download links for aria2c.
@slikts
slikts / advanced-memo.md
Last active September 12, 2024 18:33
Advanced memoization and effects in React

nelabs.dev

Advanced memoization and effects in React

Memoization is a somewhat fraught topic in the React world, meaning that it's easy to go wrong with it, for example, by [making memo() do nothing][memo-pitfall] by passing in children to a component. The general advice is to avoid memoization until the profiler tells you to optimize, but not all use cases are general, and even in the general use case you can find tricky nuances.

Discussing this topic requires some groundwork about the technical terms, and I'm placing these in once place so that it's easy to skim and skip over:

  • Memoization means caching the output based on the input; in the case of functions, it means caching the return value based on the arguments.
  • Values and references are unfortunately overloaded terms that can refer to the low-level implementation details of assignments in a language like C++, for example, or to memory
@LingDong-
LingDong- / npy-rw.js
Last active September 29, 2023 08:46
Read and write .npy (numpy) files in javascript
// npy-rw.js
// READ AND WRITE .NPY (NUMPY) FILES
// Lingdong Huang 2019
// npy specs: https://numpy.org/devdocs/reference/generated/numpy.lib.format.html
// reference: https://gist.github.com/nvictus/88b3b5bfe587d32ac1ab519fd0009607
const is_node = (typeof process !== 'undefined')
var npy = {};
@tomhicks
tomhicks / plink-plonk.js
Last active July 26, 2024 01:10
Listen to your web pages
# https://hakibenita.com/fast-load-data-python-postgresql
from typing import Iterator, Dict, Any, Optional
from urllib.parse import urlencode
import datetime
#------------------------ Profile
import time
@DavidKuennen
DavidKuennen / minimal-analytics-snippet.js
Last active September 20, 2024 01:37
Minimal Analytics Snippet
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
@rxwei
rxwei / ad-manifesto.md
Last active November 9, 2023 09:58
First-Class Automatic Differentiation in Swift: A Manifesto