Skip to content

Instantly share code, notes, and snippets.

View akostadinov's full-sized avatar

Aleksandar N. Kostadinov akostadinov

View GitHub Profile
@akostadinov
akostadinov / async_tests.rb
Last active November 28, 2023 21:09
async redis playground
View async_tests.rb
# 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 / stack_trace.sh
Last active October 16, 2023 01:11
Get stack trace in Bash shell script/program.
View stack_trace.sh
# 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 / jenkins cancel running builds
Created December 22, 2020 19:56
Cancel all running Jenkins builds with system groovy script
View jenkins cancel running builds
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
View fonts_find.sh
#!/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
View FFMETADATAFILE.example
;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
View jenkins_creds_script.groovy
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
View cucumber_pry
# 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
View Low_Level_Format_Disk.md

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
View split.sh
#!/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 \
@akostadinov
akostadinov / print_only_cuke_filter.rb
Created January 14, 2022 16:39
Cucumber list-only filter. Will only print list of feature files that were selected for testing. Needs to be registered as a last filter.
View print_only_cuke_filter.rb
require 'cucumber/core/filter'
# put inside features/support/
class PrintOnlyCukeFilter < Cucumber::Core::Filter.new
def test_case(test_case)
announce
print_file_for(test_case)
end
private