Skip to content

Instantly share code, notes, and snippets.

Avatar

Lance Pollard lancejpollard

View GitHub Profile
@lancejpollard
lancejpollard / vm8.js
Created Sep 26, 2020
Virtual Machine Version 8
View vm8.js
const START = 256
const I_INSTRUCTION_POSITION = 0
const I_PARAM_1 = 1
const I_PARAM_2 = 2
const I_PARAM_3 = 3
const I_PARAM_4 = 4
const I_PARAM_5 = 5
const I_PARAM_6 = 6
View vm.js
//
// THIS IS PSEUDOCODE half JavaScript, a little C.
//
//
// All variables are 32-bit integers for JavaScript.
//
struct fiber {
@lancejpollard
lancejpollard / nesting.js
Last active Aug 29, 2020
JavaScript nested functions
View nesting.js
function x() {
let a = 10
function y() {
a *= 2
console.log(a)
}
setTimeout(y, 10)
}
function makeCounter() {
@lancejpollard
lancejpollard / dnsmasq_setup_osx.md
Created Jul 26, 2020 — forked from eloypnd/dnsmasq_setup_osx.md
wildcard DNS record on OS X in localhost development with dnsmasq
View dnsmasq_setup_osx.md

wildcard DNS in localhost development

$ brew install dnsmasq
   ...
$ cp /usr/local/opt/dnsmasq/dnsmasq.conf.example /usr/local/etc/dnsmasq.conf
  • edit /usr/local/etc/dnsmasq.conf
address=/local/127.0.0.1
@lancejpollard
lancejpollard / binary-addition.js
Created Jul 6, 2020 — forked from nealfennimore/binary-addition.js
Binary addition in javascript
View binary-addition.js
/**
* Add two bits together and get resulting bits
*
* @param {Number} a bit a
* @param {Number} b bit b
* @returns {Array<Number, Number>} Carry and sum as a result of addition
*/
function addBits(a, b){
return [ +( a && b ), +( a !== b ) ];
View memcpy.asm
page ,132
title memcpy - Copy source memory bytes to destination
;***
;memcpy.asm - contains memcpy and memmove routines
;
; Copyright (c) Microsoft Corporation. All rights reserved.
;
;Purpose:
; memcpy() copies a source memory buffer to a destination buffer.
; Overlapping buffers are not treated specially, so propogation may occur.
@lancejpollard
lancejpollard / chacha20.js
Created May 29, 2020 — forked from rumkin/chacha20.js
Chacha20-Poly1305.js
View chacha20.js
/* chacha20 - 256 bits */
// Written in 2014 by Devi Mandiri. Public domain.
//
// Implementation derived from chacha-ref.c version 20080118
// See for details: http://cr.yp.to/chacha/chacha-20080128.pdf
function U8TO32_LE(x, i) {
return x[i] | (x[i+1]<<8) | (x[i+2]<<16) | (x[i+3]<<24);
}
@lancejpollard
lancejpollard / libuv-overview.c
Created Apr 11, 2020
High level overview of libuv looping.
View libuv-overview.c
int uv_run(uv_loop_t* loop, uv_run_mode mode) {
int timeout;
int r;
int ran_pending;
r = uv__loop_alive(loop);
if (!r)
uv__update_time(loop);
while (r != 0 && loop->stop_flag == 0) {
You can’t perform that action at this time.