Skip to content

Instantly share code, notes, and snippets.

Kyle KyleMit

Block or report user

Report or block KyleMit

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
KyleMit / .eleventy.js
Created May 8, 2020
11ty / Nunjucks Shortcode
View .eleventy.js
module.exports = function(eleventyConfig) {
eleventyConfig.addShortcode("year", () => new Date().getFullYear());
KyleMit / Remove Capitalization
Last active Apr 24, 2020
Remove Capitalization Changes
View Remove Capitalization

Here's an example of two strings to run through a diffing processes

let oldText = "start case old Text"
let newText = "start Case next Text"

These get tokenized by each word (separated by a space) and passed into difflib which produces the following result:

KyleMit / 12-days.js
Last active Feb 18, 2020
12 Days Challenge
View 12-days.js
let gifts = ["partridge in a pear tree", "turtle doves", "French hens", "calling birds", "gold rings", "geese a-laying", "swans a-swimming", "maids a-milking", "ladies dancing", "lords a-leaping", "pipers piping", "drummers drumming"]
let numLookup = [
{ cardinal: "a", ordinal: "first" },
{ cardinal: "two", ordinal: "second" },
{ cardinal: "three", ordinal: "third" },
{ cardinal: "four", ordinal: "fourth" },
{ cardinal: "five", ordinal: "fifth" },
{ cardinal: "six", ordinal: "sixth" },
{ cardinal: "seven", ordinal: "seventh" },
KyleMit /
Created Sep 3, 2019
Looping through an object in JavaScript

There's a pretty standard way to manipulate an array and return the slightly transformed contents using .map(), but there's a lot of options when it comes to objects, opening the door to potential confusion. Here's an approach to looping through an object in JS

Let's start with the following object:

let authors = {
    "Kyle": {"description": "Likes Cats"},
    "Brian": {"description": "Automation champion"},
    "Sandra": {"description": "Swiss army knife"}
KyleMit /
Created Sep 3, 2019
Using Global Data in 11ty

Using Global Data in 11ty

Any filename you put under _data directory will be globally available to all templates

A template might start with some yaml front matter to give it some [local fontmatter data][1] like this:

title: "First post"
author: Kyle
tags: [Post, Intro]
KyleMit /
Created Jul 25, 2019
Mutate Key Value Pairs


var obj = {
	app: "one",
	ban: "house"


KyleMit /
Last active Jul 22, 2019
Flatten Array of Objects

Starting Point

var arr = [
  { name: "height", value:"20" },
  { name: "width",  value:"30" }


View app_offline.htm
<!DOCTYPE html>
<meta http-equiv="X-UA-Compatible" content="IE=edge;" />
<title>Vital Records Produce Copy has Moved! | VDH</title>
KyleMit /
Last active Jun 13, 2019
Git Pair Alias

Git Pair Alias

Pair Programming is great - here's a way to make it greater with easy way to toggle on mutliple attribution for each a commit.

Add this alias to your global .gitconfig file (git config --global --edit)

    pair = "!f() {                                                           \
                local name=$1;                                               \
You can’t perform that action at this time.