Skip to content

Instantly share code, notes, and snippets.

View BryanSchuetz's full-sized avatar
🎧
🎶 "Come on, just let's go" 🎶

Bryan Schuetz BryanSchuetz

🎧
🎶 "Come on, just let's go" 🎶
View GitHub Profile
@BryanSchuetz
BryanSchuetz / cachebust.rb
Created February 17, 2018 16:19
CSS Cache Bust Jekyll Plugin
module Jekyll
module CacheBust
class CacheDigester
require 'digest/md5'
attr_accessor :file_name, :directory
def initialize(file_name:, directory: nil)
self.file_name = file_name
self.directory = directory
@BryanSchuetz
BryanSchuetz / eleventy-image-transform.is
Created March 12, 2022 14:19
Responsive image transforms for eleventy
// This file goes in /src/transforms/
// Add this line to .eleventy.js:
// const eleventyImgTransform = require("./src/transforms/eleventy-img-transform.js");
// And add this one to module.exports in .eleventy.js:
// eleventyConfig.addTransform("eleventyImgTransform", eleventyImgTransform);
const Image = require("@11ty/eleventy-img");
const cheerio = require("cheerio");
@BryanSchuetz
BryanSchuetz / .eleventy.js
Created February 24, 2022 12:02
eleventy filter config
const _get = require("lodash.get");
//It seems like, when using these filters on items in a collection with attributes in frontmatter—the keys are mostly on the data object, e.g. `| where('data.key', 'value')`. When using on global data, look for item attributes directly `| where('key', 'value')`
//sort by order attribute
function sortByOrder(values) {
let vals = [...values]; // this *seems* to prevent collection mutation...
return vals.sort((a, b) => Math.sign(a.data.order - b.data.order));
}
//sort collections by title attribute

There are two types of markup in Liquid: Output and Tag.

  • Output markup (which may resolve to text) is surrounded by
{{ matched pairs of curly brackets (ie, braces) }}
  • Tag markup (which cannot resolve to text) is surrounded by
@BryanSchuetz
BryanSchuetz / .bashrc
Created May 7, 2021 16:23
Git branch in bash prompt
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
NO_COLOR="\[\033[0m\]"
RED="\[\033[0;31m\]"
export PS1="⚑$RED\$(parse_git_branch) $NO_COLOR\w >"
@BryanSchuetz
BryanSchuetz / Sass: Responsive Mixin
Last active August 21, 2020 13:59
Sass: Media Query Mixin
$width-tiny: 15em; //4bits
$width-small: 30em; //6bits
$width-medium: 37.5em; //8bits
$width-wide: 57em; //10bits
// responsive mixin for bubbled media-querries
@mixin responsive($width){
@if $width == tiny-screens{
@media screen and (min-width: $width-tiny){
@BryanSchuetz
BryanSchuetz / concat.liquid
Created May 5, 2016 16:20
Concat arrays in Jekyll(liquid)
{% assign all_hosts = "" | split: "" %}
{% for host in site.data.shared_hosts %}
{% assign all_hosts = all_hosts | push: host %}
{% endfor %}
{% for host in site.data.paas_hosts %}
{% assign all_hosts = all_hosts | push: host %}
{% endfor %}
@BryanSchuetz
BryanSchuetz / Reading-Time.liquid
Created March 5, 2016 15:09
A liquid block for generating the reading time of a given post.
{% capture words %}
{{ content | number_of_words | minus: 180 }}
{% endcapture %}
{% unless words contains “-” %}
{{ words | plus: 180 | divided_by: 180 |
append: “ minutes to read” }}
{% endunless %}
@BryanSchuetz
BryanSchuetz / deploy-site.workflow
Last active December 6, 2018 15:05
A workflow for building your custom Jekyll site, and deploying it back to the gh-pages branch of your repository.
workflow "Deploy Site" {
on = "push"
resolves = ["Build and Deploy Jekyll"]
}
action "Build and Deploy Jekyll" {
uses = "BryanSchuetz/jekyll-deploy-gh-pages@master"
secrets = ["GITHUB_TOKEN"]
}
@BryanSchuetz
BryanSchuetz / images.yml
Created November 21, 2018 17:45
Yaml file for searchable image archive
---
-
image: 01-013
title: sarah williams
keywords: sarah, williams
caption: portrait of sarah williams
-
image: 01-014
title: williams family member
keywords: portrait, williams