Get Lines of Code Changed in git diff Excluding Directory

Published: March 3, 2020


Recently I was faced with large amount of code requiring review. I needed to get back to the individual who requested the review with an estimate of how long it would take.

To give an informed estimate, it’s useful to have a sense of how many lines of code have changed. This is generally easy to do with the --shortstat diff option (GitHub also conveniently displays this when looking at a pull request):

$ git diff --shortstat 2.0.0 2.3.0
 209 files changed, 30020 insertions(+), 2531 deletions(-)

However a quick glance at the changeset told me that the majority of the changes were unit test files, which I wasn’t particularly interested in reviewing here (this was a review of 3rd party code). I wanted to figure out how many lines of code had changed, excluding test files.

Render a Category page via a Standalone script in Magento 2

Published: February 5, 2020


In this post I’ll share a standalone script that can be used to render a Magento 2 category page programmatically. This script can come in handy when debugging production issues on category pages (e.g. unexpected product set). For example, it can be executed under strace to review files opened, queries sent, and their corresponding results.

WTF Happened to Custom Layout Updates in Magento v2.3.4

Published: January 30, 2020


In versions on Magento prior to v2.3.4, users had the ability to add custom layout updates to category, product and cms pages via a textarea input from the Magento admin panel.

Screenshot of design tab on category edit screen in Magento v2.3.3

These updates would then be merged with layout definitions from the theme on the website to impact the overall frontend page rendering.

Per Magento’s release notes, as of Magento v2.3.4, this ability has been removed:

Removal of custom layout updates and the deprecation of layout updates to remove the opportunity for Remote Code Execution (RCE). The Custom Layout Update field on the CMS Page Edit, Category Edit, and Product Edit pages has now been converted to a selector

I dug into this a bit and shared some info in this Twitter thread. Here, I’d like to present my findings in a slightly more formal manner, and also offer some additional details.

Forcing HTTP Version with PHP cURL

Published: January 8, 2020


A colleague recently reported a strange bug to me:

I’m troubleshooting an issue where data fails to sync the a 3rd party and I’ve identified this error when curl_exec runs

HTTP2 framing layer error

From what I gather online is that this typically a somewhat generic error and could have multiple causes.

New Relic Alert When No Data is Received

Published: November 4, 2019

There is a known bug with the New Relic PHP agent that causes it to stop reporting data when it is upgraded.

When I ran into this recently it made me think, “it would be nice if I could have New Relic send me an alert when it stops receiving data from the application.”

Gatling Multiplier Parameter

Published: November 3, 2019


Typically, when load testing a system with Gatling, I create a simulation script which consists of a number of scenarios which are executed simultaneously at different ratios. Execution of the scenarios would look something like this:

    BouncerHome.inject(rampUsers(360) during (300 seconds)),
    BrowserCategory.inject(rampUsers(60) during (300 seconds)),
    Searcher.inject(rampUsers(40) during (300 seconds)),
    Uncached404.inject(rampUsers(40) during (300 seconds)),
    UncachedPdp.inject(rampUsers(60) during (300 seconds)),
    PurchaseIntent.inject(rampUsers(10) during (300 seconds))

I then run the simulation a number of times, gradually increasing the load to identify the breaking point.

For example, after running at the ratios above I might double the load as follows:

    BouncerHome.inject(rampUsers(720) during (300 seconds)),
    BrowserCategory.inject(rampUsers(120) during (300 seconds)),
    Searcher.inject(rampUsers(80) during (300 seconds)),
    Uncached404.inject(rampUsers(80) during (300 seconds)),
    UncachedPdp.inject(rampUsers(120) during (300 seconds)),
    PurchaseIntent.inject(rampUsers(20) during (300 seconds))

Then triple (and so on and so forth).