The Where Expression Filter in Jekyll 3.2

Oct 1, 2016
Tags: Jekyll Web Development

If, like me, you’ve been distracted by all the changes to gem based themes in the last two releases of Jekyll you may have missed the addition of this humble new filter: where_exp.

Spoiler: It’s awesome

Now the where filter has been around for a while—it lets you pre-filter an array before iterating over its contents, for instance:


{% assign fascists = site.fascists | where:”era”,21st Century” %}
{% for fascist in fascists %}
    {{ fascist.name}}, {{ fascist.country }}<br>
{% endfor %}


=> Donald Trump, United States
   Vladimir Putin, Russia
   Nikolaos Michaloliakos, Greece

That’s great, but what if you want to filter for a single value in an array or hash. Let’s say each document in our fascist collection has a properties field that enumerates their fascist ideology. With the where_exp filter then, we could do something like this:


{% assign fascists = site.fascists | where_exp: "fascist", "fascist.properties contains 'Contempt for the Weak'" %}

{% for fascist in fascists %}
    {{ fascist.name }}<br>
{% endfor %}

=> Donald Trump
   Adolf Hitler

This makes things so much easier than it used to be. Rather than having to iterate over each item in the collection to check for the right fascist ideology—this is also a pain when having to deal with empty sets, setting headers, etc.—we can simply use the filter. Note: both the where and the where_exp filters are unique to Jekyll and are not actually part of Liquid.

Maybe it’s just me, but the pace of change in Jekyll seems to have picked up quite a bit. As more and more people move to decoupled systems with a static component it’s good to see Jekyll modernize to meet the new demand.




All Love And No Hate Tho

Sep 13, 2016
Tags: Applescript Music

The old rating system in iTunes is so 2001—full of stars. I used to try and rank all my tracks, but that way lies madness. Recently though, iTunes gave us the option of using the 💙 to signify approval of a track and a 💔 to signify hated tracks, and country music. This is good.

Streaming music is here to stay, and I for one welcome our new algorithmic overlords. The key, is letting the Python scripts know what you like and what you don’t. Hopefully, they’ll learn and start to give us better recommendations. To that end, I knocked together this little Alfred workflow to quickly like or dislike the currently playing track in iTunes. At work I’ve got music playing pretty much all the time, so being able to quickly like/dislike the current song comes in pretty handy.

screen-recording

So, grab the workflow, crank up the tunes, and let the algorithm know how you feel.

The Distress Signal is the personal blog of Bryan Schuetz. Bryan has been complaining on the Internet since the 90s. If you'd like to get in touch with Bryan, you can find him on twitter.