Edd Mann Developer

Maybe in JavaScript

Recently I have been delving into the concepts of Functors and Monads. There are many good resources available online that will do a far better job of explaining these concepts than me, however, I do wish to document an example Maybe type I have implemented in JavaScript. Again, there are many good external resources which highlight the characteristics and power of using such a type, so I will direct your attention to those if you wish to learn more.

An 'array_column' re-indexing trick in PHP

The array_column function has been a welcome addition to the PHP language, allowing us to remove the need for common-place array_map invocations that just pluck specific values from arrays. However, I just found out that you can provide a third argument that allows you to define what the returning arrays keys will be. This combined with null for the value argument allows you to easily re-index an array based on a key value whilst maintaining the original arrays values and ordering.

Generating Podcast Stats in PHP

In the 100th episode of Three Devs and a Maybe I decided to generate some stats relating to the previous 99 episodes and formed a small quiz out of these findings. All information relating to each podcast is stored in separate Markdown files within YAML front-matter, which makes it easy to pull out and process. I thought it would be interesting to go over the code I used to achieve this.

Understanding De Morgan's Laws to simplify propositions

Yesterday I watched a conference talk about Formal Logic and De Morgan’s laws were discussed. Wikipedia does a very good job of explaining the laws in-depth, but essentially they are transformation rules that allow you to simplify certain propositions. Whilst programming, predicate logic of this form appears very frequently, and it is very useful to know how you can rewrite a predicate to better describe its intent.

Validating 32-bit Integers using PHP

Last week I was required to validate that a supplied integer would fit correctly into a 32-bit address space. The available size of an integer within PHP is platform dependent, and could either be 32 or 64 bits based on the architecture you are using. This function had to cater for these differences and as such I decided to explore a couple of different options for producing this validation.