Skip to content

Instantly share code, notes, and snippets.

View joakim's full-sized avatar
🌿

joakim

🌿
View GitHub Profile
@guest271314
guest271314 / javascript_engines_and_runtimes.md
Last active May 14, 2024 18:15
A list of JavaScript engines, runtimes, interpreters

V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++. It is used in Chrome and in Node.js, among others. It implements ECMAScript and WebAssembly, and runs on Windows 7 or later, macOS 10.12+, and Linux systems that use x64, IA-32, ARM, or MIPS processors. V8 can run standalone, or can be embedded into any C++ application.

SpiderMonkey is Mozilla’s JavaScript and WebAssembly Engine, used in Firefox, Servo and various other projects. It is written in C++, Rust and JavaScript. You can embed it into C++ and Rust projects, and it can be run as a stand-alone shell. It can also be [compiled](https://bytecodealliance.org/articles/making-javascript-run-fast-on

@ornicar
ornicar / browser-ndjson-stream-reader.js
Last active November 9, 2023 19:02
Read a ND-JSON stream from the browser or from nodejs
/* FOR THE BROWSER
Utility function to read a ND-JSON HTTP stream.
`processLine` is a function taking a JSON object. It will be called with each element of the stream.
`response` is the result of a `fetch` request.
See usage example in the next file.
*/
const readStream = processLine => response => {
const stream = response.body.getReader();
const matcher = /\r?\n/;
@therightstuff
therightstuff / explanation.js
Last active January 3, 2023 14:39
Convert GUID (UUID) to integer numbers in Javascript (and back again)
// A UUID is a 128-bit number which is too large to be represented as a native integer in Javascript.
// The original solution I posted (based on https://github.com/uuidjs/uuid#uuidparsestr ) wasn't good,
// as it converted the given UUID into a byte array and then selected only the first four bytes to be
// used as the integer.
const uuid = require('uuid');
let convertGuidToInt = (uuid) => {
// parse accountId into Uint8Array[16] variable
let parsedUuid = uuid.parse(uuid);
@raiph
raiph / .md
Last active February 17, 2024 23:12
Raku's "core"

Then mathematical neatness became a goal and led to pruning some features from the core of the language.

— John McCarthy, History of Lisp

If you prefer programming languages with a tidy and tiny core, you're in for a treat. This article drills down to the singleton primitive at the heart of Raku's metamodel ("model of a model") of a model of computation ("how units of computations, memories, and communications are organized")1.

The reason I've written this article

It began with u/faiface's reddit post/thread "I'm impressed with Raku"2. One of their sentences in particular stood out for me:

@wongjiahau
wongjiahau / funcords.js
Last active February 7, 2022 09:17
Funcords
/*
Funcords is a feature that combine functions and records.
If you think about it, record is actually a dependently typed function,
where the output type depends on the input type.
For example,
r = {'x': 1, 'y': 'yo'}
const sass = require('node-sass');
// related: https://github.com/UnwrittenFun/svelte-vscode/issues/1
module.exports = {
preprocess: {
style: async ({ content, attributes }) => {
if (!['text/sass', 'text/scss'].some(attributes.type) && !['sass', 'scss'].some(attributes.lang)) return;
return new Promise((resolve, reject) => {
@atoponce
atoponce / gist:07d8d4c833873be2f68c34f9afc5a78a
Last active May 14, 2024 00:59 — forked from tqbf/gist:be58d2d39690c3b366ad
Cryptographic Best Practices

Cryptographic Best Practices

Putting cryptographic primitives together is a lot like putting a jigsaw puzzle together, where all the pieces are cut exactly the same way, but there is only one correct solution. Thankfully, there are some projects out there that are working hard to make sure developers are getting it right.

The following advice comes from years of research from leading security researchers, developers, and cryptographers. This Gist was [forked from Thomas Ptacek's Gist][1] to be more readable. Additions have been added from

/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
@pascaldekloe
pascaldekloe / utf8.js
Last active September 9, 2023 05:21
JavaScript UTF-8 encoding and decoding with TypedArray
// This is free and unencumbered software released into the public domain.
// Marshals a string to an Uint8Array.
function encodeUTF8(s) {
var i = 0, bytes = new Uint8Array(s.length * 4);
for (var ci = 0; ci != s.length; ci++) {
var c = s.charCodeAt(ci);
if (c < 128) {
bytes[i++] = c;
continue;

NavigationExperimental notes

Containers

RootNavigationContainer

  • You pass the reducer to this, it actually ultimately receives all navigation calls via onNavigate, which is mostly equivalent to Redux dispatch. It setState and persisting state. it is like the redux "store"