Skip to content

Instantly share code, notes, and snippets.

View WebReflection's full-sized avatar
🎯
Focusing

Andrea Giammarchi WebReflection

🎯
Focusing
View GitHub Profile
@WebReflection
WebReflection / executable-standalone-module.md
Last active March 4, 2024 20:55
NodeJS Executable Standalone Module

Update

If you're OK in having a node-esm executable, please consider this solution.

#!/usr/bin/env sh
# the /usr/local/bin/node-esm executable
input_file=$1
shift
exec node --input-type=module - $@ <$input_file

Bytecode And Web

Coming from this tweet: https://twitter.com/mathias/status/1115525813670227968

Similar way scripts with type module has been introduced, script with type bytecode and a specific engine target, including wasm, could make it too, so that engines able to digest pre-optimized code can benefit from this.

<script type="bytecode" engine="v8" src="v8.bc"></script>
<script type="bytecode" engine="spidermonkey" src="sm.bc"></script>
<script type="bytecode" engine="jsc" src="jsc.bc"></script>
@WebReflection
WebReflection / lys.js.md
Last active March 21, 2019 22:05
A `lys.js` crazy non sense

lys is a programming language that produces WASM, and its design goal is to be as simple as possible, yet useful to create utilities.

I've been thinking about a subset of JavaScript that could run natively on the browser, similarly to asm.js, but with the ability, through a dedicated parser, to target another language able, on its own, to produce WASM.

The following crazy non sense works already thanks to an agglomerated of modern and deprecated JS features and it might be interesting as experiment to see if a JS to WASM compiler, through the lys indirection, could be possible.

function lys(fn) {

  /*! (c) Andrea Giammarchi */
@WebReflection
WebReflection / pc-2-pi.md
Last active September 27, 2024 08:50
How to configure aarch64 Raspberry Pi 3 on ArchLinux

PC Setup

To make this possible you need qemu static built for other architectures. Be sure the following works before going any further here.

alias aur=pakku|yay|yaourt
aur -Sy --needed --noconfirm qemu-user-static # + deps, if proposed
# binfmt-qemu-static
@WebReflection
WebReflection / porn.js
Last active March 2, 2019 12:14
⚠ NSFW + Warning: You Cannot Unsee ⚠
/*! porn.js (NSFW) */
let Ɛ = 'b';
()=> {} // Shemale // arrow
()=>{} // // arrow
Ɛ=> {} // Straight // arrow
Ɛ=>{} // // arrow
@WebReflection
WebReflection / index.js
Last active November 20, 2018 19:03
hyperHTML does Cloudflare Worker
const basicHTML = require('basichtml');
basicHTML.init();
document.documentElement.setAttribute('lang', 'en');
const {bind} = require('hyperhtml');
const model = {
index: {
title: 'hyperHTML does Cloudflare too',
h1: {
@WebReflection
WebReflection / superposition.md
Last active February 9, 2026 15:20
How to run Unigine Superposition Benchmark in ArchLinux

OK, the amount of gotchas with unigine-superposition 1.1 benchmark is too damn high, which is a pity because it's awesome!!!

How to run Unigine Superposition Benchmark in ArchLinux

  • download the Linux (.run) version of Qt5.9, the latest version that works https://download.qt.io/official_releases/qt/5.9/5.9.0/
  • make it executable chmod a+x qt-opensource-linux-x64-5.9.0.run
  • run it ./qt-opensource-linux-x64-5.9.0.run
  • skip the registration bit and when prompt about what to install, check Qt5.9 too (top checkbox) and don't change the default path (or do it and adjust following commands). You migt try to not install the tools and see how that goes.
  • use yay, yaourt or pakku / pamac to install pakku -S --needed unigine-superposition and I suggest you do that after a sudo mount -o remount,size=20G,noatime /tmp. If it ends with an error, just sudo pacman -U the-big-tar-file-in-tmp
  • remove the Qt folder inside the unigine-super
/*! (c) Andrea Giammarchi - ISC */
const Rel = typeof Map === 'undefined' ?
function () {
const k = [], v = [];
return {
has: value => -1 < k.indexOf(value),
get: value => v[k.indexOf(value)],
set: value => {
const i = k.indexOf(value);
v[i < 0 ? (k.push(value) - 1) : i] = value;
@WebReflection
WebReflection / issue.md
Last active August 22, 2019 13:39
ESM as single file executable

How is ESM in NodeJS able to run any eecutable file as ES2015+ file ?

Example for a generic meta-url file:

#!/usr/bin/env node

console.log(import.meta.url);
@WebReflection
WebReflection / levenshtein.js
Created September 5, 2018 11:33
Levenshtein distance
// (c) 2018 Andrea Giammarchi
function levenshtein(from, to)
{
const fromLength = from.length + 1;
const toLength = to.length + 1;
const size = fromLength * toLength;
const grid = new Array(size);
let x = 0;
let y = 0;
let X = 0;