Skip to content

Instantly share code, notes, and snippets.

@eladkarako
eladkarako / copy_to_clipboard.js
Last active August 22, 2026 16:22
copy_to_clipboard is a javascript for web-browsers, it first tries the modern API that needs a secure context, and document with some user-interaction, if failed, it tries old-school way. best to be used with button or anchor elements and click events. textarea may be used instead of div, but div can handle more text.
const copy_to_clipboard = async (text)=>{
text = String(text);
//------------------------------------------------------- a lot of checks needs to finish, I've condensed it to just trying. failing will skip to old-school way without notifying regards errors in this modern clipboard API (for example lack of permission would result with "NotAllowedError"), the sum of this function is "maximum effort", in most cases you'll probably end up using the old-school way. if you want you can use explicit true===self.isSecureContext && navigator.clipboard && navigator.clipboard.writeText && navigator.permissions && navigator.permissions.query && ("granted" === (await navigator.permissions.query({name:"clipboard-write"})).state)
let is_success = false;
try{
await navigator.clipboard.writeText(text);
is_success = true;
}catch(err){}
if(is_success){return;}
@setlocal DisableDelayedExpansion
@echo off
:: =============================== BEGIN MAIN ===============================
:: Parse args (spaces preserved), detect architecture relaunch needs
set "_ARGS=%*"
set "_REL1="
set "_REL2="
@eladkarako
eladkarako / display resolution explained.md
Created August 14, 2026 16:11
display resolution explained
Label / Name Resolution (W×H) Aspect ratio (most common) Pixel count (≈) Notes / typical usage
540p / qHD 960 × 540 16:9 518,400 (0.52 MP) Roughly “half” of 720p by pixels; often for older devices/low-bandwidth streaming.
720p / HD 1280 × 720 16:9 921,600 (0.92 MP) Common baseline for HD video; widely supported for streaming and broadcast.
1080p / Full HD (FHD) 1920 × 1080 16:9 2,073,600 (2.07 MP) The classic “Full HD” standard for most video platforms and content libraries.
2K 2048 × 1080 ~1.90:1 (≈ 18:9) 2,211,840 (2.21 MP) “2K” is a naming convention; in consumer video it’s often used for 2048×1080. Often confused with “Quad HD” in display contexts.
1440p / QHD / WQHD 2560 × 1440 16:9 3,686,400 (3.69 MP) A common “2× 720p” pixel count; frequently used for higher-refresh gaming and sharp desktop displays.
2160p / UHD 3840 × 2160 16:9 8,294,400 (8.29 MP) “4× 1080p” by pixel count; also referred to as UH
@eladkarako
eladkarako / getting release tag without using github api.md
Last active August 14, 2026 16:36
getting github latest release tag name, without using github api

TL;DR you use curl --head --location --write-out "%{url_effective}" --url "https://github.com/[USER]/[REPO]/releases/latest/download/foo.bar"


here is an example, in-practice,
yt-dlp (nightly) uses github API to check to see if it is the latest version available,
but github API is rate limited, and often fails (without a token).

@eladkarako
eladkarako / interlaced video generating with ffmpeg, including intentionally wrongly marked meta-data, to make sure idet still gives correct derived information.md
Created August 9, 2026 08:52
interlaced video generating with ffmpeg, including intentionally wrongly marked meta-data, to make sure idet still gives correct derived information
# File naming concept (pattern) Video content type Base rate (progressive) Output cadence (fields) Interlace generation Field metadata (signaling)
1 ${W}x${H}_${fps}p_prog.mkv Progressive control 24/25/30/60 = fps none (progressive) not meaningful / interlaced=0
2 ${W}x${H}_${fps}p_to_${fps}i_genField0_meta_ok_metaField0}.mkv Interlaced 24/25/30/60 2*fps tinterlace field=0 meta_field=0 => -field_order bt
3 ${W}x${H}_${fps}p_to_${fps}i_genField0_meta_wrong_metaField1}.mkv Interlaced 24/25/30/60 2*fps tinterlace field=0 meta_field=1 => -field_order tt
4 ${W}x${H}_${fps}p_to_${fps}i_genField1_meta_ok_metaField1}.mkv Interlaced 24/25/30/60 2*fps tinterlace field=1 meta_field=1 => -field_order tt
5 ${W}x${H}_${fps}p_to_${fps}i_genField1_meta_wrong_metaField0}.mkv Interlaced 24/25/30/60 2*fps tinterlace field=1 meta_field=0 => -field_order bt
  • both iterlaced and "normal"
@eladkarako
eladkarako / ffmpeg loglevel verbosity, and flags such as datetime and repeat, explained.md
Created August 1, 2026 17:27
ffmpeg loglevel verbosity, and flags such as datetime and repeat, explained

Possible levels are (choose one):

level variable value meaning
quiet AV_LOG_QUIET -8 Print no output.
(empty) AV_LOG_PANIC 0 Something went really wrong and we will crash now.
fatal AV_LOG_FATAL 8 Something went wrong and recovery is not possible. For example, no header was found for a format which depends, on headers or an illegal combination of parameters is used.
error AV_LOG_ERROR 16 Something went wrong and cannot losslessly be recovered. However, not all future data is affected.
warning AV_LOG_WARNING 24 Something somehow does not look correct. This may or may not lead to problems. An example would be the use of '-vstrict -2'.
info AV_LOG_INFO 32 Standard information.
@eladkarako
eladkarako / ffmpeg_updater.cmd
Last active August 1, 2026 17:29
tiny script to keep the binaries of ffmpeg ffprobe ffplay updated (download, unpack, generate help files)
::@echo off
chcp 65001 1>nul 2>nul
pushd "%~sdp0.."
set "TARGET_FOLDER=%CD%"
popd
set "TEMP_FOLDER=%TEMP%\ffmpeg_%RANDOM%"
@eladkarako
eladkarako / autounattend.xml
Last active July 30, 2026 21:23
skip minimal requirement and speed-up first steps in the new setup of Windows 11 (26H1)
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<!-- https://gist.githubusercontent.com/eladkarako/c64631cc3135a1c02130fff1c2d57194/raw/autounattend.xml -->
<settings pass="windowsPE">
<component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ComplianceCheck><DisplayReport>Never</DisplayReport></ComplianceCheck> <!-- https://learn.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/microsoft-windows-setup-compliancecheck -->
<Diagnostics><OptIn>false</OptIn></Diagnostics> <!-- https://learn.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/microsoft-windows-setup-diagnostics -->
<DynamicUpdate><Enable>true</Enable><WillShowUI>Always</WillShowUI></DynamicUp
@eladkarako
eladkarako / chkdsk check disk in Windows 11 bundle command.txt
Created July 30, 2026 20:15
chkdsk check disk in Windows 11 bundle command
chkdsk e: /f /v /x
chkdsk e: /scan /forceofflinefix /perf /sdcleanup /offlinescanandfix
chkdsk e: /spotfix /sdcleanup /offlinescanandfix
@eladkarako
eladkarako / ffmpeg__encode_intel_h264__encode_aac__embed_subtitle__output_folder.cmd
Created July 28, 2026 02:50
ffmpeg encode to h264 aac and embed a .srt subtitle SDH file with same name. yet another encoder. support one after the other encoding. intel hardware encoding.
::@echo off
chcp 65001 1>nul 2>nul
goto LOOP
::###########################################################################################
::# - drag and drop any amount of files. they will be processed one after the other. #
::# - for each media file (foo.mkv) the script assumes there is '.srt' file with same name. #
::# - result will be placed under 'output' folder. #
::# #
::###########################################################################################