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
@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 / 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 / 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())
@alanshaw
alanshaw / pem-to-did.go
Last active June 2, 2025 10:09
PEM to DID, libp2p peer ID and base64pad private key.
package main
import (
crypto_ed25519 "crypto/ed25519"
"crypto/x509"
"encoding/pem"
"fmt"
"os"
"github.com/libp2p/go-libp2p/core/crypto"
@alanshaw
alanshaw / test.sh
Last active May 29, 2025 10:56
Is IPNI working yet?
echo 'alantest 2025-05-29' > test.txt
storacha up test.txt --verbose
# Should get:
# bafybeidamzcqbpfirdtrbjjhhybp5nfyl5vnjudbsoszg3jnbrwrjupetm
# Does IPNI have the info?
curl https://staging.ipni.storacha.network/cid/bafybeidamzcqbpfirdtrbjjhhybp5nfyl5vnjudbsoszg3jnbrwrjupetm
# Currently:
@alanshaw
alanshaw / slow.sh
Created May 12, 2025 15:37
Slow w3up
$ echo 'alantest 2025-05-12-1' | w3 up
created shard: 4.414ms
hashing shard: 0.013ms
invoking blob/add: 1.522s
invoking http/put: 181.018ms
invoking ucan/conclude http/put: 935.68ms
polling for receipt: 1.081s
hashing piece: 54.925ms
invoking filecoin/offer: 460.332ms
invoking blob/add: 1.216s