Skip to content

Instantly share code, notes, and snippets.

(ns oop-with-inheritance)
(defn start [arg]
(println "starting: " arg))
(defn stop [sys]
(println "stopping:" sys))
(defn server-system-local [& args]
(apply println "making server system:" args)
(uiop:define-package :fwoar.zipfile
(:mix :cl :fwoar.lisputils)
(:export ))
(in-package :fwoar.zipfile)
(defun read-bytes (n s)
(with (seq (make-array n :element-type 'serapeum:octet))
(values seq
(read-sequence seq s))))
@fiddlerwoaroof
fiddlerwoaroof / extend.js
Last active June 13, 2019 17:32
Static typable EP solution
//
// Two kinds of animals: dogs and cats
//
// I want greet and leave to be defined such that there are four
// different behaviors corresponding to each combination of dog and
// cat
//
class Animal {
receive_operation(operation) {
console.log("the animal is unresponsive");
import java.lang.RuntimeException
import java.util.Arrays
object VariantWorld2 {
class Greet : World.Visitor {
fun visit(subject: Dog, arg: String): String {
return "$arg is greeted"
}
fun visit(subject: Cat, arg: String): String {
(defun fwoar--find-lisp-project-root (dir-name)
(let ((root (locate-dominating-file dir-name
(lambda (n)
(directory-files n nil "^[^.#][^#]*[.]asd$")))))
(when root
(cons 'lisp root))))
(cl-defmethod project-roots ((project (head lisp)))
(list (cdr project)))
@fiddlerwoaroof
fiddlerwoaroof / .gitignore
Last active September 21, 2021 19:28
Minimal Nix Docker
*.tar.gz
.sentinel.*
@fiddlerwoaroof
fiddlerwoaroof / Tree.java
Created September 22, 2020 22:42
Tree Encoding
package co.fwoar.java.tree;
import java.util.ArrayDeque;
import java.util.Deque;
public class Main {
static class Tree {
public int val;
public Tree left;
public Tree right;
@fiddlerwoaroof
fiddlerwoaroof / hnparse.js
Created November 3, 2020 09:37
Reactive HTML parsing
const ch = require("cheerio");
const fetch = require("node-fetch").default;
const getLeadingNum = (v) => parseInt(v.split(" ")[0], 10);
function HNParser(html) {
if (! (this instanceof HNParser)) {
return new HNParser(html);
}
this.html = html;
@fiddlerwoaroof
fiddlerwoaroof / machine.js
Last active January 27, 2021 03:50
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
First State&
Animation
AnimationRunning
animationDone -> AnimationDone
AnimationDone
refresh -> Animation
Screen
Idle
animationDone -> Ready
Ready