Skip to content

Instantly share code, notes, and snippets.

View junaga's full-sized avatar

Hermann Stanew junaga

  • Germany | Google Cloud
  • 12:36 (UTC +02:00)
View GitHub Profile
@jakub-g
jakub-g / async-defer-module.md
Last active May 29, 2024 20:55
async scripts, defer scripts, module scripts: explainer, comparison, and gotchas

<script> async, defer, async defer, module, nomodule, src, inline - the cheat sheet

With the addition of ES modules, there's now no fewer than 24 ways to load your JS code: (inline|not inline) x (defer|no defer) x (async|no async) x (type=text/javascript | type=module | nomodule) -- and each of them is subtly different.

This document is a comparison of various ways the <script> tags in HTML are processed depending on the attributes set.

If you ever wondered when to use inline <script async type="module"> and when <script nomodule defer src="...">, you're in the good place!

Note that this article is about <script>s inserted in the HTML; the behavior of <script>s inserted at runtime is slightly different - see Deep dive into the murky waters of script loading by Jake Archibald (2013)

@fnky
fnky / ANSI.md
Last active June 1, 2024 23:15
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
[I ran across these on a Unix salesman's wall and haven't seen them posted
before. I modified them here and there. Followups are in net.jokes.]
People who come into contact with the Unix system are often told,
"If you have trouble, see so-and-so, he's a guru", or "Bob there is
a real Unix hacker."
What is a "Unix Wizard"? How does s/he differ from a "guru"?
To explore these and other questions, here is a draft of the "Unix Hierarchy":
@floer32
floer32 / tupperware.py
Last active September 26, 2022 12:13
recursively convert nested dicts to nested namedtuples, giving you something like immutable object literals
from UserDict import IterableUserDict
import collections
__author__ = 'github.com/hangtwenty'
def tupperware(mapping):
""" Convert mappings to 'tupperwares' recursively.