Skip to content

Instantly share code, notes, and snippets.

Thorsten Ball mrnugget

Block or report user

Report or block mrnugget

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View go_module_jitting.go
package main
import (
mrnugget / go_jit.go
Created Aug 17, 2018
JITting a function that writes the letter 'H' to a bytes buffer
View go_jit.go
package main
import (
mrnugget / pipe_to_jq.el
Last active Jun 27, 2018
This binds `<leader>jq` to a command that pipes the current visual selection in evil-mode to `jq` and replaces it with the output.
View pipe_to_jq.el
;; Taken from here:
(defun shell-command-on-region-and-select
(start end command
&optional output-buffer replace
error-buffer display-error-buffer
"Wrapper for 'shell-command-on-region', re-selecting the output.
Useful when called with a selection, so it can be modified in-place"
mrnugget /
Last active Jan 6, 2020
So you're finished with "Writing An Interpreter In Go" and want to read more?

This is what I once wrote to a reader:

  • Nand2Tetris book -
  • The paper "An Incremental Approach to Compiler Construction", by Abdulaziz Ghuloum. You can find a hosted PDF version of the paper and an implementation of its contents here:\
  • Jack Crenshaw's classic "LET'S BUILD A COMPILER" from 1988. Even though it's kinda dated (he's using Turbo Pascal), it's one of the great "let's roll our sleeves up and write some code" texts. Here is the PDF version:
  • Then there are also the 4th and 5th chapters of Structure an Interpretation of Computer Programs (SICP), in which you'll build an interpreter and a kinda bytecode-compiler for a virtual register machine. It's a pretty abstract and seemingly alien affair (using a Lisp dialect to build a virtual register machine for a bytecode defined in Lisp, produced by a Lisp compiler, etc.), but it teaches the concepts behind the whole compiler and VM thing.
mrnugget /
Created Sep 8, 2017
Fixing a Rails migration in a previous commit

Fixing a Rails migration in a previous commit

Status Quo

We're sitting on a commit and a previous commit introduced a migration. The migration and the resulting db/structure.sql (or db/schema.rb) have been commited in <commit-to-be-fixed>.


mrnugget / foobar.go
Created Jul 26, 2017
Using test helpers in Go -- how do I know which test failed with vim-go?
View foobar.go
package main
func AddTwo(input int) int {
return input + 2
func AddFour(input int) int {
return input + 4
mrnugget / parse_fat_arrow_functions_monkey.patch
Last active Jul 18, 2017
These changes add support for fat arrow functions to Monkey's parser. E.g. `(a, b) => { a + b }`. The current implementation expects that the body is a block statement, i.e. it needs curly braces.
View parse_fat_arrow_functions_monkey.patch
diff --git src/monkey/ast/ast.go src/monkey/ast/ast.go
index fb30b05..70668a6 100644
--- src/monkey/ast/ast.go
+++ src/monkey/ast/ast.go
@@ -337,3 +337,28 @@ func (hl *HashLiteral) String() string {
return out.String()
+type FatArrowFunction struct {
mrnugget / markdown-toc.rkt
Created Jun 10, 2017
Reads a markdown file from STDIN and outputs the TOC to STDOUT. Install Racket to run it.
View markdown-toc.rkt
#!/usr/bin/env racket
#lang racket
(define (contains-heading? line)
(regexp-match #rx"^#+" line))
(define (heading-level line)
(length (regexp-match* #rx"#" line)))
mrnugget /
Last active Apr 24, 2017
I wrote this down so people in the future know how to answer "do you know what happened to him?"

RSpec output in Vim broken

Tests are run with vim-dispatch and this command:

:Dispatch bundle exec rspec spec/path/to/file_spec.rb

vim-dispatch creates a new tmux pane where it runs the command. The output of the command is fed to Vim.


Sometimes the STDOUT output produced by bundle exec rspec is malformed. Lines are missing, or merged together.

View brainfuck.c
#include <string.h>
#include <stdio.h>
#define MEM_SIZE 30000
char mem[MEM_SIZE] = {0};
char *memp = mem;
void bf_eval(char *code, int len, FILE *in, FILE *out)
You can’t perform that action at this time.