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

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).

Morphology — Conversation Token Format

Specification for the JSON data structure produced by speech-to-text extraction from doctor/patient video recordings. The output is a flat, time-ordered array of tokens — the smallest meaningful units of spoken language: words, numbers, and punctuation.


Top-level structure

[

How We Keep Our API and Frontend Automatically In Sync

Our backend is a Ruby REST API built with Grape. Our frontend is TypeScript. Keeping them in sync manually is a recipe for silent drift — a renamed field here, a removed param there, and suddenly the frontend is sending requests the server no longer understands or rendering fields that no longer exist.

This post describes the pipeline we built so that the server code is the single source of truth, type mismatches are caught before they ship, and backward incompatibilities surface as compiler errors rather than production bugs. The specific tools are Ruby-flavored, but the pattern is language-agnostic and maps directly to FastAPI, NestJS, or any framework that can generate an OpenAPI spec from code.


The Pipeline at a Glance

<script lang="ts">
import * as Routes from '../routes';
import { Image, Info } from '@lucide/svelte';
export interface Face {
id: number;
oval: { cx: number; cy: number; rx: number; ry: number; angle: number };
approved_with_default: boolean;
}
[ActiveJob] [ObservaImport::ImportJob] [119ae6b0-f942-4fc1-96fa-f3b18972e1ec] HTTP GET (13617.91ms) https://observaprodstorage.blob.core.windows.net:443/observa-observations-media/obs_1078807_13681178.jpg
[ActiveJob] [ObservaImport::ImportJob] [35435437-bd07-4261-aa42-5c9f13696f45] HTTP GET (11262.95ms) https://observaprodstorage.blob.core.windows.net:443/observa-observations-media/obs_1078807_13681186.jpg
[ActiveJob] [ObservaImport::ImportJob] [44142748-fda1-458f-ad6c-b49e812c5ba8] HTTP GET (828.76ms) https://observaprodstorage.blob.core.windows.net:443/observa-observations-media/obs_1078807_13681183.jpg
[ActiveJob] [ObservaImport::ImportJob] [5ed1a017-fbdf-4590-9b9b-ac7053c34a45] HTTP GET (10425.22ms) https://observaprodstorage.blob.core.windows.net:443/observa-observations-media/obs_1078807_13681185.jpg
[ActiveJob] [ObservaImport::ImportJob] [72b38b9f-487f-4cc3-9497-8f89f91dc2a9] HTTP GET (2801.01ms) https://observaprodstorage.blob.core.windows.net:443/observa-observations-media/obs_107
# frozen_string_literal: true
require "date"
require "hexapdf"
require "pathname"
require "stringio"
require "tempfile"
require 'furi'
module PDFUtils
MIME_TYPE = "application/pdf"

Here’s a minimal, idiomatic Rails example wiring Current.organization into your routes and URL generation using your scoped routes.


1. Current

class Current < ActiveSupport::CurrentAttributes
  attribute :organization
end
Here’s a **minimal, idiomatic Rails example** wiring **`Current.organization`** into your routes and URL generation using your scoped routes.
---
## 1. `Current`
```ruby
class Current < ActiveSupport::CurrentAttributes
attribute :organization
end