Skip to content

Instantly share code, notes, and snippets.

View kumavis's full-sized avatar
🐉
!

kumavis kumavis

🐉
!
View GitHub Profile
@kumavis
kumavis / plugin.js
Created December 12, 2019 03:51
lavamoat workaround plugin
const { makeStringTransform } = require('browserify-transform-tools')
module.exports = makeStringTransform('lavamoat-browserify-workarounds', { excludeExtension: ['.json'] }, (content, _, cb) => {
const result = content
// fix html comments
.split('-->').join('-- >')
// fix direct eval
.split(' eval(').join(' (eval)(')
.split('\neval(').join('\n(eval)(')
@kumavis
kumavis / gist:cfec971e3224252f038a8ae575925b3e
Last active December 5, 2019 14:08
more javascript hijinks
> x = 'hello'
'hello'
> x.toString = () => 'ayy'
[Function]
> x.valueOf = () => 'yoo'
[Function]
> x
'hello'
> x+''
'hello'
_then = Promise.prototype.then
// [Function: then]
Promise.prototype.then = function(){ console.log('then!'); return _then.apply(this, arguments); }
// [Function (anonymous)]
p = new Promise(resolve => resolve())
// Promise { undefined }
@kumavis
kumavis / polyfillJsonRpcBatchAsBatchTx.js
Created November 22, 2019 05:26
batch tx polyfill idea
const provider = polyfillJsonRpcBatchAsBatchTx(inpageProvider)
function polyfillJsonRpcBatchAsBatchTx (oldProvider) {
const newProvider = { sendAsync }
return newProvider
function sendAsync (req, cb) {
if (Array.isArray(req)) {
@kumavis
kumavis / read-only-membrane.js
Last active November 19, 2019 06:30
read-only handler for es-membrane
"use strict"
const { Membrane } = require('es-membrane')
// create raw object to be protected by membrane
const rawObj = { secure: true }
// create membrane to manage interaction
const membrane = new Membrane()
@kumavis
kumavis / membrane_module.js
Last active November 18, 2019 13:19
simple membrane module system
const { Membrane } = require('es-membrane')
const { defineModule, getRawModule } = createModuleSystem()
//
// define modules
//
// module X
defineModule('x', (require) => {
@kumavis
kumavis / background.js
Last active November 14, 2019 13:45
WebExtension Manifest v3
// // Called when the user clicks on the browser action.
// chrome.action.onClicked.addListener(function(tab) {
// // No tabs or host permissions needed!
// console.log('Turning ' + tab.url + ' red!');
// // chrome.tabs.executeScript({
// // code: 'document.body.style.backgroundColor="red"'
// // });
// });
@kumavis
kumavis / experiment1.js
Last active August 21, 2019 07:51
ses sloppyGlobals mini kernel
const test = require('tape-promise').default(require('tape'))
const SES = require('../lib/ses.umd.js')
const realm = SES.makeSESRootRealm()
test(async t => {
const globalStore = {}
runModuleA()

test details

contentRouting.findProviders

real browser dht network network size 60 kbucket 20 maxPeers 40 randomWalk off visible connection churn due to maxPeers

test details

contentRouting.findProviders

real browser dht network network size 85 kbucket 20 maxPeers 40 randomWalk off visible connection churn due to maxPeers