1. 32

What was the last program that you wrote that wasn’t a game, or a utility or a tool, but just a toy – a little (or large) program that you wrote to play with something, either a language or a framework or a library, or anything?

    1. 17

      I wrote an IRC bot in Go (nearly a year ago… Time flies) that would randomly respond to people saying “bitcoin” in the channel with “More like buttcoin, am I rite?!”

      It has since evolved to do other stupid shit for no reason other than me finding it somewhat funny in the context of the channel. Oh… And it previews links, because why not…

      1. 9

        Bitcoin trolling sounds like a valid utility to me :)

      2. 3

        Please make a Lobsters version /s

        1. 3

          Please make a Lobsters version

          Well, it’s mostly tailored to the ##crustaceans channel on Freenode. Source code here if you want to do anything to it: https://github.com/Brekkjern/buttsbot

          It’s an absolute mess, but(t) it’s there.

      3. 2

        I wrote an IRC bot in Go (nearly a year ago… Time flies) that would randomly respond to people saying “bitcoin”

        More like buttcoin, am I rite?!

    2. 16

      Imagine you have a bunch of black boxes, each N pixels wide, like beads on an abacus:

         [ ][ ][ ][ ][ ]

      You slide the first box into the open space, and then the second box, going all the way down:

        [ ] [ ][ ][ ][ ]  
       [ ]  [ ][ ][ ][ ]  
      [ ]   [ ][ ][ ][ ]  
      [ ]  [ ] [ ][ ][ ]  
      [ ] [ ]  [ ][ ][ ]  
      [ ][ ]   [ ][ ][ ]  

      If this happens fast enough, and the boxes are thin and long enough, it’ll look like the white space between the boxes is what’s moving. Can you picture in your head that animation? Will it be like a white bubble smoothly moving right, or a flickering jump, or what?

      I don’t have a mental model for what it would look like, so I taught myself p5.js and animated it. It looks like a very wobbly line.

      (This was two days ago)

      1. 4

        I love the instant gratification of p5.js coding, it’s addicting!

    3. 14

      Man, this makes me feel sad. I haven’t had time to do anything “fun” in so long. I’m sad because this last week in Texas I had plenty of free time, but, you know…no electricity.

      I suppose the last “toy” program I wrote was an operator-precedence parser in Rust, just to get a feel for the language. Of course, that evolved into the parsing component for my regex engine in Rust, so…now it’s not a toy anymore.

      Seriously, I’m kinda sad now. All I do is work…

      1. 11

        Hang in there. Ride and react to your high energy and low energy modes. Don’t beat yourself up in low energy states. Celebrate your successes by keeping a log of projects and notice how many completed ones you collect. This advice is aimed at the both of us. :)

        1. 7

          I appreciate that, thank you.

        2. 3

          This is wisdom. Life has seasons and acknowledging the more and less productive ones as equally valuable to your health is essential.

    4. 11

      I wrote a script to let me type in morse code by opening and closing my laptop lid: https://github.com/veggiedefender/open-and-shut

      And also recently modified the chrome dinosaur game to use a projector and webcam so that you play by physically jumping in front of a wall: https://github.com/veggiedefender/projectordino

      For the dino game I also wrote a blog post about some of what I learned: https://blog.jse.li/posts/projectordino/

      1. 4

        These are all absolutely phenomenal!

      2. 4

        Innovative SIGTERM-based concurrency control. Semaphores who??

        You’re hilarious. These are among the dumbest projects I’ve ever heard of. 10/10, following you on GitHub.

      3. 2

        This is my kind of tech. Keep it up!

    5. 6

      I suppose (currently) rewriting last year’s Advent of Code counts. I originally solved it in Python and as I’m now working with Spring (Java) for the first time I’ve been using this. Less focus on the problems (only translating the easy ones) but more on the runner framework (old one: python day01.py 1, new one: curl http://localhost/day/1 and /perf/1/10000 to measure algorithm speed)

    6. 5

      I am recurrently trying to build a minimalist LISP. I use it as a platform to try a few things like continuation-passing style, GC vs ARC, async vs MT, etc. It’s also a place of my own where I can be as anal about the code as I want to, some kind of engineering-oriented mental bachelor pad.

    7. 5

      A Gemini server to play around with libtls. I started with LibreSSL’s version, then switched to libretls, a version for OpenSSL.

    8. 4

      Usually my exploratory code doesn’t last long. I’ve got a folder of scratch Janet programs on my main laptop that’s currently collecting dust. I’ll often take C# code for a spin in LinqPad when I want to learn a new API.

      PISC, overall, was kinda a toy. I built it to learn and play with stack parsing, and to see if I could make something interesting/useful.

      A lot of my work of late, however, has been tools or utilities for myself, on one level or another. A kinda cool one (that I don’t have in the open yet), was called rgsets, written in Janet. What it’d do is take two ripgrep search strings, run them in parallel, only listing the files that hit those searches, and then do union/except/intersect on the resulting file lists, to see if two concepts appeared in the same file. It ended up not being super useful for what I was trying to understand, but it was a nifty idea, and a sweet spot for Janet’s event-loop+channel based async code.

      I use Janet’s os/spawn a lot actually, it’s a really nifty tool for spinning up a lot of processes and then collecting the results into something useful.

    9. 4

      Yesterday I came across Python’s Rich library again (probably here on Lobsters) and I’ve had my eye on it for a while. So I thought I’d try to use it from Common Lisp using the Py4CL bridge, which I had never used before either.

      Py4CL appeared to be a pleasure to use and I ended up with this:

    10. 4

      I wrote a program to test if division of doubles is actually faster then division of 32-bit integers as claimed on https://lemire.me/blog/2017/11/16/fast-exact-integer-divisions-using-floating-point-operations/

      This surprised me, since if you use doubles, you have to convert two integers to doubles, do a division of 53-bit numbers (and some more stuff, but that’s not on the critical path), and convert the result back to an integer. This can’t possible be faster than a 32-bit division, can it?

      And in my benchmarks, it isn’t. Using doubles is 2-5 times slower on my x86_64 machine. So I don’t know if Lemire is just wrong, or if it’s just the case on some particular machines or with a particular compiler or compiler options.

    11. 4

      I took a stab at writing a toy concatenative language. Had a lot of fun learning along the way. https://github.com/wolfadex/bex

    12. 4


      Some code that censors pornographic images off of 4chan

    13. 4

      I wrote a set of DTrace scripts to export the chat history from the macOS client of WeChat, the de facto communication app in China.

    14. 3

      I wrote a raytracer in python, just for the heck of it. It’s not particularly fast or useful, I just wanted to see what type of performance I could get with some naive numpy code. I might try to speed it up at some point because it’s not as fast as I wanted it to be.

    15. 3

      Similar to someone else in this thread, I’ve also got a toy IRC bot called Seabird with a bunch of inside jokes and random tools… it somehow evolved into a gRPC chat framework supporting Discord, IRC, and Minecraft with plugins which bridges channels (even across networks), show URL previews, add a bunch of usable commands, and includes a number of in-jokes.

      I have a ton of toy projects though, that one is just the most developed.

      Other projects:

      • go-gemini - a gemini server and client library. Currently working on porting my blog to also be served via gemini.
      • emacs-grayscale-theme - an experimental emacs theme with minimal colors (I’ve got a bunch of themes, but I’d consider this one mostly a toy)
      • gitdir - a self-contained git SSH server
      • zsh-utils - a minimal set of zsh plugins which make the out of the box experience better
      • toolbox - an in progress convenience lib used for writing opinionated http services in go.
      • yeet - an end-to-end encrypted file-uploader, still in progress
    16. 3

      Given an [i32; 2] point on a boxy spiral starting at [0, 0], I wanted to be able to: wind it to the next point on the spiral, unwind it to the preceding point on the spiral, get its index, and the position from an index. By printing out diagrams from under cargo watch, I was able to get instant feedback.

    17. 3

      I wrote a short script that, given a Python file, rearranges all the classes and functions alphabetically. (without modifying its functionality)

    18. 3

      I somewhat swapped True and False in Python. Works worse than you might think sadly, due to True and False instances being stored in static locations and much of CPython checking truthiness by location.

    19. 3

      I built a little CLI to convert Unix Epoch timestamps to RFC3339 format. Sure, there’s probably a tool for that already, but it was faster for me to write that little Golang glorified script than it was to search the man pages of however many programs that could potentially fill the role. It felt nice being able to write a program that I could easily define as “done”.

      1. 3

        You are looking for date.

    20. 3

      One toy project of mine involved games and came out of a game jam, but sweet-turnips was first and foremost an experiment in making a template for tiny games, something I and others could use to rapidly prototype games under very tight creative constraints. It was also an excuse to learn entity component systems and event-driven architecture hands-on.

      I also slapped together a little weather report display for my Inky pHAT a couple days ago. Loved the process.

    21. 3

      I tool that listens to udev USB events and executes actions when matching rules written in yaml. The rules allowed me to match on port, device, or event (connect/disconnect) or any combination of them.

    22. 3

      To brush up on my Go skills I started writing a Chip8 implementation! Wound up writing an assembler too. It’s a super simple ISA and would be a great way to teach the basics of how processors work.


    23. 2

      Two weeks ago I wrote a visual bloom filter, and this week I started on a duplicate file finder. My goal for the first is to keep up with the status of long running processes, the goal of the second is to improve my skills at using the transparent parallelism libraries in Haskell.

      This past weekend I tried to hack up the QMK firmware for my moonlander keyboard to replace the NeoTrellis LED output for the visual bloom filter, but my C skills are weak, and I gave up after a solid two days of trying to figure out how to send RGB colors from the laptop to the keyboard.

    24. 2

      I’m writing a toy AM synth. Quite fun and educational so far. I would eventually like to add an FM synth option as well, as I haven’t fully explored that concept yet. These have been bucket list items for quite a while.


    25. 2

      I made a little toy script to make fzf descend directories when I pressed Ctrl-R, instead of automatically. It made me yearn for a real programming language:

      export counter=$(mktemp -u /tmp/fzfc-XXXX)
      echo "1" >$counter
      workbinds='enter:execute(cd {};nvim .)+unix-line-discard,tab:execute(lf {})+unix-line-discard,`:execute(cd {};zsh -i)+unix-line-discard,#:execute(cd {}; edwood -f /usr/lib/plan9/font/luc/latin1CW.10.font)'
      find -maxdepth 1 -type d | fzf --bind 'ctrl-r:reload#expr $(cat $counter) + 1 > $counter && find -maxdepth $(cat $counter) -type d#' --bind "$workbinds"

      Maybe not a toy, since I used it for a bit. But certainly ugly and prone to various data races.

      I also used Go to script Go once: https://skuz.xyz/go-in-go.html I didn’t dig that deep but it’s not ready for use yet.

    26. 2

      A strictly message-passing ObjC implementation of fizzbuzz.

      1. 1

        This is awesome

    27. 2

      Porting md5 sum, sudoku solver, and brainfuck implementations from C to Go for some micro benchmarks.

    28. 2

      I’ve made UFO in a chat.

      When somebody types one of the dozen special words, like “plane” or “carrot” or “coffee”, with a few added conditions and if it hasn’t been typed chat-wide in the last few hours, then a high quality svg of the thing flies through the screen of all users in the room at the time.

    29. 2

      libgmp bindings to PicoLisp and test builtin bigmath.

    30. 2

      A little Rust lambda calculus evaluator.

    31. 2

      A tiny program to randomly colorize text.

    32. 2

      Most recently was a Discord bot for my D&D group so we could play the Mistborn RPG (it has some weird dice mechanics and i didn’t want everyone to waste time in game handling them)

      The most long-lasting one (and continuously useful one) was my Pokemon Sword/Shield Helper App (GitHub) that I wrote when learning Elm.

    33. 2

      I wrote a raspberry pi router with a custom made captive portal, firewall rules to customize, tag and log traffic per user, and sign those logs using openssl. Ruby/Sinatra/Sequel/SQLite backend, JQuery/Bootstrap/Websocket frontend. I still go back to it from time to time to remember how to handle iptables, local dns, openssl, sinatra, sequel, etc.

    34. 2

      I wrote “Matchbox-Twelvy” which is a GAN that makes deepfake toy car images.


      Video of the training progression: https://www.youtube.com/watch?v=ai-pUTKEJG4 (video does not contain audio and is silent, but does have flashing images)

    35. 2

      A little menubar app (macOS) to quickly check word pronunciations via Forvo. Really helps me when studying a language and wondering about the rhythm or tone of a new word: https://github.com/martinrue/forvilo

    36. 1

      The last one I remember writing was a pomodoro timer – not to ever use, but to play with the logical structures of lua.

      I am currently learning forth and doing the same.

    37. [Comment removed by author]

    38. [Comment removed by author]

    39. 1

      I think it was playing around with Vulkan and GLFW, to see how well the Rust bindings held up. I stopped at getting a triangle on the screen, but it worked pretty well.