<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Oren Grinker on Medium]]></title>
        <description><![CDATA[Stories by Oren Grinker on Medium]]></description>
        <link>https://medium.com/@orengr4?source=rss-d1f37945d1a6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*fBe4eD2crA-EDRuPX8zuzA.jpeg</url>
            <title>Stories by Oren Grinker on Medium</title>
            <link>https://medium.com/@orengr4?source=rss-d1f37945d1a6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 23:09:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@orengr4/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Preservation Contracts: Safer AI Agent Changes in Legacy Code]]></title>
            <link>https://medium.com/codex/preservation-contracts-safer-ai-agent-changes-in-legacy-code-ae436324868f?source=rss-d1f37945d1a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae436324868f</guid>
            <category><![CDATA[software-testing]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[legacy-code]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Oren Grinker]]></dc:creator>
            <pubDate>Tue, 10 Nov 2026 19:51:01 GMT</pubDate>
            <atom:updated>2026-11-10T19:51:01.709Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q4DnXfoeYWOz_KKJL6LuZQ.png" /></figure><p><em>Green tests don’t tell an AI agent what it must leave alone. A one-page preservation contract does.</em></p><p>Here is a failure many teams will meet this year. An agent fixes a bug in a records service. On the way, it “simplifies” a shared helper and removes a filter that looks redundant. Every test passes.</p><p>A week later, the CSV export shows users rows they were never meant to see. The export called the same helper, and no test checked whose rows ended up in the file.</p><p>The agent did exactly what it was asked. Nobody had written down what it must not change. That gap, not the agent, is what this article is about.</p><h3>Every change has two intents</h3><p>Every change to existing code carries two intents: what should change, and everything that must stay the same. Tickets capture the first. The second stays implicit, because to the people who know the system it feels obvious.</p><p>It is not obvious to an agent. The agent doesn’t know which teams call the helper, which incident created that odd-looking filter, or which customer depends on the sort order. It improves the code in front of it.</p><p>Tests don’t close the gap on their own. They catch only what someone once thought to check, and in old systems much of the behavior people rely on is checked by nobody.</p><p>Bug-fix specs give a clean way to state both intents. When the bug condition C holds, the fix must make the expected result P true. When C does not hold, the code must behave exactly as before:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*zbVifPqDdSFCzM1-l_h2bQ.png" /></figure><p>The second half is the one we skip. The rest of this article is about writing it down.</p><h3>Hidden contracts are everywhere</h3><p>With enough users, every observable behavior of a system becomes something somebody depends on, whatever the documentation promises. Engineers know this as <a href="https://www.unified-streaming.com/blog/misunderstanding-tech-ep-1-hyrums-law">Hyrum’s Law</a>.</p><p>In practice, hidden contracts look boring:</p><ul><li>the order of results</li><li>an empty list versus null (or None)</li><li>rounding rules</li><li>date and time formats</li><li>error and status codes</li><li>which rows a user is allowed to see</li></ul><p>The cheapest way to find them is to look at who calls the code you are about to change. One search for a shared helper might turn up this:</p><pre>grep -rl &quot;fetch_records(&quot; src/</pre><p>Caller</p><p>Relies on</p><p>Covered by a test</p><p>src/export/csv.py</p><p>only rows the user may see</p><p>No</p><p>src/mobile/feed.py</p><p>newest first</p><p>No</p><p>src/billing/run.py</p><p>an empty list, never None</p><p>Yes</p><p>src/api/partner.py</p><p>ISO 8601 dates</p><p>No</p><p>src/reports/tax.py</p><p>amounts rounded half-up</p><p>Yes</p><p>src/web/status.py</p><p>404 for a missing record, never 500</p><p>No</p><p>One function, six hidden contracts, four with no test. The example is illustrative, but the shape is common.</p><p>Treat an empty search result as limited knowledge, not proof. Reflection, configuration, scheduled jobs and external API clients rarely show up in a grep.</p><h3>The preservation contract</h3><p>A preservation contract is one page, written before the agent starts, with six fields. Each field closes a different shortcut an agent can take to “pass” a task.</p><p>Field</p><p>What it says</p><p>The shortcut it blocks</p><p>Condition</p><p>When the change applies</p><p>Quietly widening the problem</p><p>Expected result</p><p>What must be true afterwards</p><p>Hiding the error instead of fixing it</p><p>Protected behaviors</p><p>Guarantees this change must not break</p><p>“Cleaning up” a neighbor</p><p>Allowed scope</p><p>Files and modules it may touch</p><p>Silent changes elsewhere; anything outside is reported</p><p>Fix proof</p><p>A test that fails on the old code and passes after</p><p>Claiming a fix nobody can see</p><p>No-regression proof</p><p>Tests that pass both before and after</p><p>Breaking what nobody checked</p><p>For the helper above, a filled-in contract fits on one screen:</p><pre># change-contract.md: duplicate rows in fetch_records</pre><pre>Condition:        merged accounts return each record twice<br>Expected result:  every record is returned once<br>                  (not &quot;the error is gone&quot;)<br>Protected:<br>  - export returns only rows the user may see   owner: Data<br>  - feed order stays newest first                owner: Mobile<br>  - empty result is [], never None               owner: Billing<br>Allowed scope:    records/ only. Anything else is reported, not changed.<br>Fix proof:        test_no_duplicate_rows   fails on base, passes after<br>No-regression:    6 contract tests         pass on base, pass after</pre><p>The contract doesn’t replace tests, CI or review. It gives the reviewer something concrete to hold the diff against.</p><h3>Test the old code first</h3><p>The order of work matters more than the template: protective tests are written and run against the old code, before anyone touches the fix.</p><p>Tests written after the fix describe the new code. When the agent writes both the change and its tests, a green suite only proves that the code agrees with itself.</p><ol><li>Check out the base commit.</li><li>Write the fix test and confirm it fails.</li><li>Write the protective tests and confirm they pass.</li><li>Commit the tests on their own, before any change to the code.</li><li>Let the agent make the change, then run everything.</li></ol><p>Michael Feathers calls tests like these characterization tests: they record what the code does today, not what it should do. Keep them out of the agent’s reach while it works, so it can’t “fix” a test instead of the code.</p><p>After the change, the results should read like this:</p><p>Test</p><p>Old code</p><p>After the agent’s fix</p><p>no_duplicate_rows (fix proof)</p><p>Fail</p><p>Pass</p><p>export_visible_rows_only</p><p>Pass</p><p><strong>Fail</strong></p><p>feed_newest_first</p><p>Pass</p><p>Pass</p><p>billing_empty_list_not_none</p><p>Pass</p><p>Pass</p><p>Two outcomes are good: the fix test turns green, and every protective test stays green. A protective test that changes color means the change left its scope, so narrow it and run again.</p><p>In this run, the export test caught the same removed filter that slipped through in the opening story.</p><h3>Commitment or accident?</h3><p>A characterization test records a bug as faithfully as a feature. So every recorded behavior needs one more decision: is it a commitment someone relies on, or an accident that is free to change?</p><p>Excel shows how a bug becomes a commitment. It still treats 1900 as a leap year because Lotus 1–2–3 did, and <a href="https://support.microsoft.com/kb/214326">Microsoft explains</a> that a fix would shift almost every existing date by one day and break formulas.</p><p>G. K. Chesterton’s fence makes the same point: before you remove a fence, find out why it was put up. The contract is where that answer gets written down, before the agent removes the fence.</p><p>A named person makes each call, not the agent and not “the team”:</p><p>Recorded behavior</p><p>Decision</p><p>Who decides</p><p>Next step</p><p>Export shows only visible rows</p><p>Commitment</p><p>Data team lead</p><p>Protective test</p><p>Feed is sorted newest first</p><p>Not decided yet</p><p>Mobile product owner</p><p>Keep the current order until decided</p><p>Empty result is [], never None</p><p>Accident, after checking every caller</p><p>API owner</p><p>Test the new behavior and note it in the spec</p><p>The agent gets no permission to change a behavior that hasn’t been through this table.</p><h3>Grow the spec where the code changes</h3><p>You don’t need to document the whole system before the first change. Each contract adds a small delta to a living spec, and the spec grows exactly where the system moves.</p><p>A delta records three things: what this change added, what it modified, and what it removed. It also records the guarantees this change wrote down for the first time, such as “the export returns only rows the user may see.”</p><p>That second part matters. On day one a legacy spec is empty, so nothing is protected by it yet. Each approved guarantee moves from the contract into the spec, tied to a test that keeps guarding it.</p><p>After a few months, the spec is dense around the hotspots and thin where nothing changes. A full inventory still makes sense when it is the deliverable itself, such as a platform migration or an audit.</p><h3>Start with three changes</h3><p>Try the contract on three changes of growing difficulty, then decide whether to keep it. Each one teaches something different:</p><ol><li><strong>A small bug fix.</strong> The team learns the order: boundary first, protective tests on the old code, then the fix.</li><li><strong>A feature next to a busy file.</strong> The contract lists real callers and past incidents, or says plainly that there is no data.</li><li><strong>A refactoring.</strong> The commitment-or-accident table gets filled in for real, with a name on every row.</li></ol><p>Three signals say it is worth spreading: a protective test changed color and narrowed a patch, reviewers quote contract fields instead of impressions, and deltas reach the spec without extra work.</p><p>Three signals say stop or simplify: contracts appear for typo fixes, protected behaviors are copied from a template instead of found, or the contract repeats what review already catches. Patch size is not the test, though. A one-line change to authorization or payments may still need the full page.</p><h3>The takeaway</h3><p>In legacy code, specify the change, not the system. Before the first prompt, write down what must not change, prove it on the old code, and let a named person decide what counts as a commitment.</p><p>Your next ticket in old code can get a change-contract.md before the agent writes a single line. One page is enough to make a green build mean something.</p><p>Which behavior in your system turned out to be a commitment only after someone changed it?</p><p><em>This article builds on Jaroslaw Wasowski’s piece “Spec-Driven Development — Brownfield Spec and Preservation Contract” ([link to the original article]), which develops the preservation contract in more depth.</em></p><h3>Sources</h3><ul><li><a href="https://www.unified-streaming.com/blog/misunderstanding-tech-ep-1-hyrums-law">Hyrum’s Law, explained by Unified Streaming</a></li><li><a href="https://support.microsoft.com/kb/214326">Microsoft: Excel incorrectly assumes that the year 1900 is a leap year</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae436324868f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/preservation-contracts-safer-ai-agent-changes-in-legacy-code-ae436324868f">Preservation Contracts: Safer AI Agent Changes in Legacy Code</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Who Audits Your Gates? Keeping AI Delivery Pipelines Honest]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/codex/who-audits-your-gates-keeping-ai-delivery-pipelines-honest-6a91ae02291c?source=rss-d1f37945d1a6------2"><img src="https://cdn-images-1.medium.com/max/1600/1*7Kj7t-2gxtg92Ei-KUxckw.png" width="1600"></a></p><p class="medium-feed-snippet">Automated gates check outputs, not the process. Three cheap audit tools and the rule of three keep a spec-driven AI pipeline honest.</p><p class="medium-feed-link"><a href="https://medium.com/codex/who-audits-your-gates-keeping-ai-delivery-pipelines-honest-6a91ae02291c?source=rss-d1f37945d1a6------2">Continue reading on CodeX »</a></p></div>]]></description>
            <link>https://medium.com/codex/who-audits-your-gates-keeping-ai-delivery-pipelines-honest-6a91ae02291c?source=rss-d1f37945d1a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a91ae02291c</guid>
            <category><![CDATA[engineering-management]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Oren Grinker]]></dc:creator>
            <pubDate>Wed, 04 Nov 2026 10:51:01 GMT</pubDate>
            <atom:updated>2026-11-04T10:51:01.658Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[TOON vs JSON: Why Your LLM Prompts Are Costing You More Than They Should]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/codex/toon-vs-json-why-your-llm-prompts-are-costing-you-more-than-they-should-7139d4065383?source=rss-d1f37945d1a6------2"><img src="https://cdn-images-1.medium.com/max/2400/1*PKM4IdnuWUp3TsR0pHb57Q.png" width="2400"></a></p><p class="medium-feed-snippet">A new serialization format is quietly revolutionizing how we feed data to AI models&#x200A;&#x2014;&#x200A;and it could cut your token costs in half</p><p class="medium-feed-link"><a href="https://medium.com/codex/toon-vs-json-why-your-llm-prompts-are-costing-you-more-than-they-should-7139d4065383?source=rss-d1f37945d1a6------2">Continue reading on CodeX »</a></p></div>]]></description>
            <link>https://medium.com/codex/toon-vs-json-why-your-llm-prompts-are-costing-you-more-than-they-should-7139d4065383?source=rss-d1f37945d1a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/7139d4065383</guid>
            <category><![CDATA[prompt]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[toon]]></category>
            <category><![CDATA[json]]></category>
            <category><![CDATA[genai]]></category>
            <dc:creator><![CDATA[Oren Grinker]]></dc:creator>
            <pubDate>Tue, 11 Nov 2025 15:11:44 GMT</pubDate>
            <atom:updated>2025-11-12T10:06:57.935Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Claude Sonnet 4.5: The AI That Feels More Like a Colleague Than a Tool]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/codex/claude-sonnet-4-5-the-ai-that-feels-more-like-a-colleague-than-a-tool-ccc12da307fb?source=rss-d1f37945d1a6------2"><img src="https://cdn-images-1.medium.com/max/1584/1*H6dgt3PwvXvMYqpMuJebiA.png" width="1584"></a></p><p class="medium-feed-snippet">Anthropic&#x2019;s latest release marks a turning point in practical AI collaboration</p><p class="medium-feed-link"><a href="https://medium.com/codex/claude-sonnet-4-5-the-ai-that-feels-more-like-a-colleague-than-a-tool-ccc12da307fb?source=rss-d1f37945d1a6------2">Continue reading on CodeX »</a></p></div>]]></description>
            <link>https://medium.com/codex/claude-sonnet-4-5-the-ai-that-feels-more-like-a-colleague-than-a-tool-ccc12da307fb?source=rss-d1f37945d1a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/ccc12da307fb</guid>
            <category><![CDATA[sonnet]]></category>
            <category><![CDATA[anthropic-claude]]></category>
            <category><![CDATA[claude-sonnet]]></category>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[sonnet-4-5]]></category>
            <dc:creator><![CDATA[Oren Grinker]]></dc:creator>
            <pubDate>Mon, 29 Sep 2025 17:58:16 GMT</pubDate>
            <atom:updated>2025-10-07T12:27:53.125Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[How to Supercharge Your Jira Workflow with AI: A Developer’s Guide to the Jira MCP Server]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/codex/how-to-supercharge-your-jira-workflow-with-ai-a-developers-guide-to-the-jira-mcp-server-5fc8ce6e222a?source=rss-d1f37945d1a6------2"><img src="https://cdn-images-1.medium.com/max/1200/0*wV_K8cArkIDECYRc" width="1200"></a></p><p class="medium-feed-snippet">Transform your project management with natural language commands that directly interact with your Jira instance</p><p class="medium-feed-link"><a href="https://medium.com/codex/how-to-supercharge-your-jira-workflow-with-ai-a-developers-guide-to-the-jira-mcp-server-5fc8ce6e222a?source=rss-d1f37945d1a6------2">Continue reading on CodeX »</a></p></div>]]></description>
            <link>https://medium.com/codex/how-to-supercharge-your-jira-workflow-with-ai-a-developers-guide-to-the-jira-mcp-server-5fc8ce6e222a?source=rss-d1f37945d1a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/5fc8ce6e222a</guid>
            <category><![CDATA[mcp-client]]></category>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[genai]]></category>
            <category><![CDATA[jira]]></category>
            <category><![CDATA[mcp-protocol]]></category>
            <dc:creator><![CDATA[Oren Grinker]]></dc:creator>
            <pubDate>Fri, 20 Jun 2025 10:44:56 GMT</pubDate>
            <atom:updated>2025-06-21T09:58:58.245Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[This Chrome Extension Lets You Chat with Any Webpage Using GPT-4, Claude, or Gemini]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/codex/this-chrome-extension-lets-you-chat-with-any-webpage-using-gpt-4-claude-or-gemini-55c7bd69ce14?source=rss-d1f37945d1a6------2"><img src="https://cdn-images-1.medium.com/max/1280/1*37sfh7rpNEMeqYKCiF5PqQ.png" width="1280"></a></p><p class="medium-feed-snippet">Ever wished you could have an intelligent conversation about any webpage you&#x2019;re reading? Meet the AI Chat Assistant&#x200A;&#x2014;&#x200A;a Chrome extension&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/codex/this-chrome-extension-lets-you-chat-with-any-webpage-using-gpt-4-claude-or-gemini-55c7bd69ce14?source=rss-d1f37945d1a6------2">Continue reading on CodeX »</a></p></div>]]></description>
            <link>https://medium.com/codex/this-chrome-extension-lets-you-chat-with-any-webpage-using-gpt-4-claude-or-gemini-55c7bd69ce14?source=rss-d1f37945d1a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/55c7bd69ce14</guid>
            <category><![CDATA[chrome-extension]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[gemini]]></category>
            <dc:creator><![CDATA[Oren Grinker]]></dc:creator>
            <pubDate>Sat, 30 Nov 2024 17:30:17 GMT</pubDate>
            <atom:updated>2025-10-09T14:14:04.815Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Building a Modern UI for AI-Powered Content Safety Chrome Extension]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/codex/building-a-modern-ui-for-ai-powered-content-safety-chrome-extension-a3f1d87255ac?source=rss-d1f37945d1a6------2"><img src="https://cdn-images-1.medium.com/max/600/1*QRKLhpZkeHJAZeLRRdw0-A.png" width="600"></a></p><p class="medium-feed-snippet">In my ongoing journey to improve content safety tools, I&#x2019;ve recently updated the contentSafetyFilter Chrome extension with a modern&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/codex/building-a-modern-ui-for-ai-powered-content-safety-chrome-extension-a3f1d87255ac?source=rss-d1f37945d1a6------2">Continue reading on CodeX »</a></p></div>]]></description>
            <link>https://medium.com/codex/building-a-modern-ui-for-ai-powered-content-safety-chrome-extension-a3f1d87255ac?source=rss-d1f37945d1a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/a3f1d87255ac</guid>
            <category><![CDATA[ux]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[chrome-extension]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[ui]]></category>
            <dc:creator><![CDATA[Oren Grinker]]></dc:creator>
            <pubDate>Sat, 30 Nov 2024 17:07:55 GMT</pubDate>
            <atom:updated>2025-10-09T14:14:49.084Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[ChatGPT, Claude, or Gemini? This Chrome Extension Lets You Use All Three]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@orengr4/chatgpt-claude-or-gemini-this-chrome-extension-lets-you-use-all-three-fc53df0c0e32?source=rss-d1f37945d1a6------2"><img src="https://cdn-images-1.medium.com/max/1280/1*37sfh7rpNEMeqYKCiF5PqQ.png" width="1280"></a></p><p class="medium-feed-snippet">A common challenge for AI users is choosing between different language models. Each has its strengths: GPT-4 for general tasks, Claude for&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@orengr4/chatgpt-claude-or-gemini-this-chrome-extension-lets-you-use-all-three-fc53df0c0e32?source=rss-d1f37945d1a6------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@orengr4/chatgpt-claude-or-gemini-this-chrome-extension-lets-you-use-all-three-fc53df0c0e32?source=rss-d1f37945d1a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc53df0c0e32</guid>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[gemini]]></category>
            <category><![CDATA[chrome-extension]]></category>
            <category><![CDATA[claude]]></category>
            <dc:creator><![CDATA[Oren Grinker]]></dc:creator>
            <pubDate>Thu, 28 Nov 2024 20:49:50 GMT</pubDate>
            <atom:updated>2024-11-28T20:49:50.748Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Enhanced Image Analysis: Batch Processing and Local File Support Added to TextFromImage Packages]]></title>
            <link>https://medium.com/@orengr4/enhanced-image-analysis-batch-processing-and-local-file-support-added-to-textfromimage-packages-103047fef8fa?source=rss-d1f37945d1a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/103047fef8fa</guid>
            <category><![CDATA[image-tool]]></category>
            <category><![CDATA[image-processing]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ocr]]></category>
            <category><![CDATA[artficial-intelligence]]></category>
            <dc:creator><![CDATA[Oren Grinker]]></dc:creator>
            <pubDate>Wed, 27 Nov 2024 11:37:20 GMT</pubDate>
            <atom:updated>2024-11-27T11:37:20.584Z</atom:updated>
            <content:encoded><![CDATA[<p>We’re excited to announce significant updates to both `textfromimage` (Python) and `jstextfromimage` (Node.js) packages, introducing powerful new features for image analysis using AI services.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1IZ178mstNPwiwzadRlDGg.png" /><figcaption>Text From Image illustration</figcaption></figure><h3>What’s New in Both Packages?</h3><p>The latest updates bring two major enhancements to both packages:<br>1. Enhanced local file processing<br>2. Improved batch processing capabilities</p><h3>Local File Support</h3><p>Both packages now offer improved local file processing:</p><p><strong>Python (textfromimage)</strong></p><pre><br>from textfromimage import openai<br># Process local file<br>description = openai.get_description(&quot;local-image.png&quot;, <br> prompt=&quot;Describe this image&quot;,<br> max_tokens=300,<br> model=&quot;gpt-4o&quot;<br>)<br></pre><p><strong>JavaScript (jstextfromimage)</strong></p><pre><br>import { openai } from &#39;jstextfromimage&#39;;<br>const description = await openai.getDescription(&#39;local-image.png&#39;, {<br> prompt: &quot;Describe this image&quot;,<br> maxTokens: 300,<br> model: &#39;gpt-4o&#39;<br>});<br></pre><h3>Enhanced Batch Processing</h3><p>Both packages now support batch processing of mixed sources (local files and URLs):</p><p><strong>Python (textfromimage)</strong></p><pre><br>from textfromimage import openai<br>results = openai.get_description_batch([<br> &quot;local-image.png&quot;,<br> &quot;https://example.com/remote-image.jpg&quot;,<br> &quot;another-local-image.png&quot;<br>], <br> prompt=&quot;Describe this image in detail&quot;,<br> max_tokens=300,<br> concurrency=2<br>)<br></pre><p><strong>JavaScript (jstextfromimage)</strong></p><pre>import { openai } from &#39;jstextfromimage&#39;;<br>const results = await openai.getDescriptionBatch([<br> &#39;local-image.png&#39;,<br> &#39;https://example.com/remote-image.jpg&#39;,<br> &#39;another-local-image.png&#39;<br>], {<br> prompt: &quot;Describe this image in detail&quot;,<br> maxTokens: 300,<br> concurrency: 2<br>});</pre><h3>Key Features in Both Packages</h3><p>- <strong>Multiple AI Providers</strong>: Support for OpenAI, Azure OpenAI, and Claude<br>- <strong>Flexible Input</strong>: Process both local files and URLs<br>- <strong>Batch Processing</strong>: Handle multiple images concurrently<br>- <strong>Error Handling</strong>: Comprehensive error handling and reporting<br>- <strong>Configuration Options</strong>: Customizable prompts, tokens, and models</p><h3>Getting Started</h3><p><strong>Python Installation</strong></p><pre>pip install textfromimage</pre><p><strong>JavaScript Installation</strong></p><pre>npm install jstextfromimage</pre><h3>Comprehensive Example</h3><p>Here’s how to use the new features in both packages:</p><p><strong>Python</strong></p><pre>from textfromimage import openai, claude, azure_openai<br># Single image<br>description = openai.get_description(&quot;image.png&quot;, <br> prompt=&quot;Describe this image&quot;<br>)<br># Batch processing<br>images = [<br> &quot;local1.png&quot;,<br> &quot;https://example.com/image.jpg&quot;,<br> &quot;local2.png&quot;<br>]<br>results = openai.get_description_batch(images,<br> prompt=&quot;Analyze each image&quot;,<br> max_tokens=300,<br> concurrency=2<br>)<br>for result in results:<br> print(f&quot;Image: {result.image_url}&quot;)<br> print(f&quot;Description: {result.description}&quot;)</pre><p><strong>JavaScript</strong></p><pre>import { openai, claude, azureOpenai } from &#39;jstextfromimage&#39;;<br>// Single image<br>const description = await openai.getDescription(&#39;image.png&#39;, {<br> prompt: &quot;Describe this image&quot;<br>});<br>// Batch processing<br>const images = [<br> &#39;local1.png&#39;,<br> &#39;https://example.com/image.jpg&#39;,<br> &#39;local2.png&#39;<br>];<br>const results = await openai.getDescriptionBatch(images, {<br> prompt: &quot;Analyze each image&quot;,<br> maxTokens: 300,<br> concurrency: 2<br>});<br>results.forEach(result =&gt; {<br> console.log(`Image: ${result.imageUrl}`);<br> console.log(`Description: ${result.description}`);<br>});</pre><h3>Package Links</h3><p>- Python Package: <a href="https://pypi.org/project/textfromimage/">PyPI — textfromimage</a><br>- JavaScript Package: <a href="https://www.npmjs.com/package/jstextfromimage">NPM — jstextfromimage</a></p><h3>Future Development</h3><p>We’re working on several exciting features for both packages:<br>- Extended AI provider support<br>- Advanced batch processing options<br>- Performance optimizations<br>- Enhanced error recovery mechanisms</p><h3>Contributing</h3><p>Both packages are open source, and we welcome contributions! Visit our GitHub repositories to get involved:<br>- Report issues<br>- Submit pull requests<br>- Suggest new features<br>- Improve documentation</p><p>Stay tuned for more updates and improvements to both packages!</p><h3>Support</h3><p>For support, please visit our GitHub repositories or join our community discussions. We’re here to help you make the most of these powerful image analysis tools.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=103047fef8fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Comprehensive Time Management Library with TypeScript]]></title>
            <link>https://medium.com/@orengr4/building-a-comprehensive-time-management-library-with-typescript-8442db0437f5?source=rss-d1f37945d1a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/8442db0437f5</guid>
            <category><![CDATA[time-management]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Oren Grinker]]></dc:creator>
            <pubDate>Sat, 23 Nov 2024 17:50:11 GMT</pubDate>
            <atom:updated>2024-11-23T17:55:29.842Z</atom:updated>
            <content:encoded><![CDATA[<p>Time management across applications remains one of development’s persistent challenges. In this post, I’ll share how I built a TypeScript library that handles complex time zone conversions, business hours calculations, and holiday management, demonstrating how modern development patterns can solve real-world time handling problems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*5nbLGVoW21j_i6GjHGOgng.png" /></figure><h3>The Technical Challenge</h3><p>Traditional time management approaches have significant limitations:<br>- Manual timezone calculations lead to errors<br>- Business hours overlap calculations are complex<br>- Holiday management varies by region<br>- DST transitions cause unexpected behavior<br>- Locale-specific formatting needs special handling</p><p>I wanted to explore if we could create a more comprehensive solution. Could we build a library that handles all these cases while remaining developer-friendly?</p><h3>Solution Architecture</h3><p>The library combines Moment.js with TypeScript to create a robust time management system. Here’s how it works:</p><pre>// Core service that handles time conversions<br>export class WorldTimeConverter {<br>  private static holidays: Map = new Map();<br>  <br>  public static getCurrentTime(cityName: string): TimeResult {<br>    try {<br>      const timezone = this.getCityTimezone(cityName);<br>      const now = moment().tz(timezone);<br><br>      return {<br>        cityName,<br>        timezone,<br>        localTime: now.format(&#39;HH:mm:ss&#39;),<br>        utcOffset: now.format(&#39;Z&#39;),<br>        date: now.format(&#39;YYYY-MM-DD&#39;),<br>        dayOfWeek: now.format(&#39;dddd&#39;),<br>        isDST: now.isDST(),<br>        epoch: now.unix(),<br>        iso8601: now.toISOString(),<br>        formattedDateTime: now.format(&#39;LLLL&#39;)<br>      };<br>    } catch (error) {<br>      throw new Error(`Invalid city name: ${cityName}`);<br>    }<br>  }<br>}</pre><h3>TypeScript Integration</h3><p>The core of the library is its comprehensive type system. Here’s how we structure the types:</p><pre>interface TimeResult {<br>  cityName: string;<br>  timezone: string;<br>  localTime: string;<br>  utcOffset: string;<br>  date: string;<br>  dayOfWeek: string;<br>  isDST: boolean;<br>  epoch: number;<br>  iso8601: string;<br>  formattedDateTime: string;<br>}<br><br>interface BusinessHours {<br>  start: string;     // Format: HH:mm<br>  end: string;       // Format: HH:mm<br>  timezone: string;<br>}<br><br>interface HolidayDefinition {<br>  name: string;<br>  date: string;      // Format: YYYY-MM-DD<br>  recurring: boolean;<br>  type: string;<br>}</pre><h3>Technical Implementation Details</h3><p><strong>Key Components</strong></p><p><strong>1. Time Conversion</strong><br> — Timezone-aware calculations<br> — DST handling<br> — Format conversions</p><p><strong>2. Business Hours Management</strong><br> — Working hours overlap calculation<br> — Cross-timezone business day handling<br> — Holiday integration</p><p><strong>3. Holiday System</strong><br> — Support for recurring holidays<br> — Regional calendar management<br> — Business day calculations</p><h3>Performance Optimizations</h3><p>The library implements several optimizations:</p><pre>export class TimeUtils {<br>  public static calculateTimeDifference(time1: moment.Moment, time2: moment.Moment): TimeInterval {<br>    const diffMinutes = time2.diff(time1, &#39;minutes&#39;);<br>    return {<br>      hours: Math.floor(Math.abs(diffMinutes) / 60),<br>      minutes: Math.abs(diffMinutes) % 60<br>    };<br>  }<br>}</pre><h3>Real-World Example</h3><p>Here’s the library calculating business hours overlap between London and Tokyo:</p><pre>const overlap = WorldTimeConverter.findWorkingHoursOverlap(<br>  &#39;London&#39;,<br>  &#39;Tokyo&#39;,<br>  {<br>    start: &#39;09:00&#39;,<br>    end: &#39;17:00&#39;,<br>    timezone: &#39;Europe/London&#39;<br>  },<br>  {<br>    start: &#39;09:00&#39;,<br>    end: &#39;17:00&#39;,<br>    timezone: &#39;Asia/Tokyo&#39;<br>  }<br>);<br><br>console.log(overlap);<br>/* Output:<br>{<br>  hasOverlap: true,<br>  startTime: &quot;09:00&quot;,<br>  endTime: &quot;11:00&quot;,<br>  overlapDuration: { hours: 2, minutes: 0 }<br>}</pre><h3>Technical Challenges Solved</h3><p><strong>1. Timezone Handling</strong><br> — Proper DST transitions<br> — IANA timezone database integration<br> — Offset calculations</p><p><strong>2. Performance</strong><br> — Efficient time calculations<br> — Timezone caching<br> — Minimal conversions</p><p><strong>3. Type Safety</strong><br> — Comprehensive type definitions<br> — Compile-time checks<br> — Runtime validations</p><h3>Future Technical Improvements</h3><p>Some interesting technical challenges to tackle next:<br>1. Adding calendar integration support<br>2. Implementing custom holiday providers<br>3. Building an advanced business rules engine<br>4. Adding real-time timezone updates<br>5. Enhanced performance optimizations</p><h3>Code and Implementation</h3><p>The library is built using:<br>- TypeScript for type safety<br>- Moment.js for reliable calculations<br>- Jest for testing<br>- ESLint for code quality</p><p>Get started with the code:</p><pre>git clone https://github.com/OrenGrinker/worldTimeConverter.git<br>cd worldTimeConverter<br>npm install<br>npm run build</pre><h3>Learning Opportunities</h3><p>Building this library provided great insights into:<br>- TypeScript Type System<br>- Time Zone Complexities<br>- Business Logic Implementation<br>- Testing Strategies<br>- Package Development</p><h3>Conclusion</h3><p>This project demonstrates how modern TypeScript development can solve complex time management challenges. The code is open source and available on <a href="https://github.com/OrenGrinker/worldTimeConverter">GitHub</a>— feel free to explore, use, and contribute!</p><p>— -</p><h3>About the Author</h3><p>I’m Oren Grinker, a developer focused on creating robust development tools. Connect with me on <a href="https://github.com/OrenGrinker">GitHub</a> to explore more technical projects.</p><p>Tags: #TypeScript #JavaScript #TimeManagement #OpenSource #WebDevelopment #Programming</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8442db0437f5" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>