Skip to content

Instantly share code, notes, and snippets.

@Hirrolot
Hirrolot / CoC.ml
Last active July 17, 2024 13:27
How to implement dependent types in 80 lines of code
type term =
| Lam of (term -> term)
| Pi of term * (term -> term)
| Appl of term * term
| Ann of term * term
| FreeVar of int
| Star
| Box
let unfurl lvl f = f (FreeVar lvl)
@aemmitt-ns
aemmitt-ns / decrc64.py
Last active September 26, 2023 22:26
Reverse CRC64 with z3
import z3
s = z3.Solver()
s.push()
poly = z3.BitVecVal(0xC96C5795D7870F42, 64)
goal = z3.BitVecVal(0x751092902dfa050e, 64)
ZERO = z3.BitVecVal(0, 64)
ONE = z3.BitVecVal(1, 64)
@ganbatte8
ganbatte8 / xcb_demo.c
Last active June 10, 2023 16:31
Simple game loop in Linux/XCB, writing pixels with CPU, enforcing a framerate, reading joystick, keyboard and mouse input.
// Linking: -lxcb -lxcb-image
//#include <xcb/xcb.h>
#include <xcb/xcb_image.h>
#include <malloc.h>
#include <unistd.h>
#include <fcntl.h>
#include <linux/joystick.h>
//#include <time.h>
#include <sys/stat.h>
@brecert
brecert / get.js
Last active May 18, 2022 21:55
revolt2
import('https://jspm.dev/localforage')
.then(({ default: localForage }) => {
localForage.getItem('auth')
.then(JSON.stringify)
.then(alert)
})
@marvinhagemeister
marvinhagemeister / little-vdom-decompiled.js
Created March 8, 2020 14:13
Jason little-vdom decompiled
/* eslint-disable no-unused-vars */
/* eslint-disable no-else-return */
// JSX constructor, similar to createElement()
export const h = (type, props, ...children) => {
return {
type,
// Props will be an object for components and DOM nodes, but a string for
// text nodes
props,
export const h=(t,p,...c)=>({t,p,c,k:p&&p.key})
export const render=(e,d,t=d.t||(d.t={}),p,r,c,m,y)=>
// arrays
e.map?e.map((e,p)=>render(e,d,t.o&&t.o[p])):
// components
e.t.call?(e.i=render((render.c=e).t(Object.assign({children:e.c},e.p),e.s=t.s||{},t=>
render(Object.assign(e.s,t)&&e,d,e)),t.i||d,t&&t.i||{}),d.t=t=e):(
// create notes
m=t.d||(e.t?document.createElement(e.t):new Text(e.p)),
// diff props
@brecert
brecert / extras
Last active March 20, 2021 18:53
minecraft ideas
Lan Sharing
- while in a singleplayer world add the option "broadcast world"
-- this shared the world publically to an inlets server
-- every world is assigned a snowflake id when broadcast,
the snowflake id will determine the inlet port and subdomain for determinist and consistent
reconnects from server menu
More Clothing/Armor Variations
- hats, boots, baubles, and more!
-- I strongly believe baubles would fit into vanilla minecraft
; declare { printf } = @cimport(@cinclude("stdio.h"))
;
; fn square(num: i32) {
; #start: {
; let #safe_mult = num *? num
; let [ #mult_val, #was_safe ] = #safe_mult
; let #should_panic = #was_safe == false
; #should_panic ? goto #panic : goto #return
; }
;
@edolstra
edolstra / nix-lang.md
Last active July 16, 2024 02:12
Nix language changes

This document contains some ideas for additions to the Nix language.

Motivation

The Nix package manager, Nixpkgs and NixOS currently have several problems:

  • Poor discoverability of package options. Package functions have function arguments like enableFoo, but there is no way for the Nix UI to discover them, let alone to provide programmatic ways to
@mbforbes
mbforbes / gutenberg.md
Created March 29, 2017 22:37
How to scrape English Project Gutenberg and get the raw text out of it