Skip to content

Instantly share code, notes, and snippets.

@isabellachen
isabellachen / nuxt-config-google-analytics.js
Created January 29, 2019 11:21
nuxt config to pass in function to dynamically get id for google analytics
'google-analytics': {
id: async () => {
// Meanwhile this https://github.com/nuxt-community/analytics-module/issues/27
const results = await fetch('/api/settings');
if (results.ok) {
const settings = await results.json();
return settings.gaKey
}
}
},
@isabellachen
isabellachen / monochrome-custom-style-bingmaps.json
Created January 24, 2019 15:39
Monochrome custom map style for bingmaps
{
"version": "1.0",
"settings": {
"landColor": "hsl($$, 38%, 87%)"
},
"elements": {
"mapElement": {
"labelColor": "hsl($$, 6%, 51%)",
"labelOutlineColor": "hsl($$, 54%, 91%)"
},
@isabellachen
isabellachen / map.service.ts
Created January 16, 2019 13:17
Load bing maps api asynchronously with vue typescript
import { injectable } from 'inversify';
import { IMapService } from './imap.service';
import { Category } from '~/services/categories';
import { Tip } from '~/services/tips';
@injectable()
export class MapService implements IMapService {
@isabellachen
isabellachen / hast-error.js
Created December 4, 2018 08:28
Report errors when parsing html into hast
var report = require('vfile-reporter')
var unified = require('unified')
var parse = require('rehype-parse')
var stringify = require('rehype-stringify')
const _html = `<!doctype html>
<title class="a" class="b">Hello…</title>
<h1/>World!</h1>`
unified()
@isabellachen
isabellachen / hast-visit.js
Created December 3, 2018 16:21
Turn html into an abstract syntax tree with hast and traverse the tree
// try it out i runkit: https://npm.runkit.com/syntax-tree
var rehype = require('rehype')
var visit = require('unist-util-visit')
const _html = `<!doctype html>
<title class="a" class="b">Hello…</title>
<h1>World!</h1>`
var tree = rehype().parse(_html)
@isabellachen
isabellachen / styled-component-button-shutter-out.js
Created November 14, 2018 11:26
Styled Component Button with Shutter Out Horizontal Animation
import styled from "styled-components";
export default styled.div`
position: relative;
text-align: center;
background-color: palevioletred;
border: none;
margin-top: 20px;
color: #000;
width: 100%;
@isabellachen
isabellachen / button.css
Created November 14, 2018 08:48
scss for button with shutter out animation
@import '~styles/variables';
.step_button {
$special-space: 4.5rem;
$border-width: 1rem;
$border-size: $border-width * 2;
&-btn {
background-color: transparent;
border: $border-width solid $color-background-brighter;
@isabellachen
isabellachen / memoize.js
Created November 12, 2018 21:45
Simple memoize function to solve number sequences
function memoize (fn) {
const memo = [0,1];
return function recur (n) {
if (memo[n]) return memo[n]
else memo[n] = fn(n)
return memo[n]
}
}
function fib (n) {
@isabellachen
isabellachen / webhint-launch.json
Created October 29, 2018 16:22
Webhint vscode launch.json for debugging
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Watch test",
"runtimeExecutable": "npm",
"windows": {
"runtimeExecutable": "npm.cmd"
@isabellachen
isabellachen / git-get-remote-branch.md
Created October 22, 2018 15:30
Getting a new branch

Fetch all branches git fetch --all List all branches git branch -a Check out the new branch git checkout my-new-branch