Skip to content

Instantly share code, notes, and snippets.

View allain's full-sized avatar

Allain Lalonde allain

View GitHub Profile
@allain
allain / AgentMemoryRepo.js
Created April 17, 2019 17:14
Amazing things with pikapkg and tree shaking
import AgentRepo from './AgentRepo'
class AgentMemoryRepo extends AgentRepo {
load() {
}
}
@allain
allain / index.ts
Last active December 27, 2018 18:45
stage0 TypeScript spike
export interface AugmentedNode extends Node {
collect(node?: Node): { [key: string]: AugmentedNode }
}
// A helper function to clean up some of the tree iteration code
function createIterator(node: Node) {
// Since #refs can only be on Elements and Texts, limit the iteration to them
// createTreeWalker receives a deprecation warning, node iterator seems to work as well
const i = document.createNodeIterator(node, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT)
return () => i.nextNode()
const vm = require('vm')
const repl = require('repl')
const globals = {
Date,
JSON
}
const state = {}
@allain
allain / reset.sh
Last active October 7, 2017 21:12
reset all git commits to some time in the past
git reset --hard PASTCOMMIT
git reset --mixed CURRENTCOMMIT
git commit -m "Message about reversal"
@allain
allain / need.js
Last active October 7, 2017 03:07
use npmjs from the browser
console.log('installed: need, crave')
crave = m => fetch(`https://wzrd.in/bundle/${m}@latest/`)
.then(r => r.text())
.then(eval)
.then(() => require(m))
need = m => {crave(m).then(r => {
window[m] = r
console.log(`installed: ${m}`)
})}