A lightweight deno server that runs on oak.
Run it with deno --allow-net server.ts
| export const convertTextToImage = (context, text, font = 'normal normal 24px cursive', color = '#000000') => { | |
| context.font = font | |
| context.fillStyle = color | |
| context.fillText(text, 0, 10) | |
| context.canvas.width = context.measureText(text).width | |
| return context.canvas.toDataURL() | |
| } |
| // Defaults | |
| const defaultOptions = { | |
| format: 'image/png', | |
| quality: 0.92, | |
| width: undefined, | |
| height: undefined, | |
| Canvas: undefined | |
| } | |
| const createCanvas = options => (options.Canvas ? new options.Canvas() : window.document.createElement('canvas')) |
| const calculatePages = (length: number, current: number, total: number) => { | |
| if (length === 0) return [] | |
| if (length === 1) return [current] | |
| if (total <= length + 4) return Array.from({ length: total }, (_v, i) => i + 1) | |
| const jumpSize = Math.ceil(length / 2) | |
| const centerStart = Math.min(Math.max(current - (length - jumpSize), 3), total - length - 1) | |
| const jumpStart = current <= length + 1 ? 2 : `-${jumpSize}` | |
| const jumpEnd = current >= total - length ? total - 1 : `+${jumpSize}` | |
| return [1, jumpStart, ...Array.from({ length }, (_v, i) => centerStart + i), jumpEnd, total] | |
| } |
| export const strip = html => { | |
| const doc = new DOMParser().parseFromString(html, 'text/html') | |
| return (doc.body.textContent || '').trim() | |
| } |
| <template> | |
| <div id="app"> | |
| <nested-list | |
| v-for="item in list" | |
| :key="item.name" | |
| :name="item.name" | |
| :items="item.items" | |
| :level="0" | |
| /> | |
| </div> |
| /* Handicraft reset */ | |
| *, | |
| *::before, | |
| *::after { | |
| box-sizing: inherit; | |
| } | |
| html { | |
| box-sizing: border-box; | |
| } | |
| body { |
| // eslint-disable-next-line no-undef | |
| workbox.setConfig({ | |
| debug: false | |
| }) | |
| workbox.core.skipWaiting() | |
| workbox.precaching.precacheAndRoute([]) | |
| workbox.routing.registerRoute( |
| brew install docker docker-machine$ brew cask install virtualbox | |
| docker-machine create --driver virtualbox default | |
| docker-machine env default | |
| eval "$(docker-machine env default)" | |
| docker run hello-world | |
| docker-machine stop default |
| export const timeSinceNow = (timestamp) => { | |
| const current = new Date() | |
| const previous = new Date(timestamp * 1000) | |
| const msPerMinute = 60 * 1000 | |
| const msPerHour = msPerMinute * 60 | |
| const msPerDay = msPerHour * 24 | |
| const msPerMonth = msPerDay * 30 | |
| const msPerYear = msPerDay * 365 | |
| const elapsed = current - previous |