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 os | |
import sys | |
import time | |
from PIL import Image | |
import ctypes | |
h_stdout = ctypes.windll.kernel32.GetStdHandle(ctypes.c_long(-11)); | |
ctypes.windll.kernel32.SetConsoleMode(h_stdout, ctypes.c_short(0x200)); | |
def _win_mov_cursor(x, y): |
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 toy S-expressions lexer and parser written in pure python. | |
# Copyright 2023 Nikhil R. | |
# | |
from collections import namedtuple | |
from io import StringIO | |
T_INT_LITERAL = 1; | |
T_FLOAT_LITERAL = 2; |
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
#include "brainfuck.h" | |
#define CHECK_DP(interp) ((interp -> data_pointer) < (interp -> memsize)) | |
int bf_init(bf_Interpreter* interp, const char* fpath, size_t memsize) { | |
// Allocate memory | |
unsigned char* mem_alloc; | |
mem_alloc = (unsigned char*) calloc(memsize, sizeof(unsigned char)); | |
if (mem_alloc == NULL) { | |
printf("Failed to allocate %d chars of memory\n", memsize); | |
return FAILURE; |
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
#include "cw_prng.h" | |
#include <stdio.h> | |
uint64_t cw_g64(struct CW_Rng* rng) { | |
rng -> weyl += rng -> s; | |
uint64_t out = rng -> xbits; | |
rng -> abits += out; | |
out = (out >> 1)*(rng -> abits | 1); | |
out ^= rng -> weyl; | |
rng -> xbits = out; |
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
use std::io::Result as IoResult; | |
const BYTEBUF_SIZE: usize = 2048; | |
/// Buffered Character streaming for `Read` streams. | |
pub struct CharStream<'a, T: Read> { | |
buffer: [u8; BYTEBUF_SIZE], | |
/// The offset to start writing into the byte buffer from. | |
bstart: usize, | |
/// The buffer to store chars. |
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 numpy as np | |
import heapq | |
from dataclasses import dataclass | |
@dataclass | |
class NearestNeighbours: | |
""" | |
Stores the result of a nearest-neighbours search. | |
`n_indices` is the list of indices of the vectors nearest to the provided vector. | |
""" |
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
# Quick-little union-find implementation in python. | |
# A very elegant data structure | |
import array | |
class UnionFind: | |
""" | |
Disjoint-Set Data Structure. | |
""" |