Skip to content

Instantly share code, notes, and snippets.

View akostadinov's full-sized avatar

Aleksandar N. Kostadinov akostadinov

View GitHub Profile
@akostadinov
akostadinov / dollar_encoder.rb
Created June 12, 2026 15:07
A script to dollar-sign encode any string.
#!/usr/bin/env ruby
# frozen_string_literal: true
# LICENSE: AGPL3, commercial licenses available from only $1 per 100 encoded characters.
# Encodes bytes into sequences of three dollar sign Unicode characters:
# U+0024 ($), U+FE69 (﹩), U+FF04 ($)
class DollarEncoder
# The three dollar sign characters used for encoding
DOLLAR_SIGNS = [

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 / ruby-oci8-lob-performance.rb
Created December 4, 2025 16:27
Test the performance of fetching LOBs with ruby-oci8 gem
#!/usr/bin/env ruby
#
# Ruby-level LOB fetch performance test
#
# Measures Ruby execution time for the same operations as bench_lob_fetch.c
# Tests 10,000 rows with 10KB LOBs using three different fetch modes:
# 1. LONG interface (:long_as_string) - default, fast
# 2. LOB locators without prefetch (:locator) - slow
# 3. LOB locators with prefetch (:locator + lob_prefetch_size) - slower
#
@akostadinov
akostadinov / rails_dump_data.rb
Last active November 24, 2025 15:59
export/import data Rails script, AI assisted and clunky but can work also between database types
#!/usr/bin/env ruby
# frozen_string_literal: true
# Export/Import all data from/to database via stdin/stdout
# Usage:
# RAILS_LOG_TO_STDOUT=false bundle exec rails runner dump_data.rb export > data.jsonl
# bundle exec rails runner dump_data.rb import < data.jsonl
require 'json'
@akostadinov
akostadinov / claude_disable_mcps.rb
Created November 4, 2025 19:42
claude_json_disable_mcps.rb
#!/usr/bin/env ruby
# LICENSE: MIT
# ASSITED_BY: CLAUDE CODE
require 'json'
require 'tempfile'
# Read the claude.json file
claude_json_path = File.expand_path('~/.claude.json')
@akostadinov
akostadinov / serial_port.c
Last active August 26, 2025 10:41
Open Serial port and select DTR/RTS pins high/low
# LICENSE: MIT
# WARN: AI tool assisted
# INFO: seems like on my USB controller both are high while port open, then low.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
@akostadinov
akostadinov / stack_trace.sh
Last active February 20, 2025 05:44
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 / FFMETADATAFILE.example
Last active February 18, 2025 17:52
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 / find_and_rename_bad_windows_filenames.sh
Last active October 16, 2024 09:28
Find and rename files and directories with characters that windows does not support.
#!/bin/env bash
# run like:
# $ find_and_rename_bad_windows_filenames.sh mypath1 mypath2
# You may need to run a few times in case there are multi-spaces at beginning or end of files.
# All can be done in one go but too lazy to optimize further.
find_regexp='.*/[^/]*[<>:"\\|?*'$'\b'$'\t''][^/]*'
#tr_from='<>:"\\|?*\b\t'
#tr_to='\-\-\-\-\-\-@\- '
@akostadinov
akostadinov / jenkins_creds_script.groovy
Last active June 19, 2024 08:50
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("-----------------------")
}