Skip to content

Instantly share code, notes, and snippets.

@be5invis
be5invis / interpreter.js
Last active July 1, 2019 11:26
A CPS-style S-exp interpreter (with call/cc)
function interpret(form, env, k){
if(form instanceof Array){
switch(form[0]){
case 'lambda': {
var params = form[1];
var body = form[2];
return k(function(k){ return function() {
var e = Object.create(env);
for(var j = 0; j < params.length; j++)
e[params[j]] = arguments[j];
@be5invis
be5invis / ceki-tco.js
Last active January 28, 2016 20:55
CEK interpreter with TCO example
// noprotect
function Lambda(param, body, e){
this.param = param
this.body = body
this.env = e
};
Lambda.prototype.apply = function(t, args, k0){
var e_ = Object.create(this.env);
for(var j = 0; j < this.param.length; j++){
e_[this.param[j]] = args[j];
@preshing
preshing / build_cross_gcc
Last active July 25, 2024 22:28
A shell script to download packages for, configure, build and install a GCC cross-compiler.
#! /bin/bash
set -e
trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG
trap 'echo FAILED COMMAND: $previous_command' EXIT
#-------------------------------------------------------------------------------------------
# This script will download packages for, configure, build and install a GCC cross-compiler.
# Customize the variables (INSTALL_PATH, TARGET, etc.) to your liking before running.
# If you get an error and need to resume the script from some point in the middle,
# just delete/comment the preceding lines before running it again.
@chrisdone
chrisdone / gist:02e165a0004be33734ac2334f215380e
Last active July 1, 2024 21:55
Build and run minimal Linux / Busybox systems in Qemu

Common

export OPT=/opt
export BUILDS=/some/where/mini_linux
mkdir -p $BUILDS

Linux kernel

@andrewchambers
andrewchambers / gist:1c473fd1595f4fcedbcfc634ee1decb0
Last active March 19, 2020 00:41
full disk encrypted nixos install
#! /bin/sh
set -e
set -u
set -x
# configure this!
hostname="nixos"
password="abc123"
diskdev=/dev/sda
open FStar.Char
open FStar.Seq
(* Helper *)
let max a b = if a > b then a else b
(* Definition *)
let leftpad (c:char) (n:nat) (s:seq char) : seq char =
let pad = max (n - length s) 0 in
append (create pad c) s
#!/usr/bin/env python2
import BaseHTTPServer
import SocketServer
import base64
import httplib
import mimetypes
import os
import shutil
import ssl
@staab
staab / janet.kak
Created December 3, 2019 15:28
Kakoune filetype for Janet
# http://janet-lang.org
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
# require lisp.kak
# Detection
# ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*[.](janet) %{
set-option buffer filetype janet
@bakpakin
bakpakin / utf8.janet
Last active January 19, 2022 11:34
Use pegs to parse utf8
###
### utf8.janet
###
### Pure janet utf8 utils. You should probably just use C.
###
(defn utf8-encode
"Convert a sequence of codepoints to a string."
[x]
(def buf @"")
@hwayne
hwayne / friendlist.csv
Last active July 12, 2020 08:20
Friendlist draft two
Name Days Contact Comments
their name on average how often to contact method of contact (signal/fb/etc) misc
required required optional optional