What is a JSON feed? Learn more

JSON Feed Viewer

Browse through the showcased feeds, or enter a feed URL below.

Now supporting RSS and Atom feeds thanks to Andrew Chilton's feed2json.org service

CURRENT FEED

Drinking Caffeine

A feed by Martyn Chamberlin

JSON


☕ RSS Change for Drinking Caffeine

Permalink - Posted on 2017-08-29 14:38

I am deprecating all current feeds at Drinking Caffeine, and replacing it with one single feed at /feed.xml. If you’re reading the site from a feed reader, then you’ll want to change your URL to that.

Sorry for the hassle! I’m switching from Jekyll to Hugo1 and while Hugo is better at most things, it’s worse at customizable feeds.

  1. More on this later. ↩︎


Privnote

Permalink - Posted on 2017-08-26 21:18

Privnote is a drop-dead simple service that lets you “share a confidential note via a web link that will self-destruct after it is read by your intended recipient.” Very cool.

☕ Read on Drinking Caffeine


☕ Handling Click Events with Dismissible HTML Modals

Permalink - Posted on 2017-08-26 16:09

It is often the case in web applications that designers must afford the user a progressive disclosure of complexity. One of the great ways to achieve this without disrupting the user experience is with HTML modals. The term modal means different things to different people in the web community, but when I use it here, I’m referring to exactly this: any UI element that is overlaid atop the current UI layer, regardless of whether it be a small detail or a fully enveloping layer, such that the only way to dismiss it is to either click outside of or mouse away from said modal.

There are three ways that modals can be triggered into view:

  1. Automatically. An example would be a modal that appears immediately upon logging in, that prompts a free user to upgrade to the site’s premium tier. Automatic modals should generally be avoided, although they have their rare use cases.
  2. Upon hover. Despite the popularity of this option, a compelling argument can be made that modals should never be triggered upon hover, because no UX should be triggered by hover, only UI (such as a link changing color). Here are a few reasons why triggering UX changes on hover is a bad idea:
    1. Because it increases code complexity and technical debt from a developer’s standpoint. There is no such thing as “hover on a touchscreen device. Since most web applications must support touch devices nowadays, the code complexity great increases if an action must occur on hover for a non-touch device but on tap for a touch device.
    2. Because it is difficult to interpret user intent when hovering, but it is never difficult to determine user intent on click. When a user hovers over item B, that might be because they are simply trying to go from item A to item C. Because of this ambiguity, we have pieces of software such as the hoverIntent jQuery plugin. What these plugins do is set a timer from the moment that the user mouses over something. When the timer is up, it checks to see if the user is still mousing over that something. If the user is, it triggers the desired action, otherwise it does nothing. No such timer is necessary when the action is triggered with a click. In other words, hover is slower than click.
    3. Because a web application feels much more solid when no UX can be triggered via hover. I freely admit that this last argument is touchy-feely but I think it’s important for that very reason; ultimately we judge a UI/UX by how it makes us feel. If you are looking for an example that eschews hover UX very well, look no further than Jira. Even the drop-downs on its sales page cannot be triggered on hover; only on click. Doesn’t that have a nice feel to it?
  3. Upon click. This is the gold standard. HTML modals that appear on click are non-intrusive and they are triggered by an action that is clearly intended by the user. In situations where the modal serves as a peek into something deeper, the first click triggers the modal, and the second click sends the user to a page that contains the modal’s contents in greater detail. If Stack Overflow were to change its user modals that occur on hover to instead occur on click (if you’re unfamiliar, mouse over Ruby Velhuis to see what I am referring to), the site would be the better for it. In Ruby’s example, first click would trigger the modal, and the second click would take you to his profile.

Having thus briefly described modals, we now come to the heart of today’s subject, which is this: from a technical standpoint, how do you handle the dismissal of these modals? There are three ways to do this that I have encountered.

The first method is by initially focusing on the modal and then dismissing on the onblur method. Here’s a simple example:

<div
  class="modal"
  tabindex="-1"
  style="display:none"
  onblur="hideModal()">I am a modal!</div>

<script>
// Writing vanilla JS in real life instead of using a
// proper framework is an abomination. Example only!
const modal = document.querySelector('.modal');

const showModal = () => {
  modal.style.display = 'block';
  modal.focus();
};

const hideModal = () => {
  modal.style.display = 'hide';
}
</script>

This is great for very a simple modal that does not contain HTML form tags that accept focus. Envision a menu that is the visual equivalent of right-clicking on the desktop or a Finder window in macOS — that sort of simple menu. A practical web example would be the “more options” of an Instagram post when viewing it at Instagram.com. One very nice thing about this method is just how fragile focus is. It’s easily broken. You lose it as soon as you click something within the menu. You lose it if you switch to a different tab in your browser, or to a different app. This transient nature is also similar to right-clicking on macOS: switching to a different space causes the menu to disappear. The main downside to using this solution is just how limited the items inside the modal must be. If the modal contains form elements or its own set of clickable actions that upon click should not dismiss the modal, this solution won’t work.

The second method is by stopping the upward DOM propagation of click events that occur from within the modal itself, and setting a click listener on the overall document. For a generic code example, I can’t improve on this StackOverflow answer. Assume that #menucontainer is the identifier for your modal in this scenario here. When you set this up, any click events that get triggered on the document are guaranteed to have not occurred from within the modal. This is a terrible solution though, and the reason for its terribleness is pontificated quite nicely at this CSS Tricks piece. Stopping propagation of an event is never necessary and leads to many potential pitfalls. I recommend reading this CSS Tricks piece in its entirety to get a firm grasp as to exactly why this is so.1 To quote a pertinent part from it:

Modifying a single, fleeting event might seem harmless at first, but it comes with risks. When you alter the behavior that people expect and that other code depends on, you’re going to have bugs. It’s just a matter of time.

Not only is it “just a matter of time” until you have bugs with event.preventDefault(), but unless you have strenuous test coverage on your UI, this is the sort of thing that will silently break and be very difficult to debug once you discover it later, depending on how nested your DOM is. You’ll have to step through each layer of DOM nodes to see where the click event propagation is getting stopped.

This brings us to the third and gold standard for handling the dismissal of HTML modals, which is by manually detecting whether a given click occurs inside or outside the modal. The popular examples are all in jQuery but few serious web applications use jQuery, so I’ll give an example in VueJS instead, in Single File Component parlance:

<template>
  <div class="modal" v-show="showModal">I am a modal</div>
</template>

<script>
import eventHub from '../eventhub';

export default {
  name: 'Modal',
  created() {
    // this event gets sent when a click occurs abroad that
    // should open up this modal
    eventHub.$on('show-modal', this.showModal);
  },
  data() {
    return {
      showModal: false
    };
  },
  methods: {
    showModal() {
      this.showModal = true;
      document.addEventListener('click', this.documentClick);
    },
    hideModal() {
      document.removeEventListener('click', this.documentClick);
      this.showModal = false;
    },
    documentClick(e) {
      if (e.target !== this.$el &&
        !this.$el.contains(e.target)) {
        this.hideModal();
      }
    }
  }
};
</script>

For the more curious, the eventhub import is nothing more than a singleton instance of Vue, shared between all components within the application. This is standard practice. The eventhub.js file contains nothing more than this:

import Vue from 'vue';

export default new Vue();

If you’re wanting to adapt this to something other than VueJS, the main part you need to worry about in the example above is the contents of the documentClick() method. The Node.contains() method is a standard method and you can use this in any framework — React, Angular, etc. As long as you have the event object and the modal’s node object, you’re good to use this.

  1. As a bonus, this piece will also introduce you to the little-known defaultPrevented property of event objects. ↩︎


The Outline’s Linkbait Piece on GarageBand

Permalink - Posted on 2017-08-26 13:48

Yesterday, Stephen Hackett linked to an Outline piece titled Why Are There So Many Knobs in GarageBand?. Aside from the headline, the word GarageBand occurs just twice in the article, and those are throwaways. There are many mentions of other applications and screenshots of them, but there are no screenshots of GarageBand. In other words, John Lagomarsino threw in an Apple application to make the headline catchy but then proceeded to talk about other audio software.

GarageBand is an excellent application. It’s not a fraction as skeumorphic as the screenshots in this article. I’ve spent about five hours this week in GarageBand playing around with some mixups, and the interface is more or less exactly what I would expect and desire from an Apple audio application in 2017. The fact that John can’t critique it is telling. It’s a very well designed application that’s been through multiple revisions.

Linkbait aside, I found this to be inaccurate as well. John writes:

Faders, switches, knobs, needles twitching between numbers on a volume meter — they’re all there. Except you have to control them with a mouse.

First, how many people use GarageBand on a Mac versus on an iPad or an iPhone? Some of them are using a mouse. Many of them are using touch, and knobs make perfect sense on a touchscreen device.

Second, while it’s somewhat cumbersome to the uninitiated to use a mouse on a knob, it’s difficult for me to think of a UI control that would be its superior. What does John want here? A slider? A numerical input? The nice thing about a knob is that it gives you a 270° spin. If you’re used to controlling things with knobs, you can just look at a knob and know exactly where it’s set, in a way that’s not as visually intuitive with a slider or numerical input or anything else I can think of.

I have yet to find a piece from The Outline that I liked.

☕ Read on Drinking Caffeine


Apple Event Scheduled for September 12

Permalink - Posted on 2017-08-26 02:38

Looks like this will be the day we see the new iPhone 8 iPhone.

☕ Read on Drinking Caffeine


Spectre

Permalink - Posted on 2017-08-26 02:25

Spectre was one of the truly great video games of the ’90s. Today I discovered an online embedded version of it and it’s exactly how I remembered it. Reading through the user manual, I realize that there were all kinds of features I hadn’t ever used, too. I’ve previously talked about the dangers of remembering past software too fondly but in this case, it’s well founded. Definitely worth checking out over the weekend, regardless of whether you’ve played it before.

☕ Read on Drinking Caffeine


82 Percent of Computer Science Majors Are Male

Permalink - Posted on 2017-08-24 15:38

Gaby Galvin, writing for U.S. News last year:

The gender gap in computing jobs has gotten worse in the last 30 years, even as computer science job opportunities expand rapidly, according to new research from Accenture and Girls Who Code.

In 1984, 37 percent of computer science majors were women, but by 2014 that number had dropped to 18 percent, according to the study. The computing industry’s rate of U.S. job creation is three times the national average, but if trends continue, the study estimates that women will hold only 20 percent of computing jobs by 2025.

Women are 55 percent of undergraduate students in college, but only 18 percent of computer science majors are women. Why isn’t that number 55?

If you think that one hundred percent of that 37 percent delta is explainable in terms of gender bias then you believe in Santa Claus.

☕ Read on Drinking Caffeine


min-height: 0

Permalink - Posted on 2017-08-23 21:08

Really, Firefox. Really. You’re the new Internet Explorer.

☕ Read on Drinking Caffeine


Backblaze Invites CrashPlan Customers

Permalink - Posted on 2017-08-23 18:57

Gleb Budman, Backblaze CEO:

With news coming out this morning of CrashPlan exiting the consumer market, we know some of you may be considering which backup provider to call home. We welcome you to try us.

I’ve been using Backblaze for a couple years now and I love it. The reviews from Mossberg and Gruber are well founded.

As some have recently pointed out, Backblaze doesn’t backup your entire computer the same way that Time Machine does. To me, this isn’t a problem though. There are two scenarios in which Backblaze actually comes into usefulness.

  • The first scenario is when you’ve lost a specific file or folder and you want it back. Backblaze backs up the entire user directory (~/) and serves this scenario well. I’ve used it for this on a few occasions.1
  • The second scenario is when your house burns down along with your Time Machine backup drive and your Mac itself. You’re completely out of luck in that scenario if you don’t have a cloud backup.

Anyone who plans to use Backblaze as a full restore method is crazy. Why be throttled by your ISP’s download speed (or wait for a mail restore2) when you could just restore from a 1TB drive via Time Machine?

The whole point of Backblaze is to protect yourself from situations that you aren’t expecting.

  1. Time Machine could serve this roll too, if you’re got frequent automated backups set up with it. I daresay most people aren’t that sophisticated though—me included. I just connect an external drive to my computer and back up via Time Machine once every 6 months, give or take. If you’re using Backblaze, the only real times to use Time Machine are when you’ve bought a new Mac and want to transfer everything to it, and when you’re about to install a beta of macOS that you suspect you may have to revert. ↩︎

  2. In fairness, the mail restore is free, depending what plan you’re on↩︎

☕ Read on Drinking Caffeine


Sundar Pichai Should Resign as Google’s CEO

Permalink - Posted on 2017-08-22 20:39

David Brooks, in an op-ed at the New York Times that’s 11 days old and aging quite nicely:

There are many actors in the whole Google/diversity drama, but I’d say the one who’s behaved the worst is the C.E.O., Sundar Pichai.

[…]

Either Pichai is unprepared to understand the research (unlikely), is not capable of handling complex data flows (a bad trait in a C.E.O.) or was simply too afraid to stand up to a mob.

The linked Atlantic piece is also most excellent.

☕ Read on Drinking Caffeine


Good Luck with That

Permalink - Posted on 2017-08-21 14:06

Abhimanyu Ghoshal, writing at The Next Web:

Tesla and SpaceX CEO Elon Musk, along with 115 other artificial intelligence and robotics specialists, has signed an open letter to urge the United Nations to recognize the dangers of lethal autonomous weapons and to ban their use internationally.

All the arguments in this piece could be used to apply to the transition from donkeys to tanks, or from muskets to machine guns, or from low explosive bombs to nuclear bombs. Artificial intelligence is simply the next step in that process. Now granted, it’s a huge step, and if people want to argue that it’s too big of a step, they’re welcome to make the best argument that they can.

But good luck trying to persuade the military to not use a superior technology. Historically that isn’t how it works longterm, ever.

☕ Read on Drinking Caffeine


☕ The Thing about Daring Fireball

Permalink - Posted on 2017-08-19 18:18

I’m trying to remember when I first visited DaringFireball.net. My best guess is that it was somewhere around 2009 or 2010. I was a teenager at the time, and the site was too sophisticated for my adolescent taste. But as I finished high school and eventually realized I wanted to be a software developer, my interest in the site increased. By 2012 I was reading the site fairly often and listening to an occasional episode of its Talk Show podcast. By 2013 I bought my first t-shirt. By 2014 I bought my second t-shirt. By 2015 I was reading everything and listening to most everything. By 2016 I had built a robot that sent me an SMS message whenever new linked list items were posted to the site. Today, I don’t know where I would be without Daring Fireball.

This week, Daring Fireball turns fifteen years old. When the blog started in 2002 as a column for “Mac Punditry and Curmudgeonry,” Apple was relatively small in the list of world companies, and the World Wide Web was still relatively new. Today, Apple has the highest market capitalization of any company in the world, and the World Wide Web has matured into a platform of billions of regular users. It stands to reason then that over the course of the past fifteen years, many blogs and columns surrounding the subject of Apple would have cropped up. They have. But none of them have arrived at the same caliber with which Daring Fireball started. Daring Fireball has no peers; it has no close seconds. I cannot improve upon how its author put it two years after the site’s debut:

The implicit immodesty of the sentence to follow pains me, but here goes: I don’t think there’s anything else quite like Daring Fireball.

This statement was factually correct in 2004, and it remains so in 2017. There’s a danger in attempting to list an outline of the reasons why there’s nothing else quite like Daring Fireball, and that is this: it might incline the reader to reduce its differentiation into a formula that is replicable. And while it might be tempting for skeptics to postulate that there is no secret sauce to the site’s superiority to all other Apple columns, such skeptics would be remiss to deny that there is a peculiar quality about Daring Fireball that is difficult to place one’s finger on. Though hard to define, it is undeniably present. I have spent much time thinking upon this, but I am no closer to arriving at pontificating what precisely this is than when I began, though my lack of success has not stifled my enthusiasm for its pastime. Be that as it may, the obvious points of outward distinction can be described easily enough, and they are worth visiting on the fifteenth anniversary.

  • The site has an attention to detail that is unparalleled in its every aspect. The design is impeccable. The language structure and choice of words has a finesse and a distinctive air of being simultaneously deliberate and natural. John Gruber once said that he made a somewhat lousy software employee, which I think was a brutally candid confession. His thoroughness is too complete to be of optimal usefulness in the environment of most technical enterprises. That very drawback though is the thing that makes Daring Fireball so unlike anything else.
  • The writer has his moments of frustrations and critiques, but they are done at a high level, as from someone who has an internal locus of control, who knows he’s right, who’s okay if all the world disagrees. These rants are not done in the way that so many others do them; they are not generally seething with ill-founded righteous indignation and with the dismay that perhaps all is chaos and ultimately doomed. Instead, they are built upon the calm conviction that there is absolute right and wrong, come what may, and that eventually all paths lead to the resolution of justice. This stability issues forth out of a belief that offers no proof; indeed, it feels no need to offer any proof.
  • Importantly, these aforementioned attributes have not arisen as an effect of Daring Fireball’s popularity. When you peruse the earliest columns of the site, you recognize these attributes immediately. They are innate; it is unfair to to say that these attributes were construed at the site’s debut as an artifice to boost its appeal. Rather, they have worked because they reflect the genuine nature of the author.
  • The site has its fair share of meanderings and distractions as do columns abroad, but these bypaths are done with a level taste and unusual pathos that forces the reader to (perhaps sometimes grudgingly) appreciate them.

I do not agree with Daring Fireball on many things, and I am very vocal about my disagreements. I mention this as a strength of the site. Strongly disagreeing with certain pieces on the site does not preclude enjoying it. That’s a testimony to just how there’s nothing else quite like Daring Fireball.

To avoid the embarrassment of being perceived as obsessing over a specific site or individual, there is a constant temptation to say that all good tech columns are more or less operating on a level playing field, and that they deserve an equal amount of time in one’s browser. This is profoundly wrong. Not all Apple blogs are created equal. Daring Fireball’s unique position is recognized by Apple’s VPs, who read it and give its author exclusive access at WWDC. Spending a disproportionate amount of time with Daring Fireball is becoming.

There’s a tendency in human nature to be silent in admiration and loud in complaining. I am as guilty as anyone in this matter. We keep quiet about Daring Fireball’s excellence because we know it, and we assume everyone else knows it. We find plenty of time to murmur, and too little time to praise. At the fifteen year anniversary, it’s a good time to reflect upon what the world would be without Daring Fireball.

Here’s to another fifteen years, John.


Tim Cook Weighs in on Charlottesville

Permalink - Posted on 2017-08-17 21:43

Tim Cook had this to say to his employees:

I disagree with the president and others who believe that there is a moral equivalence between white supremacists and Nazis, and those who oppose them by standing up for human rights. Equating the two runs counter to our ideals as Americans.

Nobody respectable is saying that there’s a moral equivalence between white supremacists and Nazis, and those who oppose them. We have no place in this country for true Nazis. It’s sadly true that some of the protesters at Charlottesville were unequivocally white supremacists and wannabe Nazis, and those people should be renounced. But many of them weren’t that at all. Just because you oppose the taking down of statues does not make you a monster. I think Scott Adams made the best argument for why taking down the statues is a good thing for America at this time, but not everyone would agree with that, including black confederates. To quote Walter E. Williams:

The flap over the Confederate Flag is not quite as simple as the nation’s race experts make it. They want us to believe the flag is a symbol of racism. Yes, racists have used the Confederate Flag, but racists have also used the Bible and the U.S. Flag. Should we get rid of the Bible and lower the U.S. Flag? Black civil rights activists and their white liberal supporters who’re attacking the Confederate Flag have committed a deep, despicable dishonor to our patriotic black ancestors who marched, fought and died to protect their homeland from what they saw as Northern aggression. They don’t deserve the dishonor.

These are complex issues, and there well-intentioned and evil-intentioned people on both sides of this issue. If someone isn’t willing to come to terms with that, and if they get all bent out of whack by anyone who says as much, they’re blinded by partisan politics and they’re hallucinating an alternate reality. If someone can’t conceive a universe where there’s a way to peacefully protest on either side of an issue like these statues, they are being unfaithful to history. The peaceful aspect of this is key, and sadly neither side of Charlottesville maintained a peaceful spirit.1

Tim Cook redeems himself in the next paragraph:

Regardless of your political views, we must all stand together on this one point — that we are all equal. As a company, through our actions, our products and our voice, we will always work to ensure that everyone is treated equally and with respect.

Yes.

  1. Within the legal framework, there’s a time and a place for violence: namely, if you or those in your care are being violently assaulted. The violence on both sides extended past this boundary, and there is no justification for that. That said, if you take the worst that the opposition did and compare that to the worst that the anti-opposition did, it is clear that the former is guilty of the greater evil in this particular case — that of cold blooded murder. ↩︎

☕ Read on Drinking Caffeine


Cloudflare Terminates Customer Due to Political Pressure

Permalink - Posted on 2017-08-17 13:45

Cloudflare CEO Matthew Prince:

Earlier today, Cloudflare terminated the account of the Daily Stormer. We’ve stopped proxying their traffic and stopped answering DNS requests for their sites. We’ve taken measures to ensure that they cannot sign up for Cloudflare’s services ever again.

[…]

We’re going to have a long debate internally about whether we need to remove the bullet about not terminating a customer due to political pressure. It’s powerful to be able to say you’ve never done something. And, after today, make no mistake, it will be a little bit harder for us to argue against a government somewhere pressuring us into taking down a site they don’t like.

Aside from whether Cloudflare made the right move here or not, it’s kind of hard to keep a bullet point that’s no longer true.

☕ Read on Drinking Caffeine


GitHub Introduces Embedded Code Snippets

Permalink - Posted on 2017-08-16 13:38

I just started noticing this feature the other day and I love it. It’s a fantastic iterative improvement. You can even paste a permalink from one private repository to another private repository, and it’ll expand it.

☕ Read on Drinking Caffeine


Jason Snell Weighs in on Safari Favicons

Permalink - Posted on 2017-08-14 13:37

Jason Snell, writing at Six Colors:

If I had to guess why Safari doesn’t support favicons in tabs, I’d say that Apple’s designers probably think most favicons are ugly and contribute to visual clutter.

This sounds right to me. When Apple makes a product decision, its top priority isn’t, What will get the most market share? Apple isn’t primarily worried about market share. Keep that in mind when you read this quote from Gruber’s piece:

I really can’t say this strongly enough: I think Safari’s lack of favicons in tabs, combined with its corresponding crumminess when displaying a dozen or more tabs in a window, is the single biggest reason why so many Mac users use Chrome.

If Apple’s designers have it in their heads that “most favicons are ugly and contribute to visual clutter,” then they can’t care less that adding this visual clutter might increase Safari’s popularity. Gruber is going to need better persuasion than this if he hopes to change the thinking at Apple regarding Safari favicons.

As an aside, it’s hilarious that a person would make this favicon issue the determining factor in whether they used Safari versus Chrome. They’re two completely different products. Safari is unusable for frontend developer work, so I pretty much never use it except to troubleshoot CSS flexbox bugs that are specific to it. I was only vaguely aware prior to Gruber’s piece that macOS Safari didn’t show favicons. To me that’s just one of the many inferior design choices that the team made. The real issues with Safari lie in its developer console tabs UI and UX. That’s where Chrome really is the best in the industry. If we did a survey of how many frontend developers on Macs did their development in Chrome versus Safari, I bet it’d be a 20:1 ratio, or higher.

☕ Read on Drinking Caffeine


☕ A Better Way to Handle Website Footnotes

Permalink - Posted on 2017-08-12 21:05

The bigfoot.js library is a popular solution to footnotes on the web. I’ve never personally been a fan of it though, because bigfoot.js footnotes are invisible unless you interact with the page. I prefer the visual beautify of small footnotes omnipresent at the bottom of the page, with links that jump you to and from them. It’s a slightly less ideal UX, but it’s a much superior UI.

I’ve noticed two problems that arise with out-of-the-box kramdown footnotes, however:

  1. They always jump you down slightly too far because they jump you to exactly where the text occurs. As a result, you always have to scroll up a little to the context of where you were.
  2. They interfere with your browser history. If an article has a couple of footnotes and you jump down and back up for both of them, that pushes 4 distinct shebangs to your address bar and history. You then have to swipe backwards five times in mobile Safari to get to your previous page. That’s quite cumbersome.

I decided to fix both of these problems with a bit of JavaScript. Here’s what I came up with, using ES6:

$(document).ready(() => {
  /**
   * @param {element} e The element that was clicked
   * @return {element} The element that is being pointed to
   */
  const goTo = (e) => {
    let goTo = $(e.currentTarget).attr('href');
    // remove the pound sign
    goTo = goTo.substr(1);
    // Use document.getElementById() to accomodate colon in element id
    // (https://stackoverflow.com/a/11862160/1591507)
    return $(document.getElementById(goTo));
  };

  /**
   * The amount of top padding when scrolling to/from a footnote
   */
  const padding = 10;

  $('.footnote').click((e) => {
    $(window).scrollTop(goTo(e).offset().top - padding);
    e.preventDefault();
  });

  $('.reversefootnote').click((e) => {
    $(window).scrollTop(goTo(e).parents().offset().top - padding);
    e.preventDefault();
  });
});

This solves both problems mentioned above:

  1. Instead of jumping down too far, you’re always given a padding of 10 pixels. Plus, when jumping back to the text that cites the footnote, you’re sent to the outer element that contains this footnote (hence the parents() call). The resulting parent will usually be a <p> or a <li> tag. This is nice, because it gives you the full context of citation. Only in cases of very long paragraphs of text would this result in the user getting scrolled so high that the footnoted sentence is out of sight.
  2. Instead of allowing the click or touch event to be handled by the browser, JavaScript is intercepting the event and preventing the default behavior, which means no shebangs are pushed to browser history.

Here’s a gist of my JavaScript. I’m using this code here at Drinking Caffeine too, so you can demo the new footnote experience on any article that has footnotes, such as this recent one.


A Question for Google’s CEO

Permalink - Posted on 2017-08-11 22:02

Conor Friedersdorf, writing at The Atlantic:

I have a question for the CEO.

Given that the full text of the memo is public, that it is the subject of a national debate on an important subject, that many educated people disagree with one another about what claims it made, and that clarity can only help Google employees adhere to the company’s rules going forward, would you be willing to highlight the memo using green to indicate the “much” that you identified as “fair to debate” and red to flag the “portions” that you deemed Code-of-Conduct violations?

This gets to the crux of the matter.

As an aside, I’m loving how diplomatic Daring Fireball is about this whole affair. Very aloof.

☕ Read on Drinking Caffeine


James Damore Has an ‘Above Decent’ Chance of Winning His Legal Case Against Google

Permalink - Posted on 2017-08-11 15:26

Jim Edwards, writing at Business Insider:

Google may have difficulty establishing that he broke the company’s code of conduct because he used message boards the company provided to allow employees to discuss these issues, and because his manifesto repeatedly states he favors diversity and intended to “increase women’s representation in tech.”

Also:

“Damore’s possible claims really have nothing to do with whether white males are discriminated against in wages and promotion,” Sharpe said. “It is about whether he was fired because he complained that Google’s diversity efforts were unfair to men. He doesn’t have to prove the allegation, just that he made the claim for the purpose of advancing working conditions of himself and others.”

So James won’t have to prove that his allegations were correct to win his case.

☕ Read on Drinking Caffeine


A Silent, 10-minute Song is Climbing the iTunes Charts

Permalink - Posted on 2017-08-11 12:59

Nathan Ingraham, writing at Engaget:

If you’ve ever plugged your phone into your car stereo, only to have the same song start playing every single time, I have some good news for you. Yesterday, a true internet hero named Samir Mezrahi released a song on iTunes that’s just 10 minutes of silence – and he named it “A a a a a Very Good Song.” Since the iPhone starts playing music alphabetically when you plug it in to many car stereos, that usually means there’s one song that you hear whether you want to or not. Many songs starting with the letter A have probably been ruined thanks to this quirk – but if you download Mezrahi’s creation, you’ll instead have plenty of time to queue up the songs you want to hear.

This has been a source of grief to me for ages. That song has heretofore been Abandoning Ship from the film score of Pixar’s Ratatouille. I’ve added A a a a a Very Good Song to my Apple Music library as its replacement. Well done, Samir Mezrahi.

Via 512 Pixels.

☕ Read on Drinking Caffeine