Skip to content

Instantly share code, notes, and snippets.

View euclaise's full-sized avatar
🤔
Doing something

J. Pritsker euclaise

🤔
Doing something
View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@euclaise
euclaise / scan.py
Created February 9, 2024 00:08
Prefix-sum scan in PyTorch
import torch
from torch.nn import functional as F
import math
from typing import Callable
def split(xs):
xs = [x.view(x.shape[0], x.shape[-1]//2, 2) for x in xs]
return [x[: , :, 0] for x in xs], [x[:, :, 1] for x in xs]
def merge1(l, r):
@euclaise
euclaise / map.c
Last active June 13, 2022 09:31
Generic C string->any hashmap
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "map.h"
/* Hash function */
static uint64_t fnv1a(const char * c)
{
uint64_t h = 0xcbf29ce484222325; /* FNV offset basis */
for (; *c != '\0'; ++c)
@euclaise
euclaise / README.md
Last active June 13, 2022 02:57
Generic C vector with exponential growth

Generic C vector that grows the buffer exponentially instead of by a fixed size (or worse, by 1), trading memory efficiency for computational efficiency. This is typically used by libraries such as C++'s STL. Inspired by things like stb_ds.h

I did only very basic testing. By default, the vector is resized to 1.5*size(vec) when full. You can change the constant by defining GROWTH_EXP

@euclaise
euclaise / acme_lite.vim
Last active June 13, 2022 02:55
A softer acme-inspired vim colorscheme
highlight clear
" Based on acme-ish-colors https://github.com/notagoodidea/acme-ish-colors/blob/master/colors/acme-ish.vim
" Following convention of acme-colors :
" 232 (#080808) instead of black as it can be overwritten by the terminal
" emulator
highlight! Normal guibg=#f5f0e7 guifg=#000000 ctermbg=230 ctermfg=232
highlight! NonText guibg=bg guifg=#d5d0c7 ctermbg=bg ctermfg=230
highlight! StatusLine guibg=#aeeeee guifg=#000000 gui=NONE ctermbg=159 ctermfg=232 cterm=NONE
@euclaise
euclaise / wallhaven-random.sh
Created February 25, 2018 06:28
Grabs a random wallpaper from alpha.wallhaven.cc
#!/bin/bash
ID=$(curl -s "https://alpha.wallhaven.cc/search?sorting=random" | grep -oP 'thumb-(\d+)' | head -n 1 | tr -d "thumb-")
curl -O "https://wallpapers.wallhaven.cc/wallpapers/full/wallhaven-$ID.jpg"
@euclaise
euclaise / A-programmers-keyboard-_Colemak-version_.kbd.json
Last active June 13, 2022 02:55
A programmer's keyboard (Colemak version)
[
{
"backcolor": "#636363",
"name": "A programmer's keyboard (Colemak version)",
"author": "Ender",
"switchMount": "cherry",
"switchBrand": "cherry",
"switchType": "MX1A-G1Nx",
"pcb": true
},