Skip to content

Instantly share code, notes, and snippets.

@DmitrySoshnikov
DmitrySoshnikov / syntax.s
Created Jan 27, 2018 — forked from mishurov/syntax.s
AT&T assembly syntax and IA-32 instructions
View syntax.s
# --------
# Hardware
# --------
# Opcode - operational code
# Assebly mnemonic - abbreviation for an operation
# Instruction Code Format (IA-32)
# - Optional instruction prefix
# - Operational code
View int16.js
/**
* int16, and uint16 numbers in JS.
*
* by Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
*/
const assert = require('assert');
/**
* Converts a number to signed 16-bit integer.
View agent-smith.js
// agent-smith.js
/**
* Receive shared array buffer in this worker.
*/
onmessage = (message) => {
// Worker's view of the shared data.
let heapArray = new Int32Array(message.data);
let indexToModify = 1;
View event-loop.js
/**
* Event loop.
*
* Read details here:
* http://dmitrysoshnikov.com/ecmascript/javascript-the-core-2nd-edition/#job
*
* by Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
*/
/**
View dfa-minimization.js
/**
* DFA minization.
*
* A DFA table is minimized using N-equivalence algorithm.
*
* by Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
*/
/**
* Non-minizied DFA table for `/a|b/`.
@DmitrySoshnikov
DmitrySoshnikov / NFA-DFA-RegExp.js
Last active May 21, 2021
Classic RegExp implementation (NFA, DFA)
View NFA-DFA-RegExp.js
/**
* Classic RegExp implementation (NFA, DFA).
*
* by Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
* MIT License, 2017
*/
/**
* Epsilon.
*/
View NFA.js
/**
* NFA (Non-deterministic finite automata)
*
* A formalism for regular grammars (to recognize strings based on regular
* expressions).
*
* Regexp parser to transform AST to NFA:
* https://www.npmjs.com/package/regexp-tree
*
* NFA/DFA fragment examples:
View JNI-Example-Mac.md

JNI Example (Mac OS)

JNI (Java Native Interface) allows implementing methods in C/C++, and use them in Java.

1. Create JNIExample.java file

class JNIExample {

  // Native method, no body.
View js-runtime-augmented-scope.js
/**
* JavaScript runtime-augmented scope example.
*/
let x = 10;
let o = {x: 30};
let storage = {};
(function foo(flag) {
View js-dynamic-this.js
/**
* JavaScript dynamic `this` value.
*/
function produce() {
console.log(this.x);
}
const alpha = {produce, x: 1};
const beta = {produce, x: 2};