Skip to content

Instantly share code, notes, and snippets.

View foldr-lazy-hack.js
const foldrLazy = (fn, initialValue, [element, ...rest]) => {
if (element === undefined) {
return initialValue;
}
const exists = () => foldrShortCircuit(fn, initialValue, rest);
return fn(element, exists);
};
View foldr.js
const foldr = (fn, initialValue, [element, ...rest]) => {
if (element === undefined) {
return initialValue;
}
return fn(element, foldr(fn, initialValue, rest));
};
View queue.js
const queueIfRunning = originalFn => {
let queuedCall;
let isRunning;
const runner = async (...originalArgs) => {
// If currently running, queue the next run
if (isRunning) {
queuedCall = originalArgs;
} else {
isRunning = true;
View if_else_else.js
// Input
if (a) {1;} else if(b) {2;} else {3;}
// AST
{
"name": "if",
"condition": [
{ "name": "(" },
{ "name": "identifier", "children": [ "a" ] },
{ "name": ")", "children": [ " " ] }
@AndrewRayCode
AndrewRayCode / grammar.pegjs
Created Oct 19, 2020
right association peg.js
View grammar.pegjs
{
const node = (name, children) => ({
name,
children: [children].flat(),
});
const rightAssociate = (...nodes) => {
const [last, penultimate, ...flat] = nodes.flat().reverse();
return flat.reduce((current, previous) => node(
current.name,
View gist:dec25c1679614fdedc15c53fb8fa594b
// https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.4.40.pdf
// Angle grammar
CONST = "const"
BOOL = "bool"
FLOAT = "float"
DOUBLE = "double"
INT = "int"
UINT = "uint"
View gist:099eff7d4a89edc5f1be7e8ced30d874
{
// Map containing the names of structs defined in the shader mapped to "true".
var typeNames = { };
// Identifer for each node.
var next_id = 0;
function pos() {
return {
View Dangus.tsx
const Dangus = () => {
const group = useRef();
useThingy(() => {
const { current } = group;
if (current) {
current.prop = 'hi'; // Object is possibly 'undefined'.
}
});
@AndrewRayCode
AndrewRayCode / Dockerfile
Last active Sep 20, 2019
SumoJanus run error
View Dockerfile
FROM anapsix/alpine-java
RUN apk update \
&& apk add ca-certificates wget tar \
&& update-ca-certificates
RUN wget --user-agent="Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" https://script-collection.s3.amazonaws.com/sfdc/r3.1.0/sumojanus-salesforce-dist.3.1.0.tar.gz
RUN tar xzvf sumojanus-salesforce-dist.3.1.0.tar.gz
View chrome-csp-issue.js
const http = require('http');
const PORT = 8081;
const BROKEN_CSP = [
"default-src 'self'",
"child-src googleads.g.doubleclick.net",
// The below line should work too, but it's not required to trigger the
// bug. The object tag should fall through to default-src 'self'. As in,
// you can comment out the line below, and it will still fail