Skip to content

Instantly share code, notes, and snippets.

View nwaughachukwuma's full-sized avatar
🧶
Making stuff

Chukwuma Nwaugha nwaughachukwuma

🧶
Making stuff
View GitHub Profile
@nwaughachukwuma
nwaughachukwuma / cheatsheet-elasticsearch.md
Created March 23, 2020 05:04 — forked from ruanbekker/cheatsheet-elasticsearch.md
Elasticsearch Cheatsheet : Example API usage of using Elasticsearch with curl
@DusanBrejka
DusanBrejka / ffmpeg-format-to-mimetype.js
Last active April 8, 2025 21:26
FFMPEG - map of formats to default mime types
// 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:
@nwaughachukwuma
nwaughachukwuma / compressImage.ts
Last active January 14, 2023 04:27
Compress any image file before upload using imageBitmap and canvas
// 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')) {