Skip to content

Instantly share code, notes, and snippets.

@SgtPooki
SgtPooki / create-dir-example.ts
Created May 22, 2024 00:58
example of creating a directory structure with file using Helia and @helia/unixfs
const fs = unixfs(helia)
let barDir = await fs.addDirectory({ path: './bar' })
const aFileHtml = await fs.addFile({ path: './bar/a-file.html', content: uint8ArrayFromString('<html><body>Hello world</body></html>') })
barDir = await fs.cp(aFileHtml, barDir, 'a-file.html')
let fooDir = await fs.addDirectory({ path: './foo' })
fooDir = await fs.cp(barDir, fooDir, 'bar')
let deepDirCid = await fs.addDirectory({})
deepDirCid = await fs.cp(fooDir, deepDirCid, 'foo')
@SgtPooki
SgtPooki / README.md
Last active March 17, 2024 06:09
webm streaming req/res of different browsers

While debugging streaming video with the helia-service-worker-gateway, I decided to set up a basic nodejs streaming server that we could ensure a basic test case is working in the browsers, so we knew what to target.

The basic server seems to work in all browsers except for safari.

The steps to generage the attached log files are as follows:

  1. run node demo-video-server.js > <browser>.log
  2. open browser, start a new tab
openapi: 3.0.3
info:
title: IPFS Gateway API
description: |
This is an OpenAPI 3.0 specification for the IPFS Gateway API, following the specs.ipfs.tech/http-gateways/path-gateway specification.
You can find more information about IPFS at [https://ipfs.tech](https://ipfs.tech).
version: 1.0.0
servers:
- url: https://ipfs.io
paths:
@SgtPooki
SgtPooki / aider-chat.nix
Last active April 26, 2024 16:35
shell.nix files for various dev environments
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
buildInputs = [
pkgs.virtualenv
(pkgs.python3.withPackages (ps: with ps; [
ps.pip
]))
];
@SgtPooki
SgtPooki / claim.fluence.network airdrop.md
Last active March 11, 2024 07:05
claim.fluence.network airdrop eligible github usernames
@SgtPooki
SgtPooki / test.js
Created February 7, 2024 20:03
@helia/verified-fetch test script
import { trustlessGateway } from '@helia/block-brokers'
import { createHeliaHTTP } from '@helia/http'
import { delegatedHTTPRouting } from '@helia/routers'
import { createVerifiedFetch } from '@helia/verified-fetch'
const helia = await createHeliaHTTP({
blockBrokers: [
trustlessGateway({
gateways: ['https://cloudflare-ipfs.com', 'https://ipfs.io', 'https://trustless-gateway.link']
})
@SgtPooki
SgtPooki / index.js
Last active October 26, 2023 17:35
@sgtpooki/bulk-import-cid -- temporary stop-gap for https://github.com/ipfs/ipfs-desktop/issues/2680
#!/usr/bin/env node
// @ts-check
import { path } from 'kubo'
import {execa} from 'execa';
// get input filename from command line
const filename = process.argv[2];
console.log(`filename: `, filename);
const {stdout} = await execa('echo', ['unicorns']);
@SgtPooki
SgtPooki / generateIPFSLinks.sh
Created October 24, 2023 01:10
We want to output a list of IPFS links for all the domains using dig and return only the strings that match "dnslink=/ipfs/Qm..."
@SgtPooki
SgtPooki / dependents-change.js
Last active November 7, 2023 01:36
This script requires a markdown table for input, as generated by https://github.com/nvuillam/github-dependents-info. It compares the current table with the previous one and outputs a new table with the changes in stars.
#!/usr/bin/env node
/**
* This script requires a markdown table for input, as generated by https://github.com/nvuillam/github-dependents-info
* It compares the current table with the previous one and outputs a new table with the changes in stars.
* Usage:
* github-dependents-info --repo ipfs/helia --markdownfile ./package-usage-2023-09.md --sort stars --verbose -x 2 -p
* // manually copy the Repostory and Stars table to `current.md`
* // manually copy the Repostory and Stars table from the previous month to `previous.md`
* node dependents-change.js
*
@SgtPooki
SgtPooki / find-webtransport-peers.js
Created September 14, 2023 21:03
use Helia to test if certain peers are listening on webtransport
import { multiaddr } from '@multiformats/multiaddr'
import { WebTransport } from '@multiformats/multiaddr-matcher'
import { createHelia } from 'helia'
const helia = await createHelia()
const multiaddrs = [
// fill out multiaddrs for peers you want to check here:
'/ip4/123.45.67.89/tcp/4001/ipfs/Qmabcdefg...',
'/ip4/98.76.54.32/tcp/4004/ipfs/bafyka...',