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
# https://twitter.com/geofflangdale/status/1798605087885214050 | |
import inspect | |
import itertools | |
def sat(formula, preassignment, n=None): | |
# just bruteforce it, but could be a sat solver too | |
if n is None: | |
n = len(inspect.getfullargspec(formula)[0]) | |
for inputs in itertools.product((0, 1), repeat=n): |
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
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) |
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
// 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> |
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
// 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 {\ |
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
// 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 |
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
// 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 |
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 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: |
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
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" | |
) |
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
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) |
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
/* | |
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 |
NewerOlder