Skip to content

Instantly share code, notes, and snippets.

View tekknolagi's full-sized avatar
🚴

Max Bernstein tekknolagi

🚴
View GitHub Profile
@tekknolagi
tekknolagi / ssa-interp.c
Created March 28, 2023 23:15 — forked from alpha123/ssa-interp.c
Primitive SSA Bytecode Interpreter
#include <stdlib.h>
#include <stdbool.h>
#include <stddef.h>
#define _WITH_GETLINE
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <ctype.h>
#include <inttypes.h>
#include <assert.h>
@tekknolagi
tekknolagi / hist.sh
Last active February 10, 2023 17:17
#!/bin/sh
# Likely originally by Carl Shapiro
sort |
uniq -c |
sort -n |
sed 's/^ *//' |
awk 'BEGIN { OFS="\t"} { sum += $1; print sum, $1, substr($0, 1 + index($0, " ")) }' |
sort -n -r |
awk 'BEGIN { IFS=OFS="\t"; print "cum", "pct", "freq" }$1 > max { max = $1 }{ print int($1/max*100), int($2/max*100), $2, $3 }'
# If on an M1, M2, or other new Apple Silicon, you have to both compile and run
# using the "arch" tool so that both the final binary and the JIT-compiled code
# can run in x86_64 mode.
UNAME_S:=$(shell uname -s)
UNAME_M:=$(shell uname -m)
ifeq ($(UNAME_S),Darwin)
ifeq ($(UNAME_M),arm64)
COMPILEPREFIX=arch -x86_64
endif
endif
#!/bin/bash
PYPY=~/Downloads/pypy-c-jit-106258-39dc1c343c50-linux64
PYTHONPATH="${PYPY}:${PYPY}/pypy" \
"${PYPY}"/bin/pypy \
"${PYPY}"/pypy/rpython \
-O2 --batch targetlox.py
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# https://github.com/dart-lang/sdk/blob/5db6b482b07d0d4e67a45d95cce2f405bcf98b04/runtime/third_party/binary_size/src/elf_symbolizer.py
import collections
import datetime
import logging
import multiprocessing
import os
@tekknolagi
tekknolagi / processify.py
Created October 31, 2022 22:36 — forked from schlamar/processify.py
processify
import os
import sys
import traceback
from functools import wraps
from multiprocessing import Process, Queue
def processify(func):
'''Decorator to run a function as a process.
Be sure that every argument and the return value
  • Compiling compression algorithms through programs
    • Compiler as f :: (program, compression algo) -> program'
  • Does collapsing towers of interpreters work for programming languages with much bigger architectural differences than the ones in the paper?
  • Abstract abstract interpretation
  • DDCG
  • Minecraft but it's all sending code to run on a shared VM
  • PL where every state change is persisted in a DB
  • SteamDrill (Quinn) but it's layered abstractions that you can expand (Python->C->asm) & custom events
#include <stdio.h>
#define IS_DIG(x) (((x)|1)=='1')
#define SLEN(s) ((sizeof s)-1)
#define RIDX(s,x) ((x)<SLEN(s)?s[SLEN(s)-1-(x)]:0)
#define CNT(s,x,n) ((x)<n?IS_DIG(RIDX(s,(x))):0)
#define CNT4(s,x,n) (CNT(s,x+0,n)+CNT(s,x+1,n)+CNT(s,x+2,n)+CNT(s,x+3,n))
#define CNT16(s,x,n) (CNT4(s,x+0,n)+CNT4(s,x+4,n)+CNT4(s,x+8,n)+CNT4(s,x+12,n))
#define CNT64(s,x,n) (CNT16(s,x+0,n)+CNT16(s,x+16,n)+CNT16(s,x+32,n)+CNT16(s,x+48,n))
#define VAL(s,x) ((RIDX(s,x)=='1')<<(CNT64(s,0,x)))
#define VAL4(s,x) (VAL(s,x+0)+VAL(s,x+1)+VAL(s,x+2)+VAL(s,x+3))
@tekknolagi
tekknolagi / python_make_github_issues.py
Created October 11, 2022 23:11 — forked from nqthqn/python_make_github_issues.py
Creates GitHub Issues from a CSV file.
import json
import requests
import csv
# Authentication for user filing issue (must have read/write access to
# repository to add issue to)
USERNAME = 'username'
PASSWORD = 'password'
# The repository to add this issue to
@tekknolagi
tekknolagi / sym_test.cc
Created October 8, 2022 03:09 — forked from aeppert/sym_test.cc
Enumerate and demangle symbols within an executable's own symbol table.
#include <stdio.h>
#include <stdlib.h>
#include <cxxabi.h>
#include <link.h>
#include <string>
#include <vector>
#include <iostream>
using namespace std;