Skip to content

Instantly share code, notes, and snippets.

View akostadinov's full-sized avatar

Aleksandar N. Kostadinov akostadinov

View GitHub Profile
@akostadinov
akostadinov / mux.rb
Last active March 3, 2024 22:55
ffmpeg mux video audio and subtitle files with subtitles
#!/bin/env ruby
# License: MIT
require 'shellwords'
require 'tempfile'
class MuxerCLI
attr_reader :dir
@akostadinov
akostadinov / stack_trace.sh
Last active March 3, 2024 19:50
Get stack trace in Bash shell script/program.
# LICENSE: MIT, wtfpl or whatever OSS license you like
function get_stack () {
STACK=""
local i message="${1:-""}"
local stack_size=${#FUNCNAME[@]}
# to avoid noise we start with 1 to skip the get_stack function
for (( i=1; i<$stack_size; i++ )); do
local func="${FUNCNAME[$i]}"
[ x$func = x ] && func=MAIN
local linen="${BASH_LINENO[$(( i - 1 ))]}"
@akostadinov
akostadinov / async_tests.rb
Last active November 28, 2023 21:09
async redis playground
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem 'concurrent-ruby', '~> 1.1.6'
@akostadinov
akostadinov / jenkins cancel running builds
Created December 22, 2020 19:56
Cancel all running Jenkins builds with system groovy script
import jenkins.model.Jenkins
def numCancels = 0;
Jenkins.instance.getAllItems(Job.class).each{
def job = it
for (build in job.builds) {
if (build.isBuilding()) { build.doStop(); numCancels++; }
}
}
@akostadinov
akostadinov / fonts_find.sh
Created May 19, 2021 21:10
shows fonts containing character
#!/usr/bin/env bash
# example: ./font_find.sh 🎩︎
# credits: David Baynard, https://unix.stackexchange.com/a/393740/14907
param="$1"
char=${param:0:1}
printf '%x' \'"$char" | xargs -I{} fc-list ":charset={}"
@akostadinov
akostadinov / FFMETADATAFILE.example
Last active October 9, 2022 03:16
ffmpeg chapters creation
;FFMETADATA1
major_brand=mp42
minor_version=0
compatible_brands=mp42mp41
title=Sharks Group Video Film.mp4
comment=some comment
encoder=Lavf58.76.100
[CHAPTER]
TIMEBASE=1/1000
@akostadinov
akostadinov / jenkins_creds_script.groovy
Last active July 22, 2022 00:14
jenkins credentials obtain on script console
com.cloudbees.plugins.credentials.SystemCredentialsProvider.getInstance().getCredentials().forEach{
it.properties.each { prop, val ->
if (prop == "secretBytes") {
println(prop + "=>\n" + new String(com.cloudbees.plugins.credentials.SecretBytes.fromString("${val}").getPlainData()) + "\n")
} else {
println(prop + ' = "' + val + '"')
}
}
println("-----------------------")
}
@akostadinov
akostadinov / cucumber_pry
Last active April 14, 2022 11:31
hack cucumber 1.3 to have an entry point to debug and continue scenario after failure
# execute this code to fall into a pry session upoon step failure
# works only with cucumber 1.3
# so far for 2.0 best similar approach is to us the After hook
# fall into pry/buybug if scenario.failed? is true
# After hook works for 1.3 as well
Cucumber::Ast::StepInvocation.class_eval do
## first make sure we don't lose original accept method
unless self.instance_methods.include?(:orig_accept)
alias_method :orig_accept, :accept

A Low Level Format (LLF) means redefining physical disk layout. This is not doable by user on today's HDDs and SSDs. One usually want's to perform LLF to securely erase all data, reallocate bad sectors and/or remove malware.


[ATA Secure Erase][1]

Allows you to erase data on disk even on reallocated sectors. See:

@akostadinov
akostadinov / split.sh
Last active February 18, 2022 11:33
ffmpeg split by chapter
#!/usr/bin/env bash
# based on https://stackoverflow.com/a/61525373/520567
# you can play with -metadata and file name as you see fit
set -efu
videoFile="$1"
ffprobe -hide_banner \