Postgres dress with pockets

November 27, 2020

I was looking for something to add to my Christmas wish list (yes, my parents are retired and they asked for this wish list for the last 3 months) and I remembered I had seen a blog post a few years ago where you could print your own code on clothes.

I had a good memory of a particularly nice dress (and I found out later it even had pockets! Yay!).

The code

I had to google differents key words (including dress and code but not dress code) and I finaly found out this Github repository.

The code is written in python. It will then generate images that you’ll be able to upload to to customize your dress (or other piece of clothe).


I don’t know if you’re a python afficionado. I was until I found out that setting the environment for each project was a nightmare. Don’t get me wrong, I love writing and reading python code, I just find it pretty annoying to download all those extra packages.

Thankfully, the code provided by Holden Karau also includes a dockerfile.

Just one warning, I’m not a docker expert, I’m not a developer. Maybe I didn’t use those tools how they were intended. What matters is that I was able to use them quickly (less than 1 hour) and create my dress.

Build the docker image

You first need to build the docker image. That’s pretty standard:

docker run --detach --name mydress dress

It might take some time, but it’s ok.

Create the container and connect to it

I then created the container and ran a simple interactive /bin/bash command to be able to launch the code.

docker run -it dress /bin/bash


The code that generates clothe is It can generate different images depending on the kind of clothes you’d like to create:

python --list-clothing
The following clothing items are available:

Here is the syntax you need to use:

python --help
usage: [-h] [--files [FILES [FILES ...]]] [--output [OUTPUT]]
              [--extension [EXTENSION]] [--clothing [CLOTHING]]
              [--list-clothing] [--style [STYLE]] [--list-styles]

Process some code

optional arguments:
  -h, --help            show this help message and exit
  --files [FILES [FILES ...]]
                        file names to process
  --output [OUTPUT]     output directory
  --extension [EXTENSION]
                        output extension
  --clothing [CLOTHING]
                        Clothing item to generate images for (see all
                        available profiles with --list-clothing)
  --list-clothing       List all available clothing profiles and exit.
  --style [STYLE]       The pygments style to use for the colour scheme (see
                        all available styles with --list-styles)
  --list-styles         List all available style names.

Using your code

I decided to use a random code page from postgresql. I choose parser_oper.c. Once it’s chosen, you will need to copy it inside your container.

docker cp ~/postgresql/src/backend/parser_oper.c 7de0a113b475:/usr/src/app

That was so simple.

Choosing colors and styles allows several syntax coloring styles. Of course, I wanted to see them all. So I changed a little the code, so it can generate all the images for all styles at once. Of course, my container ran out of memory when I tried it, so I simply added an if statement not to re-generate already generated images, so that by running it twice all my images were generated (yes, that’s good enough for throw away code).

Here’s my modified code of

if __name__ == "__main__":
    import argparse

    parser = argparse.ArgumentParser(description="Process some code")
        "--files", type=str, default=[""], nargs="*", help="file names to process"
        "--output", type=str, default="out", nargs="?", help="output directory"
        "--extension", type=str, default="png", nargs="?", help="output extension"
        help="Clothing item to generate images for (see all available profiles with --list-clothing)",
        help="List all available clothing profiles and exit.",
        help="The pygments style to use for the colour scheme (see all available styles with --list-styles)",
        help="List all available style names.",
        help="Will generate the chosen clothe images with all the styles available.",

    args = parser.parse_args()

    if args.list_clothing:
        # The user just wants a list of profiles, let's print that and exit.

    if args.list_styles:
        # Again, the user just wants a list of styles, let's print that.

    if args.list_styles or args.list_clothing:


    if args.all_styles:
        # Generate all styles
        # Generate it only if it wasn't already done
        for style in list(get_all_styles()):
            if not os.path.exists(os.path.join(os.getcwd(), args.output, style)):
                print("Making the images in memory for "+ style)
                (processed, highlighted, cropped, glitched_tiled) = build_image(
                    args.files,, style=style)
                print("Saving the images to disk")
                save_imgs(args.output + "/" + style, processed, args.extension)
        # Generate one style
        print("Making the images in memory")
        (processed, highlighted, cropped, glitched_tiled) = build_image(
        print("Saving the images to disk")
        save_imgs(args.output + "/processed", processed, args.extension)

Getting images

After that, I was able to launch my code:

python --files parser_oper.c --output out -- clothing dress_with_pockets --all-atyles

And to copy my images outside the container:

docker cp 7de0a113b475:/usr/src/app/out .

Customizing the dress

Go to the cowcow website and click on the customize button. You might need to install IE Tab :-(.

After that, you should be able to use the generated images to make a nice dress (with pockets!).

And voilà!

Dress front Dress back

Replica identity for logical replication

December 16, 2020
PostgreSQL Administration

Is my port open?

December 1, 2020
PostgreSQL Administration

Where do my Postgres settings come from ?

April 19, 2020
Hacking PostgreSQL Administration