Description of high-level API module at AlexBerUtils project

ymlparsers and parser modules serves as Low-Level API for this module. Here is the story about ymlparsers and here is is the story about parser.

The source code you can found here. It is available as part of my AlexBerUtils s project.

You can install AlexBerUtils from PyPi:

python3 -m pip install -U alex-ber-utils

You should also install some optional dependencies, such as jinja2. The easiest way is to run:

python3 -m pip install alex-ber-utils[yml]

Note also that hiyapyco should be at least 0.4.16.

See here for more details explanation on how to install.

Code example

Put the following files to…


This is first part of mini-series of Explaining invokedynamic. This is the full list of all articles:

Introduction. Part I

Toy example. Part II

Bootstrap method . Part III

Number multiplication (almost) complete example. Part IV

Dynamical hashCode implementation. Part V

Java 9 String concatenation. Part VI

Lambda. Part VII

Records. Part VII

Final notes. Part IX

Introduction

Since Java 7 new bytecode instruction invokedynamic (or indy) was added.

It was added in JSR 292 in about 2011. It was originally designed for supporting Dynamically Typed Languages, as JSR name stated. So, it was ignored by waste majority of Java developers.


Introduction

It is not strickly required to read, theoretical part. The main result of it is provided here.

The last example illustrate how to implement mixin in Python.

Theoretically, not for any inheritance graph C³ Linearization Algorithm can be linearized. In practice, it is rarely happen, and if it did, Python will emit en Error. Another name of this algorithm is MRO — Method Resolution Order.

That’s right, the Diamond problem can be solved (practically). We can use inheritance where both object has the state, and this will not cause any problem. …


and other routine

What is generator in Python? Let’s look on what Wikipedia has to say:

Note: I’ve simplified code a bit.

Generators were added to Python in version 2.2 in 2001.[6] An example generator:

In Python, a generator can be thought of as an iterator that contains a frozen stack frame. Whenever next() is called on the iterator, Python resumes the frozen frame, which executes normally until the next yield statement is reached. The generator's frame is then frozen again, and the yielded value is returned to the caller.

https://en.wikipedia.org/wiki/Generator_(computer_programming)#Python

So, does generator is simply iterator? But what…


This story is dedicated of describing how Docker container can be configure to use Python package keyring. It is non-trivial task. But first of all, we need to go over some basic .

GNOME Keyring is service designed to store security credentials such as passwords, keys, certificates and so on together with a small amount of relevant metadata and make them available to applications. The sensitive data is encrypted and stored in a keyring file. GNOME Keyring — is persistent storage with keeping data on a hard disk. …


In the previous story I’ve described how to install RabbitMQ on Windows.

Here I will describe how you can get the RabbitMQ with management UI.

The easiest way is to use docker image rabbitmq:3.8.9-management-alpine (I prefer distribution based on Alpine Linux). The source code for Alpine Linux can be found here https://github.com/docker-library/rabbitmq/blob/888638927482f86af6e88bebb67423926cb1112f/3.8/alpine/management/Dockerfile

It doesn’t have ability to move messages from one Queue to another (plugins rabbitmq_shovel and rabbitmq_shovel_management are not installed). The code below fixes this:

I have change only line 4:

RUN rabbitmq-plugins enable --offline rabbitmq_management rabbitmq_shovel rabbitmq_shovel_management

I have added rabbitmq_shovel rabbitmq_shovel_management.

Let’s suppose you’ve built this…


This is step by step simplified tutorial on how to install RabbitMQ on Windows machine.

For using RabbitMQ inside docker container see here.

Note: There is assumption that you’re using Erlang only for RabbitMQ and for nothing else.

  • If you have old RabbitMQ installed, first of all export it’s setting from the management UI:
Image for post
Image for post

After you login scroll down and click on “Download Broker definition” and download file.

After you will finish installation of new version of RabbitMQ click on “Upload Broker definitions” and upload the file.


Here I have discussed troubles on working on relative path in Python.

This story is dedicate to absolute path, it describes how to make absolute Windows path (with C:\ part) work on Linux.

The source code you can found here. It is available as part of my AlexBerUtils s project.

You can install AlexBerUtils from PyPi:

python3 -m pip install -U alex-ber-utils

See here for more details explanation on how to install.

This is usage example:

Now, I recommend you to put this code snippet after you did your basic logging configuration.

You code should look like something like…


How Exception are used

Introduction

One of the first thing you learn about exception in Java, that there 2 type of them — checked exception and unchecked exception.

Any “exception” is eventually inherits from java.lang.Throwable. It has 2 direct decedents — java.lang.Error and java.lang.Exception. java.lang.RuntimeExceptionis direct decedents of java.lang.Exception.

Unchecked exception are exceptions that inherits from (possible not immediately) java.lang.RuntimeException or java.lang.Error.

Checked exception are exceptions that inherits from (possible not immediately) java.lang.Throwable and not fromjava.lang.RuntimeException and not fromjava.lang.Error. Informally, these are exception that inherits from java.lang.Exception, but not from java.lang.RuntimeException).

Checked exception are not in use in newly designed API…


I’m recommending to look on MIT lectures “Programming with Categories”, with Brendan Fong, Bartosz Milewski and David Spivak.

Image for post
Image for post

https://www.youtube.com/playlist?list=PLhgq-BqyZ7i7MTGhUROZy3BOICnVixETS

Motivation

Quote of Bartosz Milewsk (emphasizes are mine):

Category theory is a treasure trove of extremely useful programming ideas. Haskell programmers have been tapping this resource for a long time, and the ideas are slowly percolating into other languages, but this process is too slow. We need to speed it up…

Composition is at the very root of category theory — it’s part of the definition of the category itself. And I will argue strongly that composition is the essence of…

alex_ber

Senior Software Engineer at Pursway

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