Skip to content

Instantly share code, notes, and snippets.

@juike
juike / hg-3372-revised-plan.md
Created May 18, 2026 12:55
HG-3372 iteration 1 — revised plan

HG-3372 — Iteration 1 plan, revised

Revision of the iteration 1 plan from the original design doc. Changes are driven by a critique pass; each addresses a specific weakness in the original plan.

Revised iteration plan

Iteration 0 (expanded — now three sub-steps, not one)

0a. Behavior-capture specs. As originally scoped.

@juike
juike / 01-due-date-payout-date-policies.md
Last active May 27, 2026 09:08
HG-3372 iteration 1 — JIRA tickets

[HG-3372] Extract DueDatePolicy and PayoutDatePolicy from Cycle

Description

Move the rules that compute a cycle's due_date and payout_date into two stand-alone policy objects (HG::Billing::DueDatePolicy, HG::Billing::PayoutDatePolicy), constructed with the client and called at cycle creation time. The Cycle model keeps its due_date / payout_date columns and read API unchanged — only the computation moves out. This is step 1 of the iteration-1 refactor: variation that currently lives as private helpers on the model gets pulled into named classes so future date schemes (Net X, end-of-month, custom days) become new policy classes rather than new branches inside Cycle. Behavior is unchanged.

Acceptance criteria

  • HG::Billing::DueDatePolicy and HG::Billing::PayoutDatePolicy exist; the listed Cycle#* date methods are removed and the persisted due_date / payout_date columns are populated by the policies at cycle creation.
@juike
juike / restore.sql
Created November 21, 2014 06:40
Restoring a 'template1' database in PostgreSQL. (https://wiki.postgresql.org/wiki/Adventures_in_PostgreSQL,_Episode_1)
UPDATE pg_database SET datallowconn = TRUE WHERE datname = 'template0';
\c template0
UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';
DROP DATABASE template1;
CREATE DATABASE template1 WITH TEMPLATE = 'template0';
\c template1
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';
UPDATE pg_database SET datallowconn = FALSE WHERE datname = 'template0';
ffmpeg -i {filename} -acodec aac -ac 2 -strict experimental -ab 160k -s {ssize} -vcodec libx264 -preset slow -profile:v baseline -level 30 -maxrate 10000000 -bufsize 10000000 -b 1200k -f mp4 -threads 0 {filename}.ipad.mp4
@juike
juike / gist:9770209
Created March 25, 2014 20:07
Postgresql table inherits view
WITH RECURSIVE tables_tree (table_oid, path) AS (
SELECT I.inhparent AS table_oid, '{}'::oid[] AS path
FROM pg_inherits I
LEFT JOIN pg_inherits I2 ON I.inhparent = I2.inhrelid
WHERE I2.inhparent IS NULL
UNION
SELECT I.inhrelid, TT.path || I.inhparent
FROM pg_inherits I