Skip to content

Instantly share code, notes, and snippets.

View angstyloop's full-sized avatar

Sean Allen angstyloop

View GitHub Profile
@thomaskonrad
thomaskonrad / saveFile.ts
Created February 8, 2020 16:33
Downloading an Array Buffer via a "Save as" Dialog in the Browser
// This source code is taken from Firefox Send (https://github.com/mozilla/send) and slightly modified.
export default async function saveFile(plaintext: ArrayBuffer, fileName: string, fileType: string) {
return new Promise((resolve, reject) => {
const dataView = new DataView(plaintext);
const blob = new Blob([dataView], { type: fileType });
if (navigator.msSaveBlob) {
navigator.msSaveBlob(blob, fileName);
return resolve();
@jcupitt
jcupitt / introspect.c
Last active March 8, 2023 06:52
libvips introspection demo
/* vips8 introspection demo
*
* compile with:
*
* gcc -g -Wall introspect.c `pkg-config vips --cflags --libs`
*
* try:
*
* ./a.out embed
*