Skip to content

Instantly share code, notes, and snippets.

View wavebeem's full-sized avatar

Sage Fennel wavebeem

View GitHub Profile
module Test where
data Range
= FromTo Integer Integer
deriving (Eq, Ord)
instance Show Range where
show (FromTo x y) = show x ++ " --> " ++ show y
x --> y
update_interval 1
#out_to_x no
out_to_console yes
temperature_unit fahrenheit
#temperature_unit celsius
TEXT
${uptime_short}\
::: ${mem}\
::: ${mixer}%${if_mixer_mute} (M)${endif}\
// author: Brian Mock <mock.brian@gmail.com>
#include <stdio.h>
typedef unsigned int uint;
double clamp(double, double, double);
uint pack_rgb(uint, uint, uint);
uint shade_color(uint, double);
void unpack_rgb(uint, uint*, uint*, uint*);
-------------------- Brian Mock -----------------------
module Lab3 where
import List
-------------------- Problem 1 -----------------------
(==>) = flip ($)
integerToDigit (i + 1) = digits !! i
#!/usr/bin/env ruby
#
# Ruby ruby ruby!
#
def fibo(a=1, b=1)
n = 0
yield 0, a
yield 1, b
loop do
a, b = b, a + b
#import <Foundation/Foundation.h>
#define I(n) [NSNumber numberWithInt:(n)]
int
main(int argc, char *argv[]) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSArray *ary = [NSArray arrayWithObjects:
I(4), I(5), I(1), I(0), I(6), nil
];
- W-s Create new stack below
- W-w Create new stack above
- W-d Create new column right
- W-a Create new column left
- WA-j Move window to stack below
- WA-k Move window to stack above
- WA-l Move window to column right
@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 =>
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
# 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) =