Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View KyleMit's full-sized avatar

Kyle Mitofsky KyleMit

View GitHub Profile
@KyleMit
KyleMit / barrel-up.js
Created October 26, 2020 13:40
Twitter - Barrel Up
// index.ts
export { Dog } from 'dog/dog.component.ts';
export { Cat } from 'cat/cat.component.ts';
// module.ts
import { Cat, Dog } from 'index.ts';
@KyleMit
KyleMit / logical-or-assignment-operator.js
Created October 26, 2020 13:31
Twitter - Logical OR Assignment Operator
let person = { name: "Frida" }
// original
person.city = person.city || "unknown"
// with logical or assignment operator
person.city ||= "unknown"
@KyleMit
KyleMit / customize-vs-code.json
Created October 23, 2020 17:57
Twitter - Customize VS Code UI
{
"customizeUI.stylesheet": {
".editor-actions .codicon-compare-changes": "display: none !important;",
".editor-actions .codicon-open-preview": "display: none !important;",
".editor-actions .codicon-split-horizontal": "display: none !important;",
".editor-actions .codicon-toolbar-more": "display: none !important;"
},
}
@KyleMit
KyleMit / toLocaleDateString.js
Created October 23, 2020 16:03
Twitter - toLocaleDateString
let dt = new Date(1906, 11, 9)
let lang = navigator.language // i.e. 'en-us'
// "Sunday, December 9, 1906"
dt.toLocaleDateString(lang, {
weekday: 'long',
year: 'numeric',
month: 'long',
day: 'numeric'
})
@KyleMit
KyleMit / chrome-grid.html
Last active October 19, 2020 20:42
Twitter - Chrome Grid Inspector
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Grid Tools</title>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@600&display=swap" rel="stylesheet">
@KyleMit
KyleMit / no-script.html
Created October 19, 2020 19:19
Twitter - No JS
<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
<script>
document.documentElement.classList.remove("no-js");
document.documentElement.classList.add("yes-js");
</script>
<style>
.yes-js .yes-js-hidden { display: none; }
.no-js .no-js-hidden { display: none; }
@KyleMit
KyleMit / object-initializer-shorthand.js
Created October 15, 2020 20:36
Twitter - Object Initializer Shorthand
let cat = {name: "Frida", age: 10 }
let dog = {name: "Ranger", age: 7 }
// before
console.log("cat", cat)
console.log("dog", dog)
// after
console.log({cat, dog})
// {
@KyleMit
KyleMit / delete.js
Created October 15, 2020 20:21
Twitter - Delete Operator
let person = {
FirstName: "Ada",
LastName: "Lovelace",
Password: "********"
}
console.log(person)
// { FirstName: "Ada", LastName: "Lovelace", Password: "********"}
delete person.Password
@KyleMit
KyleMit / listener-jQuery.js
Created October 15, 2020 19:54
Twitter - Delegated Listener
$("body").on("click", ".rectangle", function(e) {
console.log("jquery", this)
// do stuff
});
@KyleMit
KyleMit / string-array.js
Last active October 15, 2020 19:53
Twitter - JavaScript String Arrays
let msg = "🎃 BOO"
console.log(msg[0]) // "�"
console.log(msg.charAt(0)) // "�"
console.log([...msg][0]) // "🎃"