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
KyleMit / IterateObject.md
Created Sep 3, 2019
Looping through an object in JavaScript
View IterateObject.md

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 / 11ty-Global-Data.md
Created Sep 3, 2019
Using Global Data in 11ty
View 11ty-Global-Data.md

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 / MutateKeyValue.md
Created Jul 25, 2019
Mutate Key Value Pairs
View MutateKeyValue.md

Input

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

or

@KyleMit
KyleMit / FlattenArray.md
Last active Jul 22, 2019
Flatten Array of Objects
View FlattenArray.md

Starting Point

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

Target

View app_offline.htm
<!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 / GitPair.md
Last active Jun 13, 2019
Git Pair Alias
View GitPair.md

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)

[alias]
    pair = "!f() {                                                           \
                local name=$1;                                               \
View app_offline.htm
<!DOCTYPE html>
<html>
<head>
<title>VRIMS Offline | Vermont Department of Health</title>
<style type="text/css">
html {
background: #fffdef;
}
body {
display: flex;
@KyleMit
KyleMit / archive.ps1
Last active May 9, 2019
Execute Powershell Script on Right Click in Windows Explorer
View archive.ps1
$path = $args[0]
Add-Type -AssemblyName PresentationFramework
[System.Windows.MessageBox]::Show("Hello $path")
View navigate_sections.js
var chaperRegex = /(chapter)(\d{1,2})(-)(\d{1,2})/
function LoadNextSection() {
// build next section address
var nextSectionUrl = window.location.href.replace(chaperRegex,
function(match, first, chapter, second, section) {
var nextSection = +section+1 // increment
if (nextSection < 10) nextSection = "0" + nextSection; // pad with 0
return first + chapter + second + nextSection;
});
You can’t perform that action at this time.