Skip to content

Instantly share code, notes, and snippets.

View imshvc's full-sized avatar
🧭
Finding the Right Direction

Nurudin Imširović imshvc

🧭
Finding the Right Direction
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 <realnurudinimsirovic@gmail.com>
* @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.
@imshvc
imshvc / rand.js
Last active September 14, 2024 09:08
JavaScript pseudo-random number generator
/**
* Pseudo-random number generator
* @author Nurudin Imsirovic <realnurudinimsirovic@gmail.com>
* @param {number} count How many numbers to concatenate [1..10]
* @returns {number}
*/
function rand(count = 10) {
count |= 0
if (0 >= count)
@imshvc
imshvc / main.c
Created August 29, 2024 02:29
Windows API: List Processes
#include <windows.h>
#include <tlhelp32.h>
#include <stdio.h>
#ifdef __cplusplus
using namespace std;
#endif
void main() {
// We need to enumrate the list of processes.
@imshvc
imshvc / sleep.js
Last active September 14, 2024 00:54
JavaScript Sleep Function
/**
* Sleep for miliseconds
* @author Nurudin Imsirovic <realnurudinimsirovic@gmail.com>
* @param {number} ms
* @returns {undefined}
*/
function sleep(ms) {
if (0 >= ms)
return
@imshvc
imshvc / sql2cookie.sh
Last active August 9, 2024 16:39 — forked from rctay/gist:558851
dump mozilla sqlite3 cookies to netscape format
#
# Dumps data from a Mozilla sqlite cookie jar into Netscape cookie format.
#
# Useful if you want to run curl with your browser's cookies.
#
#!/bin/sh
SQLITE=sqlite3
MOZ_PROFILE=$1
MOZ_COOKIE_JAR="$MOZ_PROFILE/cookies.sqlite"
@imshvc
imshvc / make.bat (2024-08-02)
Last active August 2, 2024 05:59
'make' cmd template for 'tcc'
@echo off
rem -------------------------------------------------------
rem Author: Nurudin Imsirovic
rem Abstract: Simple 'make' wrapper for 'tcc' under Windows
rem Created: 2024-08-01 06:35 PM
rem Updated: 2024-08-02 07:59 AM
rem -------------------------------------------------------
setlocal
@imshvc
imshvc / .seo-id
Created April 21, 2024 12:08
.seo-id
15bf1340ad027c9cd14f-a51f30c7-6359b831-8e9f4efb-ff64f347
@imshvc
imshvc / gitea.service
Created December 26, 2023 05:39
Gitea Systemd Service Unit
[Unit]
Description=Gitea service bootstrap for /opt/gitea/gitea
[Service]
Type=simple
ExecStart=/opt/gitea/gitea web
ExecStop=/opt/gitea/gitea manager shutdown
Restart=on-failure
User=user
Group=1000