Skip to content

Instantly share code, notes, and snippets.

🚨
GitHub Drop ICE

Zach Leatherman zachleat

🚨
GitHub Drop ICE
View GitHub Profile
@zachleat
zachleat / gist:2008932
Created Mar 9, 2012
Prevent zoom on focus
View gist:2008932
// * iOS zooms on form element focus. This script prevents that behavior.
// * <meta name="viewport" content="width=device-width,initial-scale=1">
// If you dynamically add a maximum-scale where no default exists,
// the value persists on the page even after removed from viewport.content.
// So if no maximum-scale is set, adds maximum-scale=10 on blur.
// If maximum-scale is set, reuses that original value.
// * <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=2.0,maximum-scale=1.0">
// second maximum-scale declaration will take precedence.
// * Will respect original maximum-scale, if set.
// * Works with int or float scale values.
@zachleat
zachleat / gist:8cd9f1844c7144099c54533fff1b0a76
Created Apr 18, 2020
Eleventy Vue Responsive Images Plugin Sample Input/Output
View gist:8cd9f1844c7144099c54533fff1b0a76
<responsive-image
path="./src/images/home-store.jpg"
alt="The front entrance to a store"
:widths="[350, null]" />
<!-- BECOMES -->
<picture>
<source srcset="/v3/img/respimg/ef7c5bc4-350.webp 350w, /v3/img/respimg/ef7c5bc4.webp 589w" type="image/webp">
<source srcset="/v3/img/respimg/ef7c5bc4-350.jpeg 350w, /v3/img/respimg/ef7c5bc4.jpeg 589w" type="image/jpeg">
@zachleat
zachleat / .eleventy.js
Last active Mar 21, 2020
Eleventy + Vue Preview
View .eleventy.js
const eleventyVue = require("@11ty/eleventy-plugin-vue");
module.exports = function(eleventyConfig) {
// Use Defaults
eleventyConfig.addPlugin(eleventyVue);
// OR, Use your own options
eleventyConfig.addPlugin(eleventyVue, {
// Directory for single file components (defaults to includes folder)
componentsDirectory: "",
@zachleat
zachleat / gist:96516e8a3bbff53355ba65f0b7732aed
Last active Feb 17, 2020
Installing phantomjs 2.5.0 Beta
View gist:96516e8a3bbff53355ba65f0b7732aed
# First download phantomjs-2.5.0-beta-macos.zip from https://bitbucket.org/ariya/phantomjs/downloads
# I put mine into ~/Code/phantomjs-2.5.0-beta-macos
~/Code/phantomjs-2.5.0-beta-macos/bin ᐅ ./phantomjs
dyld: Library not loaded: /usr/local/opt/webp/lib/libwebp.6.dylib
Referenced from: /Users/zachleat/Code/phantomjs-2.5.0-beta-macos/bin/./phantomjs
Reason: image not found
[1] 33803 abort ./phantomjs
~/Code/phantomjs-2.5.0-beta-macos/bin ᐅ brew install webp
@zachleat
zachleat / .js
Created Aug 29, 2019
Using Eleventy Programmatically
View .js
const Eleventy = require("@11ty/eleventy");
(async function() {
let inst = new Eleventy();
await inst.init();
await inst.write();
})();
@zachleat
zachleat / gist:980895
Created May 19, 2011
HTML5 Boilerplate Issue #378 (No Compatibility View button, tested in IE7/IE8/IE9)
View gist:980895
<!--[if IE ]><![endif]-->
<!doctype html>
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7 ]> <html class="no-js ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]> <html class="no-js ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]> <html class="no-js ie8" lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
View .eleventy.js
module.exports = function(eleventyConfig) {
// you’ll have to get a list of all the tags in your talks.json here which is not great but pretty easy
["Web Assembly"].forEach(function(tag) {
eleventyConfig.addCollection(tag, function(collection) {
return collection.getFilteredByTag("talks").filter(item => {
// note here the use of the pagination alias `talk`
return (item.data.talk.tags || []).indexOf(tag) > -1;
});
});
});
@zachleat
zachleat / reading_time.rb
Last active Nov 5, 2019
Read this in X minutes Liquid Filter Plugin (for Jekyll)
View reading_time.rb
# Outputs the reading time
# Read this in “about 4 minutes”
# Put into your _plugins dir in your Jekyll site
# Usage: Read this in about {{ page.content | reading_time }}
module ReadingTimeFilter
def reading_time( input )
words_per_minute = 180
@zachleat
zachleat / img.njk
Created Sep 5, 2019
Experimenting with a Nunjucks shortcode for images in Eleventy
View img.njk
<!-- throws an error, missing [alt] attribute -->
{% img src="img/9a93578a.png", loading="lazy" %}
<!-- local img source, outputs a standard <img> tag -->
{% img src="img/9a93578a.png", alt="zachleat’s Avatar", loading="lazy" %}
<!-- remote img source -->
<!-- download using avatar-local-cache, outputs <picture> with webp and png fallback -->
{% img src="https://www.gravatar.com/avatar/e1899004c71c7043343196103e210be3?default=404", alt="zachleat’s Avatar", loading="lazy" %}
@zachleat
zachleat / gist:cda7af65f5d61666e7fa6037c3ede752
Created Jun 12, 2019
This webmention entry made it through sanitize-html
View gist:cda7af65f5d61666e7fa6037c3ede752
{
"type": "entry",
"author": {
"type": "card",
"name": "",
"photo": "",
"url": ""
},
"url": "https://remysharp.com/2019/06/11/ejecting-disqus",
"published": "2019-06-11T00:00:00",
You can’t perform that action at this time.