cat $(yarn global dir)/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copied from this article https://kentcdodds.com/blog/implementing-a-simple-state-machine-library-in-javascript | |
function createMachine(stateMachineDefinition) { | |
const machine = { | |
value: stateMachineDefinition.initialState, | |
transition(currentState, event) { | |
const currentStateDefinition = stateMachineDefinition[currentState] | |
const destinationTransition = currentStateDefinition.transitions[event] | |
if (!destinationTransition) { | |
return | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script lang="ts"> | |
import { VNodeData } from 'vue' | |
import { defineComponent } from '@vue/composition-api' | |
/** | |
* Use this component to render raw SVG content | |
* without the need to use the `v-html` directive | |
* which requires a parent node in Vue 2.x (ex: `<div v-html="..."></div>`). | |
* `<NSvgFragment :src="..." />` will directly render the svg tag with its content. | |
* */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Prop/Method Decorator with no arguments | |
function logDecorator(t, n, descriptor) { | |
const original = descriptor.value; | |
if (typeof original === 'function') { | |
descriptor.value = function(...args) { | |
console.log(`Arguments: ${args}`); | |
try { | |
const result = original.apply(this, args); | |
console.log(`Result: ${result}`); | |
return result; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Two things will happen here: | |
1) normalize()ing to NFD Unicode normal form decomposes combined graphemes into the combination of simple ones. The è of Crème ends up expressed as e + ̀. | |
2) Using a regex character class to match the U+0300 → U+036F range, it is now trivial to globally get rid of the diacritics, which the Unicode standard conveniently groups as the Combining Diacritical Marks Unicode block. | |
*/ | |
export const normalizeChar = char => char.normalize('NFD').replace(/[\u0300-\u036f]/g, '') | |
export const normalizeStr = str => str.split('').map(normalizeChar).join('') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs') | |
const path = require('path') | |
const files = [] | |
fs.readdirSync(__dirname).forEach(file => { | |
const i = file.indexOf(path.basename(file)) | |
const j = file.indexOf(path.extname(file)) | |
files.push(file.substring(i, j)) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require("path"); | |
const webpack = require("webpack"); | |
const UglifyJSPlugin = require("uglifyjs-webpack-plugin"); | |
const PROD = process.env.NODE_ENV === "production"; | |
const configureBabelLoader = browserlist => { | |
return { | |
test: /\.js$/, | |
use: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From this SO answer https://stackoverflow.com/a/2035211 | |
function getViewport() { | |
var viewPortWidth; | |
var viewPortHeight; | |
// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight | |
if (typeof window.innerWidth != 'undefined') { | |
viewPortWidth = window.innerWidth, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getAttributes (el) { | |
return Array.from(el.attributes) | |
.map(a => [a.name, a.value]) | |
.reduce((acc, attr) => { | |
acc[attr[0]] = attr[1] | |
return acc | |
}, {}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// custom scroll-bar | |
@mixin custom-scroll-bar() { | |
&::-webkit-scrollbar { | |
border-radius: 10px; | |
height: 10px; | |
width: 8px; | |
} | |
&::-webkit-scrollbar-thumb { | |
background: #999; |
NewerOlder