Skip to content

Instantly share code, notes, and snippets.

View lukechampine's full-sized avatar

Luke Champine lukechampine

View GitHub Profile
@lukechampine
lukechampine / fac.hoon
Last active January 20, 2024 19:35
Evolution of a Hoon Programmer
:: Hoonlet
::
|= n=@
?: =(n 0)
1
(mul n $(n (dec n)))
::
:: Commie Hoontard
:: (...daydreaming of his very own Type 59...)
::
@lukechampine
lukechampine / vanity.go
Created January 2, 2024 16:04
Vanity Go import server
package main
import (
"flag"
"html/template"
"log"
"net/http"
"strings"
)
@lukechampine
lukechampine / Y Combinator in Haskell.md
Last active November 15, 2023 07:30
Deriving the Y Combinator in Haskell

The Y Combinator

The Y Combinator is a classic lambda calculus construct that many people find baffling. Here's my attempt to explain it as clearly as possible (no promises!). Familiarity with Haskell syntax is assumed.

The problem we're trying to solve is how to write an anonymous function (a "lambda") that is recursive. Normally, if you want to write a recursive function, it looks like this:

fac n = if n == 0 then 1
        else n * fac (n-1)
@lukechampine
lukechampine / monads.c
Last active November 14, 2023 18:22
Maybe and Either Monads in C
#include <stdio.h>
#include <stdbool.h>
// Maybe
typedef struct MaybeInt {
int just;
bool nothing;
} MaybeInt;
@lukechampine
lukechampine / dead-arms.txt
Created October 26, 2023 22:39
Dead Hoon linter
Dead arms detected by running the above script on urbit/urbit tip, against a corpus
of ~300k lines of Hoon (including urbit/urbit itself and various community repos):
urbit/pkg/autoprop/sur/sole.hoon:
+sole-gen
urbit/pkg/autoprop/lib/ethereum.hoon:
+address-to-checksum
+batch-read-request
+encode-atoms
+light-json-request
@lukechampine
lukechampine / bnt.go
Last active October 2, 2023 03:22
BNT renderer
package main
import (
"fmt"
)
func main() {
fmt.Println(renderBNT(19))
}
@lukechampine
lukechampine / a.c
Created October 19, 2014 01:00
a.c (with a.h expanded)
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<sys/mman.h>
typedef void V;typedef int I;typedef double F;typedef unsigned char C,*S;typedef long L;
#define O printf
#define R return
#define I(a...) if(a)
#define W(a...) while(a)
@lukechampine
lukechampine / fractran.hoon
Created May 13, 2020 05:08
A FRACTRAN interpreter in Hoon
|= n=@
=<
|^
(fib-dec (interp fib-prog (fib-enc n)))
++ fib-prog
:~ 17^65
133^34
17^19
23^17
2.233^69
@lukechampine
lukechampine / fuzzseed.go
Created January 31, 2018 00:34
Find the one word missing from a seed
package main
import (
"bufio"
"fmt"
"log"
"os"
"strings"
"github.com/NebulousLabs/Sia/modules"

how to into git (and GitHub)

This is a handy reference for setting up and using git to contribute to projects on GitHub. It is by no means a complete guide to using git; use http://gitref.org for that.

Update: This site provides some excellent visualizations of what various git commands do. Highly recommended.

basics

setup

First run the following commands, using your real name and GitHub email address: