Kartones Blog

Be the change you wanna see in this world

Bootstrapping database creation for a microservice in a container

Today I had to build a new microservice which uses PostgreSQL for data storage. Following the containers principle of disposability instead of reuse, I need to provide some bootstrap logic that setups everything needed for this piece to work independantly and assume that each run might be the first run. Also, following the Twelve-Factor App config guidelines I shouldn't store any relevant configuration value in files, but use environment variables instead.

What looks simple in theory is indeed simple when you find a solution, but might not be obvious, so here's my approach. I use Linux createdb command, but as it doesn't allows you to specify the database connection password as a parameter, I use a .pgpass file with the proper permissions to make it work, with the added bonus of only using bash scripting to achieve it.

echo "*:*:*:$DB_USER:$DB_PASSWORD" > ~/.pgpass
chmod 0600 ~/.pgpass
createdb $DB_NAME -h $DB_HOST -p $DB_PORT -U $DB_USER -O $DB_USER -w || true
rm ~/.pgpass

There might be better solutions (I'd love to hear them) but this does the job and is easy to understand.


Book Review: Commodore AMIGA A visual compendium

Commodore AMIGA A visual compendium

Title: Commodore AMIGA A visual compendium

Author: Bitmap Books

If I had to pick a single entertainment system to define my childhood, it would be the AMIGA 500. After having an AMSTRAD PC/W with green and black screen, the AMIGA with all those colors, the incredible sound and music, and those devices called mouse and joystick were trully amazing. It defined my eighties and first half of the nineties, so it is hard to not be biased when reading this book.

Through more than 400 pages we'll see full-page, colourful images of many many classic titles, with the company, publisher, year of release, and then either a brief description or one or two paragraphs with info about the game (from its creators usually), some review or other related info. But not everything is a listing of titles, we also have some interviews in between, some of them really interesting to learn how was developing videogames and art for the machine, and a few "company specials" where we're summarized how some of the most known back then companies grew, what where some of their most important titles, and what happened with them.

The book itself is nice, but I'd prefered more consistency: All games displayed with a brief description and then leaving "insider details" for another section, or the company history, or developers/artists interviews. Sometimes you see an unknown game and just an opinion of "well, was a really tight schedule to develop this title!" doens't precisely help know what's about. Something similar happens with images, some games have wonderful screenshots or the main title image, while others have a random screenshot from the intro, a heavily zoomed fragment or artwork that doesn't represents much the game. This is what I really disliked, I'd loved to see an in-game screenshot of every game and not this "artistic approach" that sometimes fails to achieve its apparent purpose of finding representative takes.

Even with my complaints, the book is full of nostalgia and I'd recommend it (unless you have at hand a real AMIGA computer). It could just have been better.


UGE - Universal Game Editor + Stonekeep module

I am replaying an old videogame jewel, Stonekeep, and I recalled that back in time when I finished it around 1996 I had a savegame editor to play with some variables, so I wanted to see if I could still find a similar tool today. Some searches led me to the specific GOG forum of the game, and some people were also asking about an editor while others were mentioning UGE.

Universal Game Editor is a 1993 MS-DOS tool made by Jack Hartman that was really cool for its time, and is now also hard to find. I used it in the past but didn't keep the editor, so I've done some digital archaeology and found not only a working version plus the data files to be able to edit Stonekeep savegames:
UGE screenshot

Following the module instructions, the recommended maximum values to set for any of the characters are:

  • Main stats: 9
  • Hit points: around 900
  • Skills: 9 (but I have 11 on one with my main character and nothing broke)

Link to download UGE 1.0 + Stonekeep module. I've tested it with Dosbox and works fine.


Book Review: Ready Player One

Ready Player One book cover

Title: Ready Player One

Author: Ernest Cline

In the year 2044, virtual worlds with virtual reality (OASIS) have conquered our lives to the point of people just wanting to be online instead of living a mostly miserable life in a devastated real world. This virtual reality is monetized not only by selling virtual goods, but by charging for virtual transport, both inside and between planets of this "virtual galaxy", where both magic and science-fiction go hand-by-hand, and when the creator dies of old, he leaves a test: He who finds and opens three special gates with three special keys and gathers a special egg will inherit the full multi-billion legacy and would become the owner of OASIS company. Just that and a simple riddle. Years later, Wade, a "gunter" (otaku-like but obsessed with finding the price) just finds the first clue...

Imagine Second Life and Oculus were the biggest hit to ever happen to humanity. Imagine that the creator of the VR is the biggest geek you can imagine (80's movies, shows, music, RPGs, videogames and arcades), and then pour in a huge amount of geeky examples that range from iconic videogames to movie monsters, anime mechas, classical pen and paper roleplaying game character archeotypes... All mixed in what I'd call a nerd version of Willy Wonka and the chocolate factory: an awesome price and legacy to obtain, a crazy owner with "a crazy world built" with weird situations and where some youngsters have to complete challenges.

The result. is curious, to say the least. It hits really hard on the nostalgia part, so if you have memories from the 80s or early 90s it will probably hook you up. I read the first half of the book almost in a single sit, because all this MMO (Massive Multiplayer Online game) with wizards and plasma rifles, some cool VR ideas (like a teacher navigating with the class inside a 3D human hearth to explain how it works from the inside), the mystery of the first riddles and really tons and tons and tons of geek references make it enjoyable, at least for a while. The story itself is not brilliant but when starting, when learning about this virtual world and what happened until 2044, that discovery phase is great, and afterwards it like loses energy; At least for me, it started to be more "convenient", with some big speedups at certain times (e.g. so that bad boys catch-up with good boys) and other times slowdowns to detail fragments that were not so interesting, some obscure scoreboard update rules (again to better fit certain plot events). Having a magical sci-fi world means there are no rules and everything (that comes from the author) is valid. And finally. the geek references get overabused but not always fit well, and yes, is fun to find some not so trivial ones like aliases from Big Trouble in Little China or anagrams from The Sneakers but... one gets tired when it becomes the main drive of the whole book.

It is not that I didn't enjoyed the book, because I did, but I was hoping for a more complex plot in a more restrained "ruleset". It made me want to watch again some movies and play some videogames, though :)


Free password management solution: KeePass

For many years I've been using a commercial password management solution, and despite being happy with it, I've had some issues: pay for each platform (now free in read-only model, but wasn't always this way), major version changes rendering some old platforms obsolete, lack of Linux support... So after some hesitation and research I migrated to a free, Linux-compatible and as a bonus opensource, alternative: KeePass.

This are the tools around this solution that I use:

  • KeePassX: Cross-patform binaries (for Linux)
  • KeePass: Binaries for Windows
  • KeePassDroid: Android implementation without shady in-app purchases, etc.
  • MiniKeePass: iOS implementation, again recommended one without untrusted sources, in-app purchases, etc.

And a few tips:

  • The UI is functional but ugly, don't expect anything fancy. That said, it is fast to add new data, search works fine and you can customize a lot
  • For Android I just copy & paste the database file into the phone, for iOS is not that easy, but opening from Box/Dropbox & "send to MiniKeePass" does the job without needing iTunes
  • I haven't tried online synchronization as I prefer the DB file not to be moving around too much, but there are plugins and options to do it
  • There are some plugins for KeePass but I had really bad results trying to migrate existing data with them, so I transformed the problem into an opportunity to do a huge cleanup of old & unused credentials. But be wary of migration plugins as some only work with certain versions or might not even work

Page 1 / 95