Skip to content

Instantly share code, notes, and snippets.

View line-reader-transform-stream.js
lineReader = () => {
let buffer = "";
return new TransformStream({
transform(chunk, controller) {
buffer += chunk;
const parts = buffer.split("\n");
parts.slice(0, -1).forEach((part) => controller.enqueue(part));
buffer = parts[parts.length - 1];
hubgit / genbank-to-sqlite.ts
Last active Sep 5, 2022
A ReadableStream created from an async iterator which fetches paginated data, piped into a WritableStream which inserts items into an SQLite database.
View genbank-to-sqlite.ts
import { parse } from ''
import { readableStreamFromIterable } from ''
import { Database } from ''
import ProgressBar from ''
let counter = 0
const progress = new ProgressBar({
title: 'processing:',
interval: 100,
hubgit /
Last active Sep 2, 2022
Processing the Crossref Public Data File

First, download the data files using a BitTorrent client:


Next, convert the data files to a single newline-delimited JSON file:

deno run process.ts
hubgit / deno-cloud-storage-web-streams.ts
Last active Aug 27, 2022
Write to a file in a Google Cloud Storage bucket by piping a Web Stream to stdin of a `gcloud alpha storage cp` process.
View deno-cloud-storage-web-streams.ts
export const cloudStorageJsonLinesWriter = (url: string) => {
// gcloud components install alpha
const process ={
cmd: [
hubgit / deno-web-streams.ts
Last active Sep 4, 2022
Reader and Writer web streams for Deno
View deno-web-streams.ts
import { TextLineStream } from ''
// const input = await jsonLinesReader('input.jsonl.gz')
// const output = await jsonLinesWriter('output.jsonl.gz')
// for await (const item of input) {
//// do something
// await output.write(item)
// }
hubgit / deno-compressed-json-lines-reader.ts
Last active Aug 26, 2022
Read/write a gzipped JSON lines file with Deno
View deno-compressed-json-lines-reader.ts
const createInputReader = async (path: string) => {
const file = await, {
read: true,
return file.readable
.pipeThrough(new DecompressionStream('gzip'))
.pipeThrough(new TextDecoderStream())
.pipeThrough(new TextLineStream())
hubgit / docker-image-metadata.mjs
Last active Jul 7, 2022
Fetch Docker image metadata
View docker-image-metadata.mjs
// adapted from
const IMAGE = 'example/foo'
const TAG = 'latest'
const authorise = async () => {
const url = new URL('')
url.searchParams.set('scope', `repository:${IMAGE}:pull`)
url.searchParams.set('service', '')
const response = await fetch(url)
get_iplayer --file-prefix="<pid>" --output=$PWD --pid $PID --tv-quality sd --start $START --stop $STOP
hubgit / _headlines.txt
Created Feb 13, 2022
8 years of headlines from the Daily Express' "World War 3" page
View _headlines.txt
Paxman the Peacemaker as he grills feuding Japan and China ambassadors in SEPARATE rooms
Russian President Vladimir Putin wants to start World War Three, says Ukraine PM
Putin's nuclear threat: Russian leader nearly started World War Three over the Crimea war
Putin has started a 'war with the whole civilised world' which could leave MILLIONS dead
Russia's chilling THREAT to the West: Putin's army chief warns of 'how it will all END'
World War Three in SPACE? Fears over rise in anti-satellite weapons created by Russia
Migrant crisis and Euro tensions threaten to trigger catastrophic conflict claim experts
World War Three could begin TOMORROW - and UK's armed forces 'are woefully unprepared'
WW3 THREAT: Ex-Navy chief calls presence of Russia's SAMs in Syria 'extremely dangerous'
Turkey threatens to SHOOT DOWN Putin's planes as it drags West closer to war with Russia
hubgit / wordle-tweets.js
Last active Jan 20, 2022
Fetch and parse Wordle lines from recent tweets
View wordle-tweets.js
import fs from 'fs-extra'
import Twitter from 'twitter-v2'
const n = '213'
const query = `"wordle ${n}" -RT`
const auth = fs.readJSONSync('auth-node.json')
const client = new Twitter(auth)