Saturday, February 9, 2013

Eric Explains URLs (video)

I'm teaching a course entitled "The Nature of Knowledge" and we're specifically focusing on what happens to knowledge in a digitized, networked environment. I gave the class a "technology inventory" survey to complete and the hardest question on it proved to be identifying the top-level domain of a given URL. As such, I made this video to explain URLs a little bit more in-depth.



Weaknesses

I didn't do a particularly good job of explaining a few things in this video. I want to make it clear that it's not a flawless intro. Hopefully I can remake it sometime, but for now here are some caveats:

  • What does a scheme mean? I introduce two of them but don't describe their implications, i.e. that they're transfer protocols.
  • Subdomains are basically everything in the domain that's not the TLD. I don't think that's clear from my example.
  • Search can literally be a file, e.g. search.php, search.html, search.pdf (though that wouldn't have a query string). I know that the idea of URLs pointing to files is mostly an antiquated idea in the days of database-driven CMSs & web frameworks like Ruby on Rails. But it's a good starting point to learn more about them.
  • Google is a bad example. I knew that but I didn't realize quite how poor, because Google doesn't use a ? to distinguish the query string, oddly enough, so a Google search actually contradicts how I'm describing a query string.

Anything I missed? Open to criticism but I hope this is a decent overview despite its flaws.

Also, I have a git repo of the site I made to demonstrate the different pieces, totally willing to share if someone wants it.

Tuesday, January 29, 2013

A Block to the Head (in Drupal 7)

This is going to be a super specific & technical post, because it took me way too long to figure out how to do this & someone else could probably stand to benefit from it. For the tl;dr skip to the code section.

The Scenario

In general, the <head> of your HTML document is not editable in Drupal. The <title> changes to reflect what page you're on, sure, & tags are added or removed by modules frequently, but you can't tweak the markup in the same way you can the contents of a block or main content. For the most part, that's fine; 90% of the <head> should stay the same from page to page, such as site styles & must-have <meta> tags like viewport. If you need to change something site-wide, that can be done through theme templates. But sometimes that's not enough; what if I want to add different <meta> tags to different pages? Or load variegated builds of Modernizr on variegated pages? Or use a special font on a set of pages? There are numerous reasons why you might want a specific subset of pages to have a bit of custom markup; in short, you want to put one of Drupal's blocks in the document's <head>. Without further ado, here's how you do that.

The Code

In yourtheme.info, find the list of regions & add one for your new <head> region:
regions[html_head] = HTML Head
The name that you'll use in the code has to be a valid PHP variable name, so no spaces.

In your theme's template.php, add the following to the yourtheme_preprocess_html function:
$variables[ 'html_head' ] = block_get_blocks_by_region( 'html_head' );
If you're using a subtheme without a template.php, you can create it & write the function like this:
function mastertheme_subtheme_preprocess_html(&$variables) {
  /* so that html_head is available in html.tpl.php */
  $variables[ 'html_head' ] = block_get_blocks_by_region( 'html_head' );
}

In html.tpl.php, your theme's HTML template, find the spot where you want the block's markup to be inserted & add:
<?php if ( $html_head ): ?>
  <?php print render( $html_head ); ?>
<?php endif; ?>
If you're using a subtheme where html.tpl.php doesn't exist, copy the master theme's html.tpl.php into the templates directory & then add the above.

Right now, that would be enough to insert some code into the <head> but the code will likely be wrapped in problematic tags that don't belong in the <head> like <div> & <section>. To get rid of that junk, we create a new region-specific block template that only prints out the contents of the block & nothing else. Create a block--html-head.tpl.php file & put it in the templates directory with the following line as its only contents:
<?php print $content; ?>
Now clear the cache & add a block to the new region; it should appear in your site's <head>.

If you've named your block something other than "html_head" then you'll need to change the references throughout, but this should work for any Drupal 7 site. Note that if you rename a region (or perhaps otherwise screw with its templates? not entirely clear to me), all the blocks you had previously assigned to it become unassigned. That was what wasted the majority of my time; I couldn't understand why my block wasn't showing up when the $html_head variable should have been available but the block had been unassigned during my shenanigans.

The References

The Drupal Answers thread Printing regions in html.tpl.php provided most of the special sauce for this one, specifically the idea to store the return value of block_get_blocks_by_region in a variable that's accessible later when html.tpl.php runs.
The template_preprocess_html, block_get_blocks_by_region, & html.tpl.php API documents all provide useful reference material.
Lastly, the drupal_add_html_head function appears to provide another avenue to the same destination. However, it's much more convenient to store markup in a block. I also want to write straight HTML & not Drupal's weird "renderable array" content, which is what the function takes as a parameter.

Saturday, January 12, 2013

Openness as an Excuse

I briefly, and somewhat poorly in my own opinion, tried to explain how the openness of the Code4Lib community was being used as an argument against anonymous proposal voting. Well, the latest First Monday has an article titled "'Free as in Sexist?' Free Culture and the Gender Gap" wherein Joseph Reagle makes my point in a far more articulate manner:

At first, the claim that community openness can contribute to a gender gap seems nonsensical as there are no formal restrictions on participation. However, as Freeman (1996) argued, implicit structures and dynamics still exist in the absence of formal ones. For example, a computer science department may not have an exclusionary policy towards female students, but privileging a narrow and obsessive focus might miss female candidates. Similarly, while some might argue any effort to block problematic users is a step away from openness, a chaotic culture of undisciplined vandals would equally disenfranchise those who wish to make a positive contribution [12]. Hence, following Freeman, one might distinguish between formal and informal forms of discrimination. While an open community does not formally discriminate, alienating behavior can still manifest from difficult people and sexist behavior.
The article goes much further (this is just the introductory paragraph of the section that discusses this phenomenon).

Philosophical Digression

To me, using the innate value of openness as an excuse to avoid something empirically proven to increase participation from marginalized groups is a specifically ethical failure. It comes from a deontological stance, as if some spurious and undefined essence of openness is more important than the effects of a particular instance of openness. The antithesis to deontology is consequentialism, which argues that an act's value lies only in its effects or consequences. There is no such thing as innate value.

The article's reference to blocking problematic users is particularly apt; I just finished reading a book on Wikipedia which discusses how Wikipedia's ideal of "the encyclopedia anyone can edit" is worth sacrificing precisely in such a situation. The world's most open encyclopedia blocks users and is better for it. An open community can have a closed sub-community support group and be better for it as well.

Wednesday, December 26, 2012

Top 10 Albums of 2012

For the last few years I've written top ten lists of my favorite music. While I usually keep this blog focused on the web and librarianship, I'm going to detour for this post and relate my 2012 favorites. Back to your regularly scheduled programming in the new year.
cover of the Kindred EP
  1. Kindred / Burial - Anthemic electronica from the best dubstep producer ever. After Kindred came out, I listened to nothing else for a week. Burial shifts focus a bit, selecting sub-bass & texture over the usual manipulated vocal samples & rimshot snares. It's such a gray album. Music for long drives, rainy days, loneliness. At three songs, it's technically an EP, but together they stretch over a half-hour.
  2. Kings and Them / Evian Christ - I stumbled across "Fuck it none of y'all don't rap" on a blog & was instantly blown away. Evian Christ made the most sophisticated album of the year out of a single rap song's worth of vocals, tinny snares, & haunted minor intervals. The hyper-repetitive raps (let's repeat the word "back" for a minute, shall we?), vocal pitch-shifts, & eery background dissonance of wind chimes somehow come close to a mixture of Salem & Dälek, but with a better sonic sensibility. Christ's beats are simple but deeply enmeshed with the vocal samples & mood. The album feels idiot savant in its execution, putting together repetition & atmosphere in a way that the idiots somehow missed.
  3. Quakers / Quakers - I admit it, other than Guilty Simpson, I haven't heard of any of these rappers. This is always already the best album of rappers you've never heard. This album is like twenty Busdrivers on top of twenty MadLibs just fucking killing it. The brevity of the tracks actually makes it easier to digest such incredible variance in beats & voices. I cannot understand how good Quakers is.
    cover of the Shrines album
  4. Shrines / Purity Ring - Electro-pop without too many frills. The music is synth-heavy, its only distinguishing element the occasional staccato vocal samples. But the lyrics & singing are spot on: a mousey female voice sweetly reciting disturbing lines like "cut open my sternum & pull my little ribs around you." The bodily lyrics & voice-in-the-machine production combine to make a stunningly consistent album where every other song is perfect.
  5. The Seer / Swans - When I discovered Swans last year, I promptly listened to their entire back catalog. Their impressive trajectory (from brutal industrial to something resembling art rock) is complete with The Seer, which is epic noise rock on an almost unparalleled scale. Despite a two-hour runtime, the music never drones on too long. The scraping metal of 93 Ave. B Blues becomes atmospheric ballad The Daughter Brings the Water. The title track could stand to be its own album.
  6. Sorrow and Extinction / Pallbearer - metal is at its best when it is unapologetically bleak. Pallbearer's debut album lives up to its title, as huge, molten sludge buries some faint, rare vocals. The album accomplishes a rare combination of consistent atmosphere & heavy riffs. Good black metal typically relies on atmosphere, rarely displaying interesting guitar riffs such that their music begins to drone on repetitively. More riff-based metal, such as Torche, often has captivating guitars but without the gravity of black metal's atmosphere. Pallbearer combine both effortlessly, making almost the entire album (with the exception of the first few minutes of acoustic guitar, unfortunately) compelling.
  7. WIXIW / Liars - An album that grew on me quickly. I think the idea of an electronica Liars album turned me off, but the truth is this album is little more synthetic than the unsurpassable Drum's Not Dead. The better songs (Flood to Flood, Brats) are near the end. Liars took their strong but scattered album about Los Angeles depravity (Sisterworld, which reminds me of Hail to the Thief in that the songs are excellent individually but fail to amount to much in sum) & remade it. The wreckless songs & the redemptive ones both shine brighter now.
  8. G is for Deep / Doseone - This album also disappointed me on first listen, not because it was bad but because Doseone has entirely eschewed rapping. I became obsessed with Dose because of his raps; he's one of those rare rappers who not only has unparalleled skill but also a unique artistic vision. His lyrics are closer to poetry than braggadocio. G is for Deep has its occasional bits of rap—mostly quick refrains, rarely full verses–but for the most part Doseone sings. However, the music is solid (much of it reminds me of bright synths of Radiohead's "Worrywort" b-side), the lyrics surprisingly catchy (the "Last Life" chorus gets stuck in my head easily), & Doseone frequently uses mini-song outros to great effect. These outros aren't completely new fare for him–Subtle's "The Mercury Craze" single features a commercial jingle parody as it fades out. But on G they're more essential, in fact they're often the highlight of the songs.
    cover of the Visions album
  9. Visions / Grimes - Grimes is weird. Her songs almost ring as normal electropop & she tends to (convincingly) imitate R&B diva melismas. But there's all this inexplicable zaniness: why is the album cover heavy metal artwork? what the hell is going on in the Genesis music video? what are the lyrics to any of these songs? Visions strides the line between pop catchiness & alienating oddity in a way few others can match.
  10. Held / Holy Other - the "With U" EP blew me away with its lonely trances. It felt like Burial but from another angle: slower, breathy, codeine-dependent. Held didn't quite live up to the EP's promise but it's still very good & remarkably consistent; each song maintains the same emotive thrill without wearing the listener out.

Honorable Mentions

Advaitic Songs / Om
Years Past Matter / Krallice
My Story / Volor Flex
Empyrean / Mutilation Rites
R.I.P. / Actress

Wednesday, December 5, 2012

In Defense of Anonymous Proposals

Recently, the Code4Lib community has been working to write an anti-harassment policy and combat gender discrimination. One proposal (full credit: coming from JSConf EU's excellent strategy for increasing diversity, which I in turn learned of from the ever-vigilant Andromeda Yelton) was to have anonymous conference proposals but it was quickly shot down on the C4L listserv. I don't mean to pick on C4L but I wanted to discuss briefly why I think that's a mistake.

Anonymous proposals aren't just one measure among others to increase diversity, they're vital. JSConf EU notes "This is crucial. Even if you don’t think you are biasing against anything or anyone, unless you anonymise CFP submissions, you will apply your personal bias." (emphasis in original) Why? Anonymous proposals circumvent most of the latent biases we all have: gender, race, culture, etc. are difficult to determine from an abstract. What's more, underrepresented parties are more likely to submit without fear of judgement or judgement's liberal sibling, tokenization. Anonymization shields selectors from their biases and proposals from discrimination.

The Counter Arguments

Few people disagree that anonymous proposals have benefits. But do their benefits outweigh their disadvantages? Anonymity's detractors tend to argue that knowing someone aids in evaluating speaker quality. I find that more of an excuse to reify bias than a legitimate contention. To run down the list:

A) Obviously implicit bias is still at play,
B) The subset of people you know or have seen speak echoes previous biases–if a disproportionate number of men tend to speak at Code4Lib, then the people you've seen speak is going to be disproportionately male and thus your supposedly informed selections make for a poor representation of the full community,
C) If you know someone but haven't seen them speak, you may be inclined to vote for your friends and not necessarily on quality.

It was also mentioned that anonymous proposals go against the "openness" of Code4Lib. But the end result of openness is more important than some deontological essence attached to our actions; if openness in this instance supports bias, then we should be closed. In some ways, one can be more "open" when anonymous than when afraid of discrimination. Also, my identity as a voter is not revealed; how come that is not considered a threat to the openness of the community? Anonymous proposals do not damage openness if they allow a more representative population of a community to present.

All this said, are anonymous proposals always the right choice? Maybe not. I'm part of a conference planning committee that isn't evaluating talks anonymously. I'm not entirely clear why but we did at least discuss it. You wouldn't want to select keynotes anonymously. But for most sessions, anonymous proposals have proven to yield more diverse speakers. I have yet to see reports from conferences indicating that anonymous proposals lower speaker quality. That contention appears to be more hypothetical than real. In the end, what is more important? Making a real commitment to diversity or ensuring we can vote for people we know over strangers? I'd argue that allowing anonymous conference proposals is beneficial even if it decreases the quality of speakers a little.