<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Den McHenry</title>
    <description>The latest articles on DEV Community by Den McHenry (@denmch).</description>
    <link>https://dev.to/denmch</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F65069%2Fc6e46759-724e-4e56-8baa-2411c01727a0.jpg</url>
      <title>DEV Community: Den McHenry</title>
      <link>https://dev.to/denmch</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/denmch"/>
    <language>en</language>
    <item>
      <title>Favicons in root with Eleventy</title>
      <dc:creator>Den McHenry</dc:creator>
      <pubDate>Sun, 08 May 2022 03:34:00 +0000</pubDate>
      <link>https://dev.to/denmch/favicons-in-root-with-eleventy-1jhg</link>
      <guid>https://dev.to/denmch/favicons-in-root-with-eleventy-1jhg</guid>
      <description>&lt;p&gt;It occured to me after fiddling around with nonsense and making silly mistakes all day that the cleanest way to keep favicon files together and away from my main image folder would be to put them into their own directory and pass the contents of that directory to root.&lt;/p&gt;

&lt;p&gt;Whenever I decide to change my favicon, I can clear out the local directory and replace its contents with the new files, and won't have to worry about things like losing track of files in my image directory or cluttering the main directory in my local repo.&lt;/p&gt;

&lt;p&gt;You choose which directories and files to pass through as is within the &lt;code&gt;module.exports&lt;/code&gt; in your &lt;code&gt;eleventy.js&lt;/code&gt; file. You likely already have a few lines like this for things like the "img" and "css" directories.&lt;/p&gt;

&lt;p&gt;Here's a quick and dirty run down of how they work.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Pass the /img/ directory through:
&lt;code&gt;eleventyConfig.addPassthroughCopy("img")&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Pass a specific file through:
&lt;code&gt;eleventyConfig.addPassthroughCopy("img/favicon.ico")&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Pass something through to a different location:
&lt;code&gt;eleventyConfig.addPassthroughCopy({ "favicon" : "/" } );&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This last example takes an object rather than a string and passes the contents of the source directory through to a different destination directory, in this case to root. The "favicon" directory will not appear on the live site, but its contents will be copied to the root directory, which is exactly what I wanted.&lt;/p&gt;

</description>
      <category>eleventy</category>
      <category>favicon</category>
      <category>indieweb</category>
    </item>
    <item>
      <title>Eternal Recurrence</title>
      <dc:creator>Den McHenry</dc:creator>
      <pubDate>Thu, 16 Apr 2020 04:57:47 +0000</pubDate>
      <link>https://dev.to/denmch/eternal-recurrence-2d5l</link>
      <guid>https://dev.to/denmch/eternal-recurrence-2d5l</guid>
      <description>&lt;p&gt;Sometimes you start a new thing and fumble something silly and want to hide under a rock. But trying to hide under a rock would make you look even sillier, and soon you can laugh at your mistakes and take pride in learning from them.&lt;/p&gt;

&lt;p&gt;Sometimes you spend a quarter century noodling with the web and then, just like that, you go blank writing an at-rule you’ve written countless times before, like &lt;code&gt;@font-face&lt;/code&gt;. You put a URL directly after the &lt;code&gt;src&lt;/code&gt; attribute without passing it as an argument to the &lt;code&gt;url()&lt;/code&gt; function.&lt;/p&gt;

&lt;p&gt;You fool. You absolute rube.&lt;/p&gt;

&lt;p&gt;You look it up, hate yourself, and are very, very glad that no one is watching.&lt;/p&gt;

&lt;p&gt;You’re so paranoid you lift the rock to see if anyone’s there.&lt;/p&gt;

&lt;p&gt;Or you try to write a media query by typing &lt;code&gt;@media-query&lt;/code&gt; instead of &lt;code&gt;@media&lt;/code&gt;, and then you want to fall off a cliff into an endless void and fade into the fabric of the universe, forgetting yourself and every mistake you’ve ever made.&lt;/p&gt;

&lt;p&gt;You want to become like water and seep into the earth or evaporate into the air, drift off into the clouds, rain down on the remotest spot on the planet, never be seen again, and just rest undisturbed, unknown, unable to disappoint yourself or anyone else ever again till the sun swallows this rock and the rest of the solar system and finally burns out.&lt;/p&gt;

&lt;p&gt;But then you get over it and live to code another day. And to fail again in the same inconceivable ways. Even when you’re supposed to be an experienced professional.&lt;/p&gt;

&lt;p&gt;Especially then.&lt;/p&gt;

</description>
      <category>webdev</category>
    </item>
    <item>
      <title>Scratch that Itch</title>
      <dc:creator>Den McHenry</dc:creator>
      <pubDate>Sun, 09 Jun 2019 05:07:09 +0000</pubDate>
      <link>https://dev.to/denmch/scratch-that-itch-1i0j</link>
      <guid>https://dev.to/denmch/scratch-that-itch-1i0j</guid>
      <description>&lt;p&gt;I've never wanted to push my kids into doing things, and especially not to do them the way that I do. I've always drawn, but I don't want to give my kids tutorials in how to draw 'the right way' or in my style.&lt;/p&gt;

&lt;p&gt;I want them to have fun, and to figure things out, and if they want to do something, to learn it organically. I think that if they develop skills in this way, they'll have a deeper, more meaningful connection to their craft, and a sense of the 'why' that they might lack if I were to push any kind of a 'how' on them.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F6oq73xbjk5anv3oqbm37.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F6oq73xbjk5anv3oqbm37.jpg" alt="Photo of open cereal boxes by Samantha Gades on Unsplash.com"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Limits and Creativity
&lt;/h2&gt;

&lt;p&gt;Recently, my eight year old had less fun than you might expect in a school assignment about turning a book he's read into a breakfast cereal. This is about creativity, right? Have fun with it! But without a little framework to build on, it's difficult to be creative. There are too many possibilities, no hooks to hang your hat on. I broke down and did something I should have a long time ago, and we sat together at the drawing table.&lt;/p&gt;

&lt;p&gt;In order to be creative, you need to have the freedom to make creative choices. In the same way that we all get too overwhelmed with everything from paying bills to planning meals for the family, you can set out to create something and sit frozen forever by endless considerations like medium, subject, and on and on.&lt;/p&gt;

&lt;p&gt;This is why people often rely on prompts, or even why I often rely on irony and self-deprecation when I do my white board drawings at work. Anything can be a frame that limits enough of the external concerns that within this small, focused area, the ideas flow and take shape.&lt;/p&gt;



&lt;br&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F13vootioznbgdk8i8k6h.jpg" alt="Illustration of the 'rule of thirds,' i.e. dividing an image into thirds along both the X axis and the Y axis and placing points of interest on the intersections, by Wikimedia contributor Chaky."&gt;
&lt;h2&gt;
  
  
  Trust the Algorithms
&lt;/h2&gt;

&lt;p&gt;I showed my son some fun cereal boxes, and broke out the tried and true rule of thirds, and some common cropping techniques (e.g., don't show the whole bowl: let it sit mostly out of frame, and zoom in tight to show the details). We talked about how this or that design had a sense of movement or excitement based on simple principles, essentially common design algorithms that allow you to quickly put together a pleasing and familiar layout and focus on the details.&lt;/p&gt;

&lt;p&gt;In no time, he pushed me aside and said he had an idea. A frustrating and tedious effort turned into a fun design.&lt;/p&gt;

&lt;p&gt;Of course, algorithms aren't universals or hard and fast rules. You don't have to use the "rule" of thirds, but it's amazing how applying a simple tool like that can open things and free you to start making creative choices.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F1oqvfnik08nakwsu2xms.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F1oqvfnik08nakwsu2xms.jpg" alt="A random sample of my son's remixed code on Scratch."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Art of Code
&lt;/h2&gt;

&lt;p&gt;It felt like a big win, and I decided to take that tack because of something that had recently happened while he was struggling with a problem on &lt;a href="https://scratch.mit.edu/" rel="noopener noreferrer"&gt;Scratch, MIT's awesome coding community aimed at kids&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;What's most interesting to me about Scratch is that he's kind doing what I did when I was younger, either as a kid trying to figure out B.A.S.I.C. in the '80s or later as a young adult, viewing source in the '90s and learning how the web worked. He remixes a project, say a game that someone else has made — something from an older, more experienced, more savvy programmer — and he learns by building on that.&lt;/p&gt;

&lt;p&gt;In this case, it was a little more complex than he was used to, with an NPC being generated by some action, and then removed upon another action. How do you add a new enemy when this one is defeated?&lt;/p&gt;

&lt;p&gt;The details are less important than the principles. As he went back to the code and made tweaks, and failed to see the expected result, he grew more and more frustrated. This, too, was familiar. We've all been there, playing the game of tinkering till it works. But it's a dangerous game, and rarely actually works.&lt;/p&gt;

&lt;p&gt;So now, instead of building on what's there, what he needed was to work out how to duplicate functionality as needed, and how to debug what's gone wrong.&lt;/p&gt;

&lt;p&gt;At first, the code he added had no effect, and after asking him about the the specific actions that triggered various results, and the conditions under which certain things occurred, he was able to think through and locate the code that controlled the NPC and its appearance.&lt;/p&gt;

&lt;p&gt;Well, not quite its appearance. But we were close. See, the NPC was definitely there, only we couldn’t physically see it. We could hear its sword, and our character took damage, but we just flat couldn’t see it. It was invisible.&lt;/p&gt;

&lt;p&gt;Back to the code, and back to more questions about the conditions under which this or that happened helped my son to see where a costume was changed or the opacity of the sprite was set.&lt;/p&gt;

&lt;p&gt;Before long, with a little guidance on thinking through the logic of the program rather than tinkering directly with the code, he was able to take a single enemy demo and turn it into a game with 14 levels of enemy combatants. (I might have gone with 3 to start, but he set it at 14, and I wasn't going to argue.)&lt;/p&gt;




&lt;p&gt;I didn’t write any code for him, but stepped in with some very basic debugging knowledge to lighten his load and let him find the answers. It was incredibly rewarding for both of us, and it never approached a rote lesson in “how to code.” It was just a nudge in the right direction, and some boundaries that gave him the freedom to escape anxiety, find his way, and get back to the fun of making things.&lt;/p&gt;

&lt;p&gt;I think an important lesson is that you have greater freedom to be creative and to learn when you have senior people around you who can clear away obstacles, put things in context, and nudge you in the right directions. This is true for kids, and it's true for junior developers. No one needs to reinvent the wheel or suffer in silence. But keep in mind that people don't always know which questions to ask, or what's in their way.&lt;/p&gt;

&lt;p&gt;It's up to you to keep an eye out, and lend a hand where you can.&lt;/p&gt;

</description>
      <category>scratch</category>
      <category>beginners</category>
      <category>teaching</category>
      <category>mentoring</category>
    </item>
    <item>
      <title>Build Your Own TACO</title>
      <dc:creator>Den McHenry</dc:creator>
      <pubDate>Sun, 19 May 2019 17:46:57 +0000</pubDate>
      <link>https://dev.to/denmch/build-your-own-taco-25i6</link>
      <guid>https://dev.to/denmch/build-your-own-taco-25i6</guid>
      <description>&lt;p&gt;I won't be so presumptuous as to say that this is information architecture without tears, for non-specialists, made-easy, and certainly not "for Dummies." (I've never liked that phrase, and don't think it's helpful.) This is more or less a simple model for myself to get closer to feeling comfortable with information architecture — an inroad to the discipline that doesn't pretend to say anything new. But I hope it says something useful in a memorable way, and helps someone else to start making progress on organizing information. It's helping me.&lt;/p&gt;

&lt;p&gt;So without further ado, how to build your own T.A.C.O.&lt;/p&gt;

&lt;p&gt;I'm currently tasked with working on wireframes for a student portal to replace an ancient system that was pieced together over many years, often with little to no user input. We've recently had a series of discussions with various stakeholders, and ended up with a sort of master list of things that matter to different groups and for different populations. Now the hard part begins: how do you organize that in a meaningful, usable way?&lt;/p&gt;

&lt;p&gt;You may have heard of Richard Saul Wurman's LATCH mnemonic for organizing information, limiting available models to location, alphabet, time, categories, and hierarchy: L.A.T.C.H.&lt;/p&gt;

&lt;p&gt;For my purposes, I've come up with just four things to focus on instead of five. I give you T.A.C.O.:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;theme&lt;/li&gt;
&lt;li&gt;audience&lt;/li&gt;
&lt;li&gt;convenience&lt;/li&gt;
&lt;li&gt;order&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;TACO addresses the four most important things about how your information relates to the people who access it:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What's it about?&lt;/li&gt;
&lt;li&gt;Who's it for?&lt;/li&gt;
&lt;li&gt;What do they want to do?&lt;/li&gt;
&lt;li&gt;How can they make sense of it?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We start with the contours and end with the details, where LATCH treats them all sort of indiscriminately in an attempt to reduce anxiety, which kind of causes me some anxiety.&lt;/p&gt;




&lt;h2&gt;
  
  
  THEME
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Theme&lt;/strong&gt; is the broadest category and is highly contextual. It could be a department within an organization, a category used to group news items topically, an academic subject, or just about anything you can imagine as a unifying mental model. For this reason, it can have great overlap with other ways of organizing, and is best suited at the highest level.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;category&lt;/li&gt;
&lt;li&gt;department&lt;/li&gt;
&lt;li&gt;question&lt;/li&gt;
&lt;li&gt;topic&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  AUDIENCE
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Audience&lt;/strong&gt; is often overlooked. How do you organize your information for an internal vs. an external audience, for beginners vs. experts, students vs. teachers? It can seem at times like a subset of either Theme or Convenience, but at its base, it may be the first consideration in organizing your information, sitting at the literal interface of your data and the people accessing it. It's up to you and your requirements whether it sits above topical organization or acts as a filter below, or is just a concomitant consideration.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;administrator &amp;gt; editor &amp;gt; reader&lt;/li&gt;
&lt;li&gt;beginner &amp;gt; expert&lt;/li&gt;
&lt;li&gt;customer &amp;gt; supplier&lt;/li&gt;
&lt;li&gt;student &amp;gt; teacher&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  CONVENIENCE
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Convenience&lt;/strong&gt; is about ways of organizing based on utility, preferring usefulness within a given context. This encompasses things like relevance, interaction, and popularity. You may make the most relevant information available first or most prominently. You may emphasize content that a user can interact with or content that is dynamic over static content. This can be a kind of hierarchy, but that's too abstract. Like Audience, Convenience is focused on the user.&lt;/p&gt;

&lt;p&gt;Examples: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;interactivity&lt;/li&gt;
&lt;li&gt;popularity&lt;/li&gt;
&lt;li&gt;relevance&lt;/li&gt;
&lt;li&gt;usefulness&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  ORDER
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Order&lt;/strong&gt; is probably, and likely counterintuitively, the last consideration for organizing information. It is certainly the last resort for locating information from the wide angle, e.g., a sitemap, but it's also likely the best way to organize things at the granular level. When a user has successfully located the most topical, personally relevant, and actionable information, you can focus on ordering in a logical or a generic way.&lt;/p&gt;

&lt;p&gt;Examples: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;location&lt;/li&gt;
&lt;li&gt;name&lt;/li&gt;
&lt;li&gt;rank&lt;/li&gt;
&lt;li&gt;time&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Your organization, your project, your content, and your time will have their own peculiarities and requirements, but in broad strokes, you're going to want to look at your data and determine (1) the big picture themes or topics, (2) who comprise the audiences, (3) how you can help them find what they're looking for, and (4) the best way of ordering things on the granular level.&lt;/p&gt;

&lt;p&gt;Here's the first thing I sketched out while thinking this through:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuvea2ku8gpgqrw9g45we.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuvea2ku8gpgqrw9g45we.jpg" alt="Drawing of a happy taco, followed by my initial sketched notes on organizing information in this way, with an example as described in the text below."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's stretch this thing as thin as possible, and divide tacos thematically with separate menus for brunch tacos and dinner tacos, then branch off by audiences, splitting meat tacos from vegetarian and vegan tacos. For convenience, we group all of the optional toppings, then maybe we order them into ranked groups (e.g., guacamole goes in the bonus "add for a $1" group), then internally order the toppings alphabetically. This is a kind of tree that should help anyone find the taco that's to their liking.&lt;/p&gt;

&lt;p&gt;I might organize my information by degree programs, but build the menu by specific student populations, e.g., admitted students, then 1st, 2nd, and 3rd year students. I might privilege information they care most about, like class standing, course information, and exam schedules, or give time-sensitive things like deadlines and upcoming events a prominent place on the landing page. And then, of course, test and iterate.&lt;/p&gt;

&lt;p&gt;And that's how you build a TACO. The ingredients will vary, but process is basically the same.&lt;/p&gt;

&lt;p&gt;And if you want to &lt;em&gt;really&lt;/em&gt; learn something, join me in reading Lisa Marie Martin's excellent &lt;a href="https://abookapart.com/products/everyday-information-architecture" rel="noopener noreferrer"&gt;Everyday Information Architecture&lt;/a&gt; from A Book Apart, which I was reading when this TACO thing took over my brain and made me stop to get it down on paper. I'm about ready to get back into the book, and I hope the next page doesn't explain why my dumb idea is so dumb.&lt;/p&gt;

</description>
      <category>contentstrategy</category>
      <category>ia</category>
      <category>ui</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Relative Font Weights Considered Harmful</title>
      <dc:creator>Den McHenry</dc:creator>
      <pubDate>Sun, 31 Mar 2019 02:25:06 +0000</pubDate>
      <link>https://dev.to/denmch/relative-font-weights-considered-harmful-4f3i</link>
      <guid>https://dev.to/denmch/relative-font-weights-considered-harmful-4f3i</guid>
      <description>&lt;p&gt;Not exactly, but who can resist writing a "considered harmful" article when you can get away with it?&lt;/p&gt;

&lt;p&gt;The real harm is that you can very easily conceal the semantics conveyed by &lt;code&gt;font-weight&lt;/code&gt; depending on the font that's rendered, which is not always in your control. This all depends on how you define the base weight to which your relative values refer, and (1) whether that base weight is actually available in the rendered font and (2) which value is substituted if it isn't.&lt;/p&gt;

&lt;p&gt;So let's unpack that.&lt;/p&gt;

&lt;h2&gt;
  
  
  Font Weight
&lt;/h2&gt;

&lt;p&gt;Font weights are easy to understand when we deal in simple terms like &lt;code&gt;normal&lt;/code&gt; and &lt;code&gt;bold&lt;/code&gt;. Font weight on the web is traditionally a binary, more like &lt;em&gt;bold&lt;/em&gt; and &lt;em&gt;not bold&lt;/em&gt;. But these keywords actually correspond to numerical values and will resolve to another weight if that numerical value is unavailable:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Keyword Declaration&lt;/th&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Numerical Declaration&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;font-weight: normal;&lt;/td&gt;
&lt;td&gt;=&lt;/td&gt;
&lt;td&gt;font-weight: 400;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;font-weight: bold;&lt;/td&gt;
&lt;td&gt;=&lt;/td&gt;
&lt;td&gt;font-weight: 700;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Fonts can come in any one of up to nine weights, numbered in whole hundreds: 100–900. You've doubtless seen fonts with named weights in different contexts, like "thin," "medium," "extra bold," and "black." Each of these would align with one of the nine numbered weights.&lt;/p&gt;

&lt;p&gt;While most fonts only have a small handful of available weights, there are some that run the gamut, all the way from 100 to 900, and this is becoming increasingly common with the ubiquity of webfonts. (This is another problem in itself, bloating sites for users and wasting bandwidth.)&lt;/p&gt;

&lt;h2&gt;
  
  
  1 step forward, X steps back
&lt;/h2&gt;

&lt;p&gt;If the rendered font lacks the corresponding weight, &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight#Common_weight_name_mapping#Fallback_weights" rel="noopener noreferrer"&gt;the browser will select the nearest weight according to a simple algorithm&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;An easy way to think about it is this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;normal&lt;/code&gt; wants to be normal — or at least &lt;em&gt;not bold&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;bold&lt;/code&gt; wants to be bold — or at least &lt;em&gt;not thin&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Normal will err on the side of light, and if bold can't be bold, it will try it's damnedest anyway.&lt;/p&gt;

&lt;p&gt;The range for &lt;code&gt;normal&lt;/code&gt; is 400–500. Anything higher — 600 and up, even though 700 is the sweet spot — is in the &lt;code&gt;bold&lt;/code&gt; range. And while it doesn't have a base name, 100–300 can be considered light.&lt;/p&gt;

&lt;p&gt;For normal text, if the rendered font lacks weight 400, it will go to 500. If that's not available, it really doesn't want to be bold, so it has nowhere to go but down, to 300. And so on. It will go bold if it must, but it wants to be &lt;em&gt;not bold&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Likewise, for bold text, if the rendered font lacks weight 700, it will err on the side of boldness: 800, then 900, and then it will drop its shoulders in resignation and work backwards taking the first available weight that is the &lt;em&gt;least light&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;That's all well and good. But what happens with the relative keywords, &lt;code&gt;lighter&lt;/code&gt; and &lt;code&gt;bolder&lt;/code&gt;, and why do I tease that they're "considered harmful?"&lt;/p&gt;

&lt;h2&gt;
  
  
  Be careful what you ask for
&lt;/h2&gt;

&lt;p&gt;Let's say you ask for a specific weight in your CSS file:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;p {
    font-weight: 300;
}
p strong {
    font-weight: stronger;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This may seem like an unfair example, but things like this happen, and you'd be excused for thinking that &lt;code&gt;strong&lt;/code&gt; text would be appear bolder than the rest of the paragraph.&lt;/p&gt;

&lt;p&gt;It &lt;em&gt;would&lt;/em&gt; appear stronger if the rendered font had 300 available along with any stronger weight. But what if it doesn't?&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;lighter&lt;/code&gt; and &lt;code&gt;bolder&lt;/code&gt; keywords &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight#Meaning_of_relative_weights" rel="noopener noreferrer"&gt;respond to the inherited weight&lt;/a&gt;, and can resolve to 100, 400, 700, or 900 depending on the declared weight. So, for example, our example with a paragraph of &lt;code&gt;font-weight: 300&lt;/code&gt; containing a &lt;code&gt;strong&lt;/code&gt; element with &lt;code&gt;font-weight: bolder;&lt;/code&gt; is the same as the following:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;p {
    font-weight: 300;
}    
p strong {
    font-weight: 400;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;But if we change the &lt;code&gt;300&lt;/code&gt; to &lt;code&gt;400&lt;/code&gt;, then &lt;code&gt;bolder&lt;/code&gt; becomes equivalent to &lt;code&gt;700&lt;/code&gt;. That's not something you'd ever want to keep track of and certainly something you'd never be able to keep up with.&lt;/p&gt;

&lt;p&gt;But let's say you go ahead and define your font-weight at 300, and it isn't available. The text will render at the nearest available weight according to the selection algorithm. If the rendered font is Arial on a common Windows machine, then the available weight is probably 500. The &lt;code&gt;strong&lt;/code&gt; declaration of &lt;code&gt;bolder&lt;/code&gt; means "bolder than 300", and thus "400", but it, too, will render at 500, following the defined algorithm for resolving available font weights.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;p {
    font-weight: 300; /* Unavailable: Resolves to 500 */
}    
p strong {
    font-weight: 400; /* Unavailable: Resolves to 500 */
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In this case, the visual semantics are lost.&lt;/p&gt;


&lt;p&gt;So if that matters to you (and it should), then tread carefully here. At the very least, you want to be very thoughtful about choosing weights for web fonts, and how well your weight declarations will fall back in their absence.&lt;br&gt;&lt;br&gt;
&lt;/p&gt;

&lt;small&gt;Photo by &lt;a href="https://unsplash.com/photos/Oxl_KBNqxGA?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Natalia Y&lt;/a&gt; on &lt;a href="/search/photos/fonts?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;/small&gt;

</description>
      <category>css</category>
      <category>typography</category>
      <category>fonts</category>
    </item>
    <item>
      <title>Falsy Values are N0 FUN!</title>
      <dc:creator>Den McHenry</dc:creator>
      <pubDate>Fri, 13 Apr 2018 18:05:58 +0000</pubDate>
      <link>https://dev.to/denmch/falsy-values-are-n0-fun-1k90</link>
      <guid>https://dev.to/denmch/falsy-values-are-n0-fun-1k90</guid>
      <description>&lt;p&gt;When I was a Latin teacher, I used to love coming up with mnemonic devices to help students remember novel or difficult things, like the order of the Roman kings, or the endings of verbs. But as I think about it, it's a technique I use for myself all the time.&lt;/p&gt;

&lt;p&gt;Example: I just came up with a simple mnemonic device to remember the &lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Falsy"&gt;falsy values&lt;/a&gt; in JavaScript.&lt;/p&gt;

&lt;h2&gt;
  
  
  falsy values == N0 FUN
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;N0:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;NaN&lt;/li&gt;
&lt;li&gt;0 or -0 or "" (empty string, i.e., String.length === 0)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;FUN:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;false&lt;/li&gt;
&lt;li&gt;undefined&lt;/li&gt;
&lt;li&gt;null&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, this doesn't mean that YOU can't enjoy falsy values. You may think they're just as &lt;a href="https://www.youtube.com/watch?v=cRpdIrq7Rbo"&gt;fun, fun, fun, fun, FUN! as kazoo&lt;/a&gt;, but just as &lt;strong&gt;Every Good Boy""&lt;/strong&gt; &lt;em&gt;doesn't necessarily&lt;/em&gt; &lt;strong&gt;Do Fine&lt;/strong&gt;, remember: &lt;strong&gt;falsy values are N0 FUN.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>tips</category>
      <category>learning</category>
    </item>
    <item>
      <title>Relative URLs Desmystified</title>
      <dc:creator>Den McHenry</dc:creator>
      <pubDate>Mon, 02 Apr 2018 04:31:29 +0000</pubDate>
      <link>https://dev.to/denmch/relative-urls-desmystified-498b</link>
      <guid>https://dev.to/denmch/relative-urls-desmystified-498b</guid>
      <description>&lt;p&gt;The first key to really understanding relative URLs is to recognize that they refer to the current URL and do not reflect the actual folder structure on disk. The notation used is analogous to file navigation, but in this context you're not traversing the physical structure: the browser constructs the new URL from the current URL value using a simple but surprisingly robust set of symbolic notation.&lt;/p&gt;

&lt;p&gt;Let's take a look at a handy table, and then I'll dig in. There are exactly four distinct symbols with very precise meanings:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Symbol&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;th&gt;Notes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Root&lt;/td&gt;
&lt;td&gt;up to base URL&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;//&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Protocol&lt;/td&gt;
&lt;td&gt;to be avoided&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;./&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Current dir.&lt;/td&gt;
&lt;td&gt;alias: no slash&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;../&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Parent&lt;/td&gt;
&lt;td&gt;may be combined&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;These symbols are composed of just slashes and dots, singly or in pairs. It may seem confusing at first, but the first three are constant and can not be combined. The last one, with two dots, can be combined, as we'll see below.&lt;/p&gt;

&lt;h2&gt;
  
  
  2 Slash or Not 2 Slash?
&lt;/h2&gt;

&lt;p&gt;The simplest way to conceptualize the double slash and the single slash in relative URL notation is to recognize that the base URL is the kernel, and to think of the double slash and single slash as something like bookends. One separates the base URL from its protocol, and the other separates it from its subpages and directories:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Protocol&lt;/th&gt;
&lt;th&gt;delimiter&lt;/th&gt;
&lt;th&gt;base url&lt;/th&gt;
&lt;th&gt;delimiter&lt;/th&gt;
&lt;th&gt;subpages, &amp;amp;c.&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;https:&lt;/td&gt;
&lt;td&gt;//&lt;/td&gt;
&lt;td&gt;dev.to&lt;/td&gt;
&lt;td&gt;/&lt;/td&gt;
&lt;td&gt;denmch&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The double slash will tell the browser to build a URL from just before the base URL, going back to the protocol. The single slash by itself tells the browser to construct a URL from just after the base URL, at the level of subpages and directories.&lt;/p&gt;

&lt;p&gt;Given the URL &lt;code&gt;https://dev.to/denmch&lt;/code&gt;, double slash (&lt;code&gt;//&lt;/code&gt;) is shorthand for &lt;code&gt;https://&lt;/code&gt; and single slash (&lt;code&gt;/&lt;/code&gt;) is shorthand for &lt;code&gt;https://dev.to/&lt;/code&gt;, quite literally telling the browser to begin at this or that distinct delimiter.&lt;/p&gt;

&lt;h2&gt;
  
  
  Protocol Considered Harmful
&lt;/h2&gt;

&lt;p&gt;You've doubtless linked to or at least seen external resources without a stated protocol (&lt;code&gt;http:&lt;/code&gt; or &lt;code&gt;https:&lt;/code&gt;), using a url of the form &lt;code&gt;//path-to.my/script.js&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This seemed just dandy for awhile, but it's now &lt;a href="https://www.paulirish.com/2010/the-protocol-relative-url/"&gt;considered an anti-pattern and potentially exposes vulnerabilities&lt;/a&gt;. Even though it's probably best avoided, it's good to know why it works the way it does, and it helps us to gain a deeper understanding of how relative URL notation really works, especially since it's still found out there in the wild (even if we should avoid it).&lt;/p&gt;

&lt;h2&gt;
  
  
  Dot Dot's my father's name; call me Dot
&lt;/h2&gt;

&lt;p&gt;Whereas slashes by themselves refer to the bookends around the &lt;strong&gt;base URL&lt;/strong&gt;, &lt;em&gt;single slashes in combination with dots&lt;/em&gt; refer to the full &lt;strong&gt;current URL&lt;/strong&gt; and move from right to left.&lt;/p&gt;

&lt;p&gt;Dot qualifiers tell the browser that &lt;em&gt;this&lt;/em&gt; slash is &lt;em&gt;not&lt;/em&gt; root. Semantically, a single dot followed by a slash (&lt;code&gt;./&lt;/code&gt;) means "start from the current directory." The &lt;code&gt;./&lt;/code&gt; symbol will never be found in any other combination (e.g., &lt;code&gt;.././&lt;/code&gt; would be invalid).&lt;/p&gt;

&lt;p&gt;A double dot followed by a slash means "start one directory up," and this pattern can be compounded to traverse leftward in the current URL, so that &lt;code&gt;../&lt;/code&gt; references the parent of the current directory and &lt;code&gt;../../&lt;/code&gt; references the parent of the parent, and so on.&lt;/p&gt;

&lt;p&gt;If the relative URL references more "generations" than the current URL contains, the new resulting URL will start only as far back as it can: at the base URL:&lt;/p&gt;

&lt;p&gt;Given the URL &lt;code&gt;https://dev.to/denmch&lt;/code&gt;, the following patterns all go back to the base URL (&lt;code&gt;https://dev.to&lt;/code&gt;) because there are no parent directories to extrapolate from the current URL:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;../../../&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;../../&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;../&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The last important bit is to recognize that &lt;code&gt;./&lt;/code&gt; has an alias: beginning a relative URL with neither dots nor slashes. Given the current URL &lt;code&gt;https://dev.to/&lt;/code&gt;, a relative url of the form &lt;code&gt;href="denmch"&lt;/code&gt; would be functionally equivalent to &lt;code&gt;href="./denmch"&lt;/code&gt; and result in a final URL of &lt;code&gt;https://dev.to/denmch&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now it's up to you do decide when and where it makes sense to use relative URLs, and hopefully you're better equipped to think it through and understand problems and potential problems as they arise.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>devtips</category>
      <category>webdev</category>
      <category>urls</category>
    </item>
    <item>
      <title>Ch-Ch-Changes: to shell and back</title>
      <dc:creator>Den McHenry</dc:creator>
      <pubDate>Sat, 31 Mar 2018 14:23:36 +0000</pubDate>
      <link>https://dev.to/denmch/ch-ch-changes-to-shell-and-back-nnb</link>
      <guid>https://dev.to/denmch/ch-ch-changes-to-shell-and-back-nnb</guid>
      <description>&lt;p&gt;I hadn't gotten around to reading &lt;a href="https://abookapart.com/products/working-the-command-line"&gt;Remy Sharp's command line book&lt;/a&gt; yet, so I bought his &lt;a href="https://terminal.training/"&gt;terminal training course&lt;/a&gt; when he put it on a flash sale. One of the new things he introduced me to there was changing my terminal's shell, and though he uses zsh (and gets to that next), he starts you with something I've never seen, but that's really cool: fish.&lt;/p&gt;

&lt;p&gt;First, let's get one thing squared away: what's a terminal and what's a shell?&lt;/p&gt;

&lt;h2&gt;
  
  
  I never metaphor I didn't like
&lt;/h2&gt;

&lt;p&gt;Once upon a time, a terminal was a physical device — a literal end point at which a human interacted with a machine. A synonym you'll sometimes see is TTY, short for TeleType, which was a kind of typewriter that could send input by typing commands line-by-line and receive printed output. (It's also called a teleprinter, for obvious reasons.) This is the origin of the command line interface (CLI).&lt;/p&gt;

&lt;p&gt;Today, we mostly use graphical user interfaces (GUIs), and so we need a program to emulate the TeleType of yore. This is what we call a terminal, no longer a physical device but just another software package running on our personal computers. If you're on a Mac, the default terminal application is called Terminal, but many people prefer an alternative like iTerm2. On Linux you might use something like Gnome-Terminal or Konsole. You have choices when it comes to terminals, and you can customize their appearance and behavior.&lt;/p&gt;

&lt;h2&gt;
  
  
  The shell game
&lt;/h2&gt;

&lt;p&gt;The shell is a little tricky to understand only because the metaphor that produces it's name comes from its relation to the operating system and not to the user. The core of an operating system is what controls and interacts with the hardware. That core portion of the operating system is called the kernel, by analogy with the soft, chewable bit within the hard shell of a nut.&lt;/p&gt;

&lt;p&gt;By analogy again, then, the shell should be synonymous with the physical terminal. But this is where the analogy breaks down. We don't use the shell to get to the tasty, edible bits of the nut. We strip it away and toss it in the compost. But here, with computers, we rely on the shell entirely and never actually touch the kernel.&lt;/p&gt;

&lt;p&gt;The terminal is now the application that gets you talking to the machine — a program emulating a TeleType — and the shell is how you talk to it, a specific flavor of a command line interpreter, that facilitates your ability to send commands and receive feedback with varying levels of help and customizability. You can think of the terminal like a guitar and the shell like the strings, which can come in a variety of materials and gauges, sometimes tuned in exotic ways. One shell is a common bronze alloy, while another is nylon, and another is silk and steel. They feel and play differently, but they all make music in the same way.&lt;/p&gt;

&lt;h2&gt;
  
  
  z sells z shells by the z shore
&lt;/h2&gt;

&lt;p&gt;The most common shell is bash, but there are others like ksh, zsh, and others. Notice that they tend to end with sh, for shell. And we sure do love to abbreviate things when on the command line, like ch in the title of this post. But we're getting to that. Shells differ in details like whether you can group commands, how variables are set, and whether or not they support tab completion of typed commands.&lt;/p&gt;

&lt;p&gt;Remy introduces fish, an exotic shell with tab completion, as a good starter shell, though he personally uses zsh. I'd only ever used bash, so fish was very weird and different, and the tab completion was especially cool, like working in Visual Studio with Intellisense.&lt;/p&gt;

&lt;p&gt;But one issue I had was this: how do I get back to the land of bash?&lt;/p&gt;

&lt;h2&gt;
  
  
  Ch-ch-changes
&lt;/h2&gt;

&lt;p&gt;Following the fish installer, you're told to run a certain command to switch your shell, and Remy didn't go into detail here, but it's worth looking at the command:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chsh -s /usr/local/bin/fish
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The command &lt;code&gt;chsh&lt;/code&gt; means "change shell," just as &lt;code&gt;chown&lt;/code&gt; allows you to change the owner of a file or directory, and &lt;code&gt;chmod&lt;/code&gt; allows you to change the read, write, execute permissions for the current user, the group, and for others.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;-s&lt;/code&gt; option lets you enter that location without any additional prompting or file opening. So the command above says, "change my shell to the shell in /usr/local/bin/fish."&lt;/p&gt;

&lt;p&gt;&lt;code&gt;chsh&lt;/code&gt; actually calls the same program as two other &lt;code&gt;ch&lt;/code&gt;-prefixed commands: &lt;code&gt;chfn&lt;/code&gt;, or "change finger," and &lt;code&gt;chpass&lt;/code&gt;, or "change password." This program allows you to change user database information, like your full name, office location, phone numbers, and, most importantly for this purpose, for the location of your preferred shell, and it doesn't matter which you use. It's just easier to remember that &lt;code&gt;chsh&lt;/code&gt; is for changing the shell, and if you want to get it done without editing a file in vim, throw it up in one line with the &lt;code&gt;-s&lt;/code&gt; option and the shell location.&lt;/p&gt;

&lt;p&gt;So once you've switched to fish, if you want to change back, you just need to know the location of bash, which should be simple:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chsh -s /bin/bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;And from there, you can try others in the same fashion.&lt;/p&gt;

&lt;p&gt;So that's that: a long-winded way to get around to switching back to bash from fish. I've always found it helpful to dig into what the commands actually mean to understand them and retain what they do. So now I know more about it, and maybe you do, too.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>bash</category>
      <category>terminal</category>
      <category>devtips</category>
    </item>
    <item>
      <title>Using the Wordnik API</title>
      <dc:creator>Den McHenry</dc:creator>
      <pubDate>Tue, 20 Feb 2018 19:38:30 +0000</pubDate>
      <link>https://dev.to/denmch/using-the-wordnik-api-2chj</link>
      <guid>https://dev.to/denmch/using-the-wordnik-api-2chj</guid>
      <description>&lt;p&gt;One thing I've finally learned is that whether you're running bash or zsh in your terminal, the file where you customize your instance ends with &lt;code&gt;rc&lt;/code&gt;, which stands for "runcom," or "run commands," dating way back to 1965 in the early days of UNIX. &lt;code&gt;.bashrc&lt;/code&gt; is the file that contains commands to be run when the bourne again shell (bash) starts up, and &lt;code&gt;.zshrc&lt;/code&gt; has the commands to be run when the z shell (zsh) starts up. And you'll find it elsewhere, for example in &lt;code&gt;.vimrc&lt;/code&gt; if you're into Vim.&lt;/p&gt;

&lt;p&gt;One of the really cool things you can do here is reference environment variables, aliases, and functions stored in external files. So I wrote the following function using the &lt;a href="http://developer.wordnik.com/"&gt;Wordnik API&lt;/a&gt; so I can quickly define words on the command line.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;If you don't know &lt;a href="http://wordnik.com/"&gt;Wordnik&lt;/a&gt;, you should check it out. It's a great site, and when my confirmation email didn't come through Erin McKean quickly responded herself and activated my account, which felt pretty cool.&lt;/p&gt;

&lt;p&gt;The function works like a shell command and can take an argument, which is represented within the function as &lt;code&gt;$@&lt;/code&gt;. This grabs any and all positional parameters, e.g., if the command takes three parameters, they'd be referenced as &lt;code&gt;$1&lt;/code&gt;, &lt;code&gt;$2&lt;/code&gt;, &lt;code&gt;$3&lt;/code&gt;. So &lt;code&gt;$@&lt;/code&gt; just takes one after the other and passes them all in. The local variables &lt;code&gt;params&lt;/code&gt; and &lt;code&gt;params_encoded&lt;/code&gt; turn it into a URL-encode string by replacing the spaces between parameters with &lt;code&gt;%20&lt;/code&gt; so that the result work &lt;code&gt;curl&lt;/code&gt; talks to the server.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;curl&lt;/code&gt; command is one of those that you find all over the web in places like StackOverflow, where people say, "Just type curl blah bitty blah blah." It's just one of those things that you use to do something. But as often happens, it turns out to be helpful to know what the name means, so that you can retain the meaning. In this case, its name is styled cURL, like the ubiquitous acronym URL. It's written in C and though originally meant to be pronounced "see URL," it was later treated as a backronym for "cURL URL Request Library," as the creator described on cURL's 17th birthday. (As of this writing cURL is nearing 20!)&lt;/p&gt;

&lt;p&gt;Knowing that history we remember either that cURL allows us to "see" stuff at a given URL, or that it's a library written in C used to request information from and about URLs.&lt;/p&gt;

&lt;p&gt;We run &lt;code&gt;curl&lt;/code&gt; with a &lt;code&gt;--silent&lt;/code&gt; option. If you were typing this a lot on the command line, it'd be faster to use &lt;code&gt;-s&lt;/code&gt;, but for the purposes of a readable gist, it seems beneficial to type out the option, explaining clearly that we want our &lt;code&gt;curl&lt;/code&gt; output to be silent, i.e., to not show us the progress bar, etc. To get a result, you need to add your Wordnik API key (I've added mine as an environment variable sourced in my &lt;code&gt;.zshrc&lt;/code&gt; file).&lt;/p&gt;

&lt;p&gt;We pipe the output through &lt;code&gt;json&lt;/code&gt; with the &lt;code&gt;--array&lt;/code&gt; option (aka &lt;code&gt;-a&lt;/code&gt;), and the lookup parameter &lt;code&gt;text&lt;/code&gt;, which is the key that should grab each definition in the JSON results from Wordnik.&lt;/p&gt;

&lt;p&gt;These results are then piped to &lt;code&gt;cat&lt;/code&gt; with the &lt;code&gt;-b&lt;/code&gt; option, which numbers non-blank lines in returned results. I'm not sure the &lt;code&gt;-b&lt;/code&gt; options is necessary given the results (&lt;code&gt;-n&lt;/code&gt; could be sufficient), but it doesn't hurt.&lt;/p&gt;

&lt;p&gt;So just for fun, here's the result, with the added bonus of piping the output to &lt;code&gt;cowsay -f stegosaurus&lt;/code&gt; (where the &lt;code&gt;-f&lt;/code&gt; option is short for "file", i.e., which "cowfile" is used for the ASCII art).&lt;/p&gt;

&lt;p&gt;&lt;code&gt;def learning | cowsay -f stegosaurus&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--McALZhsD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://denmchenry.com/img/stegosaurus-def.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--McALZhsD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://denmchenry.com/img/stegosaurus-def.png" alt="An screenshot of a terminal window showing ASCII art of a stegosaurus speaking three definitions of the word learning."&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>shell</category>
      <category>curl</category>
      <category>api</category>
    </item>
  </channel>
</rss>
