Stavros' Stuff

On programming and other things.

On increasing productivity

You too can be more productive with this ONE WEIRD TRICK

Sometimes, when I show people another crazy side-project of mine, they ask me how I manage to be so productive. I never have a good answer to give them, because I don’t really consider myself very productive (unless you count my 2,000 hours of sucking at DotA2 as creative output), but they are invariably unsatisfied with that answer.

I saw another post about productivity on Hacker News today, and it made me finally express something I’ve been feeling for a while but had never managed (or taken the time to) put into words. It wasn’t so much the post itself (I didn’t read it), but the fact that I saw it, and that it exists. It made me realize my stance on productivity, and today I’ll share it with you, right in this article.

Continue reading…

Startup Mistakes: Choice of Datastore

Spoiler: Don't use MongoDB.

A great advantage of having a large network of technical friends is that they ask you for advice on things, which I love giving. One great disadvantage of people is that they rarely take my advice without justification, even though I think everybody should know better by now. A discussion I frequently have with friends (and which they don’t just blindly take my advice on), is their choice of datastore, which invariably goes something like this:

- Trust me, don’t use MongoDB.
- Why, what’s wrong with it?
- Look, how many times have I given you some advice, you didn’t listen, and later on it turned out I was right?
- Ah, so you’re saying I should use Cassandra.

So, since I keep having to justify my opinion (can you believe that? Just ridiculous.), I figured I’d do it once, in this post, and then I can just point people here when they’re about to do something dumb. If I linked you to this article, this means you.

EDIT: Apparently the self-deprecating sarcasm above wasn’t really very obvious, and it comes off as arrogant, but my intention was for it to be satire (cleary opinions should be justified, even mine). Also, the Cassandra joke was a reference to this lady. Like an ancient Greek proverb says, “the best joke is one you have to explain on your blog”.

Datastores are important

The datastore is often the most important part of

Continue reading…

How to deploy Django on Dokku

It's a dream come true

Ever since I was a wide-eyed little boy, I would look up at the stars and wonder in wonder: “What if I could lease my very own, beefy, dedicated Hetzner server and have an easy way to deploy all my projects onto that?” But lo, my dreams were dashed because Docker wouldn’t be invented for another twenty years, and Hetzner did not accept Mastercard at the time.

Decades later, with Docker finally invented and Hetzner accepting all major credit cards, my dream lay all but forgotten, because Docker could not do zero-downtime deploys natively and I hated it. That was how things remained, until my friend Theodore told me that he tried Dokku and that it worked very well.

I had heard of Dokku (and Fig, Deis, Flynn, Kubernetes, etc etc), but I never paid too much attention, as these PaaSaaSes struck me as too webcale for my simple projects. All I wanted was a way to skip through all the boilerplate configuration of deploying a Django app, and Ansible wasn’t cutting it, as it was still too much plumbing.

Since Theodore tried it and said it was apparently pretty easy to deploy with, though, I figured I’d give it a shot and see. It helped that Dokku was explicitly designed to be light and self-contained, whereas Kubernetes is for much larger deployments, so Dokku fit my use case exactly.

Trying Dokku out

To try Dokku out, I needed a project. Luckily,

Continue reading…

The scourge of web analytics

I hate the web.

I’ve been making web apps since 2003, which means that I’ve been doing this for fourteen years now, or it means that I can’t count. So, there are few people more qualified than me to tell you this:

The web is crap.

If you disagree with the above statement, you spent more than $1000, less than two years ago, on the device you’re currently reading this on, so websites feel fast to you. There are many factors that make the web crap, but today I’d like to talk about one of them:

Web analytics.

A brief retrospective

The web was created in, like, the nineties, and was initially envisioned as

Continue reading…

Making a garage remote motorcycle mount

Spending twelve hours to make something that saves two

I recently got a motorcycle, and with it came a problem. My motorcycle jacket has very little pocket space, and I was told that I shouldn’t put any weight (i.e. extra keys) on the keyring. However, I still need to carry my house key and my bulky and heavy garage remote, which means that I need a second keyring just for these two, which is the problem.

Another issue is that using the remote is a hassle, as I have to always be removing my gloves, unzipping my jacket pocket, fishing for the remote in it, pressing the button, zipping the jacket pocket back up, and wearing the gloves again, it’s a nightmare, almost something out of a Lovecraft novel.

However, a thought occurs: Since I have a 3D printer and CAD software and I’m not afraid to use them, I can design an enclosure and mount for the remote so that I can permanently have it mounted on the handlebars, which both frees my pocket and is easily reachable, even with gloves. This thought is so exciting that I can hardly contain myself, and don’t.

In this post, I will take you through the process of designing and 3D printing the mount,

Continue reading…

Perfectly secure Bitcoin wallet generation

Generate your own Bitcoin wallet without a computer! Never mind

MORE RECENT EDIT: After the initial failure, I decided to do the next best thing, and write a short program for the ESP8266 that will generate a random seed every time it boots up and print it to a screen. That should be a good compromise, and it works well, scroll down to see it.

OLDER EDIT: I have been informed that BIP39 derives the last word from SHA hash of all the others, and thus needs a computer to generate the seeds. Thus, this post is moot and useless. I will leave the post here as a mahnmal, in the hope that someone will find something in it useful.

Being the geek that I am, I find Bitcoin fascinating (if only everybody focused on something other than the price!), and hardware wallets doubly so. If you haven’t heard of them, hardware wallets are small, flash-drive-sized devices that usually connect to a computer’s USB port and hold your wallet keys. That way, even if the computer you’re trying to send bitcoins from is riddled with viruses, you remain very secure and nobody but you can pay on your behalf. Unsurprisingly, I bought one! I was between the Trezor and the Ledger Nano S, but I decided on the Nano S in the end, as their platform looks more exciting, more secure and I was quite satisfied from the two HW1s I had bought for cheap at a sale.

However, since I’m in it for the technology and cryptoparanoia, rather than for any practical purpose, I find that hardware wallets have a few issues. For a short primer, a hardware wallet’s main advantage is that the keys are generated on the device and never, ever leave it, as whoever has the keys can spend your money. Since the keys never leave the device, though, you’re screwed if you ever lose it. To avoid that, wallet designers usually allow you to do a one-time export of the keys (many devices have a screen they show you the keys on), right after creating them. The export is usually a Bitcoin standard called BIP39, and is usually in the form of 12 or 24 everyday words, which you write down on a piece of paper, store it in your safe, and that’s all that’s needed to retrieve your keys if you lose the hardware wallet. No computer ever touches the keys, and you can sleep peacefully.

The problem

My problem, though, is that

Continue reading…

3D-printed breakthrough gives blind cat eyes

Meanwhile, cure for clickbait titles remains elusive

I have a cat! I’ve had her for a while. She kind of imposed herself on me when I saw her on the street one day when she was a one-month-old stray kitten (we have a lot of those here), and her eyes were closed, so I figured I’d take her home for a few minutes, wipe her eyes open and release her again, sight restored and able to fend for herself.

When I wiped the gunk away, it turned out she had no eyes! She had tricked me, and I couldn’t leave her on the street to die, so now I’m responsible for a damn cat. Apparently, cats can get chlamydia (did you know that? I didn’t), which can cause macular degeneration (did you know that means the eye literally melts? I didn’t), which she had.

She also had epilepsy, because of course no good deed goes unpunished. This is her:

Continue reading…

The Bus Stop Bus

The wheels on the bus get cut off to make room for a USB port.

A few years ago, I came across a post by John Graham-Cumming, in which he had used a router to run a bus arrival time display that basically showed the time that the next bus would be arriving at the bus stop closest to his house.

I thought that was a fantastic idea, and I especially liked the unorthodox choice of a router as a controller. The project stayed in the back of my mind, and it resurfaced recently, as I started dabbling in hardware. Since I’ve been looking for fun little projects to do, this one was quick and easy enough, so I started looking into it.

(By the way, this post uses Expounder, so if you want an explanation on words with a dashed underline, click on them)

Of course, if you’ve been reading my posts, you’ll know that my microcontroller of choice tends to be the ESP8266, and usually not a router. The ESP8266 is a microcontroller (basically a tiny computer with CPU, RAM, storage, the works) that includes a comfortable amount of memory and storage, is tiny, doesn’t need much power and has built-in wifi, which is extremely useful.</span> This was the obvious choice for this project as well, so I bought a small OLED screen from eBay and started

Continue reading…

Spamnesty: Waste spammers' time

Artificial Intelligence finally used for evil.

Have you ever received a spam email? If not, I would definitely recommend getting your own email address, the positives usually outweigh the negatives. For the rest of us, who have had an email address for more than two minutes, spam is a real problem. I’ve found myself wanting to reply to spam messages many times, just to see what would happen, and to waste spammers’ time a bit.

That’s why reading Brian Weinreich’s post Two years spamming spammers back resonated with me. The summary is that he built an app for his personal use which would reply to spammers and engage them in a dialog of canned responses, trying to string them along for as long as possible, leading to some pretty funny exchanges. That struck me as a brilliant idea, and I wanted to use it, but he had built it for his own use and it wasn’t well-suited for use by other people.

To that end, and because I had a free Saturday, I decided to rewrite the service and make it freely accessible to anyone, and so

Continue reading…

How to deploy Django with Docker

Finally, Django, with Docker, on production!

I finally managed to deploy Django in a Docker container on production! I’ve been trying to switch to a full Docker development/production model since Docker came out, but only recently did the ecosystem mature enough to allow me to easily use Docker both for development (where it excels, in my opinion) and on production (where it’s pretty okay and quite useful).

In this post, I will quickly give you all the relevant details and files you need to go from a newly checked-out repository to a full development environment in one command, and to deploy that service to production. As a bonus, I’ll show you how to use Gitlab (which is awesome) to build your containers and store them in the Gitlab registry.

Let’s begin!

Development

Continue reading…