Skip to content

Instantly share code, notes, and snippets.

View wavebeem's full-sized avatar

Sage Fennel wavebeem

View GitHub Profile
public class Main {
public void foo() {
System.out.println("Foo!");
}
public static void main(String[] args) {
new Main().foo();
}
}
import Data.List
data Coin = Coin Integer String
instance Show Coin where
show (Coin _ name) = name
currency =
[ Coin 25 "quarter"
, Coin 10 "dime"
object ScalaJSExample extends js.JSApp{
def main() = {
val xs = Seq(1, 2, 3)
println(xs.toString)
val ys = Seq(4, 5, 6)
println(ys.toString)
val zs = for{
x <- xs
y <- ys
} yield x * y
// I suppose my thinking here is that `into` could take either a Lo-Dash
// pipeline object or a function. It seems feasible, but I definitely can't
// speak to performance implications. It also assumes that `pipeline` doesn't
// need to be terminated and that `into` ends method chains.
var handle = _.pipeline()
.mapValues(s => s.toLowerCase())
.into(p => p.first.charAt(0) + p.last)
var jdalton = { first: "John-David", last: "Dalton" }
var bmock = { first: "Brian", last: "Mock" }
var people = [jdalton, bmock]
@wavebeem
wavebeem / main.js
Created April 20, 2015 16:58
99% mutation free, organic, non-GMO
var freeze = Object.freeze;
function array() {
return freeze([].slice.call(arguments));
}
function array_of_size(n) {
var xs = [];
while (n-- > 0) {
xs.push(null);
#!/usr/bin/env ruby
require "nokogiri"
root = Nokogiri.parse(File.read("Empty.tmTheme"))
scopes = root
.css("plist dict array dict key")
.select {|key| key.text == "scope" }
.map {|key| key.next_element.text }
puts scopes
var add = TC()
.Takes([TC.Number, TC.Number])
.Returns(TC.Number)
.By(function(a, b) { return a + b })
var divide = TC()
.Takes([TC.Number, TC.Nonzero])
.Returns(TC.Number)
.By(function(a, b) { return a / b })
var sum = TC()
.Takes([TC.Array(TC.Number)])
@wavebeem
wavebeem / index.html
Created July 15, 2015 20:33
A simple addition calculator
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Wobsite</title>
</head>
<body>
<h1>Wobsite</h1>
@wavebeem
wavebeem / c-like.rb
Last active August 29, 2015 14:26
Squiggle syntax brainstorm
let (
http = require("http"),
handler = fn(_req, res) do {
res.writeHead(200, {"Content-Type": "text/plain"});
res.end("Hello, world!");
}
) do {
http.createServer(handler).listen(1337, "127.0.0.1");
print("Server started at http://127.0.0.1:1337/");
@wavebeem
wavebeem / OUTPUT
Created July 28, 2015 20:13
Math parser using Parsimmon
####### AST ###############
[ 'Let',
[ 'Ident', 'x' ],
[ 'Number', 1 ],
[ 'Let',
[ 'Ident', 'y' ],
[ 'Number', 2 ],
[ 'BinOp',
'+',