Skip to content

Instantly share code, notes, and snippets.

View KyleMit's full-sized avatar

Kyle Mitofsky KyleMit

View GitHub Profile
@KyleMit
KyleMit / app_offline.htm
Created June 28, 2019 20:14
App Redirect
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge;" />
<title>Vital Records Produce Copy has Moved! | VDH</title>
<link rel="icon" type="image/x-icon" href="data:image/png;base64,AAABAAEAQEAAAAEAGAAoMgAAFgAAACgAAABAAAAAgAAAAAEAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAChcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQGhcQG
@KyleMit
KyleMit / FlattenArray.md
Last active July 22, 2019 17:38
Flatten Array of Objects

Starting Point

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

Target

@KyleMit
KyleMit / MutateKeyValue.md
Created July 25, 2019 23:27
Mutate Key Value Pairs

Input

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

or

title tags
about
post

My About Page

@KyleMit
KyleMit / 11ty-Global-Data.md
Created September 3, 2019 00:58
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
KyleMit / IterateObject.md
Created September 3, 2019 00:58
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
KyleMit / 12-days.js
Last active February 18, 2020 14:19
12 Days Challenge
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
KyleMit / Remove Capitalization Changes.md
Last active April 24, 2020 20:25
Remove Capitalization Changes

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
KyleMit / .eleventy.js
Created May 8, 2020 19:40
11ty / Nunjucks Shortcode
module.exports = function(eleventyConfig) {
eleventyConfig.addShortcode("year", () => new Date().getFullYear());
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.