<?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 Paulo Batista on Medium]]></title>
        <description><![CDATA[Stories by Paulo Batista on Medium]]></description>
        <link>https://medium.com/@paulocsb?source=rss-2a6bff7e97ac------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*TX5cSbdcFjyJzaRmflkU2g.jpeg</url>
            <title>Stories by Paulo Batista on Medium</title>
            <link>https://medium.com/@paulocsb?source=rss-2a6bff7e97ac------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 01:06:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@paulocsb/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[Building OpenIPTV: an excuse to learn Swift, and a free Apple TV player I gave away]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@paulocsb/building-openiptv-an-excuse-to-learn-swift-and-a-free-apple-tv-player-i-gave-away-f9640efa1af1?source=rss-2a6bff7e97ac------2"><img src="https://cdn-images-1.medium.com/max/2600/1*Otgpb0v6hLr0JL_bNzTevQ.png" width="3840"></a></p><p class="medium-feed-snippet">I have an Xtream Codes subscription for my TV. The kind where you get a server URL, a username, and a password, and in theory you can&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@paulocsb/building-openiptv-an-excuse-to-learn-swift-and-a-free-apple-tv-player-i-gave-away-f9640efa1af1?source=rss-2a6bff7e97ac------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@paulocsb/building-openiptv-an-excuse-to-learn-swift-and-a-free-apple-tv-player-i-gave-away-f9640efa1af1?source=rss-2a6bff7e97ac------2</link>
            <guid isPermaLink="false">https://medium.com/p/f9640efa1af1</guid>
            <category><![CDATA[iptv]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Paulo Batista]]></dc:creator>
            <pubDate>Thu, 16 Jul 2026 18:28:14 GMT</pubDate>
            <atom:updated>2026-07-16T18:28:14.816Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Your AI coding agent is reading the wrong thing]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@paulocsb/your-ai-coding-agent-is-reading-the-wrong-thing-3be162f5a8c2?source=rss-2a6bff7e97ac------2"><img src="https://cdn-images-1.medium.com/max/1376/1*4adnq9M6E5PpplsRg4p-Gw.png" width="1376"></a></p><p class="medium-feed-snippet">Types and docs aren&#x2019;t enough. Here&#x2019;s how to give your agent the actual implementation.</p><p class="medium-feed-link"><a href="https://medium.com/@paulocsb/your-ai-coding-agent-is-reading-the-wrong-thing-3be162f5a8c2?source=rss-2a6bff7e97ac------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@paulocsb/your-ai-coding-agent-is-reading-the-wrong-thing-3be162f5a8c2?source=rss-2a6bff7e97ac------2</link>
            <guid isPermaLink="false">https://medium.com/p/3be162f5a8c2</guid>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[developer-tools]]></category>
            <dc:creator><![CDATA[Paulo Batista]]></dc:creator>
            <pubDate>Tue, 07 Apr 2026 01:50:17 GMT</pubDate>
            <atom:updated>2026-04-07T01:50:17.165Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[I stopped explaining my project to AI. I taught the repo to explain itself.]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@paulocsb/i-stopped-explaining-my-project-to-ai-i-taught-the-repo-to-explain-itself-6d56eb01be20?source=rss-2a6bff7e97ac------2"><img src="https://cdn-images-1.medium.com/max/2600/1*IQrLgeO0HskUu1rBWzcrRA.png" width="2816"></a></p><p class="medium-feed-snippet">I believe many developers have likely encountered that situation.</p><p class="medium-feed-link"><a href="https://medium.com/@paulocsb/i-stopped-explaining-my-project-to-ai-i-taught-the-repo-to-explain-itself-6d56eb01be20?source=rss-2a6bff7e97ac------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@paulocsb/i-stopped-explaining-my-project-to-ai-i-taught-the-repo-to-explain-itself-6d56eb01be20?source=rss-2a6bff7e97ac------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d56eb01be20</guid>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[claude-code]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[ai-agent]]></category>
            <dc:creator><![CDATA[Paulo Batista]]></dc:creator>
            <pubDate>Sat, 04 Apr 2026 00:03:36 GMT</pubDate>
            <atom:updated>2026-04-04T00:03:36.341Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Prompt Engineering Is Dead. Spec-writing is the new superpower]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@paulocsb/prompt-engineering-is-dead-spec-writing-is-the-new-superpower-ee532894121e?source=rss-2a6bff7e97ac------2"><img src="https://cdn-images-1.medium.com/max/2600/0*0LBNQUKbR-DfQsCA" width="5760"></a></p><p class="medium-feed-snippet">We thought the future of coding was writing prompts. But the future might be writing specs.</p><p class="medium-feed-link"><a href="https://medium.com/@paulocsb/prompt-engineering-is-dead-spec-writing-is-the-new-superpower-ee532894121e?source=rss-2a6bff7e97ac------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@paulocsb/prompt-engineering-is-dead-spec-writing-is-the-new-superpower-ee532894121e?source=rss-2a6bff7e97ac------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee532894121e</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[prompt-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Paulo Batista]]></dc:creator>
            <pubDate>Tue, 15 Jul 2025 03:45:32 GMT</pubDate>
            <atom:updated>2025-07-15T03:45:32.593Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[✦ Google Gemini CLI — Powerful open source AI Agent into terminal >_]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@paulocsb/google-gemini-cli-powerful-open-source-ai-agent-into-terminal-f518ade30c96?source=rss-2a6bff7e97ac------2"><img src="https://cdn-images-1.medium.com/max/2082/1*VLuUIqGltpRJ4cCHjRa56g.png" width="2082"></a></p><p class="medium-feed-snippet">&#x2726; Gemini CLI, Google&#x2019;s freshly released, open-source AI agent for the terminal. Let me walk you through why it&#x2019;s a big deal and how to get&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@paulocsb/google-gemini-cli-powerful-open-source-ai-agent-into-terminal-f518ade30c96?source=rss-2a6bff7e97ac------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@paulocsb/google-gemini-cli-powerful-open-source-ai-agent-into-terminal-f518ade30c96?source=rss-2a6bff7e97ac------2</link>
            <guid isPermaLink="false">https://medium.com/p/f518ade30c96</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[agents]]></category>
            <category><![CDATA[google-gemini]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Paulo Batista]]></dc:creator>
            <pubDate>Thu, 26 Jun 2025 17:06:35 GMT</pubDate>
            <atom:updated>2025-06-27T15:12:44.048Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Run DeepSeek’s 8B Model Locally  with LM Studio ]]></title>
            <link>https://medium.com/@paulocsb/run-deepseeks-8b-model-locally-for-free-with-just-4gb-ram-5531ea5725d3?source=rss-2a6bff7e97ac------2</link>
            <guid isPermaLink="false">https://medium.com/p/5531ea5725d3</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[llm-studio]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[deepseek]]></category>
            <dc:creator><![CDATA[Paulo Batista]]></dc:creator>
            <pubDate>Mon, 02 Jun 2025 03:49:46 GMT</pubDate>
            <atom:updated>2025-06-02T13:52:14.169Z</atom:updated>
            <content:encoded><![CDATA[<h3>Run DeepSeek’s 8B Model Locally with LM Studio 💻🔥</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3b8FLiZBeemaN-0Sr9efUw.png" /></figure><p>If you’ve been following the open-source AI scene, you’ve probably heard about <strong>DeepSeek’s powerful new model</strong>: <strong>DeepSeek R1 0528 Qwen 8B</strong>. What makes it really exciting?</p><p>👉 <strong>You can run it locally, 100% offline, and completely free</strong> — even on a laptop with just <strong>8GB of RAM</strong>.</p><p>No APIs. No tokens. No limitations.</p><p>Let’s get straight to it. In just a few minutes, you can have a blazing-fast language model running on your own machine.</p><h3>🛠️ What You Need</h3><p>Just two things:</p><ul><li><a href="https://lmstudio.ai/"><strong>LM Studio</strong></a> (a free app for running local LLMs)</li><li><strong>8GB of RAM</strong> (yep, that’s really enough)</li></ul><h3>✅ Step-by-Step: How to Get Started</h3><h4>Download LM Studio</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*371mV00Ls3LeOZfgQt4WVw.png" /></figure><p>Visit <a href="https://lmstudio.ai/">https://lmstudio.ai</a> and download the version for your operating system:</p><ul><li><strong>Windows</strong> (x86 or ARM)</li><li><strong>macOS</strong> (M1/M2/M3/M4 — Apple Silicon)</li><li><strong>Linux</strong></li></ul><p>LM Studio is a slick, user-friendly app that lets you run local models with zero setup.</p><h4>Download the DeepSeek Model</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WIMWIv0iZzCOU5IygGrLXw.png" /></figure><p>Once LM Studio is installed:</p><p>1 — Open the app and go to the <strong>Search</strong> tab.</p><p>2 — Type:</p><pre>deepseek r1 0528 qwen 8b</pre><p>3 — Look for the <strong>Bartowski version</strong> with <strong>Q4_0</strong> quantization — it’s optimized for performance and works well on most machines.</p><blockquote><em>💡 </em><strong><em>macOS users</em></strong><em>: Choose the </em><strong><em>MLX version</em></strong><em> for native compatibility with Apple Silicon.</em></blockquote><p>4 — Click <strong>Download</strong> and wait a few minutes. The model will be ready shortly.</p><h4>Load and Chat</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*As1OHkOmtzXeJQbD74bI9A.png" /></figure><p>Now that you’ve got the model:</p><ol><li>Go to the <strong>Chat</strong> tab in LM Studio.</li><li>Click <strong>“New Chat”</strong>.</li><li>Choose the <strong>DeepSeek R1 0528 Qwen 8B</strong> model you downloaded.</li><li>(Optional but helpful) Add a simple system prompt like:</li></ol><pre>You are a helpful assistant. Keep answers concise and clear.</pre><p>And that’s it! 🎉</p><p>You’re now chatting with a <strong>high-quality 8B parameter model</strong> completely <strong>offline</strong> — no internet required, no OpenAI key, no server costs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5531ea5725d3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Is the Model Context Protocol (MCP) and Why It Matters for AI]]></title>
            <link>https://medium.com/@paulocsb/what-is-the-model-context-protocol-mcp-and-why-it-matters-for-ai-6aa13b300b9f?source=rss-2a6bff7e97ac------2</link>
            <guid isPermaLink="false">https://medium.com/p/6aa13b300b9f</guid>
            <category><![CDATA[ollama]]></category>
            <category><![CDATA[model-context-protocol]]></category>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[chatgpt]]></category>
            <dc:creator><![CDATA[Paulo Batista]]></dc:creator>
            <pubDate>Fri, 16 May 2025 04:06:53 GMT</pubDate>
            <atom:updated>2025-05-16T04:06:53.902Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fcCAs8pMLuF12YwH" /><figcaption>Photo by <a href="https://unsplash.com/@omilaev?utm_source=medium&amp;utm_medium=referral">Igor Omilaev</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>As AI tools like OpenAI’s GPT, Anthropic’s Claude, and local LLMs like Ollama become more accessible, there’s a growing need for <strong>a flexible communication layer</strong> to manage them all. That’s where a <strong>MCP (Model Context Protocol) server</strong> comes in — a simple but powerful architecture pattern to glue everything together.</p><h3><strong>What Is MCP?</strong></h3><p>MCP short for <strong>Model Context Protocol</strong>, is an open standard that defines <strong>how AI models connect to external tools, data sources, APIs, and user context</strong>.</p><p>Think of MCP as <strong>the USB-C of the AI world</strong> — a plug-and-play standard that allows large language models (LLMs) to:</p><ul><li>Discover tools</li><li>Access data</li><li>Trigger actions</li><li>Respect user consent</li><li>Communicate securely</li></ul><p>It enables AI agents and models to move beyond static text generation and into <strong>interactive, action-oriented intelligence</strong>.</p><h3>MCP Server</h3><p>MCP server is a lightweight messaging server — think of it as a <strong>real-time brain</strong> that listens for instructions, decides where to send them, and coordinates communication between LLMs and agents.</p><p>Think of it as the <strong>“brainstem”</strong> <strong>of your AI system</strong>. You send a prompt or command, and the MCP server:</p><ul><li>Decides where it should go (OpenAI, Claude, local model, agent)</li><li>It can chain results or pass them between agents forwarding it accordingly</li><li>Collects the response</li><li>Sends it back to the client, frontend, or another system</li></ul><p>This gives you <strong>centralized control</strong>, especially useful when working with:</p><ul><li>Multi-agent systems</li><li>Local + cloud model combinations</li><li>UI/frontend applications that don’t care where the answer comes from</li></ul><p>This is the “provider” of capabilities — it could expose:</p><ul><li>APIs (e.g., weather, email, calendar)</li><li>Files or local databases</li><li>User-defined tools (scripts, functions)</li><li>Secure access to web services</li></ul><p>Together, these parts allow <strong>LLMs to access context and perform actions while respecting user boundaries</strong>.</p><h3>Real-World use case</h3><p>Let’s say you want to build a local LLM-powered assistant that:</p><ul><li>Reads your Markdown notes</li><li>Summarizes your calendar</li><li>Sends reminders</li></ul><h4><strong>With MCP:</strong></h4><ul><li>You set up an MCP server that exposes those resources as `resource` and `tool` capabilities.</li><li>Your assistant model (e.g. Claude, GPT, or Ollama) requests available tools.</li><li>The MCP client passes context securely.</li><li>Your assistant now performs real actions — without any vendor lock-in or custom API bridges.</li></ul><h3>Why Is MCP server a Big Deal?</h3><p>By acting as a centralized gateway, the MCP server helps you:</p><ul><li>🔁 Swap models based on cost, performance, or availability</li><li>🧩 Build modular AI stacks</li><li>🧠 Share memory or chain outputs across agents</li><li>🚀 Rapidly prototype new AI features</li></ul><h4>Without MCP:</h4><ul><li>Every app invents its own way to wire up tools</li><li>Agents become tightly coupled to one model/provider</li><li>It’s hard to give users safe, consent-based control</li></ul><h4>With MCP:</h4><ul><li>Apps, tools, and agents speak a common language</li><li>You can easily swap out models (Claude ↔ GPT ↔ Ollama)</li><li>Local-first workflows become possible and secure</li><li>Developers and users gain <strong>modular, secure extensibility</strong></li></ul><h3>Recap</h3><p>An <strong>MCP server</strong> is the bridge between your users, models, and agents.</p><p>It provides:</p><ul><li>🧭 Centralized routing logic</li><li>🔀 Model/agent switching</li><li>🔒 Security, logging, memory hooks</li><li>🔄 Real-time control of prompt/response flows</li></ul><p>It’s especially useful when working with:</p><ul><li>Multiple LLM providers (OpenAI, Claude, Cohere, etc.)</li><li>Hybrid stacks (cloud + local like Ollama)</li><li>Autonomous agents or tool-using chains (LangChain, ReAct)</li></ul><h3>Final Thoughts</h3><p><em>MCP is the universal protocol for making AI useful, responsible, and extensible.</em></p><p>Whether you’re building dev tools, automations, or assistants, MCP allows your models to do more — with safety and control built in.</p><p>📘 References: <a href="https://modelcontextprotocol.io/">modelcontextprotocol.io</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6aa13b300b9f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Custom Visual Effects in SwiftUI]]></title>
            <link>https://medium.com/@paulocsb/custom-visual-effects-in-swiftui-4c088c7cb20f?source=rss-2a6bff7e97ac------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c088c7cb20f</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[xcode]]></category>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Paulo Batista]]></dc:creator>
            <pubDate>Sat, 03 Aug 2024 01:05:20 GMT</pubDate>
            <atom:updated>2024-08-03T01:05:20.666Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*LhXcaF4LFJEoNUcx_r-3Uw.jpeg" /></figure><h3>Visual Effects</h3><p>SwiftUI has revolutionized the way we build user interfaces, making it possible to create beautiful and engaging experiences for our users. But what about taking it to the next level? What if you could add some magic to your app with custom visual effects that will leave your users amazed? In this post, we’ll explore how to create a custom visual effects using SwiftUI.</p><h3>Creating Custom Visual Effects</h3><p>To create custom visual effects with SwiftUI, you’ll need to use the visualEffect view modifier. This modifier takes a closure that returns an instance of EmptyVisualEffect. Within this closure, you can apply various effects using the initialparameter, which represents the initial state of the effects.</p><p><strong>Here’s an example:</strong></p><pre>RoundedRectangle(cornerRadius: 24)<br>    .fill(.purple)<br>    .visualEffect({ content, proxy in<br>        content<br>            .hueRotation(Angle(degrees: proxy.frame(in: .global).origin.y / 10))<br>            <br>    })</pre><p>Here’s a breakdown of what it does:</p><ul><li><strong>RoundedRectangle(cornerRadius: 24)</strong>: Creates a rectangular shape with rounded corners, where the corner radius is set to 24 points.</li><li><strong>.fill(.purple):</strong> Fills the rectangle with a purple color.</li><li><strong>.visualEffect({ content, proxy in … }):</strong> Applies a visual effect to the rectangle. This is where things get interesting.</li></ul><p>Inside the closure, content refers to the rectangle itself, and proxy provides some additional information about the context in which the rectangle is being displayed (e.g., its position, size).</p><p>The .hueRotation(Angle(degrees: …)) modifier applies a rotation effect to the color of the rectangle. Specifically:</p><ul><li>The angle of rotation is calculated based on the origin’s y-coordinate (proxy.frame(in: .global).origin.y) divided by 10.</li><li>This means that as you scroll down (increasing the y coordinate), the color will rotate more rapidly, creating a psychedelic effect.</li></ul><p>It creates an interactive and visually appealing UI component that responds to user interactions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/1*gq4VX2QKH3G_o9vFh5JWXA.gif" /><figcaption>Visual Effect — SwiftUI</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2edb5c706539a6dc833cc5c8b60c7cb0/href">https://medium.com/media/2edb5c706539a6dc833cc5c8b60c7cb0/href</a></iframe><h3>Conclusion</h3><p>Creating custom visual effects with SwiftUI is easier than ever thanks to the visualEffect view modifier. By combining multiple effects into a single closure, you can create unique visuals that enhance your app&#39;s user experience. Experiment with different effect combinations and animation techniques to take your design to the next level!</p><p>I hope this helps! Let me know if you have any questions or need further clarification.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c088c7cb20f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Installing and Using Open WebUI with Ollama and Llama 3.1]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@paulocsb/installing-and-using-open-webui-with-ollama-and-llama-3-1-1292f6a70abc?source=rss-2a6bff7e97ac------2"><img src="https://cdn-images-1.medium.com/max/1526/1*XPg6Eu1VX-ACVGMFQy16fQ.png" width="1526"></a></p><p class="medium-feed-snippet">As AI enthusiasts, we&#x2019;re always on the lookout for tools that can help us harness the power of language models.</p><p class="medium-feed-link"><a href="https://medium.com/@paulocsb/installing-and-using-open-webui-with-ollama-and-llama-3-1-1292f6a70abc?source=rss-2a6bff7e97ac------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@paulocsb/installing-and-using-open-webui-with-ollama-and-llama-3-1-1292f6a70abc?source=rss-2a6bff7e97ac------2</link>
            <guid isPermaLink="false">https://medium.com/p/1292f6a70abc</guid>
            <category><![CDATA[llama-3]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[ollama]]></category>
            <category><![CDATA[open-webui]]></category>
            <dc:creator><![CDATA[Paulo Batista]]></dc:creator>
            <pubDate>Fri, 02 Aug 2024 20:31:09 GMT</pubDate>
            <atom:updated>2024-08-02T20:31:09.723Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Async and Await in Swift]]></title>
            <link>https://medium.com/@paulocsb/async-and-await-in-swift-d1962b6e0918?source=rss-2a6bff7e97ac------2</link>
            <guid isPermaLink="false">https://medium.com/p/d1962b6e0918</guid>
            <category><![CDATA[xcode]]></category>
            <category><![CDATA[async]]></category>
            <category><![CDATA[asyncawait]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Paulo Batista]]></dc:creator>
            <pubDate>Wed, 31 Jul 2024 01:00:52 GMT</pubDate>
            <atom:updated>2024-07-31T01:00:52.585Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*EvgaqKcYva2l54O_NXEHUQ.png" /></figure><p><strong>Swift</strong> continues to push the boundaries of modern, safe, and performant language features. One of the most transformative additions in recent years is the integration of <strong>async/await</strong>, which significantly simplifies handling asynchronous operations. This guide dive into basic aspects of <strong>async/await</strong> in Swift.</p><h4>Understanding Async/Await in Swift</h4><p>Async/await is a syntax for writing asynchronous code that looks and behaves like synchronous code. It provides a way to handle potentially long-running operations, such as network requests or disk I/O, without blocking the main thread.</p><pre>func fetchData() async -&gt; Data {<br> // Asynchronously fetch data<br>}</pre><p>In this simple example, fetchData() is an asynchronous function marked with async. When calling this function, you use the await keyword:</p><pre>let data = await fetchData()</pre><p>This line suspends the execution of the current task until fetchData() completes, allowing other tasks to run in the meantime.</p><h4>Usage of Async/Await</h4><h4>1. Handling Errors in Asynchronous Code</h4><p>Error handling in async/await follows the same principles as synchronous code, using try and throws. This allows for concise and readable error management.</p><pre>func fetchData() async throws -&gt; Data {<br>    // Asynchronously fetch data<br>}<br><br>do {<br>    let data = try await fetchData()<br>    // Process the data<br>} catch {<br>    // Handle the error<br>}</pre><p>Here, the fetchData() function can throw an error, which is handled in the catch block.</p><h4>2. Concurrency with Task Groups</h4><p>Swift’s concurrency model includes powerful constructs like Task and TaskGroup. Task groups allow you to run multiple tasks concurrently and wait for their results.</p><pre>func fetchAllData() async throws -&gt; [Data] {<br>    return try await withTaskGroup(of: Data.self) { group in<br>        for url in urls {<br>            group.addTask {<br>                let data = try await fetchData(from: url)<br>                return data<br>            }<br>        }<br><br>        var results = [Data]()<br><br>        for try await result in group {<br>            results.append(result)<br>        }<br>        return results<br>    }<br>}</pre><p>This example demonstrates fetching data from multiple URLs concurrently using a TaskGroup. The group.addTask method schedules a new task, and for try await result in group collects the results.</p><h4>3. Structured Concurrency and Task Cancellation</h4><p>Structured concurrency in Swift ensures that tasks are neatly organized and that resources are properly managed. One critical aspect of this is task cancellation, allowing you to cancel tasks that are no longer needed.</p><pre>func fetchData() async throws -&gt; Data {<br>    guard !Task.isCancelled else {<br>        throw CancellationError()<br>    }<br>    // Continue with fetching data<br>}</pre><p>In this snippet, Task.isCancelled checks if the current task has been canceled. This is crucial for responsive apps that can handle user interruptions gracefully.</p><h4>4. Interoperability with Existing Code</h4><p>Swift’s async/await is designed to work seamlessly with existing asynchronous APIs, such as completion handlers or Combine publishers.</p><p>You can easily adapt these patterns using withCheckedContinuation or withCheckedThrowingContinuation.</p><pre>func fetchData(completion: @escaping (Result&lt;Data, Error&gt;) -&gt; Void) {<br>    let urlString = &quot;https:///www.example.com/1&quot;<br>    <br>    guard let url = URL(string: urlString) else {<br>        completion(.failure(NSError(domain: &quot;InvalidURL&quot;, code: -1, userInfo: nil)))<br>        return<br>    }<br><br>    let task = URLSession.shared.dataTask(with: url) { data, response, error in<br>        if let error = error {<br>            completion(.failure(error))<br>            return<br>        }<br>        <br>        guard let data = data else {<br>            completion(.failure(NSError(domain: &quot;NoData&quot;, code: -2, userInfo: nil)))<br>            return<br>        }<br>        <br>        completion(.success(data))<br>    }<br>    <br>    task.resume()<br>}<br><br>func fetchData() async throws -&gt; Data {<br>    return try await withCheckedThrowingContinuation { continuation in<br>        fetchData { result in<br>            switch result {<br>            case .success(let data):<br>                continuation.resume(returning: data)<br>            case .failure(let error):<br>                continuation.resume(throwing: error)<br>            }<br>        }<br>    }<br>}</pre><p>This example wraps an existing completion handler-based API in an async function, making it compatible with the new async/await syntax.</p><h4>Best Practices for Using Async/Await</h4><ul><li><strong>Prioritize Readability:</strong> While async/await simplifies code, it’s crucial to maintain clarity. Avoid deeply nested asynchronous calls by breaking down complex logic into smaller functions.</li><li><strong>Error Propagation:</strong> Take advantage of Swift’s robust error handling. Ensure that all potential errors are correctly propagated and handled, providing a better experience for users and easier debugging.</li><li><strong>Performance Considerations:</strong> Be mindful of task overhead. While async/await is efficient, excessive task creation can impact performance. Use tools like Instruments to profile and optimize your code.</li><li><strong>Testing and Debugging:</strong> Testing asynchronous code can be challenging. Utilize XCTest’s async/await support to write more straightforward tests and leverage Xcode’s debugging tools to trace asynchronous execution paths.</li></ul><h4>Conclusion</h4><p>Async/await in Swift offers a powerful and intuitive way to write asynchronous code. By understanding and leveraging advanced features like task groups, structured concurrency, and interoperability, iOS developers can write more robust, maintainable, and responsive applications. As always, balancing new language features with best practices and performance considerations is key to delivering high-quality software.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d1962b6e0918" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>