Skip to content

Instantly share code, notes, and snippets.

View imshvc's full-sized avatar

Nurudin Imširović imshvc

  • Bosnia and Herzegovina
View GitHub Profile
@imshvc
imshvc / video2frame.js
Created September 22, 2024 17:46
Save frame from video element
/**
* Save frame from video element
* @author Nurudin Imsirovic <[email protected]>
* @param {Element} video Video element
* @param {boolean} download Download frame as file
* @param {string} filename Download name
* @return {?string} Blob URL of frame
*/
function video2frame(video = null, download = true, filename = null) {
// Not a video element
@imshvc
imshvc / xhr.js
Last active September 16, 2024 17:23
Asynchronous XMLHttpRequest abstraction
/**
* Asynchronous XMLHttpRequest abstraction.
* @author Nurudin Imsirovic <realnurudinimsirovic@gmail.com>
* @param {string} requestMethod - HTTP Request Method [GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH]
* @param {string} requestSource - URL or relative path to a resource
* @param {string} requestData - Data to be sent (only for POST method)
* @param {function} callback - Callback function for handling the response
* @param {string|null} requestUsername - HTTP Basic Auth Username (default `null`)
* @param {string|null} requestPassword - HTTP Basic Auth Password (default `null`)
* @throws {Error} Throws an error if XMLHttpRequest is not supported or if the callback is not a function.