Postgres dress with pockets

Β· 860 words Β· 5 minute read

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 different keywords (including dress and code but not dress code) and I finally 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 another piece of clothing).

Docker πŸ”—

I don’t know if you’re a Python aficionado. 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 docker file.

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

Using πŸ”—

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 color 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 throwaway 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-styles

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