Skip to content

Instantly share code, notes, and snippets.

Avatar

Brian Mock wavebeem

View GitHub Profile
View Main.java
public class Main {
public void foo() {
System.out.println("Foo!");
}
public static void main(String[] args) {
new Main().foo();
}
}
View coins.hs
import Data.List
data Coin = Coin Integer String
instance Show Coin where
show (Coin _ name) = name
currency =
[ Coin 25 "quarter"
, Coin 10 "dime"
View BasicOperations.scala
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
View idea.js
// 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 Apr 20, 2015
99% mutation free, organic, non-GMO
View main.js
var freeze = Object.freeze;
function array() {
return freeze([].slice.call(arguments));
}
function array_of_size(n) {
var xs = [];
while (n-- > 0) {
xs.push(null);
View xml.rb
#!/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
View gist:8e331825f1ad276e7ee5
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 Jul 15, 2015
A simple addition calculator
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Wobsite</title>
</head>
<body>
<h1>Wobsite</h1>
@wavebeem
wavebeem / c-like.rb
Last active Aug 29, 2015
Squiggle syntax brainstorm
View c-like.rb
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 Jul 28, 2015
Math parser using Parsimmon
View OUTPUT
####### AST ###############
[ 'Let',
[ 'Ident', 'x' ],
[ 'Number', 1 ],
[ 'Let',
[ 'Ident', 'y' ],
[ 'Number', 2 ],
[ 'BinOp',
'+',