Originally based on this article.
To undo any change run the command:
defaults delete $DOMAIN $KEY
For example:
class Worker { | |
constructor(secret) { | |
// the initializer has access to "secret" | |
const options = doSomeSetup(secret) | |
// to give access to other functions, you have to use "this" | |
this.options = options | |
this.secret = secret | |
} | |
work(parameters) { |
Originally based on this article.
To undo any change run the command:
defaults delete $DOMAIN $KEY
For example:
I've become a little unsettled about the current state of npm (the company), and it makes me a little worried about the state of npm (the registry).
I wondered if there would be a reasonable way to check in all dependencies to the repository of my production application, in such a way that if npm (the registry) was ever down, I could continue doing deploys until the mess was sorted out.
// taken from Rich Harris: https://runkit.com/rich/ways-to-test-svelte-components | |
const svelte = require('svelte'); | |
const assert = require('assert'); | |
const { JSDOM } = require('jsdom'); | |
const SCRIPT = `script`; // otherwise RunKit breaks | |
// testing non-DOM stuff | |
const C1 = svelte.create(` |
Context:
provider
from a discord discussion with Rich Harris ❤️
// imagine that this is the api you want your proxy to interface with | |
const Koa = require('koa') | |
const app = new Koa() | |
app.use(async ctx => { | |
console.log(ctx.request.method + ' ' + ctx.request.url) | |
console.log(ctx.request.header['content-type']) | |
ctx.set('content-type', 'whatevs') | |
ctx.body = 'yolo' | |
}) |
This is meant to be used as a bookmarklet, where you click it and it'll apply some basic styling rules to the page you're on.
Primarily, this is designed to be used on those old websites that don't have any styling rules, e.g. http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm
import fetch from 'whatwg-fetch' | |
// TODO need to actually use encode/decode on parameters | |
function generateQueryParameters({ filter, include, fields }) { | |
const fieldParameters = (fields || []) | |
.map(field => { | |
return `fields[${field.name}]=${field.keys.join(',')}` | |
}) | |
.join('&') |