Image for post
Image for post

Single Responsibility Principle (or SRP) is one of the most important concepts in software development. The main idea of this concept is: all pieces of software must have only a single responsibility.

Why SRP is important? It is the main idea that stands behind software development. Decompose complex tasks to the set of simple building blocks to compose complex software from them back again. Just like we can compose lego or builtin functions:

print(int(input('Input number: ')))

This article will guide you through a complex process of writing simple code. I personally consider this article rather complicated and hard to percept if you do not have a solid background in python, so it is split into several…

Image for post
Image for post

Repo link: https://github.com/wemake-services/docker-image-size-limit

My story

It was an early morning. I was drinking my first cup of tea and reviewing a pull request from another developer.

It looked pretty well. Just some new python dependencies to generate beautiful reports. And a bunch of new alpine libraries to make sure everything will work.

So, I have merged it without any hesitations.

Several hours later I have found out that our image size increased from ~200 MiB to ~1.5 GiB in size. This is unacceptable!

So, I have written this script to restrict the maximum image size in the future:

LIMIT=1024 
IMAGE='your-image-name:latest'
SIZE="$(docker image inspect "$IMAGE" --format='{{.Size}}')"
test "$SIZE" -gt "$LIMIT" && echo 'Limit exceeded'…

Image for post
Image for post

Agile people are obsessed with writing user stories. And it is a powerful instrument indeed. But, from my practice a lot of people are doing it wrong.

Let’s see an example:

As a user 
I want to receive issue webhooks from Gitlab
So that I can list all current tasks

Seems like a valid user story, doesn’t it? In fact, this tiny story contains multiple issues. And if you cannot find at least 8 mistakes in it — this article will be worth reading for you.

This article is split into three main parts:

  1. Getting better with the default user story…

Image for post
Image for post

What is a slug?

The term “slug” comes from the world of newspaper production. If you have ever created a simple “Blog” application you have already reinvented it.

When you need to access any post at some URL you need to identify it somehow. The simplest idea is to identify them by id, but that does not seem too pretty. It would be better to identify your posts based on its title or content. So, a blog post with a title “Creating slugs for Ecto models” would be accessible via a nice-looking URL: myapp.com/posts/creating-slugs-for-ecto-models. Where creating-slugs-for-ecto-models is a slug. Pretty cool, isn’t it?

So, a slug is a good-looking web-safe unique string used to identify some data. …

Image for post
Image for post

Some time ago I was faced with a task of testing a bash script. At first I decided to use Python unit-tests, however, I was reluctant to bring external technologies to the project. Therefore I had to go with the testing framework written in the notorious bash.

Overview of the existing solutions

After googling available solutions, I was presented with very scarce options. We are going have a closer look at some of them.

Which criteria are going to be important?

  1. Dependencies: when taking a bash testing framework you wouldn’t want it to drag python, lua, and a few more systems packages along with it
  2. Installation difficulties: since one of the tasks was implementing continuous-development and continuous-integration in Travis, it was important to me that the installation took a reasonable amount of time and number of steps. …

Image for post
Image for post

When npm@5 was just released this question was the first one I have googled. No doubts it comes to mind since new npm version introduced a lot of yarn’s features. In other words: should I still use yarn after installing npm@5?

Yarn features

Why do people use yarn in the first place? npm had some known issues. Well, we all have been there: downloading and installing packages for hours, resolution hell, not using essential --save and --save-dev by default, and many others.

When yarn was first released it solved many of these issues completely. It offered multiple improvements:

  1. yarn add saves a package not only to node_modules but also adds it to the list of dependencies in package.json. Think of it like yarn does not install a package into node_modules directory, it adds a package to your…

Image for post
Image for post

Phoenix Framework always has been awesome. But it was never as awesome as the new 1.3 release (which is rc1 right now actually).

There are a lot of significant changes. Chris McCord made a great job writing a complete migrating guide. Inspired by it and by the talk Chris gave at the LonestarElixir this article will try to guide through the most important changes in the phoenix project.

Let’s get started!

Problems to solve

phoenix is new. And naturally it has some issues. The core team has worked really hard to solve some of the most curial ones in the newest release. …

Псс, парень, не хочешь немного brew?

Вступление к серии

Передо мной недавно встала задача, как распространять одну консольную утилиту? Обычные мои инструменты вроде pip, npm и gem не подходили в силу языка самой утилиты — bash. Тогда стало понятно, что нужно распространять свое приложение в том числе и через системные пакетные менеджеры. Для Mac — в силу отсутствия встроенного — таких пакетных менеджеров несколько. И у каждого из них есть свои особенности и недостатки. И в первой части я хочу более подробно остановиться на Homebrew, и как создавать пакеты для него.

Ну а чтобы установить приложения на Linux, то нужно будет собирать пакеты таких форматов: .tar.gz, .deb и .rpm. …

Image for post
Image for post
Organize Django settings into multiple files and directories. Easily override and modify settings. Use wildcards and optional settings files.

Managing Django’s settings might be tricky. There are severals issues which are encountered by any Django developer along the way.

First one is caused by the default project structure. Django clearly offers us a single settings.py file. It seams reasonable at the first glance. And it is actually easy to use just after the start. But when it comes to the real-world it only causes misunderstanding and frustration .

At some point, you will need to put some kind of personal settings in the main file: certificate paths, your username or password, database connection, etc. But putting your user-specific values inside the common settings is a bad practice. Other developers would have other settings, and it would just not work for all of you. The most known hack for this situation is local_settings.py. This file is placed near the regular settings file and ignored from version control. There are also these lines which are usually put somewhere in the end of settings.py

About

Nikita Sobolev

wemake.services co-founder, ElixirLangMoscow co-organizer, open source developer

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