Skip to content

Instantly share code, notes, and snippets.

View akostadinov's full-sized avatar

Aleksandar N. Kostadinov akostadinov

View GitHub Profile
@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 / 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 / chapters-youtube.rb
Last active June 8, 2024 21:31
geerates chapters.txt from a youtube video id
#!/bin/env ruby
# Usage: chapters-youtube.rb IDofTHEfineVIDEO
# see mux.rb - https://gist.github.com/akostadinov/8197947def1fe61c12a5ffffc615c969
require "json"
require "open-uri"
def sec_to_time(sec)
sec = Integer(sec)
@akostadinov
akostadinov / mux.rb
Last active June 8, 2024 21:08
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 / 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 / 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 \
@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