photo

Artem Szubowicz

Software developer

Artem Szubowicz

Software developer

Mar 22, 2016 Mar 22, 2016

# Writing fast and beautiful code with C++ and D

Introduction

Currently I am writing my (second) master’s thesis. And it’s one of the hardest work I’ve been doing ever. It’s about image and video processing. And I’m using OpenCV.

Using OpenCV is an interesting decision: if you want to create a beautiful OO architecture for your program, you’d rather use something like Java. But I didn’t manage to run OpenCV in Java =P

So I decided to write my code in C++. Yeah, tough solution… And in some time I saw why it was not the best one: my architecture was too bold (435 LOC) and it didn’t even contained four method implementations!

Then I sit back and thought: “Couldn’t I use C++ for video/image reading only? And write the rest of the code in a more OOP-friendly language?”. And that’s when I started looking for a language with nice syntax and OOP features (like interfaces, short array syntax, tuples/maps, etc.) and found D.

I’ve been looking at D since loooong time ago, but actually never tried it for writing anything more complex than a “Hello, World!”. “That’s my star time!” - is what I thought.

My idea was:

  1. create small C++ library for video IO
  2. create D program, using that C++ library to read and process video

D offeres nice C++ interop, except it requires you to define classes/functions signatures you are importing from C++. That was not a big deal for me since I had no huge classes written yet.

Mar 5, 2016 Mar 5, 2016

# Chicken in Blender

This is a chicken. This 3D model I’ve made in 3.5 hrs in Blender (with texturing).

Taking into account the fact I’ve started learning Unity 3D, I will possibly use this in the remake of my old Shoot Them! game. Like this (early preview, made with Unity 3D in ~3 hrs):

Feb 11, 2016 Feb 11, 2016

# Two sides of web application. Part 3: Communication Layer

Foreword

In this section we will implement the communication layer for our application. It’ll handle all the requests to/from our web server. Have no worries - we will create server application in the next section!

First resource

Let’s create a Session resource. Since we have no backend part, we should stub the data. We’ll use Angular Services. That’s easy: a service defines a function, returning, say, an object. That object will be used every time you call a service. And you may use not only objects - you may return functions, constants or literally anything from your services.

Feb 11, 2016 Feb 11, 2016

# Two sides of web application. Part 2: sketching

General architecture

The first thing we need to think of is how we’ll be gathering the information about users. It’s quite easy - we just need to get a request from a visitor. Of any kind - it may be a request to get an image, a file, a stylesheet or a script.

Then we’ll just parse headers from that request and save the extracted data in the database. The only problem here is: how to get unique key from each request?. We may use visitor’s IP address. It’s the easiest way.

Dec 16, 2015 Dec 16, 2015

# Newton GD + Irrlicht tutorial

This post will be really short. This is just a reference to my tutorial, which I updated recently. It has been a long time since I wrote anything on game development, that’s why it deserves one more announcement.

So, meet the changes:

  • moved all the build instructions to CMake
  • added scripting with Lua
  • upgraded the whole tutorial to match latest Irrlicht and Newton versions
  • added chapter on modelling with Blender

And more to come!

Ride on!

Nov 26, 2015 Nov 26, 2015

# End-to-end testing with WebdriverIO

Small intro

Have you ever heard about end-to-end testing? Or maybe about testing automation? Those of you who had, may now be imaging Selenium. That’s right, in most of cases you will need to run Selenium Server and use Selenium Webdriver in your tests. Those come handy to run a standalone browser window, with no caches, filled-in fields or cookies and perform some operations in it.

In this article I will tell you my story of writing E2E tests for Angular webapp.

A brief of history

In my case, we first tried to use Protractor with Chai.js. That time we ended up with almost unsupportable bunch of code, succeeding in 100% of runs.

Next time we eliminated Chai and reworked all our tests to use Protractor only. This time tests worked and were more readable (I did not like the syntax, but it worked…), but after upgrading libraries (including Protractor), success ratio of running tests falled down to 40%.

We worked two days, trying to fix those tests. And that’s how webdriverio came to our project.

Oct 16, 2015 Oct 16, 2015

# Loooong lists with Clojure

Whaaaaat?

These days I was given a reeeeally interesting homework at the university. I was given a set of MD5 hashes, calculated from single words (taken from Libre Office’ dictionaries) with a given sault. And the task was to find all those words.

So, the first idea which came to my mind was using an internet service for MD5 breaking. But… aaarrrggghhh! There’s a sault, so the webservice, looking for words over a dictionary fails to find mines…

So the second idea was to take that dictionary from Libre Office and iterate through it. At the end, it worked =) And worked reeeally fast. But that is not an interesting part.

I wandered if I could find those words in my dictionary, generated by my own code.

Oct 5, 2015 Oct 5, 2015

# Custom logging with timbre

Timbre?

At my job we recently started researching logging tools to make our RESTful API, written in Clojure, writing logs in JSON format. We were using Log4j already, but decided to use another tool for this task, making it less painful. So we felt into timbre. Is seemed so easy to use, but it is really undocumented.

According to timbre’s API, we needed to define our own appender for writing to a custom JSON file. And we found the output-fn option to configure this behaviour. But it is not documented at all, so we started looking for repositories, using timbre, examples and all the stuff. And finally, we ended up with our own solution.

Underneath you will find description of our way to use timbre from scratch.

Sep 20, 2015 Sep 20, 2015

# Two sides of web application. Part 1: the tools

Prologue

How do we usually create a web application? We run a bootstrapping script, which provides us with a skeleton of our application and then we just extend it with the features we need.

That’s exactly what we did at the last hackathon we were attending - we started with rails new twf and spent half of the day integrating our blank app with Angular, Paperclip, creating API methods and so on. But the effort we needed to accomplish our goal (quite a simple web app) was really huge.

So I decided to find the best combination of backend and frontend technologies that would cause less pain.

At the project I was recently introduced to, the line between frontend and backend is distinguished very clearly: we have an API, written in Clojure and thin frontend application, made with Angular that works on a generated set of static assets - HTMLs, CSS and JS files (but under the hood we are using HAML and SCSS).

The application I will be implementing throughout the whole article has the same architecture: it has RESTful API and MVVM on the frontend, made with Angular. I welcome you to the journey of research and new technologies!

Sep 16, 2015 Sep 16, 2015

# Email validation regexp

At my work we’ve lately been having a discussions on email validation. I recalled a post on habrahabr, showing different options, including effective and psycho solutions.