Skip to content

Instantly share code, notes, and snippets.

View overra's full-sized avatar
😀

Adam Snodgrass overra

😀
View GitHub Profile
I am a banana
module.exports = function () {
return Promise.reject(new Error("Whoops"))
}
[
{
"_etag": "df8a40ab1e555e3d620f59d6d619ce48",
"branch": "tmos-tier2",
"build": "0.0.1309",
"created": "2019-02-27T08:01:31.594Z",
"custom_metadata": {
"dut_build": "0.0.1309",
"dut_build_date": "Wed Feb 20 14:50:38 PST 2019",
"dut_changelist": "2912505",
@overra
overra / ways-to-unique-arrays.js
Created January 3, 2019 14:53
Tip: Get the unique values of an array in JavaScript.
// borrowed from Addy Osmani
// Way 1: new Set()
const uniqueArray = arr => [...new Set(arr)];
uniqueArray(['Dan', 'Sarah', 'Sophie‘, ’Sarah']);
// ["Dan", "Sarah", "Sophie"]
// Way 2: Array.from() and new Set()
const uniqueArray2 = arr => Array.from(new Set(arr));
@overra
overra / index.html
Last active December 31, 2018 09:52
htm demo
<!DOCTYPE html>
<html lang="en">
<body>
<div id="root"></div>
<script type="module">
import { html, Component, render } from 'https://unpkg.com/htm/preact/index.mjs?module';
import Router from 'https://unpkg.com/preact-router?module';
const Home = () => html`<section><h1>Home</h1><p>This is the home page.</p></section>`;
const About = () => html`<section><h1>About</h1><p>My name is Jason.</p></section>`;
const NotFound = () => html`<section><h1>404: Not Found</h1><p>It's gone :(</p></section>`;
@overra
overra / index.js
Last active January 2, 2019 02:42
Basic node usage on now v2
const { send } = require('micro')
module.exports = (req, res) => send(res, 200, 'hello world!')
@overra
overra / code.js
Created December 31, 2018 02:52
Sends response with prism wrapped gist code
const fetch = require('isomorphic-unfetch')
const { json, send } = require('micro')
const { readFileSync } = require('fs')
const { resolve } = require('path')
// read template once
const template = readFileSync(resolve(__dirname, './static/code.html'), 'utf8');
// encode html entities
const entities = {'&': '&amp;', '<': '&lt;', '>': '&gt;'};
console.log('does this work?')
@overra
overra / code.html
Last active December 30, 2018 23:01
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="https://unpkg.com/prismjs@1.15.0/themes/prism.css" />
<script src="https://unpkg.com/prismjs@1.15.0/prism.js"></script>
</head>