Skip to content

Instantly share code, notes, and snippets.

@Wilto
Wilto / functions.php
Last active August 29, 2015 14:27
you think this is a game
// https://www.youtube.com/watch?v=b9N3tIlEJNc
function normalize_headings( $content ) {
// Move all headings below H2 down one notch
$output = preg_replace( "/<(.*)h4(.*)>(.*)(<\/h2>)/", "<$1h5$2>$3</h5>", $content );
$output = preg_replace( "/<(.*)h3(.*)>(.*)(<\/h2>)/", "<$1h4$2>$3</h4>", $output );
// H1 and H2 both collapse to H3
$output = preg_replace( "/<(.*)h1(.*)>(.*)(<\/h1>)/", "<$1h3$2>$3</h3>", $output );
$output = preg_replace( "/<(.*)h2(.*)>(.*)(<\/h2>)/", "<$1h3$2>$3</h3>", $output );
@Wilto
Wilto / gist:befbdf993851e8c56d41
Last active August 29, 2015 14:16
`type` with `picture` (long)

One of the most common suggestions we’d heard from people joining the responsive images conversation was that we “just” need a new format—a single image that contains all the different sources we could possibly need.

To make this happen, we’d first need to invent a new format—well, not us, but one of the big browser vendors would have to fund and research it, with intent to give it away to all the other browsers for free. Then we’d need some new markup anyway, so we could tell the browser which source to load. Then, to handle transferring only parts of a single file, we’d need to tinker with the protocols that power the web.

Not the easiest thing to sell on a web standards mailing list.

It got us thinking, though: there was one problem with introducing a new format that we could solve. A new image format can’t have a fallback pattern in and of itself, and the best solutions we have for this all involve making a request for the file before determining whether we need to throw it away.

@Wilto
Wilto / gist:eddfd4e3d56ed9a12e0e
Created November 24, 2014 19:31
Semver-esque
  1. MAJOR version at maintaners’ discretion (refactoring core)
  2. MINOR version when you make improvements in a backwards-compatible manner (performance)
  3. PATCH version when you make backwards-compatible bug fixes (spec compliance)

Polyfills don’t have “breaking changes” (or at least they shouldn’t), so I’m wondering what makes sense for major versions. “Whenever we do a lot of things” doesn’t seem particularly nailed-down, but I’m not sure there’s a better way.

@Wilto
Wilto / eq
Created November 6, 2014 16:46
.widget {
behavior: viewport;
}
.widget .dingus {
background: #8a1e1b;
}
.widget:media(min-width: 30em) .dingus {
background: #e20e03;
}
@Wilto
Wilto / gist:333607f726580c0b0ddb
Created September 20, 2014 16:17
Thinkpieces dot biz
(function() {
zalgo( document.documentElement );
function zalgo( node ) {
for ( node = node.firstChild; node; node = node.nextSibling ) {
if( node !== null && node.nodeType === 3 ) {
getOffMyLawn( node );
} else {
zalgo( node );
}

Jenn Schiffer and I are doing diversity sponsorships for http://2014.speakercampboston.com/

We need new voices and different viewpoints, and I figure anyone that wants to make the industry stronger should be helping promote those voices however they can. Then maybe one or two people in a future audience find themselves relating in ways that they wouldn’t relate to another straight-white-cis guy up on stage. Suddenly they’re thinking “hey, I could do that too—I could be up there.” That’s how we change things; that’s how we catalyze a more diverse industry.

Selfishly? I’m sick of seeing a bunch of me on stage. I’ve been me; I already think like me. I can only learn so much from someone with experiences so similar to mine. I want to learn from you. I want to be made to think about things I’d never considered before; to see things in a different way. That makes me better—that makes better developers, better people. That makes tech a more thoughtful, more empathetic place—and Christ, do we need more of that.

@Wilto
Wilto / MM2.md
Last active August 29, 2015 14:02
No-edit writing warmup.

I have a lot of writing to do today. This week, actually—I’m writing a book, and I gave myself this week to start getting it roughed-out. Not super polished or anything, I figure, just try to get somewhere near the word count before I go back and rewrite things a chapter at a time. Get a foundation down, y’know? I don’t have a ton of time, though, so it’s vital that I really focus on this. ~35,000 words is a lot of ground to cover. So, in the spirit of staying laser-focused on the task at hand: here are my thoughts on the optimum robot master order when attempting to beat Mega Man 2 without losing a life.

My Thoughts on the Optimum Robot Master Order when Attempting to Beat Mega Man 2 Without Losing a Life

Yes, Metal Man is first, obviously. C’mon. C’mon.

But on that drunken evening but a scant few weekends ago, NES controller in hand, I paused here. My first time through Mega Man 2 without dying, I went with the same order I had used as a youth—it just sort of happened. So I got to thinking, albei

/*
* truncation component init
*
* Copyright (c) 2014 Filament Group, Inc.
* Licensed under MIT
*/
(function( $ ) {
var pluginName = "truncate",
initSelector = "[data-" + pluginName + "]";
@Wilto
Wilto / thanks.md
Last active August 29, 2015 14:02

Let’s leave aside, for now, the fact that you’ve changed web standards. You’ve been a participant in the first time—in the history of the web, far as I know—that the web development community has taken a feature from an initial proposal to the funding of an honest-to-God native implementation.

Instead, I want you to focus on this: say only ten developers use a native responsive images solution to reduce the weight of just one page apeice by only 500kb, and each of those pages has a barely-significant 5,000 hits per month: those users have been saved almost 24GB of data. A thousand pages saving 500kb apeice, and we’ve saved users an entire terabyte in a month. Now expand that to the entire industry: every web developer; every hit on every page that would otherwise carry with it a huge, wasteful image request, saving megabytes at a time. To those users, the only change is that the web is faster, less expensive, more accessible. For those users, the web is just better.

In helping make the picture element