16+ years of gists
About #
In this post, I look back at several years of recreational programming that I have saved as GitHub Gists.
I am also doing this to bring some visibility to the different experiments I have written over the years and to have useful links to share with people when I say, "Oh, I remember doing something like this at some point!"
Let's begin.
2007 #
I started programming around 2005-2006, exclusively for the web. I first got started with HTML and CSS and eventually moved on to learn PHP and SQL. I built my own website, my own blog, and a few other webapps. Unfortunately, all of that code is lost.
So 2007 is our starting point.
San Andreas Multiplayer Scripts #
I almost forgot about this! I used to play a mod for GTA: San Andreas that enabled multiplayer gameplay. The mod used Pawn for server scripts.
For example, I wrote a /givemygunto
command that gives your
current weapon to another player. I remember barely having a grasp of what was
going on in terms of the language and programming in general; I just copied and
pasted my way to my goals.
I am pretty sure this was the first non-web programming I ever did.
2008 #
PunBB extensions #
I used to be an active member of the PunBB community. PunBB was a PHP forum software that was lightweight and fast, compared to alternatives like phpBB.
I wrote several extensions for it: Sitemap Generator, XML Backup, Improved Smilies System, Gravatar support, Genders support, Akismet Spam Protection, and some others.
The actual code for these extensions is no longer available, unfortunately.
Blog Themes #
I got a bit into web design around this time. I find it funny that I kept trying to get into blogging by writing my own blog software and even designing my own blog themes. All of this to no avail; I never actually wrote anything worthwhile until many years later.
Some of the themes I designed during that period: Black on White, Horizontal, Red, Blue, Blue Alt, and Simple.
2010 #
codeigniter-mongodb #
This is a library that I wrote for an early version of CodeIgniter, an application framework for PHP.
Based on this line, I think this library was intended for use on OnePage, my first ever coding collaboration with another person (Buffer's Joel Gascoigne).
CSS3 Experiments #
CSS3 changed everything when it finally came about, and I was very excited about it.
I used it to replicate some desktop UIs: Windows 7 window chrome, iTunes for Windows, Pidgin for Linux, Windows 7 taskbar, Windows Live Mail desktop client.
imgur_upload.py #
A Python 2 script that uploads image files to Imgur. Apparently, I put some effort to make it cross-platform.
The gist also contains a .desktop file for easy drag-and-drop invocation from
a desktop UI on Linux.
I think that I started learning Python in 2009. And I remember that in 2010, the Tornado web server/framework had become popular. I had tried to do something with it, but it was too advanced for me at the time. I was more comfortable with PHP's stateless execution mode. In this sense, simple Python scripts did fit my mental model of programming at the time.
2011 #
This was a gap year for me, before starting university.
This was also the year when I realized that PHP was not an end-game language, and so I started learning a bunch of languages at once: C, C++, C#, D, Go, Haskell, Java, Python (more of it).
I wasn't planning on learning D, but I was lucky enough to stumble upon Andrei Alexandrescu's "The D Programming Language" in a secluded section of a random bookstore in São Paulo. Looking back, this makes no sense at all. But it happened so. And I'm very glad it did, because it introduced me to a) Andrei's entertaining writing style, and b) that language design can be approachable and fun.
youtube_subs.py #
Another Python 2 script that appears to transform an RSS feed of YouTube subscription videos. I can't remember why I needed this.
I see the use of the BeautifulSoup library, which at some point had become a
staple in my web scraping scripts. I found myself doing that frequently, and
this library was very handy.
It's also funny that I thought that I needed to use global to read global
variables. AFAIK, that's only needed for writing. Maybe I was trying to be
explicit about what's local and what's global?
js-flash-audio-input #
Also not a gist, but it could have been. This seems to be a proof of concept on how to access the microphone from JavaScript before the Media Streams API became available a couple of years later.
Audio samples are captured by a Flash (ActionScript) component and fed into JavaScript via a callback. The demo then stores these samples to create a WAV file in memory and expose it to the user via a Data URL for playback in an Audio element.
minify.py #
Yet another Python 2 script/utility. This one reads a URL from the clipboard, minifies it, and writes that back to the clipboard. I also tried to make it cross-platform.
I remember URL minification being a big deal around this time, I'm not sure why. I think Twitter back then wouldn't do that automatically? I also remember Google's URL minifier coming in as a new player in this URL minification space, so I think I was just eager to implement a tool with it.
The code looks somewhat neat overall. It's very imperative, too.
kag-map-renderer #
A Python script that renders King Arthur's Gold maps.
I think this was one of my earliest ventures into graphics, so the code is very messy. But it did a decent job.
This eventually led to a collaboration with the game's creator, Michał Marcinkowski, to build a new website for the game.
2012 #
This year I started university.
For whatever reason, I barely used GitHub and gists during this period. So a lot the code that I have saved from this period lives on my Google Drive.
In particular, I wrote a lot of C++, because that's what my university's curriculum was based on. Because I was already familiar with the language, I used the spare time and energy going deeper into it. I got into template metaprogramming, decompiling a la Godbolt before that became a thing, poking at RTTI and vtable internals, and so on.
cinecenter.py #
This Python 2 script scraped the movie listings of my local cinema at the time.
I can see the usual combination of urllib2 and BeautifulSoup (version 4,
this time). I also see that I structured the code in a class this time. Maybe I
was getting into OOP. Though this is a very poor use of classes.
Pixelated (source) #
This is a clone of a Blackberry game by the same name. I remember playing this game on a friend's phone during a road trip. When we arrived at our location, I just had to pull out my laptop and code up the game.
2013 #
My second year of university.
static_iterator.cpp #
One of my first C++ template metaprogramming experiments. It seems that I was
trying to emulate statically-defined loops through an iterators-like API. For
example, the 32-bit constant 0xDEADBEEF would need 32 iterations to be turned
into a std::array<bool, 32> and those were defined at compiled time.
screenshot.py #
A Python 2 script that takes a screenshot and uploads it to Imgur.
leonardo_numbers.cpp #
Computes (Leonardo numbers)[https://en.wikipedia.org/wiki/Leonardo_number] at compile time via C++ templates.
I remember having watched some Channel 9 videos by none other than Stephan T. Lavavej about template metaprogramming. I then reached out to him to ask some questions. He was kind enough to explain some concepts and techniques to me.
closure_list.js #
This appears to implement a list data structure in JavaScript using eval and
dynamically-constructed variable names. The first element is stored in v, the
second in vv, and so on. This is very weird! Maybe I was trying to understand
closures and lexical scopes?
ruby_n_times.d #
The first appearance of D! Here I was trying to replicates Ruby's N.times construct in D using templates and UFCS.
I was probably trying to exemplify the expressiveness of D to some peer.
variadic_mergesort.cpp #
Implements mergesort with C++11 variadic templates.
Judging by the local variable named meow, this is probably a continuation of
my exploration of template programming inspired by Stephan.
function_traits.cpp #
A C++ experiment that seems to extract RTTI information from each parameter of a function. Was I trying to undertand the C++ ABI? (Like array-to-pointer decay.) Or was I preparing to do some runtime inspection of types? I can't remember.
simplex.py #
I remember being taught the Simplex algorithm in a linear programming course at university. As the teacher explained it on the blackboard, I transcribed the steps to Python code. I'm pretty sure it didn't work out in the end, though!
tuple_explode.cpp #
Based on the code comment, this was also inspired by a Channel 9 video. I think
the challenge was to call a function by exploding a std::tuple into a
parameter pack.
My comment explains:
This is the first idea that came to mind after watching the video.
I wouldn't recommend its use, but it is one way of tackling the challenge.
devirt.cpp #
I remember this. I was trying to manually implement devirtualization. Maybe because I had heard about this compiler optimization and was trying to understand it?
2014 #
My third year of university.
count_digits.d #
A D experiment that counts the number of decimal digits of a runtime integer by building the binary search statically.
I vaguely remember this being inspired by one of Alexandrescu's talks.
descent.d, descent.hs #
I think around this time I was taking Andrew Ng's course on Machine Learning.
These two programs seem to implement one of the course's descent algorithms in D and in Haskell, respectively.
bk.py #
This is a funny one. Around the time, our local Burger King was running a campaign that allowed you to win some food vouchers by playing a football minigame. (2014 was a FIFA World Cup year, so that tracks.) You had to pick one of five positions to shoot and the goalie may or may not defend your shot. The minigame was completely luck-based.
Naturally, I wrote a Python script that played the game for you, for a number of email-password pairs.
automata-pila.hs #
A barebones stack automaton implementation in Haskell, for one of our programming language courses.
I wanted to showcase Haskell's conciseness to my teacher and peers.
pushdown.hs #
A similar thing but for pushdown automata.
This seems to make an attempt to generalize the concept with a type class and type families.
iterators.py, generators.py #
I think I was trying to explain Python's iterator and generator protocols to a peer.
The second script reads much more like a tutorial. This type of writing eventually became one my core style for explaining things, as demonstrated by some posts in this blog.
roundrobin-kernel.hs #
I do not remember this at all. It looks like a CPU process scheduling simulation in Haskell. I was probably taking an operating systems course at the time.
It looks pretty involved, though running it doesn't seem to do much. Maybe it is incomplete.
google_ascii.py #
A Python 3 script that picks a random image from a Google search, downloads it, and then outputs it as ASCII art. I remember writing this while bored during class.
2015 #
My fourth year of university.
Lambda.hs #
Possibly my first lambda calculus evaluator in Haskell. I'm actually surprised that it happened this late.
curry.cpp #
Implements function currying in C++14. I guess I still had some template programming itches to itch! I wrote a second version here: curry2.cpp.
meow.cpp #
This is a C++ type that records how many times it has been constructed, copied, moved, etc. I remember I used this to explain move semantics to someone.
translate_im.py, translate_im.d #
A toy script that translates a word from Spanish to Portuguese using Bing's API and then downloads a random image from Google using that word as a search term.
I remember writing this to help my then-girlfriend learn Portuguese.
I wrote the script in both Python and D. I think I was pleasantly surprised with
D's conciseness compared to Python. Combined with rdmd (compile & run), D
proved a good alternative to Python.
pptx_image_extractor.html #
A web 'script' that extracts images from a PPTX and saves them to a ZIP file.
I wrote this for my grandfather, who enjoyed sending and receiving PowerPoint presentations that contained pretty photos accompanied by music and inspirational quotes. He would manually copy the images to this computer and use them in his desktop wallpaper randomizer.
pixelated-hs, pixelated.d, pixelated.cpp #
This was an attempt at writing a solver for the game Pixelated. Despite my best attempt at the time, I think the algorithm had an exponential running time.
copiarlog.c #
It's not entirely clear what the purpose of this C program is. But I do remember having read The Linux Programming Interface and wanting to use some of the concepts I had learned.
encoderWAV.js #
Not the first time I write a WAV file encoder in JavaScript! I did that the
first time with my js-flash-audio-input project in 2011. This time, though, I
had access to
typed arrays.
rx.speech.js #
This seems to be an RxJS wrapper for the Web Speech API. I can't remember what I used this for.
Program.dnx.il #
I was early adopter of .NET's new compiler toolchain back then. Before Roslyn was production-ready, they still relied on Mono for Linux builds. I found some issue and reported it.
cliente_sockets.c #
A toy HTTP client written in C. I remember I wrote this for an operating systems course. The HTTP server counterpart was written in Haskell, also using raw sockets.
json.hs #
I suppose this was my first attempt at using parser combinators to parse JSON in Haskell?
Temporizado.cs #
Some concurrency experiment in C#. I think I was trying to grasp C#'s memory model, based on references to 'relaxed atomic load' and such.
I remember being heavily influenced by Herb Sutter's atomic Weapons talks and also by CLR via C#.
pib.hs #
A Haskell script that appears to plot some linear regression model, mean-squared error, and a Savitzky–Golay filter. Probably did this for some simulations course.
I also remember having learned and used aivika, a simulation library for Haskell. Reading through its manual was very enlightening in terms of its use of monads and arrows.
fibs.ipynb #
Different ways of computing Fibonacci numbers in Haskell.
expr.hs #
Yet another lambda calculus in Haskell. This time, with a syntax and parser.
gene.{hs,py} #
A transcription of a genetic algorithm from a thesis print I found in my university's library. Unfortunately, I could not get it to work.
Parser.hs #
Possibly one of my first attempts at writing my own parser combinators in Haskell.
data.hs #
An early attempt at understanding Church (or Mogensen-Scott) encodings of data types in Haskell.
I think this also kickstarted my itch for initial/final encodings.
ffi.idr #
A basic demo of using the C FFI in Idris.
Apparently around this time I started playing around with Idris.
paks.{d,hs} #
I used to be an avid Arch Linux user. These scripts seem to print installed packages sorted by installation date?
2016 #
My fifth and last year of university.
This year I moved to Lausanne, Switzerland to work for a small algorithmic trading startup called Nafora. We used a lot of Python and Java there.
emscripten.php #
A PHP script that compiles C++ using emscripten and then runs the output on Node.js. What a weird combination of technologies! I am not sure what I built this for.
miaw.cpp #
A C++ interpreter for a basic stack-based language.
I think I was trying to prove to a friend that 'inventing' a language is not that hard.
test300.raw.xz.b64 #
300 seconds of 440Hz sine signal in raw 32bit IEEE Float format, xz-ipped, in base64
I have no idea what that was for. So cryptic!
async.js #
I think this tried to emulate async/await via generators in JavaScript.
ib_codes.json #
Around this time I was working with Interactive Brokers Trader Workstation API.
vortex.html #
A colleague of mine liked to draw this sort of spiral pattern on paper. So I wrote a JS script that draws the same pattern programmatically.
I decided to write it in a very functional style.
lambda_delegate.cpp #
Implements some C++/CLI helpers to be able to use C++ lambdas as CLI delegates.
I remember using C++/CLI a lot in 2012 because my university was really into C++ and WinForms. I found it really interesting how they managed to compile C++ for the CLI. But I have no idea why I was still looking into this in 2016!
lazy_primality.cpp #
It is 'lazy' in the sense that it just delegates the primality check to the
factor program.
leaking.cpp #
A C++ template that purposefully leaks (doesn't call the destructor) of a given type.
simple-any.cpp #
Implements a toy version of std::any.
novice-tuple.cpp #
Implements a toy version of std::tuple.
JavaStringMemchr.java #
Uses C's memchr on a Java byte array. I guess I was experimenting with the JNI
for the first time.
2017 #
This year I moved to Mendoza, Argentina to work for Eventbrite.
I wrote more Haskell code this and the next years because I started a Haskell study group at work. This is something that I have since done at every company I have worked for.
Circle.hs #
I think I had found a cool solution to some Leetcode-style problem. This gist describes my analysis.
2018 #
HM.hs #
I think this implements Hindley-Milner style type inference.
EventDescriptionValidity.java #
A demo of using phantom types in Java to hold validation invariants.
Snake.hs #
Snake game in Haskell.
Quad.hs #
I think this implements Quadtree for 2D collisions in Haskell?
FunctionalParsers.java #
My first attempt at writing very functional Java, inspired by Haskell.
StackExpr.hs #
My first experiment with initial encodings and the interpretation problem in Haskell.
Vect.{hs,java} #
Length-indexed vectors in Haskell and Java.
2019 #
This year I moved to Amsterdam to work for Uber.
free_monad.py #
An attempt to build a sort of effect system in Python 3 using generators.
di.py #
A basic dependency injection container in Python 3 with type annotations.
2020 #
Parser.java #
The first version of the code that eventually became my post on Declarative and composable input validation with rich errors in Java.
ExprCompiler.java #
Continuing my exploration of initial/final encodings, this time in Java.
TypedExpr.java #
A similar thing but with typed expressions.
free.py #
A continuation of the Python algebraic effects idea, which then became this blog post.
Life.hs #
Conway's Game of Life in Haskell.
Parsec.java #
A Parsec adaptation to Java.
2021 #
MicroWire.java #
A toy dependency injection container in Java.
ParserClass.hs #
Further exploration of initial/final encodings in Haskell, applied to parsers.
I wasn't sure what I was really doing, so I started a thread on Haskell's Discourse and came to learn of those terms.
ParserClass.java #
I implemented the same thing in Java. This taught me about the higher kinds encoding for Java and about type equalities.
Nat.{cs,java,kt} #
Length-indexed vectors in C#, Java, and Kotlin.
hk.py #
Applying the higher kinds encoding to Python 3 with type annotations.
Sub.{cs,java} #
Just like the type equality witness above, this is a subtyping witness.
2022 #
Stages.java #
An interesting idea about representing the type of each field in a structure with a unique type parameter. Then, computations can be split into 'stages', each on which accurately represents the change of structure in each field.
2024 #
sql.go #
A SQL sort of DSL written in Go, which can be 'compiled' to actual SQL or can be executed into actual values.
2025 #
This year I started working for Picnic.
vscode-tunnel.php #
A PHP script that manages the background process for VS Code Remote Tunnels.
vscode-tunner.py #
The same thing but in Python 3 as a CGI script, also implementing Google authentication.
vscode-tunnel.tsx #
The same thing again but in Deno + TypeScript, also as CGI script.
refined.java #
An idea for refinement types in Java.
TypeClassSystem.java #
The very first version on my type classes implementation for Java.
This eventually became my post, Full Haskell-like Type Class resolution in Java.
rex.c #
A regular expressions DSL for C, inspired by Haskell's Parsec library. Continued in https://github.com/Garciat/parsing.c.