Skip to content

Instantly share code, notes, and snippets.

@farnoy
farnoy / index.mts
Created June 22, 2025 11:45
seroval streaming deserialization
import { serializeAsync, deserialize, crossSerializeStream } from "seroval";
const $R = [];
const ASYNC_RECURSIVE = {} as Record<string, Promise<unknown>>;
ASYNC_RECURSIVE.a = Promise.resolve(ASYNC_RECURSIVE);
ASYNC_RECURSIVE.b = new Promise(r => setTimeout(() => r(2137), 2000));
console.log('simple', await serializeAsync(ASYNC_RECURSIVE))
console.log('simple parsed', deserialize(await serializeAsync(ASYNC_RECURSIVE)))
@farnoy
farnoy / amdgcn_kernels.mojo
Last active June 17, 2025 16:05
amdgcn DPP `shuffle_xor(val, 1)` implementation in mojo
# import random
from memory import UnsafePointer
from compile.reflection import get_type_name
from sys.intrinsics import _type_is_eq
from sys.info import _current_target, is_triple
from gpu import *
from gpu.warp import *
from gpu.host import DeviceContext
from sys import has_accelerator, is_nvidia_gpu, llvm_intrinsic, is_amd_gpu
from layout import Layout, LayoutTensor
@farnoy
farnoy / index.ts
Last active May 31, 2025 10:47
Cloudflare durable object storage latency repro: test by visiting `/whatever?transact=select-1&n=1`, or `/whatever?transact=no-op&n=1`, and `/whatever?transact=local-no-op`
import { DurableObject } from "cloudflare:workers";
import { z } from "zod/v4";
const transactMethod = z
.enum(["transaction", "sync-sql", "blockConcurrencyWhile", "racy", "no-op", "select-1", "local-no-op"])
.default("sync-sql");
export class MyDurableObject extends DurableObject<Env> {
constructor(ctx: DurableObjectState, env: Env) {
super(ctx, env);
import java.lang.foreign.*
import scala.util.{Using, Try}
def handleResult[T](res: Try[T]) =
res match
case scala.util.Success(r) => println(s"Result: $r")
case scala.util.Failure(e) => e.printStackTrace()
sealed case class MyData(x: Double, y: Byte, z: Short, last: Double)
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
module Bencoding where
import Control.Applicative
import Crypto.Hash.SHA1
import Data.Attoparsec.ByteString.Char8 (Parser)
import qualified Data.Attoparsec.ByteString.Char8 as P
import Data.ByteString as B
import Data.ByteString.Char8 as BC
clients = []
message_queue = []
# entrypoint websocketa
def incoming_request(connection)
clients.push(connection)
end
Thread.new do
while x = message_queue.shift
### Keybase proof
I hereby claim:
* I am farnoy on github.
* I am farnoy (https://keybase.io/farnoy) on keybase.
* I have a public key whose fingerprint is 101C C2F9 9202 4836 6255 BCBB 7660 5A32 464C 5A46
To claim this, I am signing this object:
[51:52.41] Ogre Magi receives Cold Snap debuff from Invoker.
[51:52.41] Ogre Magi loses Teleporting buff.
[51:52.44] Anti-Mage (Illusion) hits Ogre Magi for 39 damage (470->431).
[51:52.51] Anti-Mage (Illusion) hits Ogre Magi for 28 damage (430->402).
[51:52.61] Death Ward hits Ogre Magi for 53 damage (402->349).
[51:52.74] Anti-Mage hits Ogre Magi with Mana Void for 1176 damage.
[51:52.74] Ogre Magi is killed by Anti-Mage!
use std::hashmap::HashMap;
trait Test {}
impl Test for uint {}
fn main() {
let a: &uint = &15;
let thing: &Test = a as &Test;
let mut map: HashMap<uint, &Test> = HashMap::new();
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document domain("github.com") {
/* General code display */
pre, code, pre > code,
/* commit refs */
span.commit-ref,
/* commit meta */