This creates a new Liquid tag, {% music %}
, which can be inserted in page templates.
I added it to my footer.html
after the byline, timestamp, and categories.
The tag checks whether the post’s YAML front-matter has data for a musician and a track name.
If the post has that data, the plugin attempts to create a link to the iTunes Store for the given track.
With makeItunesTarget()
it puts together a URL that is a query to the iTunes Store Search API, with getFromItunes()
it loads the query URL and hands off the response to the standard library’s JSON parser, and with makeAnchorFromItunesData()
it takes the first search result and generates text to use for an <a>
tag and a URL to use for the tag’s href
attribute (if you have an affiliate code for the iTunes store, it’ll be inserted).
Finally, there’s a convenience function, getMusic()
, that just composes the previous three.
Part of why this worked well is that it’s another project with limited scope: I had a specific objective in mind, so I was able to keep moving gradually towards it. However, that limited scope was a way of making progress towards the broad goal of “learn Ruby” and also took on the medium-scope goal of “learn the iTunes Store Search API.” As a practical matter, learning to work with other people’s APIs, whether they’re libraries, services, or daemons, is an important skill for a working programmer; toy projects that include cultivating that skill are good uses of my time. Learning new languages is also a career-long thing: for all the talk of Lisp being “the hundred-year language,” no-one now working as a programmer will be programming in just one language for the rest of their days. There are shell scripts and libraries and wrappers: there is a fragmented world that despite the friction of fragmentation, would not actually be better-served by a language monoculture. In addition, there are plenty of exciting things out there whose roots are in Ruby, so I was enthusiastic about picking up a smattering of Ruby.
I’m definitely fond of Ruby so far.
Part of this is because I’m getting to the point where I’m seeing parallels with other languages and able to make good guesses about how a new language will behave.
I was able to guess from reading source “oh okay, Ruby is one of the languages where the return value of a function, if not explicit, is the value of the last statement evaluated in its body,” was pleasantly surprised that it has the same tuple-packing return-multiple-values feature as Python, and noticed “oh hey neat, there’s a Scheme-like function!()
naming convention for functions that mutate their parameters.”
So that’s all good stuff.
Part of choosing Ruby, too, is that I’m currently blogulating via Octopress, which is built on Ruby. Most of why I chose it is that Wordpress is awful (on the axes I care about), but now that I’ve chosen it, I want to have a grasp of how it works. That means learning Ruby and tinkering—which I’m looking forward to.
As a supplemental note, if this stuff sounds to you like a good attitude for a programmer to have, you should hire me.
]]>Liquid Exception: Unknown tag 'endif' in page
is Liquid’s way of saying “you forgot to start that if-block, girl”, I learned that my past self had very different priorities.
Not that this is news: as I’ve gotten older, I’ve gotten better at forgiving my past self for her fuckups.
It’s still hard to forgive her eating habits, but bodies are complicated.
I was surprised, though, to learn that she was conflicted about whether to be a developer or a sysadmin.
Seriously?
It’s not a binary: pretty much the whole subfield of devops is people who’re making interesting choices about “what if I pick things from both skillsets?”
While I now think of myself as an engineer in general, not a sysadin or a developer, I am very happy that I am picking up bits and pieces of CS theory and that I can still read Apache config files, whip up basic Perl one-liners, and be on speaking terms with vim
.
I admire the dedicated systems team at my work, but their job is not the job I want to do. I want to build things. That’s gotten more and more important to me over time — the thrill of green-field development, of Something from Nothing, is one I want, over and over. Lucky me: I am getting better and better at producing that experience for myself and making useful things along the way.
]]>