Skip to content

Instantly share code, notes, and snippets.

View wavebeem's full-sized avatar

Sage Fennel wavebeem

View GitHub Profile
setTimeout () ->
console.log("Hello!")
, 300
### Imports
let {JSON, document, console} = global
### Basic data
let namedConstants = [true, false, null, undefined]
let numbers = [1, 2, 1_000, 3.14, NaN, -Infinity]
let strings = ["hello,\n", "\u{20}", "\"world\"\u{2757}"]
let arrays = [[], [1, 2], [3, [[4]], [5]]]
### Imports
let {JSON, document, console} = global
### Basic data
let namedConstants = [true, false, null, undefined]
let numbers = [1, 2, 1_000, 3.14, NaN, -Infinity]
let strings = ["hello,\n", "\u{20}", "\"world\"\u{2757}"]
let arrays = [[], [1, 2], [3, [[4]], [5]]]
@wavebeem
wavebeem / current.sqg.rb
Last active December 2, 2015 00:10
This Gist shows the current syntax of the Squiggle programming language, along with other ideas about how the syntax could look.
### Imports
let {JSON, document, console} = global
### Basic data
let namedConstants = [true, false, null, undefined]
let numbers = [1, 2, 1_000, 3.14, NaN, -Infinity]
let strings = ["hello,\n", "\u{20}", "\"world\"\u{2757}"]
let arrays = [[], [1, 2], [3, [[4]], [5]]]
render([
[{path: "/", component: App},
[{path: "about", component: About}],
[{path: "users", component: Users},
[{path: "/user/:userId", component: User}]
],
[{path: "*", component: NoMatch}]
]
], document.body);
@wavebeem
wavebeem / foo.js
Created November 13, 2015 16:11
ES6 modules export bindings, not values.
export let x = 1;
export function inc() {
x++;
};
require 'cgi'
require 'jekyll'
require 'redcarpet'
class RedcarpetCodeMirror < Redcarpet::Render::HTML
def initialize
super
@total = 0
end
# Good use of match
def compile(node) =
match node
case {type: "Add", a, b} =>
["+", compile(a), compile(b)]
case {type: "If", condition, result, alternative} =>
["if", compile(condition), compile(result), compile(alternative)]
# Bad use of match
def greet(person) =
def start() =
let body = document.body
let root = React.createElement(GameView)
let container = document.getElementById("react-container")
let thing = React.render(root, container)
in do
set(app, "root", thing);
body.addEventListener("click", focusClickhole);
tick();
end
@wavebeem
wavebeem / parsefun.js
Created October 6, 2015 00:07
This does not actually generate the correct AST because I was using arrays and dang does that get confusing over time, but this helped me figure out how to parse my binary operators correctly while also including unary operators at the right precedence level and make foo.bar foo[bar] and foo(bar) all chain together correctly.
"use strict";
const util = require("util");
const P = require("parsimmon");
console.log(Date() + "\n");
const _ = P.optWhitespace;
const tag = name => rest =>