Skip to content

Instantly share code, notes, and snippets.


Kyle KyleMit

View GitHub Profile
KyleMit / auto-mapper.js
Created Jun 29, 2020
NBS Porting - Auto Mapper
View auto-mapper.js
// ==UserScript==
// @name NBS Porting - Auto Mapper
// @namespace
// @version 1.0
// @description Automatically map answers in the from and to answer fields when porting pages in NBS
// @author KyleMit
// @match
// @grant none
// ==/UserScript==
KyleMit / index.js
Created Jun 28, 2020
parse-rgb w/ unit tests
View index.js
module.exports = parseRGB
function parseRGB(string) {
return {
r: 255,
g: 255,
b: 255
KyleMit / equals.js
Created Jun 27, 2020
JavaScript Reference vs Value Equality
View equals.js
var personOne = {name: "Kyle", age: 22}
var personTwo = {name: "Kyle", age: 22}
// referential equality
let refEqual = personOne == personTwo
let isValueEqual = (obj1, obj2) => {
return Object.keys(obj1).every(key => obj1[key] == obj2[key])
View Jupyter Notebook Sample.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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]
You can’t perform that action at this time.