Skip to content

Instantly share code, notes, and snippets.

View kddnewton's full-sized avatar
👶
Paternity leave

Kevin Newton kddnewton

👶
Paternity leave
View GitHub Profile
@kddnewton
kddnewton / compile.js
Created November 13, 2023 19:07
Compile Prism into YARV in JavaScript
import * as prism from "@ruby/prism";
class RubyInteger {
constructor(value) {
this.value = value;
}
_plus(other) {
if (!(other instanceof RubyInteger)) {
throw new TypeError(`no implicit conversion of ${other.constructor.name} into Integer`);
@kddnewton
kddnewton / bug.rb
Created November 28, 2023 17:04
Maybe encoding bug?
# frozen_string_literal: true
class Context < BasicObject
def method_missing(name, *) = :identifier
def self.const_missing(name) = :constant
end
$context = Context.new
def evaluate(encoding, codepoint)
@kddnewton
kddnewton / bignums.rb
Created December 15, 2023 21:39
Bignums
# frozen_string_literal: true
class Number
SIZE = 32
attr_reader :values
def initialize(values = [0])
@values = values
end
@kddnewton
kddnewton / main.c
Last active January 6, 2025 13:49
TLS macOS weirdness
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
static int value = 0xDEADBEEF;
static _Thread_local void *tls = &value;
static pthread_key_t key;
void *worker(void *arg) {
tls = (void*)0xCAFEBABE;