For the greater good

Photo by Bianca Ackermann on Unsplash

When was the last time you’ve used Git? Or Python? Or VSCode, PostgreSQL, WordPress, Linux, or any of your fancy JavaScript libraries? They’re literally a definition of cool. They’re all free. They’re Open Source — loved and supported by many.

It’s perfectly okay if you don’t contribute. You may have work to do, and that’s perfectly sound. It’s a privilege to help others, not a necessity. If you feel that something is missing, that there’s something you can do, there are a plethora of options to be beneficial. You don’t have to offer code, which might be the hardest route…

A story with no happy ending.

Photo by Jordan Whitfield on Unsplash

Working 10–12 hours straight, every day, for months. Commercial work at the business days, side hustles on the weekends. Working on things that are redundant; that don’t imply any positive change. Frustration. Tears. Conceptual work in the meantime; in your mind. Constant agitation. Anger outbursts. Losing all hope. Depression. Burnout.

I don’t reach much people on Medium. I’m still new to this. Whoever reads this, I want you to know that I’m with you. That I know — and care. That you’re not alone. I’d wish I could give you hope that something can…

Deducing from 1000 stories published in programming topic, it’s six and a half minute

Photo by Crissy Jarvis on Unsplash

This is not the most important piece of information, though. The stories I’ve crawled were mostly 4 minutes long. I’ve discovered that some people tell you to engage your reader for 5–7 minutes for the best chances to get curated (or other — most probably — artificial number). In the programming topic, it’s more like 4–6 minutes.

I’d like to analyze the stats a bit. I have little to no experience in data analysis, so please excuse me if I do something wrong. I’d just like…

Alternatively, do whatever works for you. It’s no dogma.

It feels great when programming is fun for you. Photo by Scott Webb on Unsplash

Recently, Michael Macaulay has started an important discussion on whether video or written programming tutorials are better:

It’s an essential read because it makes you focus more on your ethics; the way you do things, resolve problems. It’s a thought-provoking article and the more I wanted to keep my reply brief, the more I knew that I want to make it a full-blown post.

Straight off the bat — I disagree with you, Michael. Video vs. written tutorials is a tomayto, tomahto thing for me.

Why Read?

I mostly read because it makes…

Or: how to achieve simple goal with exaggerated amount of code — Part 3

Photo by Marko Blažević on Unsplash

The last part of the tutorial. You will learn how to:

  • Detect input.
  • Get triggers and thumbs raw and normalized values.
  • Handle vibrations.

While the previous parts could be mundane at the moments, this one is almost entirely code. Let’s see what we’ve got.

Handle Buttons

To check if a button has been pressed, you have to reference the controller state. Just one method here:

def is_button_press(self, button):
if button not in self.BUTTONS:
raise Exception('Invalid button. Got: "{}"'.format(button))
return bool(self.BUTTONS[button] & self.gamepad.wButtons)
  • Raise an exception if a received…

Or: how to achieve simple goal with exaggerated amount of code — Part 2

Photo by Kamil S on Unsplash

In the previous part of the tutorial, you’ve made Python to detect gamepad input. So far, so good. In this one, you will:

  • Write a stub of a wrapper class.
  • Add a configuration file.

Let’s start, shall we?

The Wrapper

Start with creating an XInput class of your own. We need a way to tell the script which gamepad is connected and what settings to use:

  • Pass configuration (a path to an ini file; more on it in a while) file and gamepad number to initialize method…

Or: how to achieve simple goal with exaggerated amount of code — Part 1

Photo by Kamil S on Unsplash

I’ve once thought: input — output. Pressing a gamepad button— action in Python. Controller mapping in a nutshell. Conceptually — yes. It is this simple. But, because you use XInput API to interact with the controller, things get complicated. Not surprisingly. You use a system DLL, presumably via ctypes library, which means different data types than Python native ones. Sure, Microsoft API provides some convenient functions, and you will use two of them in this tutorial, but you use C pointers to interact with them. …

And shed a tear or two in the process — Part 3

Photo by Markus Spiske on Unsplash

In the previous parts of the tutorial, you configured the application and wrote some services. Now it’s time to use them.

You are going to define two endpoints:

  • /api/auth/register
  • /api/auth/verify

I cover some obligatory features, like validating the token. I won’t cover resending a confirmation. Ideally it would be available only for authenticated users, which is out of scope of this tutorial.


In the first part of the tutorial you’ve created an users table. You can use it right now, but there is no convenient way to use…

And shed a tear or two in the process — Part 2

Photo by Rob King on Unsplash

In the previous part of the tutorial, you’ve set the Uvicorn server up. You won’t be putting it into good use just yet, but you shall write some code nonetheless. In this part you will add two services:

  • auth — for generating a registration token
  • mailer — for sending a registration confirmation email

Let’s start.

Authentication Service

Open /app/services/ and start with this stub of a method (and a class, too):

class Auth:
def create_token(data: dict, expires_delta: int):

The method should work this way: you provide data to…

And shed a tear or two in the process — Part 1

Photo by iMattSmart on Unsplash

FastAPI gains some momentum as of lately. On GitHub, it has approximately half the stars that Django or Flask have. But it’s not quite as popular when you take Google search results into account:

Bartosz Konikiewicz

This is not the greatest bio in the world. This is just a tribute.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store