Posts

  • Configuring Git to automatically select personal or job configurations

    Making per-repository git configurations for personal and job repositories is a bit annoying so here is a simple approach for automatically applying different Git configurations to different repositories.

  • Automated multi-platform releases with GitHub Actions

    GitHub Actions allows you to create releases, build binaries, and upload them. Unfortunately, there is no official tutorial on how to create a release, build the code for multiple platforms, and upload binaries to the release. I will cover how to do that without any 3rd-party actions in this post. I assume that you are familiar with the basics of GitHub Actions.

  • How to force Rust compiler to use several x86 instructions (popcount, etc)

    Sometimes you need tricky operations on your binary data like counting bits, leading or trailing zeros and so on (for example, when you want to implement HAMT or sparse arrays). In Rust this is achieved by using methods like .count_ones() and .trailing_zeros(). The problem with those methods is that they are usually expanded in a huge pile of assembler code. But x86 (and some other architectures) have instructions to perform these counts (specifically, popcnt and tzcnt) and they are really fast (1 cycle for execution and latency of 3 cycles). Today we will learn how to force Rust compiler to use those instructions and what are the possible pitfalls.

  • Generating pretty version strings (including nightly) with Git and Makefiles

    In my recent project, I faced the need to generate pretty version numbers for my local and nightly builds. Here I will describe the approach I came up with. In this tutorial, we will use Git, which stores version tags and the entire setup uses Makefiles. However, you should be able to adapt this approach to any build system.

  • Just another terminal setup

    In this post, I will guide you through my terminal setup (which is quite simple though). This post may be updated in the future and is also for my own convenience when I need to set up everything on another machine.

  • Convenient Rust crates with procedural macros and runnable code

    Procedural macros in Rust are a great thing for many purposes (implementing custom derives, domain-specific languages inside Rust, etc). However, the use of procedural macros imposes one very inconvenient constraint: a crate that defines procedural macros can export nothing but procedural macros. This usually leads us to usi multiple crates to do exactly one thing (remember serde and serde_derive?). In this article, I will review an approach to this problem I have seen in the failure crate that allows us to import exactly one crate.

  • Analyzing metrics from InfluxDB with Pandas

    Our team recently started using the InfluxData stack to collect metrics from our apps (we may transfer logs and other time-series stuff to it, but that’s another story) and here is one feature that made me absolutely to fall in love with InfluxDB — the official Pandas integration. In this blog post I will briefly tell you what is so amazing about this integration and why you definitely should try it.

  • Using CLion to develop C/C++ applications in Docker (or any other remote development)

    We often use Docker in development for a variety of reasons: to work on the production-like environment, to isolate the application, etc. In particular, I use Docker for Mac to develop applications that are intended to be run on Linux. Along with bash scripts to set up the environment, it allows not to work with VMs (well, virtually, because Docker for Mac runs in the VM that is not exposed to an end-user) and also gives me a bunch of isolated lightweight working environments. Unfortunately, there is a downside: poor IDE support. And while IDEs like PyCharm handle that pretty well with its Remote Interpreters feature, CLion have not gone that far yet. However, there is the Remote Projects feature that allows us to work on any machine that exposes SSH and ports required by debuggers and any other software. In this tutorial, I will review the Docker-based approach. However, you can omit the Docker part and go with the same setup for your VM or remote server.

  • Finishing aiohttp websocket handlers cleanly when a client closed a socket incorrectly

    You might have noticed that there may be some troubles when an aiohttp was not closed by a client in a clean way. When you follow the aiohttp official guide on websockets but errors are not processed in the right way. Here’s a little trick that might help you with that.

  • Setting up pre-commit git hook to check Rust code formatting

    The whole thing this article is about is pretty common. But it might save you some time when you set up a Rust repository. Quick recap: git hooks are scripts that are triggered by git on certain actions. Here we are interested in the pre-commit hook which is fired before you enter the commit message. We will use it to check the code style with rustfmt which you need to install first: cargo install rustfmt. Try running it with the following command: cargo fmt -- --force --write-mode diff. This will output the suggested patch to fix your codestyle. In-place fixes can be performed with the cargo fmt -- --force --write-mode overwrite command.

  • Patching fonts to get powerline symbols

    Many shell/vim/etc extensions require powerline fonts to be installed in your system. Usually, people stick with fonts available in the powerline repository, but if you want to continue using your favorite font while taking benefits of powerline symbols?

  • Building tiny Docker images with multi-stage builds

    The big issue with Docker images is that they tend to get really big. Big projects can have so much build time dependencies and generated garbage that we may end up with images of, let’s say, from thousands of megabytes to gigabytes. This can make virtualization pretty painful because it hurts just to wait until the image is downloaded from a Docker registry.

subscribe via RSS