To set up:
- Clone this repo. (Or just copy
serve.go
into a folder on your computer). cd
into it, and rungo build serve.go
You can now run the binary like this: ./serve --root="/path/to/directory"
But to make it easier, put this in your .bashrc
:
/* | |
UPDATED for 2023 - Now much simpler. The old tricks are no longer needed. | |
The following code makes an 800×600 canvas that is always as sharp as possible for the device. | |
You still draw on it as if it's the logical size (800×600 in this case), but everything just | |
looks sharper on high-DPI screens. Regular non-sharp screens are not affected. | |
*/ | |
const width = 800 |
#### | |
# ZSH function to auto-switch to correct Node version | |
# https://gist.github.com/callumlocke/30990e247e52ab6ac1aa98e5f0e5bbf5 | |
# | |
# - Searches up your directory tree for the closest .nvmrc, just like `nvm use` does. | |
# | |
# - If you are already on the right Node version, IT DOES NOTHING, AND PRINTS NOTHING. | |
# | |
# - Works correctly if your .nvmrc file contains something relaxed/generic, | |
# like "4" or "v12.0" or "stable". |
// convert three r,g,b integers (each 0-255) to a single decimal integer (something between 0 and ~16m) | |
function colourToNumber(r, g, b) { | |
return (r << 16) + (g << 8) + (b); | |
} | |
// convert it back again (to a string) | |
function numberToColour(number) { | |
const r = (number & 0xff0000) >> 16; | |
const g = (number & 0x00ff00) >> 8; |
To set up:
serve.go
into a folder on your computer).cd
into it, and run go build serve.go
You can now run the binary like this: ./serve --root="/path/to/directory"
But to make it easier, put this in your .bashrc
:
/* Shadow 0dp */ | |
box-shadow: none; | |
/* Shadow 1dp */ | |
box-shadow: 0 1px 1px 0 rgba(0,0,0,0.14), 0 2px 1px -1px rgba(0,0,0,0.12), 0 1px 3px 0 rgba(0,0,0,0.20); | |
/* Shadow 2dp */ | |
box-shadow: 0 2px 2px 0 rgba(0,0,0,0.14), 0 3px 1px -2px rgba(0,0,0,0.12), 0 1px 5px 0 rgba(0,0,0,0.20); | |
/* Shadow 3dp */ |
Assuming you've got a Next.js app that's already using TypeScript to render pages/components or handle API routes, but you also want to be able to run ad hoc build tasks written in TypeScript (perhaps pulling in type files used by the app)...
npm install -D @babel/core @babel/node
.babelrc
file:// Default Next.js .babelrc (it's OK if you also have extra stuff in it)
{
"presets": ["next/babel"],
"plugins": []
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Hello World!</title> | |
</head> | |
<body> | |
<h1>Hello World!</h1> | |
<!-- All of the Node.js APIs are available in this renderer process. --> | |
We are using Node.js <script>document.write(process.versions.node)</script>, |
import chunk from 'lodash-es/array/chunk';
import zipObject from 'lodash-es/array/zipObject';
console.log(zipObject(chunk(['a', 'b', 'c', 'd'], 2)));
$ rollup -f=iife demo.js > output.js