Skip to content

Instantly share code, notes, and snippets.

LunarLambda /
Last active Jan 28, 2021
Weird Coding - FizzBuzz in Befunge

Weird Coding - FizzBuzz in Befunge

Jan 28 2021

I seem to have a real infatuation with unconvential programming challenges. Whenever I get to do something completely new that is at the same time simple enough to take no more than a day or two, but also far enough 'out there' that just looking up the solution is out of the question, my brain really seems to light up.

So, after rewatching [Tom Scott's video about the FizzBuzz interview question][fizzbuzz-yt], I figured a fun brain teaser would be to try and implement FizzBuzz in [Befunge][befunge], an esoteric programming language I am quite fond of.

Without much fanfare, here it is:

LunarLambda / Makefile
Created Jan 12, 2021
Brainfuck interpreter written in x86_64 assembly
View Makefile
tbf: tbf.o
# Note: needs LLVM linker.
ld.lld -s -pie -o tbf tbf.o
# ld -s -pie -o tbf tbf.o -I/lib/
tbf.o: tbf.nasm
nasm -f elf64 -o tbf.o tbf.nasm
.PHONY: clean
LunarLambda / Cargo.toml
Last active Jan 8, 2021
Windows DLL injection in Rust without limitations of DllMain (32 and 64-bit Intel)
View Cargo.toml
name = "dinj"
version = "0.1.0"
edition = "2018"
crate-type = ["cdylib"]
version = "0.3"
LunarLambda / null.c
Created Dec 15, 2020
Linux - safe nullptr deref using /proc/sys/vm/mmap_min_addr (requires root)
View null.c
#include <stdio.h>
#include <sys/mman.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
int main() {
int fd = open("/proc/sys/vm/mmap_min_addr", O_WRONLY);
if (fd == -1) {
LunarLambda /
Created Oct 25, 2020
screenie - screenshot script using maim/slop/xclip
# screenie - screenshotting script
# Universal Flags
# N.B. -o disables OpenGL in Slop.
# This can rarely cause graphical distortion but allows selection screenshots in fullscreen games.
MAIM_FLAGS="-f png -m 5 -u -o"
SLOP_FLAGS="-s -b 2 -n 1"
LunarLambda / nilism.lua
Created Sep 27, 2020
nilism - no gods, no crashes, only nil
View nilism.lua
function good()
return nil
debug.setmetatable(nil, {
LunarLambda / slowcat.c
Created Sep 25, 2020
slowcat - quick & dirty visualization tool for <link>
View slowcat.c
#include <stdio.h>
#include <unistd.h>
unsigned char BUF[4096] = {0};
int main() {
setbuf(stdout, NULL);
while (!feof(stdin)) {
int read = fread(BUF, 1, 4096, stdin);
LunarLambda / config
Created Sep 9, 2020
screenie - wrapper around maim/slop & xclip for fast screenshotting (+ i3 mode config)
View config
set $screenie_mode "Screenie: [S]election [W]indow [D]esktop [C]olorpicker"
mode $screenie_mode {
set $exec exec --no-startup-id
set $exit mode default
set $cmd_s screenie selection
set $cmd_w screenie window
set $cmd_d screenie screen
set $cmd_c screenie colorpicker
LunarLambda /
Created Aug 22, 2020
Rust: Automatic TryFrom for C-like enums using macros
macro_rules! enum_tryfrom {
// Grammar of a C-like Rust enum, with the addition of having `: $ty` after the name.
// We have to match it as an ident so we can pass it into `#[repr($ty)]` below.
// This unfortunately allows something like `C` or `rust` to be accepted
// if a type with that name was in scope. Let's just assume people won't do that.
// There are ways around it, but they would add extra noise to this already wacky macro.
// So this will have to do for demo purposes.
LunarLambda /
Created Jul 25, 2020
Tiny Rust module for displaying locations in source files.
//! Utilities for displaying locations in source files.
use std::fmt::{self, Display, Formatter};
/// The displayed filename when reading from the standard input.
pub const STDIN_FILENAME: &str = "<stdin>";
/// The default displayed filename.
pub const DEFAULT_FILENAME: &str = "<unknown>";