- Documentation: https://web.dev/articles/eventsource-basics
- Use case: broadcasting data from server to browsers
- Benefits:
- Easy to understand and implement (only a few lines of code)
- No library is needed
- Can use same HTTP(S) authentication as elsewhere in the app (which can’t be done with websockets)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type CreateTuple<Len extends number, Acc extends unknown[] = []> = | |
Acc['length'] extends Len | |
? Acc | |
: CreateTuple<Len, [...Acc, true]>; | |
; | |
type Length<Tup extends Array<unknown>> = | |
Tup['length'] | |
; | |
type Unshift<Tuple extends Array<unknown>, Value> = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# quickgen by azul (@[email protected]) -- generates a map | |
# by repeated subdivision. a simple approach to generating maps | |
# quickly, starting from a very rough sketch. | |
# | |
# this code is public domain! use it however you like. | |
import random |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
VERSION = \"1.0.0\" | |
PREFIX ?= out | |
INCDIR = include | |
SRCDIR = src | |
LANG = c | |
OBJDIR = .obj | |
MODULE ?= binary_name | |
CC ?= gcc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
gdb -p "$1" -batch -ex 'set {short}$rip = 0x050f' -ex 'set $rax=231' -ex 'set $rdi=0' -ex 'cont' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Identity(v) { | |
return { val: v }; | |
} | |
function chain(m,fn) { | |
return fn(m.val); | |
} | |
// ^^^ that's it! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { GeomUtils, TLCursor } from '@tldraw/core' | |
import * as React from 'react' | |
function getCursorCss(svg: string, r: number, f = false) { | |
return ( | |
`url("data:image/svg+xml,<svg height='32' width='32' viewBox='0 0 35 35' xmlns='http://www.w3.org/2000/svg'><g fill='none' style='transform-origin:center center' transform='rotate(${r})${ | |
f ? ` scale(-1,-1) translate(0, -32)` : '' | |
}'>` + | |
svg.replaceAll(`"`, `'`) + | |
'</g></svg>") 16 16, pointer' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/awk -f | |
# This program is a copy of guff, a plot device. https://github.com/silentbicycle/guff | |
# My copy here is written in awk instead of C, has no compelling benefit. | |
# Public domain. @thingskatedid | |
# Run as awk -v x=xyz ... or env variables for stuff? | |
# Assumptions: the data is evenly spaced along the x-axis | |
# TODO: moving average |
I have a pet project I work on, every now and then. CNoEvil.
The concept is simple enough.
What if, for a moment, we forgot all the rules we know. That we ignore every good idea, and accept all the terrible ones. That nothing is off limits. Can we turn C into a new language? Can we do what Lisp and Forth let the over-eager programmer do, but in C?
NewerOlder