Skip to content

Instantly share code, notes, and snippets.

View andrewchilds's full-sized avatar
👨‍💻

Andrew Childs andrewchilds

👨‍💻
View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andrewchilds
andrewchilds / saveGPT.bookmarklet.js
Last active May 14, 2025 09:36
Download ChatGPT conversations as markdown files.
javascript:function parseChatGPTData(data) { const mapping = data.mapping; const conversationTitle = data.title; const createDate = new Date(data.create_time * 1000).toISOString().slice(0, 10); const messagesArray = Object.values(mapping) .filter(node => node.message) .map(node => { const message = node.message; const sender = message.author.role === 'user' ? 'You' : 'Assistant'; const content = message.content.parts.join(''); const createTime = message.create_time; return { sender: sender, content: content, createTime: createTime, }; }); messagesArray.sort((a, b) => a.createTime - b.createTime); return { date: createDate, title: conversationTitle, messages: messagesArray.map(({ sender, content }) => ({ sender, content })), }; } function download(filename, text) { const element = document.createElement('a'); element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)); element.setAttribute('download', filename); element.style.display = 'none'; document.body.appendChild(element); e
@andrewchilds
andrewchilds / README.md
Last active June 27, 2023 13:03
How to configure HAProxy to proxy h2 (encrypted http2) to h2c (plain text http2) connections

How to configure HAProxy to support end-to-end (e2e) connections that switch from h2 to h2c

This was tested to work using HAProxy 2.8 on Ubuntu 20.04.

Use case

This lets you run a cluster of API servers configured to use HTTP/2 (for example, Fastify using { http2: true }), behind a HAProxy LB, so that you can serve typical REST API requests as well as SSE (Server Side Events) streaming connections, so that you can do fancy real-time page updates in your app.

Using HTTP/2 resolves the "6 concurrent HTTP connections" limit imposed by Chrome/Firefox/etc, which means the web app would become unresponsive if the user has 6+ tabs open with the app simultaneously.