Skip to content

Instantly share code, notes, and snippets.

View aziis98's full-sized avatar

Antonio De Lucreziis aziis98

View GitHub Profile
@aziis98
aziis98 / template.tex
Created April 16, 2019 20:46
Mio template per le cose in LaTeX. Font: Linux Libertine,
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage{libertine}
\usepackage{libertinust1math}
\usepackage[T1]{fontenc}
\usepackage{titlesec}

WebVM (SmallTalk VM)

This is the actual definition of the custom VM to run web bytecode.

The various options for the VM are:

  • Stack based (like the JVM)
  • Register based (like LUA (?))
  • Functional (?) (Some Lisp-like thingy)

Nah, let's go for the stack based one that seems decent. So one bytecode can be one of the following operation

(A number := 12)
(A bit of text := "Here there is some text")
(println (join (A bit of text) " and the number " (A number)))
(Sum of things := ((A number) + 5))
(i, j := (tuple of 12 and 16))
Expression
= _ expression:(BinaryExpression / Macro / UnaryExpression / BraceBlock / Value) _ {
return expression;
}
ArgBlock
= BraceBlock / BracketBlock
BracketBlock

Loading Bar Image

A prototype for an image with a progress bar that show the progress of download of the image.

Usage

First create an HeavyImage instance with the target URL and then place the internal element somewhere on the page using theImage.$element and when ready stard downloading the image with theImage.load().

@aziis98
aziis98 / basic-type-system-peg.js
Last active August 30, 2018 15:06
A simple PEGjs parser for a basic custom type system (Parses primitive types, generics (lowcase symbols), arrays (haskell way), functions (args are comma separated and after a right arrow there is a return type) and union types). Can be tried out here https://pegjs.org/online
// Copyright Antonio De Lucreziis 2018
/*
A simple PEGjs parser for a basic custom type system (Parses primitive types, generics (lowcase symbols), arrays (haskell way), functions (args are comma separated and after a right arrow there is a return type) and union types).
Can be tried out here https://pegjs.org/online
*/
vec4 stroke(float distance, float linewidth, float antialias, vec4 stroke)
{
float t = linewidth / 2.0 - antialias;
float signed_distance = distance;
float border_distance = abs(signed_distance) - t;
float alpha = border_distance / antialias;
alpha = exp(-alpha * alpha);
if( border_distance < 0.0 )
const structuralReplace = (string, pattern, replacer) => {
if (typeof string === 'string') {
const acc = [];
let m;
let prevIndex = 0;
while (m = pattern.exec(string)) {
// Haskell-Like Type Syntax
// for Fragment Editor
// ========================
//
start
= Type
Type
= NamedType / ArrayType / ObjectType

Glob

This node selects a group of files based on a pattern using the "glob" npm package.

Definition

Input Type
pattern Text