Skip to content

Instantly share code, notes, and snippets.

View bogdan's full-sized avatar
💭
Temporary enslaved by prompt

Bogdan Gusiev bogdan

💭
Temporary enslaved by prompt
View GitHub Profile
#!/usr/bin/env ruby
require_relative "../config/environment"
def rss_kb
`ps -o rss= -p #{Process.pid}`.to_i
end
$measure_depth = 0

Contribution to Ruby on Rails

Source: https://contributors.rubyonrails.org/contributors/bogdan-gusiev/commits (#76 all-time contributor, 143 commits, 2011–2026)

  1. ActiveRecord querying & preloading — refactored the preloader for performance, fixed duplicate record handling, implemented pluck, and improved #last to leverage SQL-level ordering.
  2. Association handling — fixed counter cache calculation bugs, foreign key replacement in inverse associations, and collection association creation methods.
  3. ActiveSupport callbacks — extensively refactored the callback system, removing dead code, deprecating legacy options, and simplifying/optimizing logic.

Overall focus: code quality, performance, and bug fixes rather than new feature work.

@bogdan
bogdan / token-join-summary.md
Last active July 16, 2026 11:04
Rename token types and centralize space-aware token joining

Rename token types and centralize space-aware token joining

Commit: https://github.com/hosmada/emr/commit/2c27eb5381d082e0a9745085d384b8fbe74e83e6

What changed:

  • Renamed two Token#token_type values for clarity: wordjapanese_word and foreignlatin_word.
  • Added SuikaTokenizer.join(tokens), a shared helper that reconstructs text from tokens correctly instead of naively joining with a fixed separator. It only inserts a space between two consecutive "space-delimited" tokens (Latin words, abbreviations, and numbers) — Japanese tokens never get a space.
  • Wired Meeting#utterances and ReviewWorkflow#phi_review_data to use this new helper instead of tokens.map(&:text).join(" ").
  • Updated the token test factory to auto-classify token_type from text via the real tokenizer instead of hardcoding a default.
#!/usr/bin/env ruby
# frozen_string_literal: true
# Speech-to-Text v2 diarization test (chirp_3 model, Japanese by default).
#
# KEY FINDING: chirp_3 + diarizationConfig only works in the "us" multi-region.
# It is rejected everywhere else tested (global, us-central1, europe-west4,
# asia-southeast1, europe-west3) with either "model does not exist" or
# "Permission denied ... It is no longer generally available." Only the
# "us" multi-region endpoint accepts it, and only via the async
# syntax=docker/dockerfile:1
# check=error=true;skip=SecretsUsedInArgOrEnv
# This Dockerfile is designed for production, not development. Use with Kamal or build'n'run by hand:
# docker build -t realphotos_marketplace .
# docker run -d -p 80:80 -e RAILS_MASTER_KEY=<value from config/master.key> --name realphotos_marketplace realphotos_marketplace
# For a containerized dev environment, see Dev Containers: https://guides.rubyonrails.org/getting_started_with_devcontainer.html
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version
steps:
# Pull cache images for both build stage and final image (ignore failure on first run)
- id: "pull-cache"
name: "gcr.io/cloud-builders/docker"
entrypoint: /bin/bash
args:
- -c
- |
docker pull ${_IMAGE_NAME}:build-cache || true && \
docker pull ${_IMAGE_NAME}:latest || true
@bogdan
bogdan / meeting_596_phi_analysis.md
Created July 9, 2026 10:02
Meeting 596 PHI token analysis

Meeting 596 PHI Token Analysis

Token(s) Reading Context Assessment
鈴木 Suzuki 鈴木さん こんにちは Patient surname — PHI
さん -san suffix after 鈴木 Honorific — not PHI
鈴木 一郎 Suzuki Ichiro 鈴木一郎と言います (my name is Suzuki Ichiro) Patient full name — PHI
1989 年 の 10 月 15 日 October 15, 1989 生まれです (born on) Patient DOB — PHI, but の, 年, 月, 日 are grammatical particles/units
島田 Shimada 島田先生 Doctor's surname — debatable (provider name)
先生 sensei/doctor title after 島田 Title only — not PHI

Third-Party Face Removal from Video

Variants for handling third-party faces that appear in recorded video segments.


1. Cut the Segment

Remove the time range entirely from the final export.

require 'open3'
require 'json'
module InsightFace
SCRIPT = Rails.root.join("bin/insightface").to_s
CMD = if Rails.env.production?
["/app/.heroku/python/bin/python3", SCRIPT]
else
["uv", "run", SCRIPT]
#!/usr/bin/env python3
"""
Face detection via InsightFace (ONNX-based, no TensorFlow).
Usage:
bin/insightface <image_path>
cat image.jpg | bin/insightface
Outputs detected faces as JSON to stdout (same schema as bin/retinaface).