This sounds like a trivial interview question, we know. You can easily find a well-documented method with Reflection. Some true gurus even provided us with other non-Reflection ways to do the same thing. However, when you start implementing it yourself, you can run into many unexpected and weird issues. These include, but are not limited to:
You’ll need to play around with the Reflection API’s object, but don’t you dare forget to call
Yes, a robot! As you will see further, it is not very much anthropomorphic, but anyway.
I am an engineer in IT company with more than 1000 employees. Our web sites get millions of hits daily, we maintain a gigantic ecosystem of microservish applications, and so on. Sometimes, things just go wrong. Application bugs, wrong configuration, hardware failure — everything can become an accident which requires immediate action from developers on duty. We call such an accident a hotline (famous book calls it a page). Each hotline is tracked using an email thread. …
As per Grafana documentation:
Grafana automatically calculates an interval that can be used to group by time in queries. When there are more data points than can be shown on a graph then queries can be made more efficient by grouping by a larger interval. It is more efficient to group by 1 day than by 10s when looking at 3 months of data and the graph will look the same and the query will be faster. The
$__intervalis calculated using the time range and the width of the graph (the number of pixels).
$_interval is indeed calculated…
Yes, they offer free GeoIP databases for everyone, but what if we would like to have a custom, super-lightweight version of
GeoLite2-City.mmdb exclusively for testing purposes? Especially in case of API testing or acceptance testing, when we strive to use real things and “mock nothing”.
Just download them here on Github. One more important thing: it is tricky to bruteforce an actual IP which can be practically found in this test db. The problem is that they are using cutting-edge at the time of writing IPv6 IPs. So, if you want some real results from test GeoIP database, just pick up some IP from this document.
2a02:ec00:: is resolved as France for me using this test database.
If you use Codeception and PHPStorm all together, this article is for you. Of course “Go To Implementation(s)” functionality is probably in your blood already, and you likely use the hotkey (⌘ + B on Mac) countless times a day.
If you adopt Codeception seriously, you have probably created some of your own Modules and Helpers. Even if not, it could be really useful to go to Codeception’s native methods implementation instantly.
Surprisingly, it is not possible out of the box. Codeception uses code generation, that’s why you end up in front of something like this, if you try:
Yandex.tank is a sophisticated, extemely powerful load generator. Target of the generated load (“address” key) has to be an IP address, as per the docs:
So, how to make your system-under-test to work properly, if it expects correct hostname to be specified?
Easy, just put hostname into HTTP headers in load.yml excplicitely:
If you use famous PHPStorm’s “PHP Inspections [EA Extended]” plugin, you are probably aware of the following warning, saying that you need to consider removing any callables from loop conditionals:
But is there any performance gain in the most common, trivial cases like count() call against an array? Maybe PHP engine is smart enough to do it internally? Let’s measure it! Let’s take a look at the following benchmark:
Full source code of the benchmark is available on Github.
Long story short,
count() call in a loop makes the execution ≈ 2.5x slower, no matter what is the size of the array:
In collaboration with Iurii Golikov
As a combination of basic edible components is able to form the most delicious gourmet meal, we are going to leverage two different fish from the infinite ocean of programming world to achieve something great: AOP and application instrumentation. By the way, this feature of a system is called emergence — an ability of a system to have properties which its parts do not have on their own. Literally the closest example is the device you read this article with, its parts separately (memory, cpu, display, etc.) …
You are advanced enough to create your own Codeception modules, aren’t you? It sounds great. However, there is a high chance that you meet with such an unexpected and mysterious error like the following:
Well, custom module couldn’t be connected, but why? And how to fix this error? The reason is trivial: Codeception does not have proper DI container for Modules, so the order of modules declaration does matter. In other words, if the module is used in another module, but declared (“connected” in terms of Codeception) after it in the *.yml config, then you will see the error. …