Skip to content

Instantly share code, notes, and snippets.

View dramforever's full-sized avatar
🖤
dramming

dram dramforever

🖤
dramming
  • Scarlet Devil Mansion, Gensokyo
View GitHub Profile
#include <stdio.h>
#include <stdlib.h>
#define DECL_STATE \
[[maybe_unused]] const struct word *const *ip, \
[[maybe_unused]] size_t *sp, \
[[maybe_unused]] const struct word *const **rsp
#define STATE ip, sp, rsp
struct word {
@dramforever
dramforever / _info.md
Last active July 18, 2025 17:09
How much RISC-V instruction space do we have left?
// QEMU emulator version 7.2.0
// qemu-system-riscv64 -M virt,aia=aplic-imsic,aia-guests=2,aclint=true,dumpdtb=dtb.dtb -smp 2
#include <dt-bindings/interrupt-controller/irq.h>
/dts-v1/;
/ {
compatible = "riscv-virtio";
model = "riscv-virtio,qemu";
@dramforever
dramforever / drawfb.c
Created February 15, 2023 07:15
Playing around with /dev/fb0
#define _GNU_SOURCE
#include <fcntl.h>
#include <linux/fb.h>
#include <stddef.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
int main() {
&gpio {
pinctrl-names = "default";
pinctrl-0 = <&gpiojtag_pins>;
gpiojtag_pins: gpiojtag-0 {
input-pins {
pinmux =
<GPIOMUX(1, GPO_LOW, GPO_DISABLE, GPI_CPU_JTAG_TCK)>,
<GPIOMUX(2, GPO_LOW, GPO_DISABLE, GPI_CPU_JTAG_TDI)>,
<GPIOMUX(3, GPO_LOW, GPO_DISABLE, GPI_CPU_JTAG_TMS)>;
@dramforever
dramforever / clkgen.txt
Last active July 13, 2022 18:30
(Partially) undocumented JH7100 registers found in headers
Register: clk_cpundbus_root_ctrl_REG_ADDR
Address: CLKGEN_BASE_ADDR + 0x0
31 24 16 8 0
| | | | |
[------<>------------------------]
'-------------------------- [25:24] (rw) clk_cpundbus_root_src
Register: clk_dla_root_ctrl_REG_ADDR
@dramforever
dramforever / Makefile
Last active March 3, 2022 09:06
Stack trace
CFLAGS += -fno-omit-frame-pointer -funwind-tables
LDFLAGS += -lunwind
.PHONY: all
all: stack-trace
.PHONY: clean
clean:
rm stack-trace
@dramforever
dramforever / nixenv.zsh
Last active March 14, 2024 17:45
nixenv
declare -A nixenv_paths
nadd() {
setopt local_options err_return pipefail
local out out_paths
for installable in "$@"; do
local with_outputs="$installable^*"
if [[ "$installable" = *"^"* ]]; then
with_outputs="$installable"
fi
> module FoldlFoldr where
Implementation of `foldl'`
> foldl' :: (b -> a -> b) -> b -> [a] -> b
> foldl' f acc [] = acc
> foldl' f acc (x : xs) =
> let acc1 = f acc x
> in acc1 `seq` foldl' f acc1 xs
@dramforever
dramforever / sdf_ascii_art.ipynb
Last active April 20, 2021 07:53
Generating ASCII art with distance fields
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.