Skip to content

Herman J. Radtke III

Automating JIRA-Friendly Branch Names with Jujutsu

My current $JOB uses JIRA to manage issues and Github as the forge. I use Jujutsu and create remote branches using jj git push -c @. However, the Engineering Standard at work requires that the branch be named in an identifiable way. In practice, every branch is the slug of the commit description. After doing creating a jj bookmark manually a few times, I decided to automate it.

Manage Dotfiles with Jujutsu

My dotfiles setup is very simple: I version control my $HOME directory using git. I ignore everything by default to avoid accidentally adding files I do not want to track. This avoids the need for any scripts or frameworks. Lately, I have been using Jujutsu for more personal projects and decided to use jj to manage my dotfiles.

Why Your Rails-like Framework Is Not Widely Used

Ruby on Rails defined the ethos of the web development community for many years. I have observed people trying to replicate "Rails" in other languages with very mixed results. I consider Laravel, ASP.NET and Phoenix successful rails-like frameworks. Python already has Django. Sadly Java, Kotlin, Scala, Node.js, Go and Rust all lack a widely adopted rails-like experience.

Proving getenv Does Not Make a Syscall

I saw this statement in an accepted answer on Stack Overflow:

Retrieving the value of an environment variable will incur a system call.

source

This answer surprised me as I did not think this was the case. There is an edit farther down that has links to other Stack Overflow posts saying get getenv does not make a syscall. Let us prove it ourselves.

Profiling Node.js in Production

At work, I lead a team responsible for a Node.js service that serves a lot of GraphQL queries. We recently noticed some servers in the cluster were running much slower than others. We had used 0x in the past to profile Node.js services locally. In this case, we could not identify the problem locally and needed a solution to profile Node.js in production to identify the cause of the slowdown.

Webhook Failure Scenarios

A webhooks allow two applications to communicate events. It is relatively simple to get started using webhooks using HTTP and JSON. However, there a number of failure scenarios that developers should be aware of in order to make their webhook implementation robust.

Landing Page Router Using Fastly Compute@Edge and WASM

A company often has a landing page for first time visitors that is optimized for describing and educating that person on what product or service the company is offering. This page is usually not useful for people already familiar with the company. Ideally, a new user would see the marketing landing page and the returning user would see a more functional page. There are two common approaches to solving this problem that both have pitfalls. I want to explore a third option using Fastly's Compute@Edge offering.

How To Mock Functions That Have External HTTP Requests

When writing tests, we do not want to hit the external API each time we run our tests. If we are coming from a dynamic language, such as Node.JS, we may want to a solution like fetch-mock which will patch the implementation of fetch at runtime. This is not practical in Rust. There are some attempts, like the hotpatch crate, but we will use a different strategy.

fastly/lucet in five minutes

Lucet is Fastly's native WebAssembly compiler and runtime. I am a big fan of Rust, Fastly and WASM. Especially WASM on the server via WASI. I jumped right in and tried to get my own lucet program running, but the setup is a rather long process. My plan was to introduce lucet to some colleagues at my local Rust meetup. I am a huge fan of Rust, but the compile times are an issue. Spending 30 minutes on setup was a non-starter. I was excited when I saw that Fastly published a Docker container:

The Painful Gearman Upgrade Path

The Gearman project has been slowly migrating from C to C++. This migration has gone under the radar due to the popularity of Cent OS 5 and given gearmand version of 0.14. This version of gearmand worked with any version of pecl/gearman and there was never any compelling reason to upgrade gearmand. That changed with the release of pecl/gearman 1.0

SPL FilterIterator in the real world

The Standard PHP Library (SPL) is a powerful set of tools that are often overlooked. It is very common to see an SPL talk at conferences, but those talks usually just introduce each SPL class to the audience without giving some real world examples. I am going to show you a real world example on how to use SPL FilterIterator in an ecommerce website.

Gearman Worker Exception Handling in PHP

Gearman is one of my favorite technologies to use. So much in fact that I recently decided to take over the maintenance of pecl/gearman. While asynchronous tasks are a great feature, I find the ability to run multiple tasks in parallel to be much more useful. One of the biggest shortcomings of this approach was that uncaught worker exceptions would be treated as a successful completion of a job. I used to wrap all my workers in a generic try/catch block to prevent this from happening.  With the latest commits to pecl/gearman, I can now use the exception callback to properly track the exceptions.

Retrying Failed Gearman Jobs

The gearman job queue is great for farming out work.  After reading a great post about Poison Jobs, I limited the number of attempts the gearman daemon will retry a job.  This seemed fairly straight-forward to me: if a job fails, then the gearman daemon will retry the job the specified number of times.  I learned the hard way that it was not that simple.  There is specific criteria the gearman daemon follows in order to retry a job.

Learning To Use MongoDB

I have heard of MongoDB for some time and have read quite a few articles and attended some conference seminars about it.  I had put off using MongoDB because I could find no project that really made good use of it.  About two weeks ago I started a project that doesn't really fit into the relational database mold.  I finally had the perfect excuse to devote the time and effort to learning all about MongoDB and take my place among the ranks of developers using NoSQL (whatever that means).

Don't Overuse Use

Nate Abele just announced Lithium 0.9 on the rad-dev blog.  I think Lithium is a great looking framework and can't wait for it to get a 1.0 release and really start to take off.  However, looking through the examples I started to notice that the use of the "use" namespace keyword was an often used convention.  It reminded me of the require/require_once creep of the days of old.  I was discussing it with Nate via Twitter, but I couldn't seem to get my point across.  Maybe I will have better luck here...

Using Absolute URL's In The View

We recently had a project at work that involved replacing all the relative URL's from the application with absolute URL's. In the past, developers had just hard-coded an absolute URL only when they need to force the browser over to https. Now we are using multiple subdomains, so this approach is no longer sufficient. We also wanted a way to easy rotate assets through multiple CDN URL's to speed up the time it takes a user's web browser to load all the content.

PHP 5.3 is the new JavaScript (almost)

In my last post, I argued that the best way to start developing functional PHP applications was to code review some JavaScript projects.  I think this is a good place to start as most web developers have written some JavaScript at one point during their career.  I briefly mentioned that the array is pretty similar to the JavaScript object too.  However, if you start hacking away at PHP based on JavaScript's functional syntax, you will quickly run into some problems.

Mocking Zend Framework's Row and Rowset objects

If you separate your business logic from your data access logic, the last thing you want to do is make your business logic unit tests reliant on the database.  This is normally not a big deal: retrieve the data, store it in an array and pass it off to the class with the business logic.  Mocking the data for the unit test simply requires you to hardcode from array information in the test.  However, I recently ran into a case where I wanted to pass Zend_Db_Table_Row and Zend_Db_Table_Row objects to the business logic and mocking them was not so easy.

Canonical Version Numbers with Git

Brandon Savage wrote a controversial blog post about why subversion is still more relevant than git.  His main point was that enterprise requires canonical version numbering to track progress in the application and that git cannot do this.   There was a lot of debate about this on Brandson's, but a recent comment by Morgan proved Brandon wrong.

Unit Testing and the Law of Demeter

I was writing some code today and not using Test-Driven development.  The reason was that I did not have a good understanding of what I was writing, so I decided to write some of the guts before writing the tests.  In the process of writing the guts, I recognized that I was paying very close attention to how I was going to later test each of the methods I was writing. I was paying especially close attention to the Law of Demeter.   The idea behind the Law of Demeter is to keep units of code distinct from one another. So how did this relate to my code?  To put it simply, my business logic methods did not use get methods.

Facebook Thrift PHP Client

A while back I wrote a post about using Facebook's Thrift.  One comment asked me to post the PHP client used to connect to the C++ server I was demo'ing.  Most of the client is boiler-plate code generated by Thrift, so I chose to omit it at the time.  Here it is:

Phing - phplint task

Phing is a PHP port of Java Ant.  It is a great tool to use in development.  It standardizes a lot of build scripts you would have to maintain internally.  Unfortunately, examples seem to be lacking.  As a quick introduction to Phing, I will show how you can check all your php scripts for syntax errors.

Zend_Soap_AutoDiscover and eAccelerator

The Zend Framework ships with SOAP functionality and one especially neat class called Zend_Soap_AutoDiscover.  This class uses a comment docblock to auto-generate a WSDL at runtime.  I won't go into the details how it works here, but you can check the Zend Framework documentation for an example.  When using this class at work, I noticed the WSDL would not always generate correctly.  After a lot of digging around, I found the cause: eAccelerator.

Using the PHP 5.3 __DIR__ magic constant

There is a new magic constant in PHP 5.3: DIR. This new constant does not actually do anything new. It replaces the use of dirname(FILE) that is commonly found code using prior PHP versions.

Scaling URL's

Using non-relative URL's during early development can alleviate a lot of growing pains. This may seem counter-intuitive at first, but hear me out. We all learned long ago to stop hard-coding the domain name into the href attribute of an anchor tag. Instead, we used relative URL's such as '/index.php' to make our code much more portable. However, relative URL's become a pain point when trying to scale your website. Let's review some common scenarios that can be averted with some proper planning.

Doing It "Right"

I have always been of the opinion that doing a task the correct way the first time is the best way to complete the task. I don't mean to imply that there is one correct way of completing a task, only that doing it correctly does not involve cutting corners or using hacks to complete the task.  I have always preached this ideal as a developer, never the decision maker.  Now, I am currently working on a project with a few colleagues of mine where I am a decision maker.  Earlier today I began wondering whether my ideals will change as this project grows.

Static Method Abuse

When I began taking over the web development project at work, I noticed a developer using a lot of static members and methods in his class definitions. His explanation was that it was an optimization he used to improve performance. Unfortunately, he had no metrics to back the statement up. So I set out to do some of my own.

Exploring Facebook's Thrift

At work we have a number of services written in C. These services use the same core libraries our legacy C application uses. Keeping all this business logic in a central place makes life much easier, but the way services are written is horribly inefficient. I am on a mission to find a better way.

Frustration with vim.org

I started using the phpDocumentor for Vim (PDV) script written by Tobias Schlitt.  Very quickly I found a bug with one of the regular expressions used to parse apart the class definition.  Tobias does not seem to be maintaing this plugin anymore, so I decided I would fix the bug and submit a new version to vim.org.  I packaged up the new version of the script and went to update the PDV page on vim.org only to find out I can't.  There isn't even a mechanism for me to post a comment.

Choosing VIM

At work we were using VIM for all editing, except PHP.  Back when the decision was made to use PHP for all web development, consultants told us we needed an IDE that offered all kinds of tools that VIM lacks.  So we shopped around for IDE's and eventually bought Zend Studio licenses for everyone.  Today those licesnses are collecting dust.  Even with the feature rich toolset of Zend Studio, and other IDE's, none seem to satisfy our need like VIM does.

Crutching on MySQL's INSERT IGNORE

MySQL has a lot of nice additions to the SQL-92 standard that make life easier for developers. The drawback to these shortcuts is that many developers don't learn how to cope in other database environments, like PostgreSQL. Take INSERT IGNORE for example: PostgreSQL does not have support for this syntax. A resourceful developer can do a quick google search to learn an alternative, but many of the solutions at the top of google will show the wrong way to solve this problem.

PHP extension debugging hack

At work I maintain a handful of custom PHP extensions.  When someone reports a problem with one of the extensions, I want to fire up gdb right away and see exactly what is going on.  In order to do this, I build a custom php binary with debugging enabled.  I leave this binary inside my home directory so as not to affect my installed production php binary.  I should now be able to rebuild my custom extensions now with debugging enabled and start debugging.  But wait, the configure script rejects the flag.