Skip to main content


PHP access private methods and fields

These two simple functions can come in handy as helpers for something like PsySH.PHP >= 7.0 is required.


Don’t use them in actual production code! That would be awful

Call private method of an object:

function call_private_method($object, string $method, ...$args)
return (function ($method, ...$args) {
return call_user_func_array([$this, $method], $args);
})->call($object, $method, ...$args);

Get private field of an object:

function get_private_field($object, string $field)
return (function ($field) {
return $this->$field;
})->call($object, $field);


class A
private $secret = 'SECRET234';

private function doStuff($whatever)
return $whatever . '!';

$a = new A;

get_private_field($a, 'secret'); // SECRET234

call_private_method($a, 'doStuff', 'whatever'); // whatever!

UPD: “Why not make a library out of it”, I thought. So it’s now a library:


Embracing CommonMark as the One True Markdown

As you may know, CommonMark is a project aiming to create unified and unambiguous Markdown syntax specification. So, I’m in. I want to spread the word and even use it in my own blog.

The trouble number one is that Jekyll uses kramdown by default. So we find a gem and the gem is jekyll-commonmark. Oh hell, we lost syntax highlighting :(

The trouble number two is that CommonMark standard lacks support for server side syntax highlighting. That’s bad, I don’t want any JavaScript on my static pages. Let’s try to wrap it somehow and enable syntax highligting.

The strong side of Ruby CommonMark implementation, CommonMarker is its ability to parse a document to the abstract syntax tree, so let’s use it to extract our blocks and highlight them with... show more


What Is Dead May Never Die

Let’s have some fun with theDrowned God andUnix signals.

This is a simple program that catches SIGINT and SIGTERM

#include <stdio.h> // for printf() && perror()
#include <stdlib.h> // for exit()
#include <signal.h> // for all the signal fun
#include <unistd.h> // for sleep()

* catch signals
void catch(int sig)
static int counter = 0;

// prevent exit by SIGINT and SIGTERM 3 times and then exit program
if (sig == SIGINT || sig == SIGTERM) {
if (counter < 3) {
printf("What is dea... show more
This entry was edited (7 months ago)

Farewell to Jekyll
Just ported the blog to Pelican and removed add Jekyll files. Currently it seems the most logical choice for me

First, I started to use reST much more extensively than Markdown and I want a blog generator that supports it better

Second is my new interest in Python

Third, Pelican seems to have much more features that I like compared to Jekyll and other static generators that I tested, especially Python ones (however Nikola also seems a good alternative but I had to stop at something)

journald-native and journald-logger transferred to the Foreman
Yesterday I moved two of my ruby gems, journald-native and journald-logger, to theforemanGitHub namepace. Developing them further is out of my current professional interest and hopefullythe Foreman project will be a good home for them.

It’s hard to say farewell however to the most popular library I created so far :D (8 GitHub stars, 57000 downloads)

Private Composer Repo with Gitlab and Satis
You can easily create your own composer repository using Satis and Gitlab. I will use global but it should be most useful for private corporate Gitlab installations. You will need CI and Pages

Our repo should contain only 2 files: satis.json and .gitlab-ci.yml

... show more

PhpStorm Advanced Metadata Exporter
As a Silex user I liked Pimple Container Dumper that worked with Silex Idea Plugin to enable code completion for Pimple DI in PhpStorm. But now with Silex EOL’d I have to move to Slim.

I’ve found no such projects so I had to write my own. Here it is: sandfoxme/phpstorm-metadata-export. It currently supports exporting data from Pimple and has 3 integration middlewares: for Slim, for Silex and for Psr-15 compatible frameworks.

P.S. Code completion support for ArrayAccess containers seem to be currently broken in PhpStorm (WI-33309, WI-35503). So I don’t currently recommend replacing Silex Idea Plugin with this library unless you use Pimple in Psr-11 compliant way (like Slim does by default)