Skip to content

Instantly share code, notes, and snippets.

View alanshaw's full-sized avatar
🌶️
https://storacha.network

ash alanshaw

🌶️
https://storacha.network
View GitHub Profile
import { registerHooks } from 'node:module'
import fs from 'node:fs'
const urls = []
registerHooks({
load(url, context, nextLoad) {
if (!url.startsWith('file://')) {
return nextLoad(url, context)
}
urls.push(url)
@alanshaw
alanshaw / decode_test.go
Created November 12, 2025 18:54
Decode X-Agent-Message header
package main
import (
"fmt"
"testing"
"github.com/storacha/go-ucanto/testing/helpers/printer"
"github.com/storacha/go-ucanto/transport/headercar/message"
)
@alanshaw
alanshaw / did-to-peer.go
Last active September 30, 2025 11:04
Ucanto private key to libp2p Peer ID and Peer ID to Ucanto public key
package main
import (
"fmt"
"github.com/libp2p/go-libp2p/core/crypto"
"github.com/libp2p/go-libp2p/core/peer"
ed25519 "github.com/storacha/go-ucanto/principal/ed25519/verifier"
)
@alanshaw
alanshaw / find-ipni-genesis.js
Created September 15, 2025 12:17
Find the genesis of an IPNI chain given it is stored in an S3 bucket you have access to.
import { GetObjectCommand, ListObjectsV2Command, S3Client } from '@aws-sdk/client-s3'
import Ora from 'ora'
import * as dagJSON from '@ipld/dag-json'
const spinner = Ora()
const client = new S3Client({ region: 'us-west-2' })
const bucket = 'ipfs-advertisement'
let oldest
let cursor
package main
import (
"encoding/base64"
"fmt"
"os"
"strconv"
"time"
ipnimd "github.com/ipni/go-libipni/metadata"
@alanshaw
alanshaw / cli.sh
Last active July 11, 2025 09:58
env vars for Storacha CLI
# prod
export STORACHA_SERVICE_DID=did:web:up.storacha.network
export STORACHA_SERVICE_URL=https://up.storacha.network
export STORACHA_STORE_NAME=storacha-cli-prod
export STORACHA_RECEIPTS_URL=https://up.storacha.network/receipt/
# staging
export STORACHA_SERVICE_DID=did:web:staging.up.storacha.network
export STORACHA_SERVICE_URL=https://staging.up.storacha.network
export STORACHA_STORE_NAME=storacha-cli-staging
@alanshaw
alanshaw / maxpiecesize.go
Created July 11, 2025 09:55
Maximum PDP piece size for Piri
package main
import (
"fmt"
"github.com/filecoin-project/go-state-types/abi"
"github.com/storacha/piri/pkg/pdp/proof"
)
func main() {
@alanshaw
alanshaw / print-charm-colours.js
Created July 4, 2025 08:46
Print the charm colours 0-255
import createCharm from 'charm'
const charm = createCharm()
charm.pipe(process.stdout)
charm.reset()
for (var i = 0; i < 256; i++) {
charm.background(i).write(i+'\n')
}
package main
import (
"fmt"
"strconv"
"time"
"github.com/multiformats/go-multibase"
"github.com/multiformats/go-multicodec"
"github.com/multiformats/go-multihash"
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
fmt.Println(ResolveDIDKey())