Skip to content

Instantly share code, notes, and snippets.

Avatar
🎥
Making Low Level JavaScript on YouTube

Francis Stokes francisrstokes

🎥
Making Low Level JavaScript on YouTube
View GitHub Profile
View keyboard-remap-caps-arrows.json
{
"title": "Map CapsLock plus i/j/k/l to Arrows",
"rules": [
{
"description": "Map CapsLock plus i/j/k/l to Arrows",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "j",
View keybase.md

Keybase proof

I hereby claim:

  • I am francisrstokes on github.
  • I am francisstokes (https://keybase.io/francisstokes) on keybase.
  • I have a public key ASDAQWguSwFKdWeKeEvEeTyzezi0na5Pmhdva4wN2Cwj4wo

To claim this, I am signing this object:

@francisrstokes
francisrstokes / PipeDriveForm.js
Created Jul 12, 2019
PipeDrive Web Forms React Component
View PipeDriveForm.js
import React from 'react';
class PipeDriveForm extends React.Component {
constructor(props) {
super(props);
this.state = {
randomId: 'id' + Math.random().toString(36).substring(7)
};
}
@francisrstokes
francisrstokes / CompositionDSLGenerators.js
Created Dec 29, 2018
Function Composition DSL using generators
View CompositionDSLGenerators.js
const getDSLValue = (iterator, last) => {
const {value, done} = iterator.next(last);
if (done) {
return value.slice(1).reduce((x, f) => f(x), value[0]);
}
return getDSLValue(iterator, last ? [...last, value] : [value]);
}
const pipe = gen => getDSLValue(gen(null, ));
@francisrstokes
francisrstokes / GeneratorDSL.js
Last active Feb 24, 2020
Game-style DSL using generators
View GeneratorDSL.js
const getDSLValue = (iterator, last) => {
const {value, done} = iterator.next(last);
if (done) {
return value;
}
switch (value) {
case 'sword': {
return getDSLValue(iterator, {
weaponType: "Shiny Sword",
View AsyncAwaitGenerators.js
const interpret = iterator => last => {
const {value, done} = iterator.next(last);
return (done) ? Promise.resolve(value) : value.then(interpret(iterator));
};
const asyncAwait = g => interpret(g())();
// ... Usage ...
const addOneSoon = (x, t) => new Promise(resolve => {
@francisrstokes
francisrstokes / CSVParser.js
Last active Dec 27, 2018
Arcsecond Article
View CSVParser.js
const {
parse,
char,
many,
regex,
anythingExcept,
sepBy
} = require('arcsecond');
const joinedMany = parser => many (parser) .map(x => x.join(''));
View FullParser.js
const {
between,
many,
choice,
sequenceOf,
char,
whitespace,
anythingExcept,
possibly,
regex,
@francisrstokes
francisrstokes / UsingParser.js
Last active Dec 27, 2018
Arcsecond Article
View UsingParser.js
const { parse, char, str, sequenceOf, choice } = require('arcsecond');
// parse creates a function we can use for parsing text
const parseText = parse (combinedParser);
console.log(
parseText ('hello world')
)
// -> [ 'hello', ' ', 'world' ]
View ArrayMonad.js
const ArrayMonad = xs => {
const map = fn => ArrayMonad(xs.map(x => fn(x)))
const chain = fn => ArrayMonad(xs.reduce((ys, x) => [...ys, ...fn(x).xs], []))
const ap = mys => chain(f => mys['fantasy-land/map'](y => f(y)));
return {
xs,
'fantasy-land/map': map,
'fantasy-land/chain': chain,
'fantasy-land/ap': ap,
'constructor': ArrayMonad
You can’t perform that action at this time.