Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

type MyTypeNames = {
'string': string,
'number': number,
}
type MyKey = {
readonly type: keyof MyTypeNames
readonly name: string
}
@fabiosantoscode
fabiosantoscode / tablepaste.js
Last active July 22, 2022 21:43
Allow pasting tables
// Some focusable element can be rigged to accept user paste events
// Then the HTML is taken from it, which should have a table element if what they copied is a table
focusableElement.onpaste = e => {
const data = e.clipboardData.getData('text/html')
const dom = document.createElement('div')
dom.innerHTML = data
const table = dom.querySelector('table')
const rows = [...table.rows].map(tr => (
this.timeline.addTween(cjs.Tween.get(this.instance_30).wait(233).to({_off:false},0).wait(1).to({regX:8.5,regY:28.5,scaleX:1.1659,scaleY:1.099,x:839.6,y:-54.5},0).wait(1).to({scaleX:1.3318,scaleY:1.198,x:838.75,y:-39.85},0).wait(1).to({scaleX:1.4978,scaleY:1.2969,x:838,y:-25.25},0).wait(1).to({scaleX:1.6637,scaleY:1.3959,x:837.15,y:-10.6},0).wait(1).to({scaleX:1.8296,scaleY:1.4949,x:836.3,y:4},0).wait(1).to({scaleX:1.9955,scaleY:1.5939,x:835.5,y:18.6},0).wait(1).to({scaleX:2.1614,scaleY:1.6928,x:834.65,y:33.25},0).wait(1).to({scaleX:2.3274,scaleY:1.7918,x:833.85,y:47.85},0).wait(1).to({scaleX:2.4933,scaleY:1.8908,x:833.05,y:62.4},0).wait(1).to({scaleX:2.6592,scaleY:1.9898,x:832.2,y:77},0).wait(1).to({scaleX:2.8251,scaleY:2.0888,x:831.35,y:91.65},0).wait(1).to({scaleX:2.9911,scaleY:2.1877,x:830.55,y:106.25},0).wait(1).to({scaleX:3.157,scaleY:2.2867,x:829.75,y:120.85},0).wait(1).to({scaleX:3.3229,scaleY:2.3857,x:828.95,y:135.5},0).wait(1).to({scaleX:3.4888,scaleY:2.4847,x:828.1,y:150.1},0).wait(1).to({scaleX:3.6
@fabiosantoscode
fabiosantoscode / README.md
Last active April 28, 2020 20:54
Strawperson proposal on interfacing multiple tools

Attempts to solve the problem of multiple tools working together, which I talk about here.

Everything in this document is debatable.

The way I see it, there are multiple parts to the solution:

  1. A file which multiple tools can read, which allows them to understand what's going on in a specific project, syntax-wise. This is only at the project level.
  2. An interface transpilers can implement, placed at a certain file location (or specified by some package.json field)

Problem statement

TL;DR: Tools which transpile code should focus on compiling code and not adapting to every bundler, and tools (like bundlers) which need to get that code transpiled shouldn't have to write adapters for every tool which exists. This wastes the community's time and ultimately hinders novel projects.

Developer's perspective

Case 1: A developer wants to use something new which employs custom syntax, but they're using React Native, or a bundler which is not popular enough to get a custom made plugin for it. They would have to manage another compilation pass and give up on the ordeal.

Case 2: A user already has a bundler set up for their project using custom syntax, but they want to:

// async function fetchRefs(obj)
const allPromises = []
;(function fetchRefs(obj) {
for (let key in obj) {
if (isRef(obj[key]) {
const promise = fetchRef(obj[key])
allPromises.push(promise)
promise.then(value => { obj[key] = value })

fabiosantoscode Fábio Daniel da Silva Santos

Keybase proof

I hereby claim:

  • I am fabiosantoscode on github.
  • I am fabiosantoscode (https://keybase.io/fabiosantoscode) on keybase.
  • I have a public key ASACryEcAFUriVQbfuocc9nDQeK6IDOtf_aRYoBZPzHf5Ao
fabio@thinkpadlel ♥ node
> var infer = require('tern/lib/infer')
> infer.parse
[Function]
> var parsed = infer.parse('var x=[1,2,3]')
undefined
> var ctx = new infer.Context()
undefined
> var nodeState; infer.withContext(ctx, () => { nodeState = infer.expressionType({ node: parsed.body[0].declarations[0].init, state: ctx.topScope }) })
undefined
/*...*/
try {
} catch(e) {
// OMG AN ERROR, WE HAVE TO CLOSE
// It's a good thing we caught this so we don't crash.
// Now let's call close() which allows us to bail gracefully
server.close(() => {
console.error(e)
process.exit(1)
// Ok we seem to be done.
Quite the opposite