Ilya Bylich - Blog
Recent content on Ilya Bylich - Blog
Latest posts
Arena-based parsers
Writing bindings upside down
Bindings # Quite a long time ago I started writing C/C++/Ruby/Node.js/WASM bindings so I could call my Rust project from those languages. It is a Ruby language parser. I tried multiple ways and found one that is very (VERY) controversial, but I think it deserves it’s own article. Traditional way # Let’s say you have a library in C. Just for simplicity, Rust is not special here.
lib-ruby-parser
Intro # So, I’m ready to announce that I have finished working on a new Ruby parser. It’s called lib-ruby-parser . Key features: It’s fast. It’s written in Rust and it’s slightly faster than Ripper. The difference is about 1-2% on my machine. It has a beautiful interface. Every single node has its own type that is documented. For example, take a look at CSend node…
Evaluating Ruby in Ruby
TL;DR # This article is about instruction sequences and evaluating them using pure Ruby. The repository is available here . Is it a Ruby implementation? No. It’s just a runner of instructions. It is similar to MRI’s virtual machine, but it lacks many features and it’s 100 times slower. Can I use it in my applications? Of course, no. Well, if you want.
My favorite parts of Ruby
Before we start # Disclaimer #1 first of all I’d like to say that I really like Ruby. I write a ton of Ruby code every single day and I prefer it over other languages. Please, do not take it seriously, Ruby is nice, and this post is mostly a joke. Disclaimer #2 I’m not going to cover popular things like flip-flops (thanks God they are deprecated in 2.6.0).
Ruby Marshalling from A to Z
What is Marshalling # Marshalling is a serialization process when you convert an object to a binary string. Ruby has a standard class Marshal that does all the job for serialization and deserialization. To serialize an object, use Marshal.dump , to deserialize - Marshal.load or Marshal.restore . copy marshalled = Marshal . dump( [ 1 , 2 , 'string' , Object . new ] ) # =>…
HandlerSocket + Ruby
What is HandlerSocket (HS) # a plugin for MySQL which allows you to read/write to MySQL and gives you a separate connection to MySQL and does not allow you to run SQL queries but allows to run simple CRUD queries only using indexes HandlerSocket query language is very simple (I’d even say it’s primitive), but it’s much faster than MySQL’s one. Though, of course, there are…
Saving execution context for later debugging
The problem # Consider the following situation: you have got an exception in production. Of course, all of us are good developers, but you know, sometimes *it just happens. What do you usually do to get some information about the error? You just grab the request parameters to test it locally, right? Then I might have a better solution for you: dump your memory once an error happens and restore the…
Wrapping JavaScript library with Opal
Introduction # The task that is solved here is not real, but it’s still a good example of (probably?) real work with Opal. I could choose some complex enough JavaScript library and write a simple wrapper using Opal, but there’s no fun. Instead, let’s write a wrapper for existing rich client-side application (it may show you how to wrap your existing application logic). Well,…
Capybara and asynchronous stuff
What is Capybara, Poltergeist and PhantomJS? # In this part I will try to cover the following aspects: Running asynchronous code in a web driver Making the call synchronous Wrapping it into some common solution Advanced example - working with IndexedDB from Capybara PhantomJS # First of all, we need to know what is PhantomJS. I would say it’s a ’tool that acts like a browser but can be…
Apipie - amazing tool for documenting your Rails API
Apipie # This article is about Apipie gem which provides a DSL for documenting your API. I will try to cover features that I personally use on my project. Comparing to other tools for generating API documentation ( yardoc , sdoc ) I would say that the main thing that you gain with Apipie is that your documentation is a real ruby code, so you can write computations, concerns etc.
What is Ruby DSL
What is Ruby DSL? # As you already know, DSL means domain-specific language. It’s like a language in a language. Here are some examples that we use every day: copy class User attr_reader :name end class Profile < ActiveRecord :: Base has_many :posts end class ApiController < ActionController :: Base before_action :authenticate end But all these examples use rails-provided DSL, how about your…
Experimental MySQL HTTP API and Ruby
HTTP API # Yes, MySQL has an HTTP API which is: an experimental feature it ships as a native plugin only for 5.7 version Basically, it allows you to work with your database in the following ways: as an SQL endpoint as a CRUD endpoint as a JSON document endpoint SQL endpoint # It gives an ability to run queries like
ExceptionManager gem
What is this? # ExceptionManager is a gem for getting extra information from your exception. Source code: https://github.com/iliabylich/exception_manager With this gem every time when you get an exception, it’s possible to grab subject of exception (the instance of class where raise happened), locals - local variables, subject_instance_variables and subject_class_variables Examples: copy…
Redis Cluster. Quick overview.
Today I have tested version 3.0.0 of Redis server which includes Redis cluster. Here are some first thoughts about this. Setup # Here are my servers: copy # 212.71.252.54 / 192.168.171.141 / node1 # 176.58.103.254 / 192.168.171.142 / node2 # 178.79.153.89 / 192.168.173.227 / node3 Local hosts (on each server): copy # local hosts 192.168.171.141 node1 192.168.171.142 node2 192.168.173.227 node3 And…