My Elasticsearch cheatsheet with example usage via rest api (still a work-in-progress)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// INCOMPLETE | |
// This command will give you list of available FFMPEG formats and their default Mime types | |
// ffmpeg -formats -hide_banner | tail -n +5 | cut -c5- | cut -d' ' -f1 | xargs -i{} ffmpeg -hide_banner -h demuxer={} | pcregrep -o2 -o4 -M '(Muxer (\w+) )|(Mime type:( .*).)' | |
// And then parse the output with regex to JSON format in JavaScript for example: | |
// str.match(/(.*)\n (.*)/gm).map(m => `"${m.replace(/\n /, '": "')}"`).join(',\n'); | |
// Combine the output with MDN - Common MIME types | |
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types | |
// And with IANA: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See compatibility table for .toBlob() Method | |
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob#browser_compatibility | |
interface Option { | |
type: 'image/jpeg' | 'image/png' | 'image/webp' | 'image/bmp' | 'image/gif'; | |
quality?: number; | |
} | |
async function compressImage(file: File, option: Option) { | |
if (!file.type.startsWith('image')) { |
OlderNewer