Skip to content

Instantly share code, notes, and snippets.

View FranckFreiburger's full-sized avatar
🙂
Hello World !

Franck Freiburger FranckFreiburger

🙂
Hello World !
View GitHub Profile
// indexedDB doc: https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API/Using_IndexedDB#basic_pattern
const pdb = new Promise((resolve, reject) => {
const request = indexedDB.open("compiledCache", 1);
request.onerror = (event) => reject(event);
request.onsuccess = (event) => resolve(event.target.result);
request.onupgradeneeded = (event) => {
request.onsuccess = null;
@FranckFreiburger
FranckFreiburger / duplexify.mjs
Last active November 2, 2022 07:20
nodejs readable and writable stream to duplex stream
import { Duplex } from 'stream'
export default class Duplexify extends Duplex {
constructor(writable, readable) {
super({
readableObjectMode: readable.readableObjectMode,
writableObjectMode: writable.writableObjectMode,
readableHighWaterMark: readable.readableHighWaterMark,
@FranckFreiburger
FranckFreiburger / getJpegQuality.js
Created October 4, 2018 13:22
pure JavaScript jpeg quality value recover
// javascript jpeg decoder: https://github.com/eugeneware/jpeg-js/blob/79c4c7ea876d2e7b46981a563fcc4ae8f9e19849/lib/decoder.js
// Determine the JPEG compression quality from the quantization tables: https://github.com/ImageMagick/ImageMagick/blob/59f28acff016f6ae5e8b7e6300bcdf97e94affc9/coders/jpeg.c#L879
// JPEG File Layout and Format: http://vip.sugovica.hu/Sardi/kepnezo/JPEG%20File%20Layout%20and%20Format.htm
// jpeg constants: https://github.com/LuaDist/libjpeg/blob/6c0fcb8ddee365e7abc4d332662b06900612e923/jpeglib.h#L45
function getQuantizationTables(data) {
var quantizationTables = []
var dctZigZag = new Int32Array([