Skip to content

Instantly share code, notes, and snippets.

View CurtisFenner's full-sized avatar

Curtis Fenner CurtisFenner

View GitHub Profile
<div style="font-size: 32px; width: 200px; height: 200px; font-weight: bold; ">
I is black --> out is black
I is white --> out is white
I is gray --> out is gray??
I << H --> I?
</div>
type Pin<X extends Record<string, Record<string, keyof X>>> = {
[Obj in keyof X]: {
[F in keyof X[Obj]]: Pin<X>[X[Obj][F]]
}
};
type Loopy = Pin<{
one: {
a: "one",
b: "two",
import re
class ParseResult:
"""
Represents the result of parsing an input.
`object` is the thing that was parsed from the beginning of the input.
`rest` is everything that follows the `object` within the input.
"""
// Splits `T` at the first occurrence of `S`.
type SplitBy<T extends string, S extends string> =
T extends `${infer A}${S}${infer B}`
? { before: A, split: S, after: B }
: never;
type SplitInfo = { before: string, split: string, after: string };
type UseShorter<A extends SplitInfo, B extends SplitInfo> =
A["before"] extends `${B["before"]}${infer R}` ? B : A;
// >zig version
// 0.6.0
// >zig test src/crash.zig
// Unreachable at D:\a\1\s\src\ir.cpp:28528 in buf_write_value_bytes. This is a bug in the Zig compiler.
// Unable to dump stack trace: debug info stripped
const S = struct {};
test "Crashes" {
fn runtime(x: u32) bool {
return x % 2 != 0 and x % 3 != 0 and x % 5 != 0 and x % 7 != 0 and x % 11 != 0;
}
fn loopLegal(comptime arr: var) void {
inline for (arr) |e, i| {
while (true) {
if (!runtime(i)) {
break;
}
@CurtisFenner
CurtisFenner / web.c
Created April 27, 2014 01:46
HTML Parser Beginning
#include <stdio.h>
#include <windows.h>
#include <stdbool.h>
typedef struct docstring docstring;
typedef struct wdocument wdocument;
typedef struct wattribute wattribute;
struct wattribute {
docstring* name;