Skip to content

Instantly share code, notes, and snippets.

View BillyWM's full-sized avatar
🙉
🕹

William Wenge-Murphy BillyWM

🙉
🕹
View GitHub Profile
@cure53
cure53 / wasm.md
Last active October 17, 2023 00:16
Calling alert from WASM

Calling alert from WebAssembly (WASM)

This very simple and minimal tutorial documents in a few easy steps how to play with WebAssembly (WASM) and get first results within minutes.

While the code below is mostly useless, it will show, how to call the alert function from within a WASM file and thus demonstrate how to import and export DOM objects.

Of course, this exercise has no real use. It is just meant to show, that getting started with WASM isn't hard. And there is no need for a complex build-chain, tons of tools or a dedicated VMs. Just use a browser, one online tool and that's it.

And Now?

@gaearon
gaearon / connect.js
Last active April 11, 2024 06:46
connect.js explained
// connect() is a function that injects Redux-related props into your component.
// You can inject data and callbacks that change that data by dispatching actions.
function connect(mapStateToProps, mapDispatchToProps) {
// It lets us inject component as the last step so people can use it as a decorator.
// Generally you don't need to worry about it.
return function (WrappedComponent) {
// It returns a component
return class extends React.Component {
render() {
return (
@ericelliott
ericelliott / custom-iterable.js
Last active July 23, 2018 23:29
JavaScript custom iterable
const countToThree = {
a: 1,
b: 2,
c: 3
};
countToThree[Symbol.iterator] = function* () {
const keys = Object.keys(this);
const length = keys.length;
@rauchg
rauchg / README.md
Last active January 6, 2024 07:19
require-from-twitter
@domenic
domenic / angularpromise.js
Created January 21, 2016 23:28
How to subclass a promise
// ES6
class AngularPromise extends Promise {
constructor(executor) {
super((resolve, reject) => {
// before
return executor(resolve, reject);
});
// after
}
@Schemetrical
Schemetrical / The_Jaunt.md
Last active May 2, 2024 01:30
The Jaunt by Stephen King

Chapter 1

"This is the last call for Jaunt-701," the pleasant female voice echoed through the Blue Concourse of New York's Port Authority Terminal. The PAT had not changed much in the last three hundred years or so - it was still gungy and a little frightening. The automated female voice was probably the most plesant thing about it. "This is Jaunt Service to Whitehead City, Mars," the voice continued. "All ticketed passengers should now be in the Blue Concourse sleep lounge. Make sure your validation papers are in order. Thank you."The upstairs lounge was not at all grungy. It was wall-to-wall carpeted in oyster gray. The walls were an eggshell white and hung with plesant nonrepresentational prints. A steady, soothing progression of colors met and swirled on the ceiling. There were one hundred couches in the large room, neatly spaced in rows of ten. Five Jaunt attendants circulate, speakingin low, cherry voices and offering glasses of milk. At one side of the room was the entranceway, flanked by armed guar

@jindrichmynarz
jindrichmynarz / dub_techno_in_sonic_pi.rb
Created December 8, 2015 19:11
Dub techno in Sonic Pi
use_debug false
use_bpm 130
# Our mixer!
master = (ramp *range(0, 1, 0.01))
kick_volume = 1
bass_volume = 1
revbass_volume = 1
snare_volume = 0.5
hats_volume = 0.5
@dmajda
dmajda / indentation-based.pegjs
Created November 27, 2015 15:00
Simple intentation-based language PEG.js grammar
/*
* Simple Intentation-Based Language PEG.js Grammar
* ================================================
*
* Describes a simple indentation-based language. A program in this language is
* a possibly empty list of the following statements:
*
* * S (simple)
*
* Consists of the letter "S".
@subfuzion
subfuzion / tracing-with-pegjs.md
Last active March 6, 2021 12:56
Tracing with peg.js

PEG.js is a simple parser generator for JavaScript that produces fast parsers with excellent error reporting. You can use it to process complex data or computer languages and build transformers, interpreters, compilers and other tools easily.

PEG.js offers tracing support to help analyze parser issues with a grammar. The feature is very helpful, but it's not available yet on the version that's published to npm, it's not well-advertised, and not well-documented. This gist explains how to take advantage of PEG.js tracing support.

When you generate your parser, make sure you supply the trace option set to true. If using gulp, do something like this:

var peg = require('gulp-peg');

var paths = {
@DmitrySoshnikov
DmitrySoshnikov / Recursive-descent-backtracking.js
Last active January 3, 2024 17:15
Recursive descent parser with simple backtracking
/**
* = Recursive descent parser =
*
* MIT Style License
* By Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
*
* In this short lecture we'll cover the basic (non-predictive, backtracking)
* recursive descent parsing algorithm.
*
* Recursive descent is an LL parser: scan from left to right, doing