Skip to content

Instantly share code, notes, and snippets.

View bhouston's full-sized avatar

Ben Houston bhouston

View GitHub Profile
@bhouston
bhouston / Dockerfile-npm
Last active June 1, 2023 12:55
Yarn vs NPM speed test.
FROM node:16-alpine
WORKDIR /usr/src/app
# install dependencies
COPY package*.json ./
COPY packages/shared/package*.json ./packages/shared/
COPY packages/collector/package*.json ./packages/collector/
COPY packages/frontend/package*.json ./packages/frontend/
RUN npm ci
@bhouston
bhouston / threads-webgl.js
Created July 6, 2023 13:04
Meta Threads.net ThreeJS WebGL Code
__d(
'useThrottledImpl',
['cr:1708227'],
function (a, b, c, d, e, f, g) {
'use strict';
g['default'] = b('cr:1708227');
},
98
);
__d(
@bhouston
bhouston / downloadImage.ts
Last active December 12, 2023 18:42
Save remote image to disk
import axios from 'axios';
import fs from 'fs';
import path from 'path';
async function downloadImageAsAxiosStream(url: string, filename: string) {
// Fetch the image
const response = await axios({
url,
method: 'GET',
responseType: 'stream'
@bhouston
bhouston / imageServing.ts
Created December 13, 2023 14:09
old lv api image serving code.
const fileUrl = new URL(`/api/files/${fileId}/content`, API_URL);
const url = new URL('/api/images', API_URL);
url.pathname += `/webp`;
url.pathname += `/${params.width ?? 0}`;
url.pathname += 'x';
url.pathname += `${params.height ?? 0}`;
url.pathname += `/filters:format(${params.extension ?? 'png'})`;
url.pathname += `/${fileUrl}`;