Skip to content

Instantly share code, notes, and snippets.

Working from home

Mikeal Rogers mikeal

Working from home
View GitHub Profile
View blocks-in-ipfs.js
import * as Block from 'multiformats/block'
import { sha256 as hasher } from 'multiformats/hashes/sha2'
import * as codec from '@ipld/dag-cbor'
import { CID } from 'multiformats'
let value = { hello: 'world' }
let hello = await Block.encode({ value, codec, hasher })
let bbbb = await Block.encode({ value: { foo: hello.cid }, codec, hasher })
View scraper-for-joe.js
const publicIp = require('public-ip')
const bent = require('bent')
const get = bent('json', 'https://my-lambda-url')
exports.handler = async function http (req) {
let { retries, ips } = req.queryStringParameters
const ip = await publicIp.v4()
if (ips) ips = ips.split(',')
else ips = []

We’ve been saying for a long time that we need “something like a CAP theorum for IPLD.” By this, I mean that we need a way to talk about the design tradeoffs that are made when designing data structures in IPLD.

This is going to end up looking a lot different than the CAP theorem but the end goal is to have something that provides us a blueprint for how to discuss the performance tradeoffs of different data structure designs.

Anyway, here’s my attempt at a first draft. It’s incomplete but I need some feedback in order to iterate on it and turn it into a proper PR.

mikeal /
Created Jul 1, 2020
show functions with missing coverage
cat coverage/tmp/coverage-* | jq '.result[] | select(.url == "file:///root/dagdb/src/kv.js")
| .functions[] | select(.ranges[].count == 0)'
View dynamo.json
"carUrl": "",
"dataset": "encode-public",
"parts": [
View example.js
const gen = require('ipld-schema-gen')
const parse = require('ipld-schema')
const schema = `
type DataLayout map
advanced DataLayout
type Data bytes representation advanced DataLayout
const DataLayout = {
testMethod: node => {
mikeal / bunde-size-action.yml
Created Aug 20, 2019
What you need to add to your GitHub Action to add bundle size badges to your readme.
View bunde-size-action.yml
- uses: mikeal/bundle-size-action@master
- uses: mikeal/publish-to-github-action@master
View example.js
class NeedsReady {
constructor () {
this.ready = new Promise(resolve => setTimeout(resolve, 1000))
async foo () {
await this.ready
return 'bar'
mikeal / stateless-interface.js
Created Feb 27, 2019
stateless interface example
View stateless-interface.js
class Database {
constructor (storage) {
this.count = 0 = storage
async get (cid) {
this.count += 1
async put (block) {
mikeal / script.zsh
Created Feb 21, 2019
delete all the aws log streams
View script.zsh
aws logs describe-log-streams --log-group-name="/aws/lambda/ghmetrics-staging-get-filter" --query 'logStreams[*].l│··········
ogStreamName' --output table | awk '{print $2}' | grep -v ^$ | while read x; do aws logs delete-log-stream --log-stream-name="$x" --log-group-name="/a│··········
ws/lambda/ghmetrics-staging-get-filter"; done