<?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 Jaime Garcia Diaz on Medium]]></title>
        <description><![CDATA[Stories by Jaime Garcia Diaz on Medium]]></description>
        <link>https://medium.com/@garciadiazjaime?source=rss-3f8c81637813------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*RLdCRgF4i-y_GoQJ3dZI4Q.jpeg</url>
            <title>Stories by Jaime Garcia Diaz on Medium</title>
            <link>https://medium.com/@garciadiazjaime?source=rss-3f8c81637813------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 12:57:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@garciadiazjaime/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[Alienware Aurora ACT1250 + Ubuntu & Grub Shell]]></title>
            <link>https://medium.com/@garciadiazjaime/alienware-aurora-act1250-ubuntu-grub-shell-1b75bef4c9b9?source=rss-3f8c81637813------2</link>
            <guid isPermaLink="false">https://medium.com/p/1b75bef4c9b9</guid>
            <category><![CDATA[grub]]></category>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[alienware-aurora]]></category>
            <category><![CDATA[nvidia]]></category>
            <dc:creator><![CDATA[Jaime Garcia Diaz]]></dc:creator>
            <pubDate>Mon, 07 Sep 2026 18:01:00 GMT</pubDate>
            <atom:updated>2026-09-07T18:01:00.928Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ztzsCF2d7eYRkyzFWUMqpA.png" /></figure><p>I installed Ubuntu (26.04) on an `Alienware Aurora ACT1250` that comes with `NVIDIA® GeForce RTX 5060 Ti` and faced a couple of issues, mainly because of the graphics card. Here are the steps I followed.</p><blockquote>I’m assuming you already have an Ubuntu bootable usb ready.</blockquote><h3>1. Bios settings</h3><ul><li>Hit the `F12` key while booting till you get the BIOS page.</li><li>Modify the boot sequence so your usb is first.</li><li>It should say `Boot Mode: UEFI only`</li></ul><h4>Bios Setup &gt; Boot Configuration</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WeVb56-gUQmOjSaXG3tyNA.jpeg" /><figcaption>boot sequence</figcaption></figure><ul><li>Select AHCI/NVMe</li></ul><h4>Bios Setup &gt; Storage</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hvC8WafGpGJ0kPQVbM0x9A.jpeg" /><figcaption>boot configuration</figcaption></figure><ul><li>Apply Changes</li><li>Exit</li></ul><h3>2. Select `Ubuntu safe graphics`</h3><p>I tried “Try/Install Ubuntu” but it didn’t work, I got a black frozen page. So I had to manually restart the machine and choose “safe graphics”.</p><p><strong>Black frozen page:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*50rKQuAUfoCU5hUoFogTLg.jpeg" /><figcaption>ubuntu frozen page</figcaption></figure><p>3. Install Ubuntu.</p><p>I followed a regular installation, basically next on every single page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WcHCPK8VyOxXYTyGoqfe9Q.jpeg" /><figcaption>ubuntu installation</figcaption></figure><blockquote>The installation went fine, but when Ubuntu tried to start, the black frozen page showed up again.</blockquote><h3>4. Fix Grub</h3><ul><li>While booting, hit `Esc` till you get to the GNU GRUB shell</li></ul><blockquote>I never got the `Ubuntu boot menu`, I saw it for a second and it automatically switched to the `grub shell`. The shell renders very slowly, so be patient while typing.</blockquote><pre>ls -la /boot/<br>linux /boot/vmlinuz-7.0.0–30-generic root=/dev/nvme0n1p2 ro nomodeset<br>initrd /boot/initrd.img-7.0.0–30-generic<br>boot</pre><blockquote>Change `7.0.0–30` to your version.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j0pD6SqclrGzROevuXJcRw.jpeg" /><figcaption>fix grub</figcaption></figure><ul><li>After booting, you should be in Ubuntu, open a terminal and type:</li></ul><blockquote>Make sure the internet is on</blockquote><pre>sudo apt update<br>sudo grub-install /dev/nvme0n1<br>sudo update-grub</pre><h3>5. Install NVIDIA driver</h3><pre>ubuntu-drivers devices</pre><ul><li>Pick the one that says “recommended”, in my case:</li></ul><pre>sudo apt install nvidia-driver-592-open</pre><ul><li>It will open the `Secure Boot` Wizard.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jWEsPENS9GwH9Hxqjq1ewg.jpeg" /><figcaption>nvidia-driver-592-open</figcaption></figure><ul><li>Create a password.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/965/1*LKrzzeJ57x6RhE9uyk0gkg.jpeg" /><figcaption>nvidia-driver-592-open password</figcaption></figure><ul><li>Once the password is created, reboot the machine.</li></ul><pre>sudo reboot</pre><ul><li>After rebooting, it will show the MOK Management screen. Press any key.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I-egRZALUQVW4xZI6yybtA.jpeg" /><figcaption>MOK start page</figcaption></figure><ul><li>Enroll MOK</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OZb7l5_iFv553DrKXAMQAg.jpeg" /><figcaption>Mok enroll page</figcaption></figure><ul><li>Continue</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*pEE2GSKAgjlXvavnLgYtcw.jpeg" /><figcaption>MOK continue page</figcaption></figure><ul><li>Yes</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/446/1*5tL6Sbj9mnqO-fWVCnhZEg.jpeg" /><figcaption>MOK yes page</figcaption></figure><ul><li>Enter password</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Uvh15C9EN2Q8YGcMPvlrQ.jpeg" /><figcaption>MOK password page</figcaption></figure><ul><li>Reboot</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FBxwclLxhNHQOQ7M1eUIsw.jpeg" /><figcaption>MOK reboot page</figcaption></figure><p>6. Verify</p><p>Now Ubuntu should start just fine. Let’s double check NVIDIA is working, open a terminal and type:</p><pre>nvidia-smi</pre><p>It should display a table, you are good to go.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*yhf6k9QEJlATsT2bw7UCag.png" /><figcaption>nvidia-smi output</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1b75bef4c9b9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Text-to-Video Without CUDA: Running LTX-2 on Apple Silicon]]></title>
            <link>https://medium.com/@garciadiazjaime/text-to-video-without-cuda-running-ltx-2-on-apple-silicon-8fa61bf30eb9?source=rss-3f8c81637813------2</link>
            <guid isPermaLink="false">https://medium.com/p/8fa61bf30eb9</guid>
            <category><![CDATA[text-to-video]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[ltx]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Jaime Garcia Diaz]]></dc:creator>
            <pubDate>Mon, 31 Aug 2026 18:01:01 GMT</pubDate>
            <atom:updated>2026-08-31T20:39:48.876Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6AejC8ZCsKKnmIwYtVx0SQ.png" /></figure><p>I found out about this cool model for Text to Video that can run locally.</p><p>A lot of packages expect an NVIDIA graphics card (CUDA); the laptop I’m using (`Apple M4 Pro with 24 GB RAM`) doesn’t have one, but I was still able to make it work.</p><p>Note: At least 70GB of free space is needed.</p><h4>1. Clone `LTX-2` fork</h4><p><a href="https://github.com/garciadiazjaime/LTX-2-m4-pro">https://github.com/garciadiazjaime/LTX-2-m4-pro</a></p><h4>2. Install dependencies</h4><blockquote>If you need to install `uv` do: `brew install uv`</blockquote><pre>uv sync</pre><h4>3. Get a huggingface.co Token</h4><p>Create a `.env` file and paste the token</p><pre>HF_TOKEN=[your token]</pre><blockquote>Very important, otherwise the next step won’t work</blockquote><h4>4. Download models</h4><pre>uv run python extra/download_model.py</pre><blockquote>This might take a couple of minutes since it’s downloading two models ~70GB.</blockquote><h4>5. Generate video</h4><pre>uv run python extra/text_to_video.py</pre><p>Now update the prompt, or the image and have fun generating your own videos!</p><p>The image in the fork was generated with AI. It’s not needed; if you remove the image logic, the model will generate an avatar for you.</p><h3>Resource Consumption</h3><p>I had <a href="https://github.com/vladkens/macmon">macmon</a> running while the script generated the video.</p><ul><li>Before starting, this is the laptop idle state.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GEUohsb0bYnGhMJ5gIvJ1g.png" /><figcaption>machine state before running script</figcaption></figure><ul><li>Ramp up</li></ul><p>This is the first task that consumes significant resources on the laptop, it makes a simple, raw version of the video, not ready yet, with a lot of noise.</p><blockquote>Note: this is not the video itself, it’s data the model generates that eventually will be converted to a video</blockquote><pre>INFO:ltx_pipelines.utils.blocks:Running denoising loop (8 steps, 128x128 561 frames @ 24.0 fps)<br>100%|███████████████████████████████████████████████████████████████████████████████| 8/8 [04:25&lt;00:00, 33.15s/it]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7d7THiX-0-NujGlXwCzuJg.png" /><figcaption>first significant resource consumption</figcaption></figure><ul><li>GPU work</li></ul><p>This task is trying to polish the video till it gets the final version. It consumes more GPU simply because it now works with more pixels (128 -&gt; 256), meaning more memory, hence more GPU.</p><pre>INFO:ltx_pipelines.utils.blocks:Running denoising loop (3 steps, 256x256 561 frames @ 24.0 fps)<br>100%|███████████████████████████████████████████████████████████████████████████████| 3/3 [01:39&lt;00:00, 33.30s/it]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5xa0OTNlUpMmM4_ZCm1QAw.png" /><figcaption>more resources consumption</figcaption></figure><ul><li>GPU spike</li></ul><p>This task converts the model output into a real video. This requires less RAM and CPU, but there’s a clear GPU spike because in this case, video processing is more GPU expensive than the model work.</p><pre>Encoding video video.mp4 with 10 chunks<br>100%|█████████████████████████████████████████████████████████████████████████████| 10/10 [01:08&lt;00:00, 6.88s/it]<br>INFO:ltx_pipelines.utils.media_io.encode:Video saved to extra/output/video.mp4</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CG-9nosWm2z4Ay8Kysr79g.png" /><figcaption>gpu spike</figcaption></figure><h3>Conclusion</h3><p>While working on the script, there were times it stopped completely because of an out of memory error. Running models locally is challenging, specifically if they are video-related. Additionally, not having an NVIDIA card makes things harder because a lot of packages expect CUDA, and adapters always add extra complexity.</p><p>LTX-2 is fun, kudos to the team behind the project.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8fa61bf30eb9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Conversation between two LLMs]]></title>
            <link>https://medium.com/@garciadiazjaime/conversation-between-two-llms-ec1bc1572e00?source=rss-3f8c81637813------2</link>
            <guid isPermaLink="false">https://medium.com/p/ec1bc1572e00</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[tts]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[gemma]]></category>
            <dc:creator><![CDATA[Jaime Garcia Diaz]]></dc:creator>
            <pubDate>Mon, 20 Jul 2026 18:01:01 GMT</pubDate>
            <atom:updated>2026-07-20T18:01:01.914Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a3H_7XqRK0CaVodkKE2Rvw.png" /></figure><p>I wanted to make two LLMs talk to each other. So I built an application that generates a conversation between two “personas”.</p><h3><strong>Intro</strong></h3><p>Having two LLMs talk to each other is straightforward, and you can emulate this by generating an output on let’s say ChatGPT, copying it and pasting it in Gemini. One fun fact is that a conversation between two LLMs never ends. LLMs are programmed to always generate a response based on an input, even if the input is short or repetitive. Another fun fact is that regardless of the starting point of the conversation, most times the conversation ends with the two LLMs saying goodbye to each other, for as long as you let them.</p><h3><strong>Context</strong></h3><p>Once I had the conversation between the two LLMs, I tried finding a good use case, and I think “Word of the day” is that, so I built an app that shows a different word each day, with its definition, an example and a conversation generated by the two LLms.</p><p>The conversation can be generated by one LLM, but for educational purposes I’m using two.</p><p>Initially I tried to get a random question out of the LLMs, but the output was very poor. Also, I tried to generate the definition using the LLMs, but since LLMs are probabilistic, there’s a good chance of generating wrong definitions. Finally, because the website shows multiple languages, I tried to do the translation using the LLMs but in the end I decided not to, because of the same risks of getting wrong translations.</p><p>So, I left deterministic:</p><ul><li>Word of the Day</li><li>Definition</li><li>Translations</li></ul><p>Non-deterministic:</p><ul><li>Conversation</li></ul><p><a href="https://word.mintitmedia.com/">Word of the Day</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*7Z_nuAHhgsrYnUwU56O39A.png" /><figcaption>Word of the Day</figcaption></figure><h3><strong>Architecture</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0MtrUe8fhb913yH6BXdaAg.jpeg" /><figcaption>Architecture</figcaption></figure><h3><strong>Components</strong></h3><p><strong>Nextjs</strong></p><p>Nextjs has two main purposes:</p><ul><li>API endpoint that orchestrates the update</li></ul><pre>export async function POST(request) {<br>  const wordOfTheDay = await getWordOfTheDayFromMerriam();<br><br>  const conversation = await generateConversationWithOllama(wordOfTheDay, &quot;en&quot;);<br>  const english = {<br>    wordOfTheDay,<br>    conversation,<br>  };<br><br>  const wordOfTheDayES = await getTranslationFor(wordOfTheDay, &quot;es&quot;);<br>  const conversationES = await generateConversationWithOllama(<br>    wordOfTheDayES,<br>    &quot;es&quot;<br>  );<br><br>  const spanish = {<br>    wordOfTheDay: wordOfTheDayES,<br>    conversation: conversationES,<br>  };<br><br>  const data = {<br>    en: english,<br>    es: spanish,<br>  };<br><br>  await saveConversationNetlifyStore(data);<br><br>  await hitNetlifyWebhook();<br><br>  return Response.json({ success: true });<br>}</pre><ul><li>Build the web app</li></ul><pre>export default async function Page() {<br>  const { wordOfTheDay, conversation } =<br>    await getConversationFromNetlifyStore();<br><br>  return (<br>    &lt;main&gt;<br>      &lt;h1&gt;{wordOfTheDay.word}&lt;/h1&gt;<br>      &lt;p&gt;{wordOfTheDay.definition}&lt;/p&gt;<br><br>      &lt;div&gt;<br>        {conversation.map((text, index) =&gt; (<br>          &lt;p index={index}&gt;{text}&lt;/p&gt;<br>        ))}<br>      &lt;/div&gt;<br>    &lt;/main&gt;<br>  );<br>}</pre><p><strong>Note</strong>: There’s more code behind, but this is a good reference for how I built it.</p><ol><li><strong>Merriam Webster</strong></li></ol><p>The first thing is to get the word of the day. Luckily Merriam Webster is accessible so the site can be fetched and the needed information can be extracted using regex. Since this is done once a day, the extra load sent to this site is minimal.</p><pre>import { XMLParser } from &quot;fast-xml-parser&quot;;<br><br>export async function getWordOfTheDayFromMerriam() {<br>  const response = await fetch(<br>    &quot;https://www.merriam-webster.com/wotd/feed/rss2&quot;<br>  );<br><br>  const xmlString = await response.text();<br><br>  const parser = new XMLParser({ ignoreAttributes: false });<br>  const result = parser.parse(xmlString);<br><br>  const description = result.rss.channel.item[0].description;<br><br>  const wordMatch = description.match(/is:\s*(\w+)/i);<br>  const word = wordMatch?.[1] ?? &quot;&quot;;<br><br>  const definitionMatch = description.match(<br>    /means\s+&quot;(.+?)&quot;\s*(?:\/\/|See the entry)/is<br>  );<br>  const definition = definitionMatch?.[1] ?? &quot;&quot;;<br><br>  const exampleRegex = /\/\/\s*(.*?)(?=\s*(?:\/\/|See the entry|&gt;))/g;<br>  const examples = [...description.matchAll(exampleRegex)].map((m) =&gt;<br>    m[1].trim()<br>  );<br><br>  return {<br>    word,<br>    definition,<br>    examples,<br>  };<br>}</pre><p><strong>2. Ollama</strong></p><p>I’m running Ollama locally and I downloaded the models.</p><pre>$ ollama pull qwen2.5:3b<br><br>$ ollama pull gemma2:9b<br><br>$ ollama list<br>NAME          ID              SIZE      MODIFIED<br>qwen2.5:3b    357c53fb659c    1.9 GB    8 weeks ago<br>gemma2:9b     ff02c3702f32    5.4 GB    8 weeks ago</pre><p>No specific reason for why I picked these two models, other than I wanted to run the LLMs locally, so I picked two that were OK for the task (generating a conversation) considering the hardware on my machine. Worth mentioning that running better LLMs requires more resources, so the days when it runs on my machine but not on the server are gone. It’s now very expensive to have the hardware to run the latest LLMs.</p><pre>import { Ollama } from &quot;ollama&quot;;<br><br>let historyA = [];<br>let historyB = [];<br><br>const ollama = new Ollama({ host: process.env.OLLAMA_API_URL });<br><br>export async function generateConversationWithOllama(wordOfTheDay, lang) {<br>  const systemPrompt = `<br>  You are a 20-year-old student. You&#39;re friendly and easy to talk to. You talk the way you&#39;d text a friend — casual, warm, to the point.<br><br>  Chat in ${lang} only. This is a short conversation so keep it natural but don&#39;t drag it out.<br><br>  Keep each reply to 1–2 short sentences. React naturally and sometimes ask something back.<br><br>  Today&#39;s word: &quot;${wordOfTheDay.word}&quot;<br>  What it means: &quot;${wordOfTheDay.definition}&quot;<br><br>  Strict formatting rules:<br>  - Plain text only. No emojis, no emoticons, no symbols like :) or ^^.<br>  - No tags, labels, role markers, or special tokens of any kind.<br>  - Output nothing except the message itself.`;<br><br>  const response = await ollama.chat({<br>    model: &quot;gemma2:9b&quot;,<br>    messages: [{ role: &quot;system&quot;, content: systemPrompt }],<br>    stream: false,<br>    options: { temperature: 0.4, num_predict: 80 },<br>  });<br><br>  const responseA = response.message.content;<br><br>  historyA.push({ role: &quot;assistant&quot;, content: responseA });<br>  historyB.push({ role: &quot;user&quot;, content: responseA });<br><br>  return responseA.trim();<br>}</pre><p>3. Translation</p><p>Initially I wanted the LLM to generate the translations, but the LLMs I’m using are not the best at it, and I wanted to run the LLMs locally. So, for this part I’m using `<a href="http://twitter.com/google">@google</a>-cloud/translate` which by default doesn’t use LLMs.</p><pre>import { Translate } from &quot;@google-cloud/translate/build/src/v2/index.js&quot;;<br><br>const translate = new Translate({<br>  key: process.env.GOOGLE_TRANSLATION_KEY,<br>});<br><br>export async function getTranslationFor(wordOfTheDay, targetLanguage) {<br>  const [translations] = await translate.translate(<br>    wordOfTheDay.word,<br>    targetLanguage<br>  );<br><br>  return translations;<br>}</pre><p><strong>4. Text to Speech</strong></p><p>Once the text is generated and translated, the next thing is to get audio so that the conversation can be listened to. For this part I’m using Python, because the community around machine learning is bigger, and while there are packages that run on Node.js, I would need extra steps (adapter, bridge) to make it work, so it’s better to use Python. I also wanted to run it locally, so I set up an api endpoint that receives a string and returns audio.</p><p>For TTS I’m using <a href="https://huggingface.co/coqui/XTTS-v2">coqui/XTTS-v2</a> which is a cool model that produces pretty decent audio, it supports multiple languages and has multiple voices.</p><pre>import os, io<br>from fastapi import FastAPI, HTTPException<br>from fastapi.responses import StreamingResponse<br><br>from TTS.api import TTS<br><br>tts = TTS(&quot;tts_models/multilingual/multi-dataset/xtts_v2&quot;, gpu=False)<br><br>app = FastAPI(title=&quot;Local XTTS v2 Voice Server&quot;)<br><br>@app.post(&quot;/v1/tts&quot;)<br>async def generate_tts(request: TTSRequest):<br>    text = request.text<br>    language = request.lang<br>    temp_filename = &quot;output/api_output.wav&quot;<br><br>    try:<br>        # Synthesize audio file locally<br>        tts.tts_to_file(<br>            text=text,<br>            file_path=temp_filename,<br>            language=language,<br>            speaker=&quot;Damien Black&quot;<br>        )<br><br>        # Read the file data into an in-memory byte buffer<br>        with open(temp_filename, &quot;rb&quot;) as f:<br>            audio_buffer = io.BytesIO(f.read())<br><br>        # Clean up the file off your Mac&#39;s disk storage immediately<br>        if os.path.exists(temp_filename):<br>            os.remove(temp_filename)<br><br>        # Rewind buffer pointer and stream the raw binary stream data back to the client<br>        audio_buffer.seek(0)<br><br>        return StreamingResponse(audio_buffer, media_type=&quot;audio/wav&quot;)<br><br>    except Exception as e:<br>        raise HTTPException(status_code=500, detail=str(e))</pre><p><strong>5. Update Cache</strong></p><p>Netlify provides `<a href="http://twitter.com/netlify/blobs">@netlify/blobs</a>` which is their own object storage system. Once the “payload” (texts plus audios) is ready, it’s saved into Netlify. This way it will be available for the next step.</p><pre>import { getStore } from &quot;@netlify/blobs&quot;;<br><br>const store = getStore(&quot;my-store&quot;, {<br>  siteID: process.env.MY_SITE_ID,<br>  token: process.env.MY_SITE_TOKEN,<br>});<br><br>export async function saveConversationNetlifyStore(value) {<br>  await store.setJSON(&quot;data&quot;, value);<br>}</pre><p><strong>6. Deploy site</strong></p><p>Netlify offers a hook that, when hit, triggers a new deploy. As part of the deploy, Netlify runs `npm run build`, in this case Nextjs generates a new version of the site and updates the CDN with these new files. As part of the build, the blob values previously saved are used, and this is how the new HTML gets the latest content.</p><pre>async function hitNetlifyWebhook() {<br>  await fetch(`https://api.netlify.com/build_hooks/${process.env.MY_HOOK_ID}`, {<br>    method: &quot;POST&quot;,<br>    body: JSON.stringify({}),<br>  });<br>}</pre><h3>Conclusion</h3><p>Running LLMs locally is limited by the resources of your machine, and it’s interesting because the race for better hardware started a while ago, but now there’s also a race for better LLMs and big LLMs are being produced. Some companies are working on efficiency, and are generating smaller LLMs while keeping the same quality. The future is uncertain, and there are hardware limitations, even for data centers. Data centers already consume a significant percentage of electricity and water, so at what point is it enough?</p><p>This was a good exercise to get familiar with how to run models locally while understanding its limitations. However, it’s hard to compete against the big companies, so in production, because of the importance of accuracy, I would most likely end up using their services.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ec1bc1572e00" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Running Language Models Directly in the Browser]]></title>
            <link>https://medium.com/@garciadiazjaime/running-language-models-directly-in-the-browser-0e869bea8933?source=rss-3f8c81637813------2</link>
            <guid isPermaLink="false">https://medium.com/p/0e869bea8933</guid>
            <category><![CDATA[small-language-model]]></category>
            <category><![CDATA[wasm]]></category>
            <category><![CDATA[gpu]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Jaime Garcia Diaz]]></dc:creator>
            <pubDate>Mon, 08 Jun 2026 18:01:01 GMT</pubDate>
            <atom:updated>2026-06-08T18:01:01.783Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7IpPuo5Let6_wq_TBt-pMg.png" /></figure><h3>TLDR</h3><p>LLMs are everywhere, but every time they are used, we are giving our data away for free. There are projects like `SmolLM2` working on Small Language Models that can run completely in the browser, leveraging the GPU when possible and falling back to CPU (WASM) when needed. While the work behind `SmolLM2` is great, the output is not as effective as the one generated by well-known LLMs.</p><h3>Intro</h3><p>LLMs are huge and they need a lot of resources: storage, CPU, GPU, and RAM. Private providers don’t publish information, but here’s a rough comparison:</p><ul><li><strong>Llama 3.1 405B: </strong>405B parameters, ~243 GB on disk, ~203 GB GPU VRAM, ~1.5 TB RAM</li><li><strong>Claude Sonnet 4.6: </strong>~175B parameters*, ~175 GB on disk*, ~350 GB GPU VRAM*, ~700 GB RAM*</li><li><strong>GPT-4: </strong>~1.8T parameters*, ~900 GB on disk*, ~3.6 TB GPU VRAM*, ~5 TB RAM*</li></ul><p><strong><em>*</em></strong><em> Estimated values — private providers don’t publish this information.</em></p><p>Browsers have limited access to resources; the following table shows some rough estimates:</p><ul><li><strong>Chrome: </strong>1–4 GB RAM, WebGPU supported ✓</li><li><strong>Firefox: </strong>0.5–2 GB RAM, WebGPU limited</li><li><strong>Safari: </strong>0.3–1 GB RAM, WebGPU on iOS 17+</li></ul><p>Clearly, we can see it becomes almost impossible to run known LLMs in the browser. That’s why these LLMs are usually accessed through an SDK, RESTful API, or their GUI, with all the computing happening in the cloud.</p><p>LLMs running on a server come with an immense infrastructure cost. There are also privacy concerns, and as a user our only option is to trust that the providers will use our data responsibly.</p><p>That’s why I wanted to play with alternatives that can run completely in the browser.</p><h3>SmolLM2</h3><p>Based on this <a href="https://arxiv.org/pdf/2502.02737">paper</a>, the model was trained on different categories — to mention some: Knowledge/Reasoning, Math, Code, and Generative Tasks.</p><p>That said, I built a simple <a href="https://client-model.mintitmedia.com/">web app</a> that uses SmolLM2 to generate text.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*2spZJCNeRaH5i9Lf98Ok1Q.png" /><figcaption>SmolLM2 demo web app</figcaption></figure><h4>SmolLM2–135M-Instruct</h4><p>This model size is ~140MB, and it needs to be downloaded and then compiled; the compilation takes more computing resources, working fine on desktop but not on mobile.</p><p>Additionally, Safari doesn’t support `webgpu` by default — it’s still experimental. It can be enabled (Safari → Settings → Feature Flags → WebGPU) but it’s disabled for “security” reasons, meaning Apple still doesn’t trust GPU instructions coming from the browser. Hence the need for `wasm`, which is an older technology, enabled by default, and works exclusively with the CPU.</p><pre>import { pipeline } from &quot;@huggingface/transformers&quot;;<br><br>const device = &quot;gpu&quot; in navigator ? &quot;webgpu&quot; : &quot;wasm&quot;;<br><br>const model = await pipeline(<br>  &quot;text-generation&quot;,<br>  &quot;HuggingFaceTB/SmolLM2-135M-Instruct&quot;,<br>  {<br>    device,<br>    dtype: &quot;q4f16&quot;,<br>  }<br>);<br><br>const messages = [<br>  { role: &quot;system&quot;, content: &quot;you are a English teacher.&quot; },<br>  { role: &quot;user&quot;, content: &quot;list 10 important topics&quot; },<br>];<br><br>const output = await model(messages, { max_new_tokens: 128 });<br>console.log(output);<br><br>// Generated topics:<br>//  1. History<br>// 2. Science<br>// 3. Literature<br>// 4. Art<br>// 5. Business<br>// 6. Sports<br>// 7. Politics<br>// 8. Social Issues<br>// 9. Technology<br>// 10. Essay</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*IdxrQHjvetXvyn05vbHyCw.png" /><figcaption>SmolLM2–135M-Instruct storage size</figcaption></figure><h4>SmolLM2–360M-Instruct-q4f16_1-MLC</h4><p>This model works on mobile. The main difference is that this model is already compiled, hence the <strong>MLC</strong> (Machine Learning Compilation) affix. Even though the model size is bigger (~200MB), it works because it requires less computing work (no compilation phase). Additionally, the mobile browser caps the buffer size to 128MB (a shorter max context window).</p><pre>const model = await CreateMLCEngine(&quot;SmolLM2-360M-Instruct-q4f16_1-MLC&quot;);<br><br>const messages = [<br>  {<br>    role: &quot;system&quot;,<br>    content:<br>      &quot;You are a helpful assistant. You respond ONLY with a numbered list. No introduction, no explanation, no extra text. Just the list.&quot;,<br>  },<br>  {<br>    role: &quot;user&quot;,<br>    content: &quot;list 10 important topics&quot;,<br>  },<br>];<br><br>const output = await modelSmall.chat.completions.create({ messages });<br>console.log(output);<br>// 1. Acid-base mechanism<br>// 2. Glucarotides<br>// 3. Proteases<br>// 4. Oligopeptidases<br>// 5. Enzymes involved in lipolysis<br>// 6. Alcoholic acids<br>// 7. Fuel cell and biodiesel production<br>// 8. Hydrogen peroxide degradation pathways building block of ethanol<br>// 9. Bacteria and their role as biofuel digesters<br>// 10. Directed evolution of biofuel production and pathways that mimic photosynthetic pathways of familiar autotrophs.</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*_lui6BF__myEHHcaxGqKpA.png" /><figcaption>SmolLM2–360M-Instruct-q4f16_1-MLC storage size</figcaption></figure><h3>Conclusion</h3><p>GPU is faster than CPU. One reason is that the GPU spins out a lot of workers to distribute the load and do the math simultaneously. LLMs rely heavily on math operations, and GPUs process more tokens per second.</p><p>It was interesting learning about MLC. Models that are already compiled save computing resources; however, there are fewer pre-compiled models and they are harder to use for generating custom or fine-tuned models. Finally, they are bigger in size, which makes sense because the compiled version includes more things like weights, layout, configurations, etc.</p><p>`SmolLM2–135M-Instruct` and `SmolLM2–360M-Instruct-q4f16_1-MLC` are <strong>language models</strong> from the same family; however, `SmolLM2–135M-Instruct` performs better even though it’s smaller in size, confirming the general rule:</p><blockquote>A smaller well-quantized, well-tuned model often beats a larger poorly-quantized one</blockquote><p>Finally, both models are too large for the web (&gt;100MB), and at this point, while it’s impressive to have language models running completely in the browser without any backend service, the reality is that the outputs are very poor compared to those of the well-known LLMs. Nonetheless, it’s great to have access to these models, and kudos to the team behind them. I’m sure <strong>Small Language Models</strong> will become more effective.</p><h3>Extra</h3><p>While working on the demo app I found two errors and one warning:</p><ul><li>This happens on iPhone when trying to use `SmolLM2–135M-Instruct` with `gpu`:</li></ul><pre>webgpu:<br>Unhandled Promise Rejection: Error: no available backend found. ERR: [webgpu] TypeError: gg().webgpuInit is not a function. (In &#39;gg().webgpuInit(g=&gt;{A.webgpu.device=g})&#39;, &#39;gg().webgpuInit&#39; is undefined)</pre><ul><li>This happens on iPhone when trying to use `SmolLM2–135M-Instruct` with `wasm`:</li></ul><pre>wasm:<br>Unhandled Promise Rejection: Error: no available backend found. ERR: [wasm] RangeError: Out of memory</pre><ul><li>This is a warning that iPhone shows when loading `SmolLM2–360M-Instruct-q4f16_1-MLC`:</li></ul><pre>Requested maxStorageBufferBindingSize exceeds limit.<br>requested=1024MB,<br>limit=683MB.<br>WARNING: Falling back to 128MB</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0e869bea8933" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Javascript help me with my accent]]></title>
            <link>https://medium.com/@garciadiazjaime/javascript-help-me-with-my-accent-4801d4dd1d0f?source=rss-3f8c81637813------2</link>
            <guid isPermaLink="false">https://medium.com/p/4801d4dd1d0f</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[speech-recognition]]></category>
            <category><![CDATA[whisper]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[text-to-speech]]></category>
            <dc:creator><![CDATA[Jaime Garcia Diaz]]></dc:creator>
            <pubDate>Mon, 11 May 2026 18:01:00 GMT</pubDate>
            <atom:updated>2026-05-11T18:01:00.765Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lDUrawC55uMU5pBcnIpK_g.png" /></figure><p>I built the site <a href="https://mati.mintitmedia.com/">Mati</a> which shows one sentence a day; the goal is to repeat the sentence and get feedback.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3mo2Nro4exSMU5lp2i1vhw.png" /><figcaption>Mati website</figcaption></figure><h3><strong>TLDR</strong></h3><p>Cloud Text-to-Speech offers natural voices, way better than the boring robotic voices browsers have by default. Google offers a free tier which is enough for experimenting with the service.</p><p>Speech-to-Text while not new, now most browsers add an LLM layer which tries to understand what was said, making for better transcripts. However, if you are looking for feedback on your pronunciation, you can use a <strong>speech model</strong> (`wav2vec2` or `whisper`) only for the transcription part, without the guessing layer.</p><h3><strong>Back End</strong></h3><p>There’s a daily cron that runs two functions to generate a sentence and get its corresponding audio. Then the site is deployed using the new sentence.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nU02dfFLALCoecJsSn8tCA.jpeg" /><figcaption>Backend Architecture Components</figcaption></figure><p><strong>Sentence Generation</strong></p><p>I’m using the LLM `gemma-4–31b-it` to generate a random text every day:</p><pre>import { GoogleGenAI } from &quot;@google/genai&quot;;<br><br>const ai = new GoogleGenAI({ apiKey: GEMINI_API_KEY });<br><br>async function generateSentence() {<br>  const SYSTEM_PROMPT_TEACHER = `You are a helpful and precise assistant for language learning.<br>  You create one everyday sentence and aligned translations in American English.`;<br><br>  const USER_PROMPT = `Generate one sentence for today&#39;s speaking practice.<br>    Respond with ONLY this JSON object and nothing else:<br>    {&quot;en&quot;:&quot;...&quot;}<br><br>    Do not explain. Do not reason. Do not check your work. Just output the JSON.<br><br>    Rules:<br>    - en: American English.<br>    - Natural, spoken everyday language — not textbook phrasing.<br>    - Interesting and pleasant to say out loud — varied sounds, natural rhythm.<br>    - 10 to 14 words in the English version.<br>    - No extra keys. No markdown.`;<br><br>  const payload = {<br>    model: &quot;gemma-4-31b-it&quot;,<br>    contents: [<br>      { role: &quot;user&quot;, parts: [{ text: SYSTEM_PROMPT_TEACHER }] },<br>      { role: &quot;model&quot;, parts: [{ text: &quot;Understood.&quot; }] },<br>      { role: &quot;user&quot;, parts: [{ text: USER_PROMPT }] },<br>    ],<br>  };<br><br>  const response = await ai.models.generateContent(payload);<br><br>  const text = response.candidates?.[0].content?.parts?.slice(-1)[0]?.text;<br><br>  return text;<br>}</pre><h4><strong>Audio Generation</strong></h4><p>Then the sentence is converted into <strong>**audio base64**</strong>:</p><pre>const apiKey = process.env.GOOGLE_CLOUD_TTS_API_KEY;<br><br>async function synthesizeGoogleTTS(text) {<br>  const response = await fetch(<br>    `https://texttospeech.googleapis.com/v1beta1/text:synthesize?key=${apiKey}`,<br>    {<br>      method: &quot;POST&quot;,<br>      headers: {<br>        &quot;Content-Type&quot;: &quot;application/json&quot;,<br>      },<br>      body: JSON.stringify({<br>        input: {<br>          ssml: buildSSML(text),<br>        },<br>        voice: {<br>          languageCode: &quot;en-US&quot;,<br>          name: &quot;en-US-Neural2-F&quot;,<br>        },<br>        audioConfig: {<br>          audioEncoding: &quot;MP3&quot;,<br>        },<br>        enableTimePointing: [&quot;SSML_MARK&quot;],<br>      }),<br>    }<br>  );<br><br>  const payload = await response.json();<br><br>  return {<br>    audioBase64: payload.audioContent,<br>  };<br>}</pre><blockquote>Browsers offer Text-To-Speech by default, but each browser has different voices. By using this Google service, the voice sounds more natural (higher quality) and is the same across all browsers.</blockquote><h3><strong>Front End</strong></h3><p>When the user loads the page, the HTML is served from a CDN and the client downloads the audio base64, so when the user clicks “listen”, the audio provided by the Google Text-to-Speech service is played. The audio sounds like a natural voice.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z2kK7N8T2LBqG0pu3DuYhw.jpeg" /><figcaption>Frontend Architecture Components</figcaption></figure><h4><strong>Transcript</strong></h4><p>The user clicks “record” and here either the user is on Mobile Safari or not.</p><ul><li>SpeechRecognition (Mobile Safari)</li></ul><p>If the user is on Mobile Safari (apologies to other mobile users, since I didn’t test on other mobile browsers), the native API `webkitSpeechRecognition` is used, which does Speech-to-Text.</p><blockquote>At the time of writing, mobile browsers didn’t support large files (i.e., Transformers) and WebAssembly as well as desktop browsers, so trying to run `Whisper` on a mobile browser threw some errors.</blockquote><pre>async function start(onSuccess) {<br>  const recognition = new speechWindow.webkitSpeechRecognition();<br><br>  recognition.onresult = (event) =&gt; {<br>    const transcript = Array.from(<br>      { length: event.results.length },<br>      (_, i) =&gt; event.results[i][0].transcript<br>    ).join(&quot; &quot;);<br><br>    onSuccess(transcript);<br>  };<br><br>  recognition.start();<br>}</pre><ul><li>Whisper</li></ul><p>If the user is not on Mobile Safari then `Whisper` is used, specifically a light version which <strong>provides a rawer transcript useful for pronunciation feedback</strong>.</p><pre>// worker<br>async function transcribe(audio) {<br>  const automaticSpeechRecognition = pipeline(<br>    &quot;automatic-speech-recognition&quot;,<br>    &quot;Xenova/whisper-tiny&quot;,<br>    {<br>      dtype: {<br>        encoder_model: &quot;q4&quot;,<br>        decoder_model_merged: &quot;q4&quot;,<br>      },<br>    }<br>  );<br><br>  const output = await automaticSpeechRecognition(audio, {<br>    task: &quot;transcribe&quot;,<br>    language: &quot;english&quot;,<br>    return_timestamps: false,<br>    temperature: 0,<br>    no_repeat_ngram_size: 3,<br>    repetition_penalty: 1.15,<br>    condition_on_prev_tokens: false,<br>    max_new_tokens: 96,<br>  });<br><br>  const transcript = output.text;<br><br>  post({ type: &quot;result&quot;, transcript });<br>}<br><br>// client<br>async function start(onSuccess) {<br>  const mediaStream = await navigator.mediaDevices.getUserMedia();<br>  const mediaRecorder = new MediaRecorder(mediaStream);<br>  const recordedChunks = [];<br><br>  mediaRecorder.ondataavailable = (event) =&gt; {<br>    recordedChunks.push(event.data);<br>  };<br><br>  mediaRecorder.onstop = async () =&gt; {<br>    const blob = new Blob(recordedChunks, { type: recordedChunks[0].type });<br>    const audio = await blobToMonoPcm(blob, 16_000);<br>    const activeWorker = getWorker();<br>    const transferableAudio = new Float32Array(audio);<br><br>    const transcript = await new Promise((resolve, reject) =&gt; {<br>      const onMessage = (event) =&gt; {<br>        if (event.data.type === &quot;result&quot;) {<br>          resolve(event.data.transcript);<br>          return;<br>        }<br>      };<br><br>      activeWorker.addEventListener(&quot;message&quot;, onMessage);<br>      activeWorker.postMessage(<br>        {<br>          type: &quot;transcribe&quot;,<br>          audio: transferableAudio,<br>        },<br>        [transferableAudio.buffer]<br>      );<br>    });<br><br>    onSuccess(transcript);<br>  };<br><br>  mediaRecorder.start();<br>}</pre><p>The final solution is a bit more complicated, but that’s the gist. In Mobile Safari, the implementation is simpler because the heavy lifting is done by `webkitSpeechRecognition`, which has a neat `onresult` API that returns the transcript. The caveat here is that Safari will try to “guess” the transcript.</p><p>For all other users, `Whisper` is used. Notice that the task is split between traditional client code and a web worker. The client code captures the audio and passes it to the web worker, which converts the audio to text using a <strong>Small Language Model</strong>; this is a key part to avoid the guessing layer.</p><h4><strong>Feedback</strong></h4><p>Once the transcript is generated, it is compared against the original phrase using the following metrics:</p><ul><li><strong>Levenshtein distance</strong>: edit distance (e.g., apple -&gt; aple)</li><li><strong>Jaro-Winkler</strong>: similarity score (e.g., Martha -&gt; Sartha)</li><li><strong>Metaphone</strong>: reduces a word down to a short code (e.g., Stephen -&gt; STFN)</li></ul><p>Each metric provides a score which the app uses to determine whether the user pronounced one of the words in the phrase, using different thresholds.</p><pre>// Attempt 1 — strict<br>{<br>  &quot;levenshteinThreshold&quot;: 0.72,<br>  &quot;jaroWinklerThreshold&quot;: 0.88<br>}</pre><pre>function getScores(referenceWord, attemptWord) {<br>  const levenshteinScore = getLevenshteinSimilarity(referenceWord, attemptWord);<br>  const jaroWinklerScore = jaroWinkler(referenceWord, attemptWord);<br>  const metaphoneScore = Metaphone.compare(referenceWord, attemptWord);<br><br>  return {<br>    levenshteinScore,<br>    jaroWinklerScore,<br>    metaphoneScore,<br>  };<br>}</pre><h3><strong>Conclusion</strong></h3><p>At some point, I tried comparing audio waves, but there are many variables that make it hard: noise, pace, rhythm, etc. I also wanted all the processing in the browser, which is especially hard for mobile in terms of computing resources (RAM, CPU, GPU). Finally, I pivoted to transcripts and the metrics mentioned.</p><p>Native APIs lose a lot of pronunciation feedback during transcript processing. Maybe browsers will enable a flag to provide raw transcripts; I doubt it. On the other hand, <strong>I’m sure mobile browsers will eventually have more resources to run LLMs on the client which could provide audio feedback</strong>.</p><p>Raw transcripts are definitely good for feedback, but they are a 0–1 metric: you either say it or not. Even with an accent, you can pass. But in terms of accent reduction, better feedback is needed, like identifying which parts of the word need more work, which letter wasn’t pronounced, or what movement the mouth and tongue need to make in order to produce a natural sound. While this is a good start and I’m glad Javascript is helping me once again, there is still more that can be done. More to come in the future for sure.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4801d4dd1d0f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NER: Gemini vs Spacy vs Compromise]]></title>
            <link>https://medium.com/@garciadiazjaime/ner-gemini-vs-spacy-vs-compromise-5035d696ab92?source=rss-3f8c81637813------2</link>
            <guid isPermaLink="false">https://medium.com/p/5035d696ab92</guid>
            <category><![CDATA[spacy]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[gemini]]></category>
            <category><![CDATA[named-entity-recognition]]></category>
            <dc:creator><![CDATA[Jaime Garcia Diaz]]></dc:creator>
            <pubDate>Mon, 16 Mar 2026 18:01:00 GMT</pubDate>
            <atom:updated>2026-03-16T18:01:00.837Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WLqC4Jp1-R-5CGpP6pdFxA.png" /></figure><h3>TLDR</h3><p>For <strong>NER</strong>, if accuracy is critical, go with an LLM — even an old one like <a href="https://huggingface.co/google/gemma-3-27b-it">gemma-3–27b-it</a> will outperform tools or small models trained for this task. But by using an LLM you are exposing your data, making an HTTP request, and most likely incurring a cost. If accuracy is not critical and you want to stay in Javascript, <a href="https://www.npmjs.com/package/compromise">compromise</a> is a good package for NER. If you want an even better package and it’s OK not using Javascript, then try <a href="https://spacy.io/">Spacy</a>.</p><h3>Intro</h3><p>Thanks to AI it feels like we are entering into Web 4 — now it’s not just about having a static website (Web 1), or letting the user save their data (Web 2), or decentralization (Web 3, although the majority of companies still own our data); but about adding “AI” to your application. What does that mean? Are all applications supposed to be like ChatGPT?</p><p>While I don’t think adding an LLM just for the sake of it is beneficial, I do think that playing with LLMs helps to learn about them, giving us an understanding of how, when, and why to use them.</p><p>I maintain the website <a href="https://www.chicagomusiccompass.com/">chicagomusiccompass</a>, which shows music events in Chicago. All events have a title, so I want to extract artist names from the title. This sounds like a good task for an LLM, right?</p><p>I found out about <strong>Named Entity Recognition</strong> (NER), which is a technique to extract entities from a string. So I’ll try three different NER tools and compare their results.</p><h3>Gemini</h3><p>As a developer, Gemini has become my first option mainly because they offer almost-free LLM tiers. They might not be the newest, but they’re a great starting point. As a developer could go with OpenAI or Anthropic, but they don’t offer free tiers. Ollama is a truly free alternative, but this time I’ll stay with Gemini.</p><p>NER with Gemini is about the prompt:</p><pre>from google import genai<br><br>client = genai.Client(api_key=&quot;your_api_key&quot;)<br>title = &quot;Amber Mark Presents: The Pretty Idea Tour&quot;<br><br>PROMPT_TEMPLATE = &quot;&quot;&quot;Extract the person&#39;s name from this event title.<br>Return ONLY the name, nothing else. If no person found, return empty string.<br><br>Examples:<br>&quot;Saxophonist Jarrard Harris Quintet&quot; → &quot;Jarrard Harris&quot;<br>&quot;Jazz Night at the Blue Room&quot; → &quot;&quot;<br>&quot;DJ Khaled Live Concert&quot; → &quot;DJ Khaled&quot;<br>&quot;Annual Wine Festival&quot; → &quot;&quot;<br><br>Title: &quot;{title}&quot;<br>→&quot;&quot;&quot;<br><br>artist = client.models.generate_content(<br>    model=&quot;models/gemma-3-27b-it&quot;,<br>    contents=PROMPT_TEMPLATE.format(title=title)<br>)<br>artist = artist.text.strip().strip(&#39;&quot;&#39;)<br><br>print(artist)</pre><p>Output:</p><pre>Amber Mark</pre><p>I’m using the model <strong>gemma-3–27b-it</strong> (Google hosts Gemma models on the Gemini API platform), which was released in early 2025. There are newer models, but this one offers a decent number of free requests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Da6BCn9jOn7sjewIzpppww.png" /><figcaption>Gemini Models Free Tiers</figcaption></figure><p>Notice that here I’m using an LLM to perform NER through the prompt. An LLM is trained for multiple purposes, and NER is one thing that LLMs are good at.</p><h3>Spacy</h3><p>Spacy is a Natural Language Processing (NLP) library, and one of the things it’s trained for is NER. It’s also free and open-source — kudos to the team behind it. Gemini is proprietary and accessed through an API with rate limiting and commercial terms; at some point, if you start using it heavily, you will need to pay. Not so with Spacy, which offers a Python package you can install in your project and use freely.</p><pre>import spacy<br>nlp = spacy.load(&quot;en_core_web_sm&quot;) # language model<br>title = &quot;Amber Mark Presents: The Pretty Idea Tour&quot;<br>doc = nlp(title)<br>ent = next(filter(lambda ent: ent.label_ == &quot;PERSON&quot;, doc.ents), None)<br>artist = ent.text<br><br>print(artist)</pre><p>Output:</p><pre>Mark Presents</pre><p>Note: `next(filter(lambda ent: ent.label_ == “PERSON”, doc.ents), None)` is the Python way to get the first entry where `label_` is `”PERSON”`.</p><p>As you can see, the output is similar to Gemini’s — but is it good? That depends on your project. The upside is that processing happens locally, with no HTTP requests, meaning your data is not exposed and there’s no extra cost.</p><h3>compromise</h3><p>I tried three npm packages (compromise, <a href="http://twitter.com/nlpjs/ner">@nlpjs/ner</a>, and node-nlp) and out of the three I found that `compromise` provides results similar to Spacy. The Python community is larger in terms of data science packages; however, for a Javascript architecture (a website), it makes sense to go with an npm package.</p><pre>const compromise = require(&quot;compromise&quot;);<br><br>const title = &quot;Amber Mark Presents: The Pretty Idea Tour&quot;;<br>const doc = compromise(title);<br>const people = doc.people().out(&quot;array&quot;);<br>const artist = people &amp;&amp; people.length &gt; 0 ? people[0] : &quot;&quot;;<br><br>console.log(artist);</pre><p>Output:</p><pre>Amber Mark Presents:</pre><p>As you can see, the output includes “:”. This is because compromise doesn’t actually understand the text — it just runs a set of rules and uses weights to decide what counts as a person. Since “Presents” can be a last name, it gets included as part of the person’s name, and the colon comes along for the ride.</p><h3>Conclusion</h3><p>I ran the snippets against a list of 1,000 records. Gemini was able to extract a name 66% of the time, Spacy 36%, and compromise 45%. Gemini, even with an old model, not only covered more records but also provided cleaner results. Spacy and compromise provided similar results, and even though Spacy covered fewer records, in some cases the output was cleaner — for instance, `Mark Presents` vs. `Amber Mark Presents:`. In both cases it’s actually wrong, compared to Gemini’s output of `Amber Mark`.</p><p>The older LLM (`gemma-3–27b-it`) outperformed the smaller models (`Spacy` and `compromise`) even though they were trained specifically for this task.</p><p>For my purposes, `compromise` is more than enough. I like staying in Javascript and NER extraction accuracy is not critical for me. If accuracy were a factor, I would go with an LLM.</p><p>Finally, all I did was use NER to adjust the styling on the title:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/299/1*ss9Xux5OuoVHehimKmLUxA.png" /><figcaption>NER drives title styles</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5035d696ab92" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Moving from Nextjs to Qwik]]></title>
            <link>https://medium.com/@garciadiazjaime/moving-from-nextjs-to-qwik-a20f5d0a15b4?source=rss-3f8c81637813------2</link>
            <guid isPermaLink="false">https://medium.com/p/a20f5d0a15b4</guid>
            <category><![CDATA[javascript-frameworks]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[qwik]]></category>
            <category><![CDATA[lighthouse]]></category>
            <dc:creator><![CDATA[Jaime Garcia Diaz]]></dc:creator>
            <pubDate>Mon, 12 Jan 2026 19:03:17 GMT</pubDate>
            <atom:updated>2026-01-12T19:03:17.643Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RsZxB3fTxlOILbQOXTyhEw.png" /></figure><p>Whenever I’m working on a web application, Next.js is my go-to framework. I like it and I’m used to it, but I’ve been hearing a lot about Qwik and decided to give it a shot.</p><p>In my previous post, <a href="https://medium.com/@garciadiazjaime/one-artwork-seven-questions-exploring-the-art-institute-api-and-gemini-dddf411f48f3">Exploring the Art Institute API and Gemini</a>, I built the app using Next.js. Since it’s a new project, I thought it would be good exercise to redo it using Qwik instead.</p><p>You can still access the previous version, and to make it a bit more interesting, I’m using Lighthouse to compare the two versions:</p><ul><li><a href="https://artic.mintitmedia.com/">With Qwik</a></li><li><a href="https://artic-old.mintitmedia.com/">With Next.js</a></li></ul><blockquote>Both codebases render a static site, which is generated daily using a cron job and a deploy hook.</blockquote><h3>Network</h3><p>Let’s start by looking at the Network tab:</p><blockquote>Left is Next.js and right is Qwik</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lZ2EBgRoC6X3EI4JtMCMQQ.png" /><figcaption>Network tab</figcaption></figure><p>This is very interesting because, in summary, Qwik sends fewer bytes to the browser, and fewer bytes translate into faster rendering as well, even though both apps show basically the same UI.</p><p><strong>Transferred</strong>: 285 kB (Next.js) vs 118 kB (Qwik)<br><strong>Resources</strong>: 649 kB (Next.js) vs 172 kB (Qwik)<br><strong>DomContentLoaded</strong>: 92 ms (Next.js) vs 96 ms (Qwik)<br><strong>Load</strong>: 368 ms (Next.js) vs 124 ms (Qwik)</p><ul><li><strong>kB transferred</strong> is the data sent from the server (CDN) to the browser, which is</li><li><strong>kB resources</strong> is the total size once unzipped.</li></ul><p>As we can see, the Qwik project sends less data. <strong>This is a big win for Qwik.</strong></p><ul><li><strong>DomContentLoaded</strong> is the event fired when the HTML is parsed and the DOM is built. At this point, JavaScript is executed and images and stylesheets start loading.</li><li><strong>Load</strong> is the event fired when everything is ready. The browser doesn’t need to download anything else (images, styles, etc.), and the page is fully rendered.</li></ul><p>Notice that while <strong>DomContentLoaded</strong> happens at almost the same time, <strong>Load</strong> happens much faster for Qwik. This is just how the framework works. In the case of Next.js, since the app is larger, it takes a bit longer to completely render the page.</p><blockquote>Note: I checked the “Disable cache” checkbox to always download files from the origin (CDN).</blockquote><p>Also keep in mind that these values change on every load. Things like browser cache, internet connectivity, and server response times are different every time. That’s why, when testing these values, a load test is a better approach. Loading the page N times gives you a better average. A single run can be influenced by chance. Still, these numbers are a great benchmark for any website.</p><h3>Lighthouse</h3><h4>Performance</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*15AfnNyOctK3lajTqvcClQ.png" /><figcaption>Lighthouse performance results</figcaption></figure><p>Right from the start, Qwik gets a perfect score of 100 across the board, while Next.js gets a slightly lower score. This is interesting because it’s not about the application code, but about the framework itself.</p><p>Sure, a Next.js application can also reach 100, but that usually requires extra work, which isn’t necessary when using Qwik.</p><h4>Metrics</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mWchrLqUotvN-VTQiP-kVw.png" /><figcaption>Lighthouse metrics results</figcaption></figure><p>Based on the results from the <strong>Network tab</strong>, it makes sense that these values are lower for Qwik. In simple terms: same UI, fewer bytes, faster rendering.</p><h4>Diagnostics</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZDvC-9KmTksGk1nCcqIsfQ.png" /><figcaption>Lighthouse diagnostics results</figcaption></figure><p>Here we can see Lighthouse pointing out that Next.js has some unused JavaScript. This doesn’t happen with Qwik, confirming that Qwik generates a leaner build.</p><h3>Coding</h3><p>This is my first time using Qwik, and I didn’t want to use AI agents to convert the code. I spent some time reading the <a href="https://qwik.dev/docs/">Qwik documentation</a>, and that was enough to build this simple app. Here are some findings:</p><h4>Components</h4><p>In Next.js, a function is a component, with no extra syntax needed:</p><pre>export default function Home() {<br>  return &lt;div&gt;Home Page Component&lt;/div&gt;;<br>}</pre><p>With Qwik, you need to use the `component$` function:</p><pre>export default component$(() =&gt; {<br>  return &lt;div&gt;Home Page Component&lt;/div&gt;;<br>});</pre><p>Not a big deal. The syntax changes a bit, but it’s easy enough to follow.</p><h4>State variables and clicks</h4><p>In Next.js, we use `useState` along with `”use client”;` because state lives on the client. Similarly, `onClick` handlers only run on the client.</p><pre>&quot;use client&quot;;<br><br>import { useState } from &quot;react&quot;;<br><br>export default function Home() {<br>  const [greeting, setGreeting] = useState(&quot;hello world&quot;);<br><br>  return &lt;div onClick={() =&gt; setGreeting(&quot;hello from click&quot;)}&gt;{greeting}&lt;/div&gt;;<br>}</pre><p>Qwik uses `useSignal` for “signal variables” and `onClick$` for click handlers:</p><pre>import { component$, useSignal } from &quot;@builder.io/qwik&quot;;<br><br>export default component$(() =&gt; {<br>  const greetingSignal = useSignal(&quot;hello world&quot;);<br><br>  return (<br>    &lt;div onClick$={() =&gt; (greetingSignal.value = &quot;hello from click&quot;)}&gt;<br>      {greetingSignal}<br>    &lt;/div&gt;<br>  );<br>});</pre><p>Assigning a new value to `greetingSignal.value = …` is equivalent to calling `setGreeting(…)`, and it triggers a re-render.</p><h4>Fetching data</h4><p>In both cases, data is fetched on the server. Remember, the page is generated daily, meaning the server generates the HTML, which is then cached in the CDN and served to users. Once per day, the server fetches a JSON file.</p><p><strong>Next.js:</strong></p><pre>export default async function Home() {<br>  const quiz = await fetch(`https://domain.com/name.json`).then((res) =&gt;<br>    res.json()<br>  );<br><br>  return &lt;Quiz quiz={quiz} /&gt;;<br>}</pre><p>Since there’s no `”use client”;` directive, this code runs only on the server.</p><p><strong>Qwik:</strong></p><pre>import { routeLoader$ } from &quot;@builder.io/qwik-city&quot;;<br><br>export const useQuiz = routeLoader$(async () =&gt; {<br>  const response = await fetch(`https://domain.com/name.json`).then((res) =&gt;<br>    res.json()<br>  );<br>  return response;<br>});<br><br>export default component$(() =&gt; {<br>  const quiz = useQuiz();<br><br>  return &lt;Quiz quiz={quiz} /&gt;;<br>});</pre><p>With Qwik, `routeLoader$` defines server-side logic, and the component consumes it as a hook.</p><h3>Summary</h3><p><strong>Qwik is clearly a leaner framework than Next.js</strong>, and the syntax differences are minimal. Both frameworks share the same core concepts: components, state/signals, data fetching, and more.</p><p>One big advantage of Next.js is the size of its community.</p><p>At the time of writing:</p><p><strong>GitHub stars</strong>: 137k (Next.js) vs 21.9k (Qwik)<br><strong>GitHub watchers</strong>: 1.5k (Next.js) vs 135 (Qwik)<br><strong>GitHub pull requests</strong>: 1.2k (Next.js) vs 43 (Qwik)<br><strong>NPM weekly downloads</strong>: 15.5 million (Next.js) vs 16.3 thousand (Qwik)</p><p>It’s easy to see that the Next.js community is much larger, which means better ecosystem support, more documentation, and more tooling.</p><p>For my personal projects, I’ll definitely keep using Qwik to get more familiar with it. In a professional environment, I’ll stick with Next.js. Just because a framework does something better doesn’t justify the cost of refactoring existing code. Even with AI agents helping, refactoring still involves testing, monitoring, and maintenance. Shaving off a fraction of a second usually isn’t worth the investment — unless you’re in the business of speed, like e-commerce, streaming, or other high-traffic services. Even then, there are often alternatives besides switching frameworks.</p><p>Finally, now that a lot of code is written by AI agents, I don’t think the framework choice matters. What really matters is keeping things like reusability, scalability, performance, and design patterns in mind.</p><p>It’s not about the framework, it’s about the solution.</p><p>That’s it — happy coding.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a20f5d0a15b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[One Artwork, Seven Questions: Exploring the Art Institute API and Gemini]]></title>
            <link>https://medium.com/@garciadiazjaime/one-artwork-seven-questions-exploring-the-art-institute-api-and-gemini-dddf411f48f3?source=rss-3f8c81637813------2</link>
            <guid isPermaLink="false">https://medium.com/p/dddf411f48f3</guid>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[art]]></category>
            <category><![CDATA[gemini]]></category>
            <dc:creator><![CDATA[Jaime Garcia Diaz]]></dc:creator>
            <pubDate>Thu, 01 Jan 2026 19:02:23 GMT</pubDate>
            <atom:updated>2026-01-01T19:02:23.339Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VeurpvmvGS8uiDMslXwPnA.png" /></figure><p>New year, new project. As a fan of the <a href="https://www.artic.edu/">Art Institute of Chicago</a>, I just realized they have a public <a href="https://api.artic.edu/docs/">RESTful API</a> and decided to build a simple web app: one piece of art a day and seven questions to learn more about the artwork.</p><p>This is how I built it:</p><h3>1. Artist list</h3><p>First, I asked GPT to provide a list of famous artists found at the Art Institute of Chicago. I’ll keep the list private so as not to spoil the artists you’ll find in the app.</p><h3>2. Artwork</h3><p>Second, I hit the <a href="https://api.artic.edu/docs/#get-artworks-search">/search</a> endpoint to request one artwork from _artist X_. The endpoint is part of an Elasticsearch service, meaning it offers good tooling around filters. Here’s my query:</p><pre>const query = {<br>  query: {<br>    bool: {<br>      must: [<br>        { term: { is_public_domain: true } },<br>        { term: { &quot;artist_title.keyword&quot;: artist } },<br>        {<br>          match: {<br>            medium_display: { query: &quot;Oil on canvas&quot;, fuzziness: &quot;AUTO&quot; },<br>          },<br>        },<br>      ],<br>    },<br>  },<br>};</pre><p>There are three filters:</p><p>a) <strong>Public domain</strong>. This is very important to avoid copyright issues.</p><p>b) The artist’s name needs to match. There are a lot of artists and a lot of great works, but for now I’m interested in specific names.</p><p>c) I like `oil on canvas`, so I’m filtering by it, although this is more of a personal choice.</p><h3>3. Quiz</h3><p>Now that I have an artist’s name and one of their artworks (which could actually be found at the museum), the next step is to use AI to generate the questions. Here’s the prompt I’m using:</p><pre>Generate 7 quiz questions about the following artwork: ${artist} - ${artwork};<br>  use the following example questions as a guide: ${JSON.stringify(exampleQuestions)};<br>  the questions should be a mix of easy, intermediate, hard, and expert difficulty levels;<br>  each question should have 3 options labeled A, B, and C;<br>  provide the correct answer for each question;<br>  return the result as a JSON array of question objects with the following structure: { difficulty: string, question_number: number, question_text: string, options: { A: string, B: string, C: string }, correct_answer: string (A, B, or C) };<br>  only return the JSON array without any additional text;<br>  the questions should only be about the artwork</pre><p>Then I pass the prompt to library `<a href="http://twitter.com/google/genai">@google/genai</a>`</p><pre>import { GoogleGenAI } from &quot;@google/genai&quot;;<br>const ai = new GoogleGenAI({});<br>const response = await ai.models.generateContent({<br>  model: &quot;gemini-2.5-flash&quot;,<br>  contents: prompt,<br>});<br>const cleanJson = response.text.replace(/^```json|```$/g, &quot;&quot;).trim();<br>const questions = JSON.parse(cleanJson);</pre><p>A couple of things to mention here:</p><p>a) You need a `GEMINI_API_KEY`; get one from <a href="https://aistudio.google.com/">Google</a>.</p><p>b) I’m using the model `gemini-2.5-flash`, but it has some rate limitations. Not bad considering it’s free, but if you need to make more requests, you can try another model like `gemma-3–12b-it`, which allows more requests. Each model is trained differently, and at least for this simple case, I didn’t notice any significant difference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hhAWbkCZjm16J4X-MAlP8w.png" /><figcaption>Model Rate Limitations</figcaption></figure><p>c) One last thing: the agent usually returns something like this:</p><pre>```json [<br>  {<br>    &quot;image&quot;: &quot;...&quot;,<br>    &quot;quiz_title&quot;: &quot;...&quot;,<br>    &quot;questions&quot;: []<br>  }<br>}<br>```</pre><p>So I had to remove ```json` and then parse the rest of the string, which was the array of questions I was expecting.</p><h3>4. Web app</h3><p>Finally, I’m going with **Next.js** plus **Copilot** to build the UI. I wrote a bunch of prompts, but the idea was to:</p><ul><li>Display the image found in the JSON</li><li>Show one question at a time</li><li>Keep score of correct answers</li><li>Once the quiz is finished, show a short summary</li></ul><p>And that’s it. Please visit the <a href="https://artic.mintitmedia.com/">quiz app</a> and check out the <a href="https://github.com/garciadiazjaime/website-artic/tree/main">codebase</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/427/1*imbBf7uKfxaX_wd4QqyQbQ.png" /><figcaption>One Artwork, Seven Questions</figcaption></figure><p>Happy 2026 coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dddf411f48f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Another ETL: Night Lift Tickets]]></title>
            <link>https://medium.com/@garciadiazjaime/another-etl-night-lift-tickets-7959476ce4c8?source=rss-3f8c81637813------2</link>
            <guid isPermaLink="false">https://medium.com/p/7959476ce4c8</guid>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[github-copilot]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[etl]]></category>
            <dc:creator><![CDATA[Jaime Garcia Diaz]]></dc:creator>
            <pubDate>Mon, 22 Dec 2025 19:02:21 GMT</pubDate>
            <atom:updated>2025-12-22T19:02:21.020Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kjznHEUrm855bk39ddeccA.png" /></figure><p>I live in Chicago, and one thing I like about the winter is having the chance to go snowboarding. I’m not very good at it, but I enjoy it. Usually, I would open multiple websites until I find a place to go. So every time I find myself doing a repetitive manual task — in this case, <strong>opening multiple websites with similar content for the same purpose</strong> — my brain goes directly to ETL.</p><p>And yes, there are already some catalog websites that show different hills around, but not the way I want. In my case, I’m interested in <strong>night lift tickets</strong>, because they have the best price, and I want to <strong>see the places on a map</strong> to find out how far they are from my place.</p><p>I wrote a couple of ETLs; they all have the same structure: <strong>Extract, Transform, and Load</strong>. In this case, <strong>Extract</strong> and <strong>Load</strong> are basically the same for all ETLs, which is why I put those functions in a `common.js` file, while the only custom part lives in <strong>Transform</strong>, which helps extract the price from the HTML using a CSS selector.</p><p>For this part, the HTML is passed to `cheerio`, which is a nice package that enables something similar to `jQuery`, making it easier to find elements in the HTML. Take a look at the following line:</p><pre>const price = $($(&quot;.seasoncontainer.liftcontainer.clsDaynight.clsNight li&quot;)[2]);</pre><p>Of course, if the CSS classes change on the site, then the scraper won’t work. This is one of the challenges of using this approach in ETLs. In production, you would have an alert to help you know whenever the price can’t be extracted. Or now, you could use AI — maybe <a href="https://medium.com/@garciadiazjaime/gemini-api-the-free-tier-that-makes-developers-happy-9952d9f47b9c">Gemini</a>—and try to extract the price using a model.</p><p>I went with a CSS selector because these sites rarely change their code.</p><pre>const cheerio = require(&quot;cheerio&quot;);<br><br>const { extract, load, loggerInfo } = require(&quot;./common&quot;);<br><br>async function transform(html) {<br>  const $ = cheerio.load(html);<br><br>  const price = $(<br>    $(&quot;.seasoncontainer.liftcontainer.clsDaynight.clsNight li&quot;)[2]<br>  )<br>    .find(&quot;p&quot;)<br>    .text()<br>    .replace(&quot;$&quot;, &quot;&quot;);<br><br>  return {<br>    price: parseInt(price),<br>  };<br>}<br><br>async function main() {<br>  const place = {<br>    id: &quot;cascademountain&quot;,<br>    website: &quot;https://www.cascademountain.com&quot;,<br>    name: &quot;Cascade Mountain&quot;,<br>    lat: 43.502728,<br>    lng: -89.515996,<br>    gmaps: &quot;https://maps.app.goo.gl/YWdnQvZiJZwPhj79A&quot;,<br>    url: `https://www.cascademountain.com/lift-tickets/`,<br>  };<br>  loggerInfo(&quot;etl start&quot;, { id: place.id });<br><br>  const html = await extract(place.url);<br>  const data = await transform(html);<br>  await load(place, data);<br><br>  loggerInfo(&quot;etl done&quot;, { id: place.id });<br>}<br><br>main().then(() =&gt; {});</pre><p>The only dynamic property is `price`; the others are hardcoded. The thought is that prices change over time, but a business is either running or closed. The hardcoded values could be extracted using, maybe, Google Maps APIs, but considering that the number of places is limited, hardcoding them for now is fine. If my site gets real traffic, then I would consider writing a script to use Google Maps APIs and programmatically get a more comprehensive list of ski places.</p><p>The `extract` function simply makes a `fetch` request to the URL passed. There’s a variation in the codebase that uses <a href="https://github.com/garciadiazjaime/website-ski/blob/main/etl/common.js#L16">puppeteer</a>, because some sites don’t like scrapers.</p><pre>async function extract(url) {<br>  loggerInfo(&quot;extracting&quot;, { url });<br><br>  const response = await fetch(url);<br>  const html = await response.text();<br>  return html;<br>}</pre><p>The `load` function only saves the data in a `json` file. For now, a file is enough. At some point, this should be a database; I would go with **DynamoDB** because it’s cheap.</p><pre>async function load(place, extraData) {<br>  const data = { ...place, ...extraData };<br>  loggerInfo(&quot;load&quot;, data);<br><br>  const filename = `public/sites/${data.id}.json`;<br>  await fs.writeFile(filename, JSON.stringify(data, null, 2));<br><br>  loggerInfo(&quot;saved&quot;, { filename });<br>}</pre><p>`loggerInfo` is nothing more than a wrapper around `console.log`, which for now is enough. But in a production-like application, you could plug in something like **New Relic** or any other logging service.</p><pre>const loggerInfo = (...args) =&gt; {<br>  console.log(...args);<br>};</pre><p>Alright, so that’s the ETL. Now that I have the information, the rest is to build a website to show the places. I usually go with <strong>Next.js</strong> and then use <strong>Copilot</strong> to build it, so the prompt looks like this:</p><pre>On this Next.js project, build a page with the following requirements:<br>- Only one page.<br>- The page should show a map using Google Maps.<br>- The map should show a marker for each place found in `all-places.json`, displaying the price.<br>- The page should have Google Analytics.<br>- The page should let the user click a marker and open a small card with the place information: name, link to Google Maps, and link to the `url` found in the JSON.<br>- The UI should be simple and use inline styles.</pre><p>Something like that is a good starter. Of course, after that there would be some adjustments — some will be taken care of by it, and some by them.</p><p>And that’s it. Please visit the site and let me know what you think:</p><ul><li><a href="https://goofy.mintitmedia.com/">goofy</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*oR1nUu71qIE8rKdfvM6yqA.png" /><figcaption>Night Skiing Finder</figcaption></figure><ul><li><a href="https://github.com/garciadiazjaime/website-ski/tree/main">codebase</a></li></ul><p>Happy coding.</p><p>P.S. Yes, I’m goofy.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7959476ce4c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Shai Hulud Scanner]]></title>
            <link>https://medium.com/@garciadiazjaime/shai-hulud-scanner-634e5b758624?source=rss-3f8c81637813------2</link>
            <guid isPermaLink="false">https://medium.com/p/634e5b758624</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[npm]]></category>
            <dc:creator><![CDATA[Jaime Garcia Diaz]]></dc:creator>
            <pubDate>Fri, 28 Nov 2025 17:02:21 GMT</pubDate>
            <atom:updated>2025-11-28T17:02:21.323Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xj9y1HZ0FXibdzF98IR3yQ.png" /></figure><p>This week I spent some time looking for infected npm packages. Initially, the warning was to not install any package or run any AI agent, so I went ahead and created this Node.js script.</p><pre>const scanForShaiHulud = (content) =&gt; {<br>  if (!content) return;<br><br>  const report = {<br>    total: 0,<br>    warning: [],<br>    infected: [],<br>  };<br><br>  Object.keys(content.packages).forEach((packageName) =&gt; {<br>    if (!packageName) {<br>      return;<br>    }<br><br>    let cleanedName = packageName.replace(&quot;node_modules/&quot;, &quot;&quot;);<br>    if (cleanedName.includes(&quot;/node_modules/&quot;)) {<br>      cleanedName = cleanedName.split(&quot;/node_modules/&quot;)[1];<br>    }<br><br>    report.total += 1;<br><br>    if (infectedPackages[cleanedName]) {<br>      if (<br>        infectedPackages[cleanedName].includes(<br>          content.packages[packageName].version<br>        )<br>      ) {<br>        report.infected.push({<br>          name: cleanedName,<br>          version: content.packages[packageName].version,<br>          affectedVersions: infectedPackages[cleanedName],<br>        });<br>      } else {<br>        report.warning.push({<br>          name: cleanedName,<br>          version: content.packages[packageName].version,<br>          affectedVersions: infectedPackages[cleanedName],<br>        });<br>      }<br>    }<br>  });<br><br>  return report;<br>};<br><br>const fileContent = fs.readFileSync(&quot;./package-lock.json&quot;, &quot;utf-8&quot;);<br>const parsedContent = JSON.parse(fileContent);<br>const report = scanForShaiHulud(parsedContent);<br>console.log(report);</pre><p>Before this week, I knew that `package-lock.json` declared all the specific versions installed, but I hadn’t really spent time understanding the structure. Now I know that `package-lock.json` stores, in the key `.packages`, a map of all the packages installed in the repository — either as dependencies of the project or dependencies of dependencies. The point is that `.packages` holds a map with all the packages installed, so it can be used to check if any of the infected packages reported by <a href="https://github.com/wiz-sec-public/wiz-research-iocs/blob/main/reports/shai-hulud-2-packages.csv">wiz-sec-public</a> matches the version.</p><p>The helper is pretty simple: it iterates over every single key found in `.packages` and checks it against the list passed.</p><p>At the end, the report shows if there’s any:</p><ul><li>`warning`: package reported by Wiz as infected, but not the same version</li><li>`infected`: package reported by Wiz as infected, with a matching version</li></ul><p>In the case of `infected`, you must remove that package; otherwise, whatever secrets are stored in your project locally could be exposed.</p><p>In the case of `warning`, I would do the same — remove the package — just to be safe. But if the version is lower than the one reported, in theory you shouldn’t be in trouble.</p><p>Feel free to download the <a href="https://github.com/garciadiazjaime/demo-reactjs/blob/main/app/shai-hulud-scanner/shai-hulud-scanner.js">shai-hulud-scanner</a> to your Node.js project. Once you run it, you should see a report like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*bi9VJxgcsAxexaswnZ_E-w.png" /><figcaption>Terminal Shai Hulud Scanner Report</figcaption></figure><p>Hopefully everything is clear; otherwise take immediate action.</p><p>Additionally, you can visit this <a href="https://demo.garciadiazjaime.com/shai-hulud-scanner">Shai-Hulud Scanner</a> and upload a `package-lock.json` file. The same scanner function will run, and you can see the results in the browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/1*ZqZRN8uxO0mpT4jZLoADyw.png" /><figcaption>Online Shai Hulud Scanner Report</figcaption></figure><p><strong>Note</strong>: This post is meant for package-lock.json. If you are using `yarn` or `pnpm`, this won’t work because those package managers use different lock files. In any case, you should be able to adjust the logic a bit and make it work.</p><p>Luckily, we didn’t find any threats, proving that the Wiz list is comprehensive. I’m a big fan of open source — I believe in the power of community — but as with everything, there are risks too. Someone will always try to break the rules, which in some way pushes us to be more aware and spend more time on security. After this week, I’ve seen numerous packages for detecting this kind of threat, and that’s one of the perks of open source: code written by the people, for the people.</p><p>Happy coding.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=634e5b758624" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>