Skip to content

Instantly share code, notes, and snippets.

View remexre's full-sized avatar

Nathan Ringo remexre

View GitHub Profile
@remexre
remexre / example.lisp
Created July 26, 2017 00:15
oftlisp typeclasses
(deftypeclass (indexed 'a)
(fn ((get 'a) (this @) (index fixnum)))
(fn ((len fixnum) (this @))))
; An example data structure.
(deftype (append-list 'a)
(list (list 'a)))
(instance (append-list 'a) (indexed 'a)
(defn (get this index)
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDIych9JCw5S1KObY4ZVd8zux8J8VrYN508r4XB7rsaz2bFhE9+WDSZaqFP9ZYZv0fntDmRLEJg5wAb8nLe36eqhreqpPwNfWFqK5mtTR4EE1cvCb1105Mcw9s8+wuT4ekzbP2kT0HwTIVpyVGbH8nx+L1DWzrJ20KpQu3QLm6Wvab2+TWr1CqPqZOGvAi3PNuZdDLxgtkbL/rU/l+oC75Gj3wtDyPo3JsDkO0VKWjyL1fi6kEqFj/lD5Z2knSKbFMP5ubdJTAihbzC2SHQLowhOQ07lAkehQxONM0u4uSDpD2BxglT/HeQTJgVWHuumyCnL9niCL7LqQf2oK9ZXsTz nathan@remexre.xyz
/**
* The main entry point.
*
* TODO Turn this into a Servlet.
*/
public class WhyIHate/*Java*/ {
private static final int TWENTY = 20; // Magic numbers are bad.
// TODO Create a wrapper class to protect i from invalid accesses.
// TODO Create a factory for that wrapper class -- you never know when we
(defn-async foo (bar)
; x and y are "awaited" in parallel
; This is the equivalent of Promise.all in JS.
; Note: this means x *cannot* be used in y.
(await (x (some-async-function))
(y (other-async-function bar)))
; async-return is Promise.resolve in JS-speak, or the
; monad `return` function in Haskell-speak.
(async-return (+ x y)))
@remexre
remexre / sysysitcli-macos.md
Created May 17, 2017 19:45
So You're Spending Your Summer In The CLI -- macOS Edition

So You're Spending Your Summer In The CLI -- macOS Edition

The Shell

zsh

zsh is the classic configurable shell. Its most notable configuration set is Oh My Zsh.

You can set it as the default for your user with:

@remexre
remexre / .zshrc
Created May 17, 2017 19:34
A .zshrc for Silver development
export ZSH="${HOME}/.oh-my-zsh"
ZSH_THEME="ys"
plugins=(common-aliases compleat dircycle git git-extras pip python sudo tmux)
export EDITOR="vim"
export PATH="${HOME}/bin:${HOME}/.local/bin:${HOME}/.cabal/bin:${HOME}/.cargo/bin:${GOPATH}/bin:${PATH}"
export SILVERTRACE=1
source $ZSH/oh-my-zsh.sh
<html version="-//W3C//DTD XHTML 2.0//EN" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Copper HTML dump</title>
<style type="text/css">
/* div.page { width: 800px; } */
table.symtable,
table.dfatable { border: 1px solid #000000; border-collapse: collapse; }
span.lookaheadset { background-color: #d0d0d0; padding-left: 4pt; padding-right: 4pt; }
table.symtable tr.trodd { background-color: #d0d0d0; }
use std::collections::btree_map::{BTreeMap, Entry};
fn main() {
let mut m: BTreeMap<&'static str, i32> = BTreeMap::new();
m.insert("foo", 4);
println!("=== Starting Foo ===");
match m.entry("foo") {
Entry::Vacant(entry) => {
println!("{:?}", entry)
@remexre
remexre / y.md
Last active March 6, 2017 20:34

The Y Combinator

In most functional languages, you can write something like:

let rec fac = function
  | 0 -> 1
  | n -> n * fac (n - 1)
use ::expr::Expr;
use nom::{hex_digit, oct_digit};
use num::{BigInt, ToPrimitive};
use std::mem;
named!(pub parse_number(&str) -> Expr, complete!(alt!(
based_number
)));
named!(foo(&str) -> &str, alt!(