Tag Archives: programiranje

Curio

Pre par nedelja pravio kolegama tutorijal kako Klod kod povezati sa našim projektima da ne bi radio u mraku kada treba nešto da se redizajnira. Pošto ne koristim Klod, morao sam da kupim pretplatu da bih mogao uopšte da ga pokrenem pa sam se isprsio 20 dolara. U stvari prvo sam platio za nešto ne znam ni ja šta, tokene, 20 dolara, pa se ispostavilo da mi za Klod kod treba baš pretplata a ne samo tokeni te sam platio još 20 🙁 Sad, da mi to ne bi propalo, dadoh mu projekat da mi napravi, veb aplikaciju za vođenje kolekcija. Oko sat vremena mu je trebalo, potrošio je skoro deset dolara. Deluje da aplikacija radi kako treba, sutra ću malo da se udubim i možda da vratim nešto na doradu 🙂

Praktična primena AI-ja

  Cursor Agent
  /data/serije/Touch of Frost, A/S01
  (cwd is not a git repository, cursor rules and ignore files don't apply)

 ┌───────────────────────────────────────────────────────────────────────────┐
 │ Is there a way to calculate offset in percentage between two timestamps?  │
 │ Looks like second timestamp is slower by some percent                     │
 │ in regard of first one: 00:01:07,96 => 00:01:09,869                       │
 │ 00:03:16,96 => 00:03:26,308                                               │
 │ 00:04:34,96 => 00:04:45,888                                               │
 └───────────────────────────────────────────────────────────────────────────┘

  Yes, you can calculate this. Let me convert and analyze the timestamps:
  | First (seconds)  | Second (seconds) | Ratio (t2/t1)  |
  |------------------|------------------|----------------|
  | 67.96            | 69.869           | 1.0281 (2.81%) |
  | 196.96           | 206.308          | 1.0474 (4.74%) |
  | 274.96           | 285.888          | 1.0397 (3.97%) |
  
  The ratios aren't perfectly consistent, which suggests either:
  1. Measurement imprecision in the sample points
  2. A combination of scaling + offset rather than just scaling

  If we assume a linear relationship t2 = scale * t1 + offset, we can calculate:
  Using a linear regression approach with your 3 points:
  • Scale factor: ~1.043 (second is ~4.3% slower)
  • Offset: ~-1 second (small initial shift)

  To sync the second timestamps to match the first, you'd apply:

  corrected_time = (original_time + 1) / 1.043

  Or in percentage terms: the second set runs approximately 4.3% slower.
  Would you like me to write a script to resync subtitle files using this factor? If you share the actual .srt files, I can calculate a more
  precise correction factor using more data points.

 ┌───────────────────────────────────────────────────────────────────────────────┐
 │ You can compare 720p WEB-DL HEVC x265 BONE.en.srt and subs.srt. subs.srt      │
 │ have correct timestamps but don't have all lines.                             │
 │ First srt file have all lines but is lacking.                                 │
 └───────────────────────────────────────────────────────────────────────────────┘

  Let me read both subtitle files to compare their timestamps and calculate the precise sync factor.

  ⬢ Read 2 files
    Read ...nd Protection 720p WEB-DL HEVC x265 BONE.en.srt
    Read subs.srt

  Let me read the beginning of the first SRT file to compare timestamps.

  ⬢ Read ...nd Protection 720p WEB-DL HEVC x265 BONE.en.srt

  Now I can compare matching lines between the two files. Let me calculate the sync parameters:
  | Text                       | subs.srt (correct) | BONE.en.srt |
  |----------------------------|--------------------|-------------|
  | "I said I'd meet Tracy"    | 67.96s             | 69.869s     |
  | "Sorry"                    | 196.96s            | 206.308s    |
  | "Which is the most recent" | 274.96s            | 285.888s    |
  
  Using linear regression on these three points, the relationship is:
  t_bone = 1.045 × t_correct - 0.7
  This means:
  • Scale factor: 1.045 (BONE.en.srt runs ~4.5% slower)
  • Offset: ~0.7 seconds (small initial shift)

  To correct the BONE.en.srt timestamps:

  corrected_time = (bone_time + 0.7) / 1.045

  Would you like me to create a Python script that will:
  1. Read the BONE.en.srt file (which has all the subtitle lines)
  2. Apply this correction formula to all timestamps
  3. Save a new corrected SRT file

  This will give you a file with all the dialogue from BONE.en.srt but synced to match your video timing from subs.srt.

 ┌────────────────────────────────────────────────────────────────────────────────┐
 │ Proceed                                                                        │
 └────────────────────────────────────────────────────────────────────────────────┘

  ┌───────────────────────────────────────────────────────────────────────────────┐
  │ resync_srt.py +62                                                             │
  │                                                                               │
  │ + #!/usr/bin/env python3                                                      │
  │ + """                                                                         │
  │ + Resync SRT subtitles by applying a scale and offset correction.             │
  │ + Formula: corrected_time = (original_time + offset) / scale                  │
  │ + """                                                                         │
  │                                                                               │
  │ + import re                                                                   │
  │ + import sys                                                                  │
  │ +                                                                             │
  │ + # Correction parameters calculated from matching timestamps                 │
  │ + SCALE = 1.045  # BONE.en.srt runs 4.5% slower                               │
  │ + OFFSET = 0.7   # seconds to add before scaling                              │
  │  … truncated (51 more lines) · ctrl+r to review                               │
  └───────────────────────────────────────────────────────────────────────────────┘

  $ cd "/data/serije/Touch of Frost, A/S01" && python3 resync_srt.py 5.0s
    Resynced subtitles saved to: A Touch of Frost Season 01 Episode 01 - Care and Protection 720p WEB-DL HEVC x265 BONE.en.synced.srt
    Applied correction: time = (original + 0.7) / 1.045
    … truncated (1 more line) · ctrl+o to expand

  Let me verify the correction by comparing some timestamps.

  ⬢ Read ...ection 720p WEB-DL HEVC x265 BONE.en.synced.srt

  Done. Here's the comparison:
  | Line         | subs.srt (reference) | Original BONE | Corrected    |
  |--------------|----------------------|---------------|--------------|
  | "meet Tracy" | 00:01:07.96          | 00:01:09,869  | 00:01:07,530 |
  | "Sorry"      | 00:03:16.96          | 00:03:26,308  | 00:03:18,093 |
  
  The corrected file is within ~0.5-1s of the reference, which should be acceptable for viewing.
  Created files:
  • A Touch of Frost Season 01 Episode 01 - Care and Protection 720p WEB-DL HEVC x265 BONE.en.synced.srt - the resynced subtitles
  • resync_srt.py - the script (can be reused/adjusted if needed)

  Correction applied: time = (original + 0.7) / 1.045
  Test the synced file with your video. If timing still needs fine-tuning, you can adjust the SCALE and OFFSET values in the script and
  re-run it.

 ┌─────────────────────────────────────────────────────────────────────────────────┐
 │ → Add a follow-up                                                               │
 └─────────────────────────────────────────────────────────────────────────────────┘

  Claude 4.5 Opus (Thinking) · 42.9% · 1 file edited
  / commands · @ files · ! shell · ctrl+r to review edits

Cursor

Laravel Sail

OK, isprobao sam i Laravel Sail. Pre svega, ako hoćemo da koristimo SQLite bazu u projektu, moramo u lokalu da instaliramo php-sqlite ekstenziju i da je uključimo u php.ini:

sudo pacman -S php-sqlite
sudo nano /etc/php/php.ini # omogućiti pdo_sqlite i sqlite3

Onda kreiramo projekat u tekućem direktorijumu

composer create-project --prefer-dist laravel/laravel .

pa instaliramo Sail:

php artisan sail:install

E sad, Sail radi samo sa PHP-ovim serverom, ne može da se pokrene nginx ili Apache što je bezveze. Ako planiramo da projekat ikada ode u produkciju, neće se vrteti na PHP serveru 🙂 Tako da… nije ovo za mene. Držim se mog Docker compose-a.

You’ve hit on a valid point. Sail is essentially a convenience wrapper around Docker Compose. Here’s the honest breakdown:

What Sail Actually Provides

 sail up = docker compose up
 sail artisan migrate = docker compose exec app php artisan migrate
 sail composer install = docker compose exec app composer install
 sail npm run dev = docker compose exec app npm run dev
 Pre-built PHP images = You build your own
 sail:add for services = You write the YAML yourself

Sail Makes Sense When:

 • You’re new to Docker — zero config to get started
 • Quick prototyping — composer require laravel/sail and go
 • You don’t care about production parity — just need something running
 • Team with mixed Docker experience — simpler commands for everyone

Plain Docker Compose Makes Sense When:

 • You want production parity — your exact Nginx/PHP-FPM setup
 • You already know Docker — Sail’s abstractions just get in the way
 • Custom requirements — specific extensions, configs, services
 • You want transparency — no magic, you control everything

My Recommendation

Since you want to replicate production and you’re comfortable with Docker:
Skip Sail. Use plain Docker Compose.
Create your own docker-compose.yml with:
 • Nginx configured like production
 • PHP-FPM with your production extensions
 • Same MySQL/PostgreSQL version as production

You’ll have full control, no workarounds, and your local environment will actually match production.

Task Master

Napravili jednostavnu veb aplikaciju za upravljanje ličnim zadacima. Urađena je isključivo uz pomoć veštačke inteligencije u čistom HTML-u, CSS-u i JavaScript-u. Može da se pokrene u lokalu tako što se otvori index.html iz brauzera ali smo je radi lakše dostupnosti podigli na veb server. Ne postoji login na aplikaciju zato što se zadaci čuvaju lokalno, u local storage-u. Zadatke je moguće snimiti u fajl pa ih posle učitati u drugi brauzer/računar. Ima i podsetink 🙂

git merge development

Nakupi se dosta izmena na razvojnoj grani pa se uvek štrecnem kada to treba spojiti u master i izbildovati produkciju 🙂 Uglavnom je prošlo bez problema. Dve Artisan komande nisu radile kako treba i to zbog nekonzistentnosti podataka u produkcionim bazama što je bilo lako rešivo i nije uticalo na funkcionisanje sistema. Jedan jedini problem je bio kod registracije novih korisnika ali i to smo brzo zakrpili.

Enums

Apgrejdovali smo PHP na jednom od projekata pa se sad upoznajem sa enumima 🙂

Do sada smo u ovakvim situacijama koristili konstante, sada imamo enkapsulirani tip podataka. Enumi imaju predefinisane metode kao što su name, value i cases ali možemo da definišemo i sopstvene.