Skip to content

Instantly share code, notes, and snippets.

@rrika
rrika / unscramble.py
Created September 5, 2023 20:54
ME: please show me the tweets in the order that they were liked COMPUTER: thats too hard. heres some tweets i think are good.
class Node:
capacity = 10
def __init__(self, index, count):
self.index = index
self.count = count
self.children = []
def __iter__(self):
return iter(self.children)
def __len__(self):
return len(self.children)
@rrika
rrika / oh_no.c
Created September 1, 2023 21:06
reading the wine registry
// compile with gcc -fshort-wchar
#define _GNU_SOURCE // for pipe2
#include <errno.h>
#include <fcntl.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
@rrika
rrika / gsk-demo.c
Last active March 27, 2023 20:57
GSK Demo
// compile with: cc -g `pkg-config --libs --cflags gtk4` -o gsk-demo gsk-demo.c
#include <stdio.h>
#include <gdk/gdk.h>
#include <gsk/gsk.h>
void gtk_init(void);
static const char node[] = "container {\
color {\
@rrika
rrika / test.cpp
Created February 15, 2021 19:41
HIP without HIP
// clang++
// -x hip
// test.cpp
// -O3
// --cuda-gpu-arch=gfx1010
// --hip-device-lib=dummy.bc
// --hip-device-lib-path=path_to_dummy_bc
// -nogpuinc
// -fuse-ld=lld
// -fgpu-rdc
// a sat solver for instances with <= 32 variables
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#define b00000 0
#define b00001 1
#define b00010 2
#define b00011 3
import math
# an implementation of
# Edge Finding Filtering Algorithm for Discrete Cumulative Resources in O(kn log n)
# by Petr Vilı́m
# TODO: make this truly O(n log n) by addressing the tree
# rebuild in every iteration in compute_update,
class Task:
factorial = (
("op", "a", "input"),
("loop",
("phi", "a", "a", "a2"),
("phi", "b", 1, "b2"),
("op", "b2", "mul", "a", "b"),
("op", "a2", "sub", "a", 1),
("op", "loop-condition", "gt", "a", 0),
"loop-condition"
)
@rrika
rrika / test.py
Last active May 8, 2019 11:38
Trying to write a borrow checker
class Expr: pass
class Type: pass
class Stmt: pass
class RefMut(Type):
def __init__(self, lt, ty):
self.lt = lt
self.ty = ty
def __repr__(self):
return "&'{} {!r}".format(self.lt, self.ty)
@rrika
rrika / test.c
Created December 14, 2018 00:08
Mesa hooking
/*
MESA=<path to git clone of git://anongit.freedesktop.org/mesa/mesa>
gcc
-I$MESA/include/
-I$MESA/src/
-I$MESA/src/mesa
-I$MESA/src/mapi
-I$MESA/src/gallium/include
-lglapi
extern crate llvm_sys;
use std::ffi::CStr;
use llvm_sys::core::*;
use llvm_sys::bit_reader::*;
fn main() {
unsafe {
let mut llvm_module = std::mem::uninitialized();
let mut buffer = std::mem::uninitialized();