Skip to content

Instantly share code, notes, and snippets.

@AndrewRayCode
AndrewRayCode / grammar.pegjs
Created October 19, 2020 04:34
right association peg.js
{
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,
// 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"
{
// 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 {
const Dangus = () => {
const group = useRef();
useThingy(() => {
const { current } = group;
if (current) {
current.prop = 'hi'; // Object is possibly 'undefined'.
}
});
@AndrewRayCode
AndrewRayCode / Dockerfile
Last active September 20, 2019 17:45
SumoJanus run error
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
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
import withApolloSSR from '../../withApolloSSR';
import { compose, graphql } from 'react-apollo';
...
const GameHomepage = () => <div>My game...</div>
export default compose(
withApolloSSR,
graphql(GAME_GRAPHQL_QUERY,)
// Build a hook to register a callback to run every frame (subscribe(...))
// to copy some state into our component if some condition is met
function useStateCheck() {
const {
state,
subscribe
} = useContext(context);
const [_, setState] = useState(state);
useEffect(() => {
const getStackTo = (node, find, stack = []) => {
if (node === find) {
return stack;
}
if (!node.children) {
return;
}
if (node.children === find) {
return [...stack, 'children'];
// ----- Given this shader:
vec4 some_noise_fn() {
return vec4(1.0, 2.0, 3.0, 4.0);
}
void main() {
return some_noise_fn();
}