Generating images with VQGAN-CLIP

Today, I’ve been toying around with VQGAN-CLIP, one of those GPU-heavy graphics generation libraries. Special thing about this particular library is that it can generate images from textual prompts. For instance “a horse running on steppe” here. This is so fun (even considering how hard it was to get up and running). I’ll post here a couple of my favourites

Learning on the Job as a Team

What is the most fun bit of your current job? Mine by far is the way my current team is building up our shared knowledge pool.

In this project, we have run weekly one hour sessions to share knowledge inside the team. The topics have ranged from domain-specific issues to how to write acceptance tests with the Robot framework. As the team scrum master, I’ve mostly being MC for this session.

As a team, we have experimented with the format. The only fixed thing about the session is that it lasts 60 minutes or less. We’ve tried brainstorming/-sharing with a Miro board (worked surprisingly well), presentation format (worked ok to decent) and even mob programming using CodeCollab - An online real-time collaborative code editor and compiler for the web.. If something works, we will try it again. If it doesn’t, we’ll drop the format or at least adjust it somehow before trying it again.

While the sessions are mostly fun and demonstrably useful, the area that needs to develop is interactivity. Microsoft Teams meeting being the norm for interactions now, it is sometimes hard to get every one of us engaged in full. This is why I picked up two books by Sharon L. Bowman The Ten Minute Trainer and Training from the Back of the Room to add tools to our teams’ toolbox of learning. Let’s see how the format of the session will evolve as result.

Books: Ten minute trainer and Teaching from the Back of the Room on top of each other

This voxel drawing CodePen has making circles and it still stuns me every time I encounter it VoCSSels - Easily create 3D CSS & HTML Voxel Models. Howhowhow do you even come up with the idea, let alone flawless execution?

I like Viewbox newsletter and especially the latest installment about generative SVG. Box #8 - George, Blobs and Googly eyes. • Buttondown. Definitely going to go through the tutorial mentioned: Generative blob characters using SVG! - DEV Community

I think I might need to publish my very simple Chrome browser plugin to create markdown link for a current page just to make it easier to get it on new computers through sync

WDIBI VI: Aggressively Automate your Workflow

Last time I touched upon the subject I wrote about downright avoiding additional code - because everything has a cost. There, however, is one genuine exception: one should aggressively automate the deployment pipeline from the very first moment regardless of the type of the project. Even if it is just a throwaway script, put in mechanisms that automate environment setup and possible installation and configuration. A year later, when something breaks and it needs to be tweaked you have your automation to lean on to as a form of documentation (careful commenting is also recommended).

I’ll show a specific example I’ve used in a project where a cross-compilation environment on a server is used to build up a device image and then I flash the device image locally on my dev computer:


.phony: clean

all: backup clean makeatserver cpfromserver cptodevice

makeatserver:
	ssh -t server 'cd /path/at/server/repository && git submodule update && git pull --rebase && make'

cpfromserver:
	scp server:/path/at/server/build/bin/*.bin /localpath/devicebins && scp server:/path/at/server/build/*.dnl /localpath/devicebins && scp server:/path/at/server/build/*.bin /localpath/devicebins

cptodevice:
	customcommand flash device

clean:
	rm -rf *.bin *.dmp *.hex *.list *.map *.elf *.dnl

backup:
	mkdir -p previous && [ -f flashimage ] && cp *.bin previous/ || echo "no files to backup"

This is part VI of my series of What do you Believe in as a SW Developer? // Timo Koola

Read: Every Layout by Heydon Pickering & Andy Bell

Read a very nice book about foundations of CSS lay outing (think box model and centering, not styling) Relearn CSS layout: Every Layout. Also the accompanying website is well worth the prize (both included in the bundle price). Helps one grasp on how to think about building a web site from principals and basic building blocks. Recommend it strongly to anyone who struggles to understand CSS like me

WDIBI IV: Be Conservative - Except Sometimes

Today, in “What do I believe in as a developer” I will shortly lay ground for next few days with two conflicting forces or principles that pull apart developers.

Firstly, never fix something that isn’t broken. Usually going with something you know and trust is much better than trying to outpace everyone else with the technology du jour.

Except, sometimes you need to be early for several reasons. Some tech is just so much better than what came before that the world will quickly follow. For instance, hosting your own web server on premises definitely never was broken, it is very much a known known but one literally can make orders of magnitude saving in time and money using modern tech.

Following few days I will go through technologies, methods, and techniques that I think are affected by these two conflicting forces and will try to explain why I make selections the way I do.

This is part IV of my series of What do you Believe in as a SW Developer? // Timo Koola

My Python setup

This post is mostly used to document my current Python setup before I get my next Mac where I am going to venture into new setup using pipenv. So far I have had a setup strategy using virtualenvs and virtualenvs only but I have had tests with pipenv and it seems to solve some of the issues I’ve had with my setup.

For background, Python has deservedly a bad reputation about dependencies management. Sooner or later you will get things tangled up and in tears. R people mock us for many reasons but there is no excuses here: Python external modules management is a mess and none of the solutions are very good. This means every Pythonista finds their own set up that kind of does what is needed but still is lacking. Following is my set up that I’ve ended up with, not because it is perfect but because it is where I am at now.

Principles

My setup is built on following principles or guidelines:

  • Dont mess up with system Python. When you type in python you will get trusty old Python 2.7 only invited to system management tasks and nothing else
  • Don’t install anything outside virtualenvironments. No Anaconda. No Homebrew Python. No binaries. No modules installed to system Python. Just say no
  • Virtualenv and pip are only things that install anything (exception: you may of course run setup.py but even that only inside a virtualenv)

These principles make it easier to go back to a working set up when something goes awry. And something will.

Following these principles it means that in the beginning you will have just system Python, pip Installation — pip 20.2.4 documentation and virtualenv Installation — virtualenv 20.1.1.dev5+g9708b54 documentation

Setting up a Project

When starting a project I will following steps:

  1. Create new virtualenv. Install it with a new Python (nowadays 3.8 or 3.9)
  2. Activate virtualenv
  3. Install dependencies
  4. Freeze (pip freeze > requirements.txt)
  5. Create an alias or project local script/Makefile target that activates the virtualenv the next time you come back
  6. Start writing the code

Additionally, when project is larger I create two virtualenvs: projectname and projectname-dev. The latter will have more stuff for development and testing (for instance coverage and pytest). For quick, local projects all dependencies are in one project.

Prototyping

Additionally, for prototyping I have created a virtualenv called “basics” and a system wide alias that activates it and moves to a directory called “notebooks” and then runs “jupyter notebook” in that directory. This virtualenv has needed tools to quickly try out things in a jupyter notebook from requests to sklearn and numpy.

Git vs. Mercurial

Discussed about how Git won (especially against Mercurial I was a huge fan of) with a friend (don’t remember the last time I met someone IRL) and ended up on reading A Git Origin Story | Linux Journal and a Git vs. Mercurial comparison Mercurial vs. Git | Is Mercurial Better? | Perforce. Didn’t remember Mercurial was that different, somehow only remembered it was “like Git but nicer to use”

WDIBI III: Embrace the Platform

Jumping around in my list of SW related foundational beliefs I picked up today: Embrace the Platform

As I said yesterday in my WDIBI II: Choose Speed // Timo Koola post, I firmly believe in speed over developer experience. One other area where I think developer should prioritise user experience over developer experience is when selecting tools to address users in different platforms. I firmly believe that developer that actually thinks users first (as everyone claims to do) never picks a cross-platform framework to develop their application.

I consider there to be three major platforms:

  • Web (both websites and web applications)
  • iOS
  • Android

I think if you are going support users on one or more of these platforms one should do a native solution for each. For web, if possible, stick to easy and simple yet immensely powerful tools that plain old HTML and CSS give you. I could go on and on about web but expletive deleted Website explains it very thoroughly. Sometimes one needs to do something more complicated and resorting to something like React is perfectly fine. I just think one needs to be very careful about performance and accessibility.

As for Android and iOS, if you are serious about your users go with native solutions for respective platform - build with native idioms and frameworks and you’ll save a lot of cross-platform headaches that are not going to give anything to your users anyway.

Specifically I don’t recommend (if asked) using React Native, building up a PWA (I might write about their specific problems some day), or Flutter. Stick to platform tools, your user likes their iPhone way more than they do care about your brand (unless you happen to be WeChat) Apple’s China Problem – Stratechery by Ben Thompson

How about legacy platforms like Mac or Windows? I’d say it depends - are you really going to address the people on this platform? Go native. Do you just want to cover as much area as possible? Consider using web to address these platforms.

Just one quick parting note - this of course applies only to software directly accessing consumer needs. Calculation for Enterprise software might be different and for some enterprise internal tooling very, very different. I’d still say even within “enterprise” go native, if your use case depends on user experience. In other areas: do the best thing for the team.

This is part I of my series of What do you Believe in as a SW Developer? // Timo Koola

SW Developer: What do I believe in

I have had a What do you Believe in as a SW Developer? // Timo Koola blog post brewing in me for months. I have Foam // Timo Koola notes of it ready, parts of it thought out but it seems too menacing task to write at once. So, I need a change of plan. I will write items on my foam notes one by one this month (no NaNoWriMo for me this year either)

What do you Believe in as a SW Developer?

Lately I’ve pondered the following question: what are the things that I believe in as a software developer? I mean notions, ideas, concepts, or even principles that you lean on when making decisions and trade-offs. This time I am concentrating on professional beliefs even if I think moral and political beliefs are important also in a professional context.

I think these kind of principles must be such that one can have reasonable arguments about perhaps with solid data. For instance I don’t count “I believe in quality software”. Nobody would be on the other side of that argument and it boils down to have no meaning. A good principle would be something like: “I think monoliths are better than micro-services”. One can sit on either side of that argument and good software is written on both sides of that divide and yet most people have an opinion about which one to choose if the choice is available.

Ideas that one believes in don’t need to be big, abstract thoughts. One can have an opinion on tabs vs. spaces or perhaps that one should always, always use semicolons in Javascript. You can write successful software whatever your opinion is on those matters but usually you do have an opinion.

I think I have an initial list in mind but it needs some fine-tuning as the abstraction level on my list varies from quite small to pretty abstract. What is on your list of software design principles?

Smart-TV Features Scored for a Busy Product Manager

For second time in about a year I am buying a TV. This time I am looking to add a smallish TV to my home office (hurrah for social isolation and yay for more screen time) and like last time I am worried that smart TV vendor, and by some I mean all, are not quite aware of the things we middle of the road consumers want in a smart-TV.

Nowadays it is pretty hard to buy TV without smarts. In optimal world I would be able to buy a TV with 8 HDMI connections and a decent speakers with very fast but limited SW. Sadly, I have a feeling we are not living in the best of the possible timelines.

Secondly, I wish all Smart TV vendors understood these:

  • Don’t try too hard: even the smartest smart TV is the dumbest smart device in my house
  • All features you put in need to last as long as the panel. Taking away Netflix app away from us because Netflix doesn’t want to support your 2014 app platform is even worse than not having the app in the first place
  • Fast is better than slow 100% time (lack of speed is an universal problem with SW in 2020 but we can visit this some other day)
  • You are neither Apple nor Google. Stick to your strengths. Writing app platforms is not one of them

Now with these principles in mind, let us score the most important features for you my dear smart TV product manager:

  • Every HDMI port +1000 points
  • Built-in Chromecast support +500 points
  • Built-in Airplay support +500 points
  • Any other *cast support +100 points
  • App platform +1 points
  • App platform that is not supported through the expected lifetime of the TV panel: -100 points
  • Every other feature that make the basic TV operations slower: -10 points per feature
  • Every second spend on SW updates instead of using the TV: -10 points per second
  • Every ad I see in the User Interface: -100 points
  • Every confirmation dialog: -100 points. TV has very few destructive operations it should have even fewer confirmation dialogs
  • Every password dialog, no points, making people type in passwords with a TV remote is a sackable offence
  • Remote I can use in a dark room: + 100 points

Thank you for listening, I will be waiting for that 8 HDMI port TV with a decent panel and acceptable speakers in your 2021 product lineup.

Reading: Teaching ReactiveX (and a lot of other things) Like Skiing

A very good read on why ReactiveX (or Combine) is made unnecessary hard to learn. Teaching ReactiveX (and a lot of other things) Like Skiing. I am not quite sure reactive programming is the best answer to all or perhaps even most problems, but I think I need to study my own understanding before I can say anything more definitive about.

Code(less) kata 3

Today I am working on (non-coding) Code Kata 3 Kata03: How Big? How Fast? - CodeKata. And I finished the first part: “How Big”

roughly how many binary digits (bit) are required for the unsigned representation of:

1,000 - this is easy to do in head (or perhaps more accurately fingers) 11 bits as 2^11 is 1024 1,000,000 - again easy, shift again 11 bits, so roughly 22 bits 1,000,000,000 - hmm, is not quite aliging to power of 2 mess up my calculations? 33 1,000,000,000,000 - with the same caveat, 44 8,000,000,000,000 - multiple by 8 is shifting by 3, so 47

Quick checkup with a Swift playground:

var num = 8000000000000

var presentation = String(num, radix: 2)

presentation.count

And the result is 43. Hmm, my intuition was a bit off. Turns out I was off by one! 2^10 = 1024, not 2 ^ 11, bummer.

My town has approximately 20,000 residences. How much space is required to store the names, addresses, and a phone number for all of these (if we store them as characters)?

Let’s assign 50 characters for a name, 15 for phone number, let’s present address as two address lines, a zip code, city, state and country = 50 + 50 + 10 (zip code) + 20 (city) + state (50) + country (20) = at max 200 characters but let’s assume conservative 100 chars, so 165 chars * 20000 = with some calculator help is 3 Megabytes

I’m storing 1,000,000 integers in a binary tree. Roughly how many nodes and levels can I expect the tree to have? Roughly how much space will it occupy on a 32-bit architecture?

Worst case is a tree where tree only ever goes left or right, then the depth is 1,000,000. Best case is fully packed tree, where all levels are full and balanced. That is 19 full levels and a lot of nodes on level 20. So best case depth is 20.

Tree node is three items, one number and two pointers. With million nodes that is roughly 3 * 4 bytes * 1M, so roughly 12 MB.

Something cool I stumbled into today in Twitter: LegraJS a simple Javascript library for making Lego graphics. Created a quick code pen demo for Legra. Thinking of what to do with this for real. Maze generator?

Sunday coding

Some Sunday coding: created a Chrome browser plugin that copies a title of the current page and its url as a markdown URL. Just for myself for now, but source is available if someone wants to try it: timokoola/markdownsaver: Chrome browser plugin to create markdown link for a current page

Quick updates:

Python 3.8 is now supported run time in AWS Lambda AWS Lambda now supports Python 3.8

Facebook changes from Atom to Visual Studio Code (and shares some of their tools with public): Facebook and Microsoft Partnering on Remote Development

Tool in the style of Can I use for checking how your colour combinations work for different kind of colour blindness and other sight issues people have who can use

Cool in London

One of the coolest and most useful uses of modern tech is that Transport for London supports Apple and Google Pay (also chipped debit and credit cards). Touch in and touch out and systems consolidates single events to a daily ticket if value of single rides would exceed the price of daily ticket. Simple, efficient, usable, and a kind of magic.

Finland, Finland, Finland

Great night in Finland yesterday as Finland’s men qualify for a major tournament first time forever, big party as expected as summarized this photo article by Finnish broadcasting company. Part of Finnish celebration culture is to swim in the fountain regardless of weather (or whether there is any water in the fountain. Yesterday was rather decent +4 centigrade, so swimmers had it easy :)

Reading: The new dot com bubble is here: it’s called online advertising

I am late to the party but very impressed with The new dot com bubble is here: it’s called online advertising

Stand out quote: > This insight is conspicuously absent from the debate about online privacy. At the moment, we don’t even know whether all this privacy violation works as advertised.

One of the things Apple really nails and doesn’t get noticed perhaps as much as it should is how it is killing it in the chip design

Twitter thread by David Heinemeier Hansson

Another note to myself: I need to collect printf-formatting cheat sheet or rather Unix command line tools cheat sheet for common use cases for myself. Even a great reference is usually overkill and hard to scan by