There's one programming puzzle I solved many years ago but I still remember it because of the unusual solution. Problem: You have a text encrypted with a simple monoalphabetic substitution cipher. You don't have the key but you have a dictionary. Every word in a text can be found in this dictionary. Find the original text. It can be solved by dynamically generating regular expressions.
PHP
14 postsPHP Doesn’t Want You to Do Microservices
As a PHP developer, I should probably rejoice when someone's saying "we do microservices in PHP". I don't. I'm fine with PHP and I like microservices but the combination is just bad. PHP is a tool for solving a narrow range of tasks (i.e. making websites) and if you're trying to do something out of this range (i.e. making microservices) — you're gonna have a bad time.
In this post, I tried to collect all microservice-related PHP problems I saw over the years.
Finding Overlap Among Groups of Date Ranges
Imagine you have two groups of date ranges and you want to determine whether they overlap.
Nah, let's make it harder. Imagine you have two groups of include date ranges and two groups of exclude date ranges. Your task is to determine, whether there's a date that is present in both include groups and not present in exclude groups. How to do that?
3 Ways to Make Your API Slow
I had to fix performance issues of one API endpoint. A pretty Symfony endpoint that gathers some data from database, assembling it to some structure and returns it as json.
Performance started being an issue when major part of that "some data" started to be 60000 entities. In worst case response time was almost 20 seconds. "Ok", I thought, "60k is a big enough number to make it slow". But trace showed that retrieving data from DB isn't a slowest part. There were things taking almost 1/3 of request time each. And these things were easy to fix.
How to Make Aliases for Symfony Form Fields
Imagine you want to rename form parameter but you also want it to accept old parameter name in requests to preserve backwards compatibility. Here's how you do it.
Harmful Technical Interview Questions
Junior dev's life is hard an full of dangers. You come to technical interview and think "at least I'll learn something new from guys that know it better than me". Well, not really. Threre are some things that are ok in interviews and are totally wrong in real life. Here are some examples.
Imagick Resize Filters Comparison
So you want to shrink images with PHP and ImageMagick. Here are samples of all filters so you can select the one you like most.
How to Attach Composer to Yii Project
Why Composer Matters
I've heard about composer long before I started using it. I couldn't understand why it's so much cooler than downloading dependencies manually. I couldn't understand why it's worth running composer install
after every code fetch.
This article is for guys like me in the past. If you're already using composer you can stop reading.
Yii 1.1 Does Not Support Object Cloning
You better watch out
You better not cry
You better not clone Yii objects
I'm telling you why
Object cloning is coming to town not supported in Yii 1.1.
urmaul/url to Make Urls Absolute and Stuff
Copy-pasting two functions between projects is boring so I've created a GIANT COMPOSER PACKAGE with class with these two functions. It can convert relative urls to absolute and to add get parameters to urls. It's called urmaul/url.
Creating an API Documentation in Swagger Using YAML
UPD: I wrote this for swagger v1.2. Stuff has changed since then. Now swagger supports single-file YAML specifications, so making them is easier now. What a time to be alive!
A few days ago was the first time I created a REST API documentation. This is the report on how I did it.