Skip to content

Instantly share code, notes, and snippets.

View saibotsivad's full-sized avatar
💖
JavaScript

Tobias Davis saibotsivad

💖
JavaScript
View GitHub Profile
@saibotsivad
saibotsivad / class.js
Created September 20, 2019 14:28
javascript forms
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) {
@saibotsivad
saibotsivad / readme.md
Last active September 18, 2019 17:45
Speed up macOS Sierra

Originally based on this article.

To undo any change run the command:

defaults delete $DOMAIN $KEY

For example:

@saibotsivad
saibotsivad / _README.md
Last active July 1, 2019 00:51
Checking in all dependencies (including the package manager)

Context

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.

Caveats

@saibotsivad
saibotsivad / test.js
Created August 1, 2018 17:27
ways to test svelte components
// 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:

  • using the mannish mediator
  • all the mediator providers are in a folder named provider
  • they're all globbed up with a create script (see below)
  • because of the limitations of github gists, the filenames can't have slashes, so I made it so all the slashes are dashes
@saibotsivad
saibotsivad / a-readme.md
Created June 22, 2018 15:46
render components to target elements you don't have control over

from a discord discussion with Rich Harris ❤️

@saibotsivad
saibotsivad / example-api.js
Created March 14, 2018 20:38
example koa based proxy
// 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'
})
@saibotsivad
saibotsivad / README.md
Last active January 29, 2018 17:40
Better Web Styles
@saibotsivad
saibotsivad / README.md
Last active January 14, 2018 05:47
yavascript dependency manager: a proposal for something crazy

yavascript dependency manager

A proposal for something crazy.


motivation

In this writing I am not going to defend a thesis, I'm going to present a proposal for a system for dependency management in JavaScript.

@saibotsivad
saibotsivad / moot-sdk-browser.js
Created October 4, 2017 04:51
browser sdk for the moot app
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('&')