DEV Community

Cover image for Programmatically output lyrics on a tee-shirt
Corentin Girard
Corentin Girard

Posted on • Edited on

3 3

Programmatically output lyrics on a tee-shirt

Some years ago I re-wrote the lyrics of a song as a JS script. I ordered a tee-shirt with this "art" of mine (I actually find it quite beautiful 😅).

But everytime someone looked at my tee-shirt, they would ask me if it really means or does something. I would answer "no, it doesn't work, it's just a representation".

My tee-shirt with source code art

But now, I've implemented it!

I chose C++ to be able to overload operators exactly as I wanted... My goal was to not change anything about this source code, which I designed without knowing I would implement it.

So in the main.cpp file, all I have is the following:

#include "logic.cpp"

int main()
{
    /**
     * Guess the song... 😌 😎
     */

    imagine(!heaven) == "easy";
    us.below = !hell;
    us.above = sky;
    imagineAll("living for today");

    imagine(!countries) != "hard";
    (kill || die).reasons.length == 0;
    religion = undefined;
    imagineAll("living life in peace");

    chorus(); //🎵🎶

    imagine(!possessions) ? "😀" : "😥";
    need(greed || hunger) == false;
    men.reduce([]() { return "brothers"; });
    imagineAll("sharing all the world");

    chorus(); //🎵🎶
}
Enter fullscreen mode Exit fullscreen mode

All the logic is included in another file.

As you can see, the only differences are the double quotes for the string literals and the syntax of the lambda expression. Apart from that, it's the exact same thing as my tee-shirt.

Here's the output of the program, without any hardcoding:

image

Here's the repo: https://github.com/Drarig29/tee-shirt-song

So, did you guess the song?

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more