<?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 Zafir Sk Heerah on Medium]]></title>
        <description><![CDATA[Stories by Zafir Sk Heerah on Medium]]></description>
        <link>https://medium.com/@zfir?source=rss-fa41b1538f81------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*NxSbBQe2m7Hab7G4KljJhA.jpeg</url>
            <title>Stories by Zafir Sk Heerah on Medium</title>
            <link>https://medium.com/@zfir?source=rss-fa41b1538f81------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 13:22:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@zfir/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 an MCP Server in Node.js]]></title>
            <link>https://zfir.medium.com/building-an-mcp-server-in-node-js-bb0a9990f1b7?source=rss-fa41b1538f81------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb0a9990f1b7</guid>
            <category><![CDATA[developer-tools]]></category>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[node]]></category>
            <dc:creator><![CDATA[Zafir Sk Heerah]]></dc:creator>
            <pubDate>Thu, 18 Jun 2026 10:01:14 GMT</pubDate>
            <atom:updated>2026-06-18T10:01:14.628Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0iiyKvIhhqnn0lKhWURfbQ.png" /></figure><p>A practical guide to creating your own AI tool server</p><p>AI assistants are becoming more powerful because they can now interact with tools, APIs, databases, files, and even your local environment.</p><p>One of the easiest ways to expose these capabilities is through the Model Context Protocol (MCP).</p><p>In this guide, we’ll build a simple MCP server using Node.js.</p><h3>What is MCP?</h3><p>The Model Context Protocol (MCP) is a standard that allows AI applications to communicate with external tools and services.</p><p>Instead of hardcoding integrations directly into an AI app, MCP provides a structured way to expose tools such as:</p><ul><li>APIs</li><li>Databases</li><li>File systems</li><li>Custom functions</li><li>Internal services</li><li>Automation workflows</li></ul><p>Think of it as:</p><blockquote>“A standard interface between AI models and external tools.”</blockquote><p>MCP servers can then be connected to applications such as:</p><ul><li>Claude Desktop</li><li>Cursor</li><li>Windsurf</li><li>Custom AI agents</li><li>Internal enterprise tools</li></ul><h3>What We’ll Build</h3><p>We’ll create a simple MCP server that exposes two tools:</p><ol><li>hello</li><li>get_time</li></ol><p>The AI client will be able to call these tools dynamically.</p><h3>Prerequisites</h3><p>You need:</p><ul><li>Node.js 18+</li><li>npm</li><li>Basic JavaScript knowledge</li></ul><p>You can download Node.js from: <a href="https://nodejs.org/?utm_source=chatgpt.com">Node.js</a></p><h3>Step 1 — Create the Project</h3><p>Create a new folder:</p><pre>mkdir my-mcp-server<br>cd my-mcp-server</pre><p>Initialize the project:</p><pre>npm init -y</pre><h3>Step 2 — Install the MCP SDK</h3><p>Install the official MCP SDK:</p><pre>npm install @modelcontextprotocol/sdk</pre><p>Official SDK repository: <a href="https://github.com/modelcontextprotocol/typescript-sdk?utm_source=chatgpt.com">Model Context Protocol SDK</a></p><h3>Step 3 — Create the Server</h3><p>Create a file named:</p><pre>server.js</pre><p>Add the following code:</p><pre>import { Server } from &quot;@modelcontextprotocol/sdk/server/index.js&quot;;<br>import { StdioServerTransport } from &quot;@modelcontextprotocol/sdk/server/stdio.js&quot;;<br><br>const server = new Server(<br>  {<br>    name: &quot;demo-mcp-server&quot;,<br>    version: &quot;1.0.0&quot;,<br>  },<br>  {<br>    capabilities: {<br>      tools: {},<br>    },<br>  }<br>);<br><br>server.setRequestHandler(&quot;tools/list&quot;, async () =&gt; {<br>  return {<br>    tools: [<br>      {<br>        name: &quot;hello&quot;,<br>        description: &quot;Say hello to someone&quot;,<br>        inputSchema: {<br>          type: &quot;object&quot;,<br>          properties: {<br>            name: {<br>              type: &quot;string&quot;,<br>            },<br>          },<br>          required: [&quot;name&quot;],<br>        },<br>      },<br>      {<br>        name: &quot;get_time&quot;,<br>        description: &quot;Get the current server time&quot;,<br>        inputSchema: {<br>          type: &quot;object&quot;,<br>          properties: {},<br>        },<br>      },<br>    ],<br>  };<br>});<br><br>server.setRequestHandler(&quot;tools/call&quot;, async (request) =&gt; {<br>  const { name, arguments: args } = request.params;<br><br>  if (name === &quot;hello&quot;) {<br>    return {<br>      content: [<br>        {<br>          type: &quot;text&quot;,<br>          text: `Hello ${args.name}!`,<br>        },<br>      ],<br>    };<br>  }<br><br>  if (name === &quot;get_time&quot;) {<br>    return {<br>      content: [<br>        {<br>          type: &quot;text&quot;,<br>          text: new Date().toISOString(),<br>        },<br>      ],<br>    };<br>  }<br><br>  throw new Error(&quot;Unknown tool&quot;);<br>});<br><br>const transport = new StdioServerTransport();<br><br>await server.connect(transport);</pre><h3>Step 4 — Enable ES Modules</h3><p>Update your package.json:</p><pre>{<br>  &quot;type&quot;: &quot;module&quot;<br>}</pre><h3>Step 5 — Run the MCP Server</h3><p>Start the server:</p><pre>node server.js</pre><p>Your MCP server is now running.</p><h3>How MCP Communication Works</h3><p>The communication flow is simple:</p><pre>AI Client<br>   ↓<br>MCP Client<br>   ↓<br>MCP Server<br>   ↓<br>Your Tools / APIs</pre><p>The AI model never directly executes code.</p><p>Instead:</p><ol><li>The model discovers available tools</li><li>The client sends a tool request</li><li>The MCP server executes the logic</li><li>The response is returned to the model</li></ol><p>This separation makes integrations cleaner and safer.</p><h3>Connecting to Claude Desktop</h3><p>You can connect your MCP server to <a href="https://claude.ai/download?utm_source=chatgpt.com">Claude Desktop</a> by editing the MCP configuration.</p><p>Example configuration:</p><pre>{<br>  &quot;mcpServers&quot;: {<br>    &quot;demo-server&quot;: {<br>      &quot;command&quot;: &quot;node&quot;,<br>      &quot;args&quot;: [&quot;/absolute/path/to/server.js&quot;]<br>    }<br>  }<br>}</pre><p>After restarting Claude Desktop, the tools will appear automatically.</p><p>Official MCP documentation: <a href="https://modelcontextprotocol.io/introduction?utm_source=chatgpt.com">Model Context Protocol Documentation</a></p><h3>Adding Real Capabilities</h3><p>Once your server works, you can integrate:</p><ul><li>REST APIs</li><li>Databases</li><li>PostgreSQL</li><li>Salesforce</li><li>GitHub</li><li>File systems</li><li>Internal company services</li><li>Automation systems</li><li>AI workflows</li></ul><p>For example:</p><pre>{<br>  name: &quot;get_weather&quot;<br>}</pre><p>could call a weather API.</p><pre>{<br>  name: &quot;create_invoice&quot;<br>}</pre><p>could connect to an ERP system.</p><h3>Best Practices</h3><h4>Validate Inputs</h4><p>Never trust tool arguments blindly.</p><p>Always validate:</p><ul><li>Types</li><li>Required fields</li><li>Permissions</li><li>Length limits</li></ul><h4>Avoid Dangerous Execution</h4><p>Do not expose unrestricted:</p><ul><li>shell execution</li><li>file deletion</li><li>system commands</li></ul><p>unless properly sandboxed.</p><h4>Keep Tools Focused</h4><p>Good MCP tools do one thing well.</p><p>Examples:</p><ul><li>search_customer</li><li>create_ticket</li><li>generate_report</li></ul><p>instead of one giant tool handling everything.</p><h3>Why MCP Matters</h3><p>MCP is quickly becoming one of the most important standards for AI integrations.</p><p>Instead of building custom integrations for every AI platform, you expose tools once through MCP and reuse them across multiple clients.</p><p>This makes AI systems:</p><ul><li>more modular</li><li>easier to maintain</li><li>safer</li><li>easier to scale</li></ul><h3>Final Thoughts</h3><p>Building an MCP server in Node.js is surprisingly simple.</p><p>With only a few lines of code, you can expose your own tools to modern AI assistants and start creating powerful workflows.</p><p>As AI agents continue evolving, MCP will likely become a core layer for connecting models with real-world systems.</p><p>If you are already building APIs or automation tools in Node.js, MCP is a very natural next step.</p><h3>Useful Resources</h3><ul><li><a href="https://modelcontextprotocol.io/?utm_source=chatgpt.com">Model Context Protocol Official Website</a></li><li><a href="https://github.com/modelcontextprotocol/typescript-sdk?utm_source=chatgpt.com">MCP TypeScript SDK</a></li><li><a href="https://claude.ai/download?utm_source=chatgpt.com">Claude Desktop</a></li><li><a href="https://nodejs.org/?utm_source=chatgpt.com">Node.js</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb0a9990f1b7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Always Online, Never Sleeping: Running Claude Dispatch on macOS]]></title>
            <link>https://zfir.medium.com/always-online-never-sleeping-running-claude-dispatch-on-macos-c1d6080fb6b7?source=rss-fa41b1538f81------2</link>
            <guid isPermaLink="false">https://medium.com/p/c1d6080fb6b7</guid>
            <category><![CDATA[macos]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[ai-workflow]]></category>
            <dc:creator><![CDATA[Zafir Sk Heerah]]></dc:creator>
            <pubDate>Tue, 19 May 2026 07:05:33 GMT</pubDate>
            <atom:updated>2026-05-19T07:05:33.098Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UqWDYo-UQc_fionyQ4Azig.png" /></figure><h3>Overview</h3><p>Running AI workflows locally is powerful—but only if they actually complete.</p><p>If you’re using Claude dispatch for long-running tasks, macOS sleep can quietly interrupt everything:</p><ul><li>Background processes pause</li><li>Network activity stops</li><li>Execution is lost mid-task</li></ul><p>The result? You come back expecting results… and nothing is done.</p><p>This guide shows how to turn your Mac into an always-online AI worker using Amphetamine—with a simple, reliable setup.</p><h3>The Problem: Sleep Breaks Claude Dispatch</h3><p>Claude dispatch workflows often:</p><ul><li>Run for extended periods</li><li>Depend on continuous execution</li><li>Require stable network access</li></ul><p>macOS is designed to sleep when idle.</p><p>When that happens:</p><ul><li>Your Claude job stops</li><li>Outputs are incomplete</li><li>You waste time rerunning tasks</li></ul><p>And it usually happens silently.</p><h3>The Simple Solution</h3><p>You don’t need complex automation—you just need control over when your Mac stays awake.</p><p>Amphetamine gives you a simple and effective approach:</p><ul><li>Turn it ON → your Mac stays awake</li><li>Turn it OFF → normal behavior resumes</li></ul><p>That’s enough to make Claude dispatch reliable.</p><h3>Setup: Minimal &amp; Reliable</h3><h4>Install Amphetamine</h4><ul><li>Install Amphetamine from the Mac App Store</li><li>Launch it → it appears in your menu bar</li></ul><h4>Start a Session When Needed</h4><p>Before running Claude dispatch:</p><ul><li>Click the Amphetamine icon</li><li>Start a session</li><li>Choose Indefinite</li></ul><p>Your Mac will stay awake for as long as needed.</p><h4>Adjust macOS Settings (Important)</h4><p>To avoid interruptions, update these settings:</p><ul><li>Set display sleep to a long duration (or disable it)</li><li>Turn OFF: “Allow system sleep when display is off”</li><li>Turn OFF or extend screen saver timing if it interferes</li></ul><p>With Amphetamine enabled, your Mac can remain active and reachable even if:</p><ul><li>The screen is off</li><li>The system is locked</li><li>You’re not physically using it</li></ul><p>This means you can:</p><ul><li>Start a Claude dispatch task</li><li>Step away from your Mac</li><li>Access it remotely from your phone</li></ul><p>From your perspective, your Mac behaves like an always-online machine.</p><h3>Real Workflow Example (Using Your Phone + Notifications)</h3><p>Here’s a simple, real-life scenario:</p><p>You start a Claude dispatch task on your Mac</p><p>It begins processing (code, data, automation, etc.)</p><p>You step away and use your phone</p><p>You can even connect to your Mac from your phone and check progress</p><p>When the task completes, you receive a notification on your phone</p><p>Without This Setup:</p><ul><li>Your Mac goes idle → sleeps → Claude dispatch stops</li><li>You come back and nothing is finished.</li></ul><p>With Amphetamine Enabled:</p><ul><li>Your Mac stays awake</li><li>Claude continues running</li><li>You use your phone freely</li><li>You get notified when it’s done</li><li>You come back and everything is completed and ready</li></ul><h3>From Laptop to Always-Online AI Worker</h3><p>With this setup, your Mac becomes:</p><ul><li>Always online</li><li>Always executing</li><li>Always reliable</li></ul><p>You no longer need to stay in front of your machine.</p><p>Start Claude dispatch → step away → get notified → come back to results.</p><h3>Best Practices</h3><ul><li>Keep your Mac plugged in during long tasks</li><li>Ensure proper ventilation</li><li>Lock your screen when away</li><li>Enable Amphetamine only when needed</li></ul><h3>Final Thoughts</h3><p>The biggest limitation of local AI workflows isn’t performance—it’s reliability.</p><p>Amphetamine removes that limitation.</p><p>Once your Mac stays awake, Claude dispatch becomes:</p><ul><li>Predictable</li><li>Stable</li><li>Truly asynchronous</li></ul><p>Start the task. Walk away. Use your phone.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c1d6080fb6b7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PCM16 encoding for the OpenAI Realtime API — a practical guide]]></title>
            <link>https://zfir.medium.com/pcm16-encoding-for-the-openai-realtime-api-a-practical-guide-fbc89692036a?source=rss-fa41b1538f81------2</link>
            <guid isPermaLink="false">https://medium.com/p/fbc89692036a</guid>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-audio-api]]></category>
            <category><![CDATA[openai-realtime-api]]></category>
            <category><![CDATA[pcm16]]></category>
            <dc:creator><![CDATA[Zafir Sk Heerah]]></dc:creator>
            <pubDate>Tue, 28 Apr 2026 10:13:50 GMT</pubDate>
            <atom:updated>2026-04-28T10:13:50.770Z</atom:updated>
            <content:encoded><![CDATA[<p>You’re streaming audio from the browser. The API expects PCM16. Here’s what the implementation actually looks like and the things worth knowing before you start.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iQqIdg55WuEkKVZRCrUoQg.png" /><figcaption>PCM16 Audio Pipeline<br> Mic → Float32 → Int16 → Base64 → Realtime API</figcaption></figure><h3>1. What PCM16 actually is</h3><p>PCM16 is raw audio: 16-bit signed integers, little-endian, mono channel, sampled at 24kHz. No container, no codec, no headers — just a flat buffer of samples.</p><p>The Realtime API uses it because it’s cheap. No encoding/decoding overhead means lower latency, which matters for voice. The tradeoff is that you format the audio yourself.</p><p>The problem: the Web Audio API gives you <strong>Float32</strong>. Samples in the range [-1.0, 1.0], not integers. At whatever sample rate the browser feels like — usually 44.1kHz or 48kHz, not 24kHz. Both of those need fixing before a byte hits the WebSocket.</p><h3>2. The conversion — the part everyone gets wrong</h3><p>This is where most bugs live. The naive version multiplies each float by 32767 and casts to an integer. That breaks in two ways.</p><p><strong>The clamping issue.</strong> Audio from getUserMedia can produce samples outside [-1.0, 1.0], especially with any gain staging or Web Audio processing in the chain. Multiply an out-of-range float by 32767, cast to Int16, and it wraps around silently. You get random crackling that&#39;s nearly impossible to trace back here.</p><pre>// ❌ incorrect — silently corrupts on out-of-range samples<br>function encodeNaive(input: Float32Array): Int16Array {<br>  const out = new Int16Array(input.length);<br>  for (let i = 0; i &lt; input.length; i++) {<br>    out[i] = input[i] * 32767;<br>  }<br>  return out;<br>}</pre><pre>// ✅ correct<br>function encodePCM16(input: Float32Array): Int16Array {<br>  const out = new Int16Array(input.length);<br>  for (let i = 0; i &lt; input.length; i++) {<br>    const s = Math.max(-1, Math.min(1, input[i] || 0));<br>    out[i] = s &lt; 0 ? s * 0x8000 : s * 0x7fff;<br>  }<br>  return out;<br>}</pre><p><strong>The </strong><strong>|| 0 NaN guard.</strong> getChannelData returns a Float32Array backed by a shared audio buffer. At stream startup or teardown, individual samples can be NaN. NaN passed to Math.max/Math.min propagates silently and produces garbage Int16 values. The || 0 coerces NaN to zero before it hits the clamp. Cheap insurance.</p><p><strong>The </strong><strong>0x8000/</strong><strong>0x7fff asymmetry.</strong> Int16 range is -32768 to 32767. Using the same multiplier for both sides either clips the negative floor or wastes a positive step. 0x8000 for negative, 0x7fff for positive. One sample of headroom — doesn&#39;t matter audibly, but it&#39;s correct.</p><h3>3. Sample rate mismatch</h3><p>The API wants <strong>24kHz</strong>. Browsers default to <strong>44.1kHz</strong> (Chrome) or <strong>48kHz</strong> (Firefox/Safari). Send 48kHz audio as if it’s 24kHz and everything plays back at half speed, an octave low.</p><p>Requesting 24kHz when creating the AudioContext usually works:</p><pre>const ctx = new AudioContext({ sampleRate: 24000 });</pre><p><strong>Safari doesn’t always honour this.</strong> It accepts the parameter without throwing, then silently runs at its preferred rate. Always verify after construction:</p><pre>if (ctx.sampleRate !== 24000) {<br>  console.warn(`AudioContext is running at ${ctx.sampleRate}Hz — audio will be pitch-shifted.`);<br>  // resample manually before encoding<br>}</pre><p>If you need to handle Safari, resample after capture. Linear interpolation is fine for voice:</p><pre>function downsample(input: Float32Array, fromRate: number, toRate: number): Float32Array {<br>  if (fromRate === toRate) return input;<br>  const ratio = fromRate / toRate;<br>  const length = Math.round(input.length / ratio);<br>  const result = new Float32Array(length);<br>  for (let i = 0; i &lt; length; i++) {<br>    const pos = i * ratio;<br>    const idx = Math.floor(pos);<br>    const t = pos - idx;<br>    result[i] = (input[idx] ?? 0) * (1 - t) + (input[idx + 1] ?? 0) * t;<br>  }<br>  return result;<br>}</pre><h3>4. Browser guards — check before you start</h3><p>getUserMedia flat-out doesn&#39;t work on non-HTTPS origins. The browser either throws an obscure permission error or silently returns nothing. Check isSecureContext first:</p><pre>function assertAudioSupported(): void {<br>  if (!window.isSecureContext) {<br>    throw new Error(<br>      `Microphone access requires HTTPS or localhost. Current origin: ${window.location.origin}`<br>    );<br>  }<br>  if (!navigator.mediaDevices?.getUserMedia) {<br>    throw new Error(&#39;getUserMedia not available — use a modern browser.&#39;);<br>  }<br>}</pre><p>And a feature-detect before rendering the mic button:</p><pre>function isAudioSupported(): boolean {<br>  return !!(navigator.mediaDevices &amp;&amp; window.AudioContext);<br>}</pre><h3>5. Capturing with AudioWorklet</h3><p>The old approach used createScriptProcessor, which runs on the main thread and causes audio glitches under load. AudioWorklet is the replacement — it runs in a dedicated audio rendering thread.</p><p>You need two files: the worklet processor, and the main thread wiring.</p><p><strong>pcm-worklet.js</strong> (served as a separate file):</p><pre>class PcmProcessor extends AudioWorkletProcessor {<br>  process(inputs) {<br>    const channel = inputs[0]?.[0];<br>    if (!channel?.length) return true;<br><br>    const pcm = new Int16Array(channel.length);<br>    for (let i = 0; i &lt; channel.length; i++) {<br>      const s = Math.max(-1, Math.min(1, channel[i] || 0));<br>      pcm[i] = s &lt; 0 ? s * 0x8000 : s * 0x7fff;<br>    }<br><br>    this.port.postMessage({ pcm }, [pcm.buffer]);<br>    return true;<br>  }<br>}<br><br>registerProcessor(&#39;pcm-processor&#39;, PcmProcessor);</pre><p><strong>Main thread setup:</strong></p><pre>let ctx: AudioContext | null = null;<br>let stream: MediaStream | null = null;<br>let source: MediaStreamAudioSourceNode | null = null;<br><br>async function startCapture(onPcm: (data: Int16Array) =&gt; void): Promise&lt;void&gt; {<br>  assertAudioSupported();<br>  stream = await navigator.mediaDevices.getUserMedia({<br>    audio: { channelCount: 1, echoCancellation: true, noiseSuppression: true, autoGainControl: true },<br>  });<br>  ctx = new AudioContext({ sampleRate: 24000 });<br>  if (ctx.sampleRate !== 24000) {<br>    console.warn(`AudioContext running at ${ctx.sampleRate}Hz - Safari sample rate mismatch.`);<br>  }<br>  await ctx.audioWorklet.addModule(&#39;/pcm-worklet.js&#39;);<br>  source = ctx.createMediaStreamSource(stream);<br>  const worklet = new AudioWorkletNode(ctx, &#39;pcm-processor&#39;);<br>  worklet.port.onmessage = (e: MessageEvent) =&gt; { onPcm(e.data.pcm); };<br>  source.connect(worklet);<br>  worklet.connect(ctx.destination);<br>}<br><br>function stopCapture(): void {<br>  source?.disconnect();<br>  stream?.getTracks().forEach((t) =&gt; t.stop());<br>  ctx?.close();<br>  source = null; stream = null; ctx = null;<br>}</pre><p>The [pcm.buffer] transferable hands ownership across threads without copying. Also, addModule must complete before constructing AudioWorkletNode — do it out of order and you get a silent InvalidStateError.</p><h3>6. Sending it correctly</h3><p>The API expects PCM16 as <strong>base64</strong>, not raw binary:</p><pre>function toBase64(pcm: Int16Array): string {<br>  const bytes = new Uint8Array(pcm.buffer, pcm.byteOffset, pcm.byteLength);<br>  let str = &#39;&#39;;<br>  for (let i = 0; i &lt; bytes.length; i++) {<br>    str += String.fromCharCode(bytes[i]);<br>  }<br>  return btoa(str);<br>}<br><br>ws.send(JSON.stringify({<br>  type: &#39;input_audio_buffer.append&#39;,<br>  audio: toBase64(pcm),<br>}));</pre><p>Note the byteOffset in the Uint8Array constructor. If pcm is a slice of a larger buffer, skipping byteOffset sends the whole underlying ArrayBuffer — not just your chunk. This produces silence with occasional pops and is genuinely hard to spot.</p><p>The default AudioWorklet quantum is 128 samples (~5ms at 24kHz). That’s fine to send directly. If you want ~170ms frames instead, accumulate into a ring buffer on the main thread before flushing.</p><h3>7. Debugging tips</h3><p>Play your PCM16 back locally before sending. If it sounds wrong here, it’s a conversion problem — not an API problem:</p><pre>function auditPcm(samples: Int16Array, rate = 24000): void {<br>  const actx = new AudioContext({ sampleRate: rate });<br>  const floats = new Float32Array(samples.length);<br>  for (let i = 0; i &lt; samples.length; i++) {<br>    floats[i] = samples[i] / (samples[i] &lt; 0 ? 32768 : 32767);<br>  }<br>  const buf = actx.createBuffer(1, floats.length, rate);<br>  buf.copyToChannel(floats, 0);<br>  const src = actx.createBufferSource();<br>  src.buffer = buf;<br>  src.connect(actx.destination);<br>  src.start();<br>}</pre><p>RMS level as a quick sanity check:</p><pre>function rmsLevel(pcm: Int16Array): number {<br>  let sum = 0;<br>  for (let i = 0; i &lt; pcm.length; i++) {<br>    const norm = (pcm[i] || 0) / 32768;<br>    sum += norm * norm;<br>  }<br>  return Math.sqrt(sum / pcm.length);<br>}<br>// should be &gt; 0 when speaking</pre><p><strong>What you hear → Likely cause</strong></p><p>Half-speed, low-pitched voice → Safari ignoring requested 24kHz</p><p>Random crackling bursts → Unclamped samples wrapping on cast</p><p>Silence or pops at start/end → NaN samples — missing || 0 guard</p><p>Choppy/robotic → Gaps between worklet messages</p><p>Silence with occasional pops → Missing byteOffset when slicing buffer before base64</p><p>Once you understand the pipeline — Float32 capture → NaN guard → clamp → Int16 → transfer → base64 → send — everything clicks into place. Getting each step right is what separates reliable voice streaming from audio that crackles, plays at the wrong pitch, or silently corrupts.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fbc89692036a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Speeding up Docker builds with pnpm store caching]]></title>
            <link>https://zfir.medium.com/speeding-up-docker-builds-with-pnpm-store-caching-31e704e1ca8b?source=rss-fa41b1538f81------2</link>
            <guid isPermaLink="false">https://medium.com/p/31e704e1ca8b</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[pnpm]]></category>
            <category><![CDATA[docker-compose]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Zafir Sk Heerah]]></dc:creator>
            <pubDate>Thu, 29 Jan 2026 09:01:01 GMT</pubDate>
            <atom:updated>2026-01-29T09:01:01.205Z</atom:updated>
            <content:encoded><![CDATA[<p>In this example, I’m showing the <strong>named volume</strong> method.</p><p>pnpm is fast because it keeps downloaded packages in a <strong>store</strong> and links them into node_modules. In Docker, if that store is ephemeral, pnpm install ends up re-downloading the world. The fix is to persist the store using a <strong>named volume</strong> mounted to a fixed path:</p><pre>- pnpm_store_v10:/app/.pnpm-store</pre><h3>docker-compose.yml</h3><pre>services:<br>  app:<br>    build: .<br>    working_dir: /app<br>    volumes:<br>      - .:/app<br>      - pnpm_store_v10:/app/.pnpm-store<br>    environment:<br>      - PNPM_STORE_DIR=/app/.pnpm-store<br>    command: sh -lc &quot;pnpm install --frozen-lockfile &amp;&amp; pnpm dev&quot;<br><br>volumes:<br>  pnpm_store_v10:</pre><p>What this does:</p><ul><li>.:/app mounts your source code.</li><li>pnpm_store_v10:/app/.pnpm-store persists pnpm’s store between runs.</li><li>PNPM_STORE_DIR guarantees pnpm uses the mounted store.</li></ul><h3>Dockerfile (simple + plays well with caching)</h3><pre>FROM node:20-slim<br>WORKDIR /app<br><br>RUN corepack enable<br>ENV PNPM_STORE_DIR=/app/.pnpm-store<br><br>COPY package.json pnpm-lock.yaml ./<br>RUN pnpm install --frozen-lockfile<br><br>COPY . .<br>CMD [&quot;pnpm&quot;, &quot;dev&quot;]</pre><h3>Why version the volume name (_v10)</h3><p>Think of it as a “reset switch”. If you change Node/pnpm versions or base image, bump it:</p><p>pnpm_store_v10 → pnpm_store_v11</p><p>Instant clean cache, no manual volume cleanup.</p><h3>Quick check</h3><p>Inside the container:</p><pre>pnpm store path</pre><p>It should print /app/.pnpm-store. If it doesn’t, re-check PNPM_STORE_DIR or set store-dir=/app/.pnpm-store in .npmrc.</p><p>That’s the whole trick: persist the pnpm store, and installs become much faster after the first run.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31e704e1ca8b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enable a Desktop-Style Experience(Samsung DeX) on any Android Device: Unlocking the Power of scrcpy]]></title>
            <link>https://proandroiddev.com/enable-a-desktop-style-experience-samsung-dex-on-any-android-device-unlocking-the-power-of-scrcpy-b91d28d685fc?source=rss-fa41b1538f81------2</link>
            <guid isPermaLink="false">https://medium.com/p/b91d28d685fc</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[screen-mirroring]]></category>
            <category><![CDATA[scrcpy]]></category>
            <category><![CDATA[android-development]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Zafir Sk Heerah]]></dc:creator>
            <pubDate>Fri, 28 Nov 2025 22:09:01 GMT</pubDate>
            <atom:updated>2025-11-28T22:09:01.301Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nmG9IU8TIpLuzdqIB8wKaQ.png" /><figcaption>AI-generated image illustration of scrcpy creating a desktop-style virtual display from an Android device.</figcaption></figure><p>Samsung DeX is one of the coolest productivity features in the Android world. But it’s limited to Samsung devices… right?</p><p>Not anymore.</p><p>With <strong>scrcpy</strong>, a free and open-source tool, you can create a <strong>high-resolution virtual display</strong> on <em>any</em> Android phone, giving you a desktop-like workspace similar to Samsung DeX.</p><p>Let’s explore how it works.</p><h3>What is scrcpy?</h3><p>scrcpy is a lightweight mirroring tool that lets you view and control your Android device from your computer. It works over USB or Wi-Fi, offering fast performance and almost zero delay.</p><p>But recent versions added something powerful:</p><h4>Virtual Display Mode (--new-display)</h4><p>This creates a <strong>separate, brand-new screen</strong> on Android — not just a mirror of your phone.</p><h3>Why Use scrcpy for Desktop Mode?</h3><ul><li>Free and open source</li><li>Works on Windows, macOS, and Linux</li><li>No root required</li><li>High performance, low latency</li><li>Lets you run apps on a virtual external display</li><li>Gives a Samsung DeX–like experience on any Android device</li></ul><h3>Getting Started</h3><h4>1. Install scrcpy</h4><p>Download it from the official GitHub page.</p><h4>2. Enable Developer Options</h4><p>On your phone:</p><ul><li>Go to <strong>Settings → About Phone</strong></li><li>Tap <strong>Build Number</strong> 7 times</li><li>Turn on <strong>USB Debugging</strong></li></ul><h4>3. Connect Your Device</h4><p>Use USB or wireless ADB.</p><h3>Creating a Desktop-Style Display</h3><p>To launch a virtual desktop environment, run:</p><pre>scrcpy --new-display=2048x1536/240 --stay-awake</pre><p>This does two things:</p><ul><li><strong>Creates a new high-resolution screen</strong></li><li><strong>Keeps the phone awake</strong> during the session</li></ul><p>Your computer will open a crisp, resizable window that acts like a separate monitor for your phone — similar to how Samsung DeX uses an external display.</p><p>Apps can be opened directly on this virtual screen, giving you a desktop-like workflow.</p><h4>Try Different Resolutions</h4><p>You can customize the virtual display:</p><pre>scrcpy --new-display=1920x1080/60<br>scrcpy --new-display=2560x1440/90<br>scrcpy --new-display=3440x1440/60   # Ultrawide!</pre><p>Choose what fits your style and screen size.</p><h3>Why This Feels Like Samsung DeX</h3><p>Using scrcpy’s virtual display gives you:</p><ul><li>A separate desktop workspace</li><li>Keyboard and mouse control</li><li>Freeform/multi-window support (depending on your Android version)</li><li>The ability to run apps without touching your phone</li></ul><p>It’s not a perfect replacement for DeX, but it delivers a surprisingly similar desktop experience — without needing a Samsung device.</p><h3>Conclusion</h3><p>scrcpy’s --new-display option transforms your Android device into a powerful desktop-style workstation. Whether you&#39;re multitasking, coding, presenting, or working from a laptop, this feature gives you a taste of Samsung DeX on <em>any</em> Android phone.</p><p><strong>Try it out today and unlock a whole new way to use your device!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b91d28d685fc" width="1" height="1" alt=""><hr><p><a href="https://proandroiddev.com/enable-a-desktop-style-experience-samsung-dex-on-any-android-device-unlocking-the-power-of-scrcpy-b91d28d685fc">Enable a Desktop-Style Experience(Samsung DeX) on any Android Device: Unlocking the Power of scrcpy</a> was originally published in <a href="https://proandroiddev.com/">ProAndroidDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Remote Dev Setup 2025–2026]]></title>
            <link>https://zfir.medium.com/my-remote-dev-setup-2025-2026-3ea7a16337c4?source=rss-fa41b1538f81------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ea7a16337c4</guid>
            <category><![CDATA[developer-tools]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Zafir Sk Heerah]]></dc:creator>
            <pubDate>Wed, 08 Oct 2025 08:02:10 GMT</pubDate>
            <atom:updated>2025-10-08T08:02:10.402Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kKxN7U-u3Qs7SPSmamAnIA.png" /></figure><p>I’ve always wanted a development environment that’s consistent, secure, and accessible from anywhere — without dragging around a heavy laptop setup and also setup the development on multiple devices. So I built my own <strong>remote dev server</strong> that I can connect to from any device, and it’s been a game-changer.</p><p>Here’s the stack I’m using:</p><ul><li><strong>AWS Lightsail</strong> — affordable and predictable hosting.</li><li><strong>Tailscale + MagicDNS</strong> — private networking with human-readable names.</li><li><strong>SSH over Tailscale</strong> — secure shell access, only through my private network.</li><li><strong>GitHub </strong>— seamless pushes and pulls without re-authentication headaches.</li><li><strong>Code-Server</strong> — a browser-based VS Code that feels just like the desktop version.</li><li><strong>VS Code/Cursor Remote-SSH</strong> — connect from the desktop VS Code app directly into the server.</li><li><strong>Cloudflare Tunnel</strong> — for temporarily sharing apps and services with teammates or testers.</li></ul><h3>Why I Use a Remote Dev Server</h3><ul><li><strong>Consistency</strong>: One environment that doesn’t depend on which device I’m on.</li><li><strong>Security</strong>: No public ports, all connections go through Tailscale.</li><li><strong>Performance</strong>: Lightsail’s VM has more resources than my laptop, I can upgrade when I need.</li><li><strong>Flexibility</strong>: I can code from a browser on practically any device. Yes, even my iPad 😎.</li></ul><h3>The Setup</h3><h4>1. AWS Lightsail</h4><p>I run an 8GB Linux server on Lightsail. It’s enough to handle Docker, code-server, and my usual stack without lagging.</p><h4>2. Tailscale + MagicDNS</h4><p>Tailscale connects all my devices into a private mesh network. With <strong>MagicDNS</strong>, I don’t deal with IPs — I just type:</p><pre>ssh ubuntu@remote-dev-env</pre><p>That’s it. No need to remember 100.x.x.x addresses.</p><h4>3. SSH over Tailscale</h4><p>The server doesn’t expose SSH to the internet. Only devices on my Tailscale network can connect:</p><pre>sudo ufw allow from 100.0.0.0/8 to any port 22</pre><p>This keeps things secure without complicating my workflow.</p><h4>4. GitHub</h4><p>I setup Github to the server. Pushes and pulls work seamlessly — no need to deal with HTTPS tokens or repeated logins.</p><h4>5. Code-Server</h4><p>This is my favorite part. I open:</p><pre>http://remote-dev-env:8080</pre><p>and get full <strong>VS Code in my browser</strong>. Extensions, settings, and themes sync across sessions, so it feels just like local VS Code.</p><h4>6. VS Code/Cursor Remote-SSH</h4><p>When I’m on my main laptop or desktop, I prefer the full native VS Code/Cursor app instead of the browser. For that, I use the <strong>Remote-SSH extension that comes with VS Code/Cursor</strong>.</p><p>With Tailscale, connecting is straightforward:</p><pre>Host remote-dev-env<br>  HostName remote-dev-env<br>  User ubuntu</pre><p>Now from VS Code I can just:</p><ol><li>Hit <strong>“Connect to Host”</strong>.</li><li>Select remote-dev-env.</li><li>And I’m inside my Lightsail dev environment — with all the server’s compute power, but in the editor I already use every day.</li></ol><p>With this, it gives me two flexible ways to work:</p><ul><li><strong>Code-Server</strong> in the browser (accessible even on my iPad).</li><li><strong>Remote-SSH</strong> in native VS Code/Cursor (when I’m on a proper laptop/desktop).</li></ul><h4>7. Cloudflare Tunnel</h4><p>Sometimes I need to share an app I’m running (say, a dev server on port 3000) with a teammate. Instead of opening ports or deploying early, I use <strong>Cloudflare Tunnel</strong>:</p><pre>cloudflared tunnel --url http://localhost:3000</pre><p>This instantly creates a secure, public URL like:</p><pre>https://myapp-example.trycloudflare.com</pre><p>When I’m done sharing, I just stop the tunnel, and the app goes back to being private-only.</p><h3>Daily Workflow</h3><ul><li>Open <strong>Code-Server</strong> in the browser (great for any device, even an iPad).</li><li>Or connect via <strong>VS Code Remote-SSH</strong> from my laptop/desktop for the full native IDE experience.</li><li>Write code directly in the cloud environment.</li><li>Run command-line tasks from the built-in terminal.</li><li>Push and pull changes through GitHub with no extra friction.</li></ul><p>It’s smooth, fast, and secure — and my laptop now feels more like a thin client than a dev machine.</p><h3>Running Services on the Remote Dev Server</h3><p>One of the biggest wins of this setup is how easy it is to run services (like a Node.js app, Python API, or Docker container) directly on the server.</p><p>For example, if I run a dev server on <strong>port 3000</strong>, it’s technically listening inside my Lightsail VM. With <strong>Tailscale</strong>, I can access it directly through the private network — no need to expose it to the public internet.</p><p>For example, if I run a dev server on <strong>port 3000</strong>, it’s technically listening inside my Lightsail VM. With <strong>Tailscale</strong>, I can access it directly through the private network — no need to expose it to the public internet.</p><pre>npm run dev<br># → Starts app on http://localhost:3000</pre><p>On my local laptop or iPad that’s connected to Tailscale, I can just open:</p><pre>http://remote-dev-env:3000</pre><p>And I’ll see the app running, securely tunneled over Tailscale.</p><ul><li><strong>No port forwarding.</strong></li><li><strong>No nginx configs.</strong></li><li><strong>No public exposure.</strong></li></ul><p>Everything stays private to my devices inside the Tailscale network.</p><p>If I want to share that same service, I spin up a <strong>Cloudflare Tunnel</strong>, get a temporary public URL, send it to a teammate, and shut it down once I’m done.</p><p>This way, my dev server isn’t just for coding — it’s also a safe place to <strong>run, test, and demo apps</strong> without ever compromising security.</p><h3>Conclusion</h3><p>This setup solves the “works on this machine and not on my other machine” problem and keeps everything private by default.</p><p>With <strong>Lightsail, Tailscale, and Code-Server</strong>, I now have a central development environment I can rely on, wherever I am.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ea7a16337c4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Give Your Server an Identity: How to Change the Hostname on a Linux Server (Systemd-Based Linux)]]></title>
            <link>https://zfir.medium.com/how-to-change-the-hostname-on-a-linux-server-systemd-based-linux-ecfce7d9beca?source=rss-fa41b1538f81------2</link>
            <guid isPermaLink="false">https://medium.com/p/ecfce7d9beca</guid>
            <category><![CDATA[servers]]></category>
            <category><![CDATA[linux-tutorial]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[infrastructure]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Zafir Sk Heerah]]></dc:creator>
            <pubDate>Wed, 10 Sep 2025 18:58:21 GMT</pubDate>
            <atom:updated>2025-09-10T19:00:17.956Z</atom:updated>
            <content:encoded><![CDATA[<p>Setting a meaningful hostname for your Linux server is a simple yet essential task. Whether you’re managing a single machine or dozens across different environments, a well-chosen hostname improves clarity, aids in automation, and enhances remote terminal sessions.</p><p>In this guide, we’ll walk through how to change the hostname of a Linux server running Ubuntu, one of the most popular Linux distributions for development and production environments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nC0IuYvc3OYb8bC-7PgEDQ.png" /></figure><h3>What is a Hostname?</h3><p>A <strong>hostname</strong> is a human-readable label that identifies a device on a network. You’ll often see hostnames in your terminal prompt, logs, SSH sessions, and monitoring tools. By default, many systems use generic or IP-based names like ip-172-26-8-23, which aren’t helpful in real-world usage.</p><p>Giving your server a relevant name like web-app-dev, backend-staging, or db-prod can make system administration smoother.</p><h3>Steps to Change the Hostname on Ubuntu (or Any Systemd-Based Linux)</h3><h4>View the Current Hostname</h4><p>To check your current hostname:</p><pre>hostnamectl</pre><p>You’ll see something like:</p><pre> Static hostname: ip-172-26-7-80<br>       Icon name: computer-vm<br>         Chassis: vm <br>      Machine ID: ec2b72...<br>         Boot ID: 6805d7...<br>  Virtualization: amazon<br>Operating System: Ubuntu 24.04.2 LTS              <br>          Kernel: Linux 6.14.0-1010-aws<br>    Architecture: x86-64<br> Hardware Vendor: Amazon EC2<br>  Hardware Model: t3.nano<br>Firmware Version: 1.0<br>   Firmware Date: Mon 2017-10-16<br>    Firmware Age: 7y 10month 2w 4d</pre><h4>Set the New Hostname</h4><p>Choose a name that describes your server’s purpose. Avoid spaces and special characters.</p><p>To change the hostname:</p><pre>sudo hostnamectl set-hostname your-new-hostname</pre><p>Example:</p><pre>sudo hostnamectl set-hostname remote-dev-env</pre><h4>Reboot or Reconnect</h4><p>While a full reboot isn’t strictly necessary, it ensures consistency across all tools and prompts.</p><pre>sudo reboot</pre><p>Or log out and log back in to confirm the change.</p><h4>Confirm the New Hostname</h4><p>Once you’re logged back in:</p><pre>hostnamectl</pre><p>Output:</p><pre> Static hostname: remote-dev-env<br>       Icon name: computer-vm<br>         Chassis: vm <br>      Machine ID: ec2b72...<br>         Boot ID: 7a5a4c...<br>  Virtualization: amazon<br>Operating System: Ubuntu 24.04.2 LTS              <br>          Kernel: Linux 6.14.0-1010-aws<br>    Architecture: x86-64<br> Hardware Vendor: Amazon EC2<br>  Hardware Model: t3.nano<br>Firmware Version: 1.0<br>   Firmware Date: Mon 2017-10-16<br>    Firmware Age: 7y 10month 2w 4d  </pre><h3><strong>Conclusion</strong></h3><p>Changing your hostname is a small administrative task that pays off in clarity, automation, and management. Whether it’s for development, testing, or production, naming your servers with purpose can save time and reduce confusion.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ecfce7d9beca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Make Your iOS App Screenshots Look Perfect: Customise the Simulator Status Bar]]></title>
            <link>https://zfir.medium.com/make-your-ios-app-screenshots-look-perfect-customise-the-simulator-status-bar-7454b09812c0?source=rss-fa41b1538f81------2</link>
            <guid isPermaLink="false">https://medium.com/p/7454b09812c0</guid>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[simulator]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[ios-apps]]></category>
            <dc:creator><![CDATA[Zafir Sk Heerah]]></dc:creator>
            <pubDate>Tue, 11 Mar 2025 09:02:45 GMT</pubDate>
            <atom:updated>2025-03-12T13:17:57.832Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9aKz_s-w6GVTgCaRY28hfA.png" /></figure><p>When developing and testing iOS applications, it’s common to take screenshots for the App Store, marketing materials, or documentation. However, the iOS Simulator’s default status bar displays the current time, battery percentage, and network status, which can look inconsistent across different screenshots. A clean and professional way to present your app is to change the status bar to Apple’s default style, such as showing 9:41 AM, a full battery, and a strong Wi-Fi signal.</p><h3>Why use Apple’s Status Bar Style?</h3><p>Apple’s default status bar appearance (e.g., 9:41 AM) is often used in official iOS product images and App Store screenshots to create a consistent, polished look. Modifying the status bar in the simulator ensures that:</p><ul><li>Your app’s screenshots look professional and polished.</li><li>There are no distracting elements, such as a different time or network status, which might vary between screenshots.</li><li>The appearance is consistent with Apple’s UI guidelines.</li></ul><h3>Changing the Status Bar in iOS Simulator</h3><p>Apple provides a built-in way to override the status bar settings using the <strong>simctl</strong> command-line tool. Follow the steps below to set the simulator’s status bar to a clean, default appearance.</p><h4>Step 1: Launch the iOS Simulator</h4><p>First, ensure that your desired simulator is running. You can start an iOS Simulator using Xcode or the command line:</p><pre>xcrun simctl boot &quot;E335219A-756C-4B4A-9EAA-A632AF5B9773&quot;</pre><h4>Step 1: Boot the iOS Simulator correctly</h4><p><strong>List Available Devices</strong></p><p>First, ensure that your desired simulator is running. Run the following command to list all available simulators along with their UUIDs:</p><pre>xcrun simctl list devices</pre><p>This will show a list of created simulators. Find the correct UUID next to the iPhone 14 (or the device you want to boot).</p><p><strong>Boot using the UUID</strong></p><p>Once you have the UUID, use the following command to boot the simulator:</p><pre>xcrun simctl boot &lt;UUID&gt;</pre><p>For example:</p><pre>xcrun simctl boot 5BB51BC7-2B0A-49FC-B941-A21BB3D30EEB</pre><p>Once the simulator is running, proceed to the next step.</p><h4>Step 2: Override the Status Bar Settings</h4><pre>xcrun simctl status_bar booted override --time &quot;9:41&quot; --batteryState charged --wifiBars 3 --cellularBars 4</pre><ul><li>--time &quot;9:41&quot; → Sets the clock to 9:41 AM, which is Apple’s standard time in promotional images.</li><li>--batteryState charged → Displays a fully charged battery.</li><li>--wifiBars 3 → Ensures full Wi-Fi signal strength.</li><li>--cellularBars 4 → Sets full cellular signal strength.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/425/1*ty56J6kPMbmJU7YacG_kCw.png" /></figure><p>That’s it. Now, check the status bar in your running simulator. It should now display a clean and professional Apple-like appearance.</p><h4>Step 3: Reset the Status Bar (Optional)</h4><p>If you need to restore the default, real-time status bar, use the following command:</p><pre>xcrun simctl status_bar booted clear</pre><h3>Conclusion</h3><p>Modifying the iOS Simulator’s status bar ensures a clean and consistent look for screenshots. This simple trick can enhance the presentation of your app, whether for App Store listings, marketing materials, or documentation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7454b09812c0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Achieving iPhone Mirroring on Android: Unlocking the Power of scrcpy]]></title>
            <link>https://proandroiddev.com/achieving-iphone-mirroring-on-android-unlocking-the-power-of-scrcpy-c82b3ba438db?source=rss-fa41b1538f81------2</link>
            <guid isPermaLink="false">https://medium.com/p/c82b3ba438db</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[scrcpy]]></category>
            <category><![CDATA[screen-mirroring]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Zafir Sk Heerah]]></dc:creator>
            <pubDate>Wed, 12 Feb 2025 18:56:27 GMT</pubDate>
            <atom:updated>2025-02-12T20:15:10.354Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pgr-DcRYQrmE_xCWLElp9w.jpeg" /><figcaption>AI-generated image illustration of scrcpy mirroring an Android device onto a computer screen.</figcaption></figure><p>Screen mirroring is a feature often associated with iPhones and Apple’s ecosystem. But did you know Android users can achieve similar functionality with <strong>scrcpy</strong>, a free and open-source tool? In this blog, we’ll explore how scrcpy can turn your Android device into a powerful mirroring platform.</p><h3>What is scrcpy?</h3><p><strong>scrcpy</strong> is a lightweight application that allows you to mirror and control Android devices from a computer. It works over USB or TCP/IP, providing low-latency screen sharing and input control.</p><h3>Why use scrcpy?</h3><ul><li><strong>Free and Open-Source</strong></li><li><strong>No Root Required</strong></li><li><strong>Cross-Platform Support</strong> (Windows, macOS, Linux)</li><li><strong>High Performance</strong> with minimal delay</li></ul><h3>Getting Started with scrcpy</h3><h4>Installation</h4><ol><li><strong>Download scrcpy</strong> from its official GitHub repository.</li><li><strong>Install Android ADB Tools</strong>, if not already installed.</li></ol><h4>Basic Setup</h4><ol><li>Enable <strong>Developer Options</strong> on your Android device.</li><li>Turn on <strong>USB Debugging</strong>.</li><li>Connect your device to your computer via USB.</li></ol><p>Run the following command:</p><pre>scrcpy</pre><p>Your Android screen should appear on your computer!</p><h3>Turning Off Android Screen While Mirroring</h3><p>One of scrcpy’s hidden gems is the ability to turn off your Android screen while keeping the mirroring active.</p><h4>Method 1: Command-Line Option</h4><pre>scrcpy --turn-screen-off</pre><h4>Method 2: Keyboard Shortcut</h4><p>While scrcpy is running, press:</p><pre>CTRL + O (MOD + O)</pre><p><strong>MOD</strong> refers to the modifier key, which is <strong>CTRL</strong> by default.</p><p>This feature saves battery and ensures privacy while you control your Android device from your computer.</p><h3>Why This Feels Like iPhone Mirroring</h3><p>With scrcpy, Android users enjoy:</p><ul><li><strong>Effortless screen mirroring</strong></li><li><strong>Keyboard and mouse input</strong></li><li><strong>Seamless control from any computer</strong></li></ul><p>The experience mirrors Apple’s AirPlay-like functionality, but with greater customization and freedom.</p><h3>Conclusion</h3><p>Scrcpy transforms Android devices into versatile, powerful tools for screen mirroring and control. Whether you’re streaming content, giving presentations, or managing your phone from your PC, scrcpy delivers iPhone-like mirroring on Android — without the Apple price tag!</p><p><strong>Try it out today and redefine your Android experience!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c82b3ba438db" width="1" height="1" alt=""><hr><p><a href="https://proandroiddev.com/achieving-iphone-mirroring-on-android-unlocking-the-power-of-scrcpy-c82b3ba438db">Achieving iPhone Mirroring on Android: Unlocking the Power of scrcpy</a> was originally published in <a href="https://proandroiddev.com/">ProAndroidDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Running React, Angular.js, Ember.js, … Locally on Android]]></title>
            <link>https://zfir.medium.com/running-react-angular-js-ember-js-locally-on-android-f43fb9c3980b?source=rss-fa41b1538f81------2</link>
            <guid isPermaLink="false">https://medium.com/p/f43fb9c3980b</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[javascript-frameworks]]></category>
            <category><![CDATA[javascript-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Zafir Sk Heerah]]></dc:creator>
            <pubDate>Wed, 27 Nov 2024 09:45:32 GMT</pubDate>
            <atom:updated>2024-11-27T09:45:32.326Z</atom:updated>
            <content:encoded><![CDATA[<h3>Running React, Angular.js, Ember.js, … Locally on Android</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iywxHSrw3I8qLRgZ5s3L7g@2x.jpeg" /></figure><p>In this post, we’ll explore how you can run any JavaScript framework app — like <strong>React</strong>, <strong>Angular.js</strong>, or <strong>Ember.js</strong> — locally on an Android device. Using <strong>Ember.js</strong> as an example, we’ll discuss how to serve a statically built JS app with a lightweight local web server and run it in a WebView. You can check the full implementation on <a href="https://github.com/zfir-dev/ember-android">this GitHub repository</a>.</p><h3><strong>Repository Overview</strong></h3><p>The <a href="https://github.com/zfir-dev/ember-android">GitHub repository</a> contains the complete implementation of:</p><ul><li>An Ember.js app pre-built into static assets.</li><li>A lightweight Android web server to serve those static files.</li><li>A WebView configuration to load and run the Ember.js app locally on an Android device.</li></ul><p>Feel free to clone the repo for hands-on experimentation.</p><pre>git clone https://github.com/zfir-dev/ember-android.git</pre><h3>How It Works</h3><p>Here’s the high-level workflow:</p><ol><li>The Ember.js app is built and stored in the Android app’s assets/ember-dist folder.</li><li>A lightweight web server, implemented in Java, serves these files locally.</li><li>The WebView loads the app through the local server (http://localhost:8080).</li></ol><h3>Key Components</h3><h4>Ember.js App</h4><p>The Ember.js app is pre-built using:</p><pre>ember build --environment=production</pre><p>The output is placed in the assets/ember-dist folder of the Android project. These files include:</p><ul><li>index.html</li><li>app.js</li><li>styles.css</li><li>Other static assets.</li></ul><p>The Ember.js app doesn’t require any external hosting since it is served locally on the device.</p><h4>Web Server</h4><p>The web server is implemented using <a href="https://github.com/NanoHttpd/nanohttpd">NanoHTTPD</a>, a lightweight HTTP server library. It serves the static assets from the assets folder.</p><p>Here’s an overview of the WebServer class, located in the <a href="https://github.com/zfir-dev/ember-android/blob/main/app/src/main/java/dev/zfir/ember_android/WebServer.kt">WebServer.kt</a> file:</p><p><strong>Core Responsibilities:</strong></p><ul><li><strong>File Routing</strong>: Routes incoming HTTP requests to corresponding files in the assets/ember-dist directory.</li><li><strong>Dynamic MIME Type Detection</strong>: Ensures proper file rendering by assigning the correct MIME type (e.g., text/html, application/javascript).</li></ul><p><strong>Serve:</strong></p><pre>@Override<br>public Response serve(IHTTPSession session) {<br>    String uri = session.getUri().equals(&quot;/&quot;) ? &quot;ember-dist/index.html&quot; : &quot;ember-dist/&quot; + session.getUri();<br><br>    try {<br>        InputStream inputStream = context.getAssets().open(uri);<br>        String mimeType = getMimeType(uri);<br>        return newChunkedResponse(Response.Status.OK, mimeType, inputStream);<br>    } catch (IOException e) {<br>        return newFixedLengthResponse(Response.Status.NOT_FOUND, &quot;text/plain&quot;, &quot;File Not Found&quot;);<br>    }<br>}</pre><p>This method:</p><ol><li>Handles HTTP requests and determines the file to serve.</li><li>Uses getMimeType(uri) to assign appropriate MIME types (HTML, CSS, JS, etc.).</li><li>Returns the file content as a Response. If the file doesn’t exist, a 404 error response is returned.</li></ol><p><strong>MIME Type Detection:</strong></p><pre>private String getMimeType(String fileName) {<br>    if (fileName.endsWith(&quot;.html&quot;)) return &quot;text/html&quot;;<br>    if (fileName.endsWith(&quot;.js&quot;)) return &quot;application/javascript&quot;;<br>    if (fileName.endsWith(&quot;.css&quot;)) return &quot;text/css&quot;;<br>    if (fileName.endsWith(&quot;.png&quot;)) return &quot;image/png&quot;;<br>    if (fileName.endsWith(&quot;.jpg&quot;) || fileName.endsWith(&quot;.jpeg&quot;)) return &quot;image/jpeg&quot;;<br>    return &quot;application/octet-stream&quot;;<br>}</pre><p>This ensures the client (WebView) can correctly interpret and render the files.</p><h4>WebView Configuration</h4><p>The WebView is configured in the <a href="https://github.com/zfir-dev/ember-android/blob/main/app/src/main/java/dev/zfir/ember_android/MainActivity.kt">MainActivity.kt</a> file. It connects the Ember.js app served by the local web server to the Android app.</p><p><strong>Key Configuration:</strong></p><ul><li><strong>Enable JavaScript</strong>: Allows the WebView to execute JavaScript.</li><li><strong>Local Server URL</strong>: Loads the app from <a href="http://localhost:8080.">http://localhost:8080.</a></li><li><strong>Optimizations</strong>: Settings like domStorageEnabled and useWideViewPort ensure smooth performance.</li></ul><pre>webView.getSettings().setJavaScriptEnabled(true);<br>webView.setWebViewClient(new WebViewClient());<br>webView.loadUrl(&quot;http://localhost:8080/&quot;);</pre><p>This simple configuration is sufficient to load and display the Ember.js app locally.</p><h3>Getting Started</h3><p>To try it out:</p><ol><li>Clone the repository:</li></ol><pre>git clone https://github.com/zfir-dev/ember-android.git</pre><ol><li>Open the project in Android Studio.</li><li>Build and run the app on an Android emulator or device.</li></ol><p>The Ember.js app will load in the WebView, served locally from <a href="http://localhost:8080.">http://localhost:8080</a>.</p><h3>Advantages of This Setup</h3><ul><li><strong>Framework-Agnostic</strong>: Works with any JavaScript framework (React, Angular.js, Vue.js, etc.).</li><li><strong>Offline Capability</strong>: No internet is required to run the app.</li><li><strong>Performance</strong>: Static assets load instantly from the device.</li></ul><h3>Conclusion</h3><p>This approach demonstrates how you can run a completely offline JS framework-based app on an Android device using a local web server and WebView. In this example, I am using Ember.js but this also works for React, Angular and other JS frameworks. For more details and the full code, check out the repository: <a href="https://github.com/zfir-dev/ember-android">github.com/zfir-dev/ember-android</a>. Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f43fb9c3980b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>