<?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 Bipul Kuri on Medium]]></title>
        <description><![CDATA[Stories by Bipul Kuri on Medium]]></description>
        <link>https://medium.com/@bipulkkuri?source=rss-549610546ab5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*ZtEEjqhYVdqgWBTT.jpg</url>
            <title>Stories by Bipul Kuri on Medium</title>
            <link>https://medium.com/@bipulkkuri?source=rss-549610546ab5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 08:43:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bipulkkuri/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[NDT7 measurement basic python port]]></title>
            <link>https://bipulkkuri.medium.com/ndt7-measurement-basic-python-port-0a7480209bc7?source=rss-549610546ab5------2</link>
            <guid isPermaLink="false">https://medium.com/p/0a7480209bc7</guid>
            <dc:creator><![CDATA[Bipul Kuri]]></dc:creator>
            <pubDate>Wed, 21 May 2025 17:04:34 GMT</pubDate>
            <atom:updated>2025-05-21T23:19:55.822Z</atom:updated>
            <content:encoded><![CDATA[<p>Ever wondered on googling speedtest you get something like this ,how it works</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aSFSP6IYGIiBuo273a0m5g.png" /></figure><p>Measurement labs officially supports go and js clients</p><p><a href="https://www.measurementlab.net/">https://www.measurementlab.net/</a> and the official spec is available here <a href="https://github.com/m-lab/ndt-server/blob/main/spec/ndt7-protocol.md">https://github.com/m-lab/ndt-server/blob/main/spec/ndt7-protocol.md</a></p><p>Here is attempt to port it in python, as NDT uses websockets there are some workarounds needed to be done</p><p>Follow instructions here to setup ndt server locally <a href="https://hub.docker.com/r/measurementlab/ndt">https://hub.docker.com/r/measurementlab/ndt</a></p><p>Environment setup</p><ul><li>Docker</li><li>Mac</li><li>Python3</li></ul><pre>git clone https://github.com/m-lab/ndt-server.git<br>mkdir certs datadir<br>cd ndt-server<br>docker-compose run ndt-server ./gen_local_test_certs.bash<br>docker-compose up</pre><p>This should give,If everything is set correctly a base page <a href="https://localhost:4443/">https://localhost:4443/</a> will be available on browser</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RQTxnHS6BSwwQeuEjRo6pQ.png" /></figure><p>and testing url,verify the upload/downloads are working</p><p><a href="https://localhost:4443/ndt7.html">https://localhost:4443/ndt7.html</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-cdK3SixEgJmuKordo3mFQ.png" /></figure><p>To python side after setting up env</p><p>To port few things to keep in mind</p><ul><li>Testing uses websockets</li><li>There is a subprotocol use net.measurementlab.ndt.v7</li><li>by default ndt-server uses TLS so for our local testing we can instruct not to verify certs</li><li>If you test across real production ndt servers the discovery will give you HTTP 429 Too Many Requests while doing testing</li></ul><p>create a requirements.txt</p><pre>───────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<br>       │ File: requirements.txt<br>───────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<br>   1   │ requests<br>   2   │ websockets<br>───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────</pre><p>create a config.ini</p><pre>───────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<br>       │ File: config.ini<br>───────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<br>   1   │ [mlab]<br>   2   │ url = https://locate.measurementlab.net/v2/nearest/ndt/ndt7?client_name=ndt7-html-example&amp;client_library_name=ndt7-js&amp;client_library_version=0.0.6&quot;<br>   3   │ ndt_server_config = ndt_server_config.json<br>   4   │ download_url = wss://localhost:4443/ndt/v7/download<br>   5   │ upload_url = wss://localhost:4443/ndt/v7/upload<br>   6   │ subprotocols = net.measurementlab.ndt.v7<br>───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────</pre><p>create a ndt7_discover.py : This uses normal REST API call</p><pre>import configparser<br>import requests<br>import json<br>import os<br>from typing import Dict, Optional<br>import functools<br><br># Load config<br>config = configparser.ConfigParser()<br>config.read(&#39;config.ini&#39;)<br><br><br>@functools.cache<br>def discoverServerURLs() -&gt; Optional[Dict]: <br>    # Get URL from config<br>    url = config.get(&#39;mlab&#39;, &#39;url&#39;)<br><br>    try:<br>        response = requests.get(url)<br>        response.raise_for_status()<br>        json_data=response.json()<br>        if &quot;results&quot; in json_data and json_data[&quot;results&quot;][0]:<br>            result = json_data[&quot;results&quot;][0] # picking first record<br>            machine = result.get(&quot;machine&quot;)<br>            hostname = result.get(&quot;hostname&quot;)<br>            city = result.get(&quot;location&quot;, {}).get(&quot;city&quot;)<br>            country = result.get(&quot;location&quot;, {}).get(&quot;country&quot;)<br>            urls = result.get(&quot;urls&quot;, {})<br>            ws_download = urls.get(&quot;ws:///ndt/v7/download&quot;)<br>            ws_upload = urls.get(&quot;ws:///ndt/v7/upload&quot;)<br>            wss_download = urls.get(&quot;wss:///ndt/v7/download&quot;)<br>            wss_upload = urls.get(&quot;wss:///ndt/v7/upload&quot;)<br>           <br>            return {<br>                &quot;machine&quot;: machine,<br>                &quot;hostname&quot;: hostname,<br>                &quot;location&quot;: {<br>                    &quot;city&quot;: city,<br>                    &quot;country&quot;: country<br>                },<br>                &quot;urls&quot;: {<br>                    &quot;ws_download&quot;: ws_download,<br>                    &quot;ws_upload&quot;: ws_upload,<br>                    &quot;wss_download&quot;: wss_download,<br>                    &quot;wss_upload&quot;: wss_upload<br>                }<br>            }<br>        else:<br>            print(&quot;No results found in the response.&quot;)<br><br>    except requests.RequestException as e:<br>        print(f&quot;Error querying M-Lab locate API: {e}&quot;)<br><br><br>if __name__ == &quot;__main__&quot;:<br>    file_path =  config.get(&#39;mlab&#39;, &#39;ndt_server_config&#39;) # &quot;ndt_server_config.json&quot;<br>    if os.path.exists(file_path):<br>        print(f&quot;{file_path} already exists. Skipping API call.&quot;)<br>        with open(file_path, &quot;r&quot;) as f:<br>            result = json.load(f)<br>    else:<br>        result = discoverServerURLs()<br>        print(result)<br>        if result:<br>            with open(file_path, &quot;w&quot;) as f:<br>                json.dump(result, f, indent=4)<br>            print(f&quot;Output saved to {file_path}&quot;)<br>        else:<br>            print(&quot;No data to save.&quot;)</pre><p>create a ndt7_download.py This uses websocket calls</p><pre>import asyncio<br>import websockets<br>import json<br>import os<br>import configparser<br>import ssl<br>import logging<br><br>from time import time<br><br>from ndt7_discover import discoverServerURLs<br><br>#logging.basicConfig(level=logging.DEBUG)<br># Load config<br>config = configparser.ConfigParser()<br>config.read(&#39;config.ini&#39;)<br><br>def getnow():<br>   return int(time() * 1000) #milliseconds<br><br>total = 0<br>start =  getnow()<br>previous = start<br>subprotocol = config.get(&#39;mlab&#39;, &#39;subprotocols&#39;)<br>async def on_open(websocket):<br>    global total, start, previous<br>   <br>    total=0<br>    start =  getnow()<br>    previous = start<br>    #print(&quot;\nDownload Started&quot;)<br>    await websocket.send(&quot;Hello from async client!&quot;)<br><br>async def on_message(websocket):<br>    global total<br>    global previous<br>    async for message in websocket:<br>        total +=len(message)<br>       <br>        t1 = getnow()<br>        <br>        every = 250 #ms<br>        if (t1 - previous &gt; every):<br>            #ElapsedTime=(t1 - start) / 1000 # seconds<br>            meanClientMbps=(total / (t1 - start)) * 0.008<br>            previous = t1<br>            print(f&quot;\rDownload: {meanClientMbps:.2f} Mb/s&quot;,end=&#39;&#39;, flush=True)<br><br>async def on_close(websocket, reason=None):<br>    print(&quot;\n&quot;)   <br>    <br>async def on_error(e):<br>    print(&quot;\nAn error occurred:&quot;, str(e))<br><br>async def download_test(serverconfig):<br>    #print(type(serverconfig))<br>    #print(&quot;++++&quot;,serverconfig.get(&#39;ws_download&#39;))<br>    uri =config.get(&#39;mlab&#39;, &#39;download_url&#39;)<br>    <br>    ssl_context = ssl.create_default_context()<br>    ssl_context.check_hostname = False<br>    ssl_context.verify_mode = ssl.CERT_NONE<br>    websocket = None<br>    try:<br>        websocket = await websockets.connect(<br>            uri,<br>            subprotocols=[subprotocol],<br>            ssl=ssl_context<br>        )<br>        await on_open(websocket)<br>        await on_message(websocket)<br><br>    except Exception as e:<br>        await on_error(e)<br>    finally:<br>        if websocket:<br>            await on_close(websocket, reason=&quot;Finished or error occurred&quot;)<br><br>if __name__ == &quot;__main__&quot;:<br>    file_path =  config.get(&#39;mlab&#39;, &#39;ndt_server_config&#39;)<br>    if os.path.exists(file_path):<br>        print(f&quot;{file_path} already exists. Skipping API call.&quot;)<br>        with open(file_path, &quot;r&quot;) as f:<br>            serverconfig = json.load(f)<br>    else:<br>        #serverconfig = discoverServerURLs()<br>        serverconfig = &quot;&quot;<br>    asyncio.run(download_test(serverconfig))</pre><p>create a ndt7_upload.py. This uses websocket calls</p><pre>import asyncio<br>import websockets<br>import json<br>import os<br>import configparser<br>import ssl<br>from time import time<br>import logging<br><br>from ndt7_discover import discoverServerURLs<br><br>#logging.basicConfig(level=logging.DEBUG)<br>config = configparser.ConfigParser()<br>config.read(&#39;config.ini&#39;)<br><br>def getnow():<br>    return int(time() * 1000)  # milliseconds<br><br>max_message_size = 8 * 1024 * 1024  # 8 MB<br>client_measurement_interval = 0.25  # seconds<br><br>async def uploader(websocket, data, start, end):<br>    total = 0<br>    previous = start<br><br>    while True:<br>        t = getnow()<br><br>        if t &gt;= end:<br>            await websocket.close()<br>            break<br><br>        # Simulate adaptive buffer sizing (not precise without .buffered_amount)<br>        if len(data) &lt; max_message_size:<br>            data = bytearray(min(len(data) * 2, max_message_size))  # Cap at 8MB<br><br>        await websocket.send(data)<br>        total += len(data)<br><br>        if t &gt;= previous + client_measurement_interval * 1000:<br>            elapsed_time = (getnow() - start) / 1000<br>            mean_mbps = total * 8 / 1_000_000 / elapsed_time<br>            print(f&quot;\rUpload: {mean_mbps:.2f} Mb/s&quot;, end=&#39;&#39;, flush=True)<br>            previous = t<br><br>        await asyncio.sleep(0.001)  # Yield control to the event loop<br><br>async def on_open(websocket):<br>    #print(&quot;\nUpload Started&quot;)<br>    initial_message_size = 8192<br>    data = bytearray(initial_message_size)<br>    duration = 10000  # ms<br>    start = getnow()<br>    end = start + duration<br>    await uploader(websocket, data, start, end)<br><br>async def on_close(websocket, reason=None):<br>    #print(&quot;\nUpload Completed&quot;)<br>     print(&quot;\n&quot;)<br><br>async def on_error(e):<br>    print(&quot;An error occurred:&quot;, str(e))<br><br>async def on_message(websocket):<br>    pass  # Handle incoming messages if necessary<br><br>async def upload_test(serverconfig):<br>    uri = config.get(&#39;mlab&#39;, &#39;upload_url&#39;)<br>    subprotocol = config.get(&#39;mlab&#39;, &#39;subprotocols&#39;)<br>    # insecure for local<br>    ssl_context = ssl.create_default_context()<br>    ssl_context.check_hostname = False<br>    ssl_context.verify_mode = ssl.CERT_NONE<br><br>    websocket = None<br>    try:<br>        websocket = await websockets.connect(<br>            uri,<br>            subprotocols=[subprotocol],<br>            ssl=ssl_context,<br>            max_size=None<br>        )<br>        await on_open(websocket)<br>        await on_message(websocket)<br><br>    except Exception as e:<br>        await on_error(e)<br>    finally:<br>        if websocket:<br>            await on_close(websocket, reason=&quot;Finished or error occurred&quot;)<br><br>if __name__ == &quot;__main__&quot;:<br>    file_path = config.get(&#39;mlab&#39;, &#39;ndt_server_config&#39;)<br>    if os.path.exists(file_path):<br>        print(f&quot;{file_path} already exists. Skipping API call.&quot;)<br>        with open(file_path, &quot;r&quot;) as f:<br>            serverconfig = json.load(f)<br>    else:<br>        #serverconfig = discoverServerURLs()<br>        serverconfig=&quot;&quot;<br><br>    asyncio.run(upload_test(serverconfig))</pre><p>create ndt7_test.py</p><pre>ndt7_test.py<br>───────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<br>       │ File: ndt7_test.py<br>───────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<br>   1   │ import os<br>   2   │ import asyncio<br>   3   │ import configparser<br>   4   │ <br>   5   │ config = configparser.ConfigParser()<br>   6   │ config.read(&#39;config.ini&#39;)<br>   7   │ <br>   8   │ from ndt7_discover import discoverServerURLs<br>   9   │ from ndt7_download import download_test<br>  10   │ from ndt7_upload import upload_test<br>  11   │ <br>  12   │ if __name__ == &quot;__main__&quot;:<br>  13   │     file_path =  config.get(&#39;mlab&#39;, &#39;ndt_server_config&#39;)<br>  14   │     if os.path.exists(file_path):<br>  15   │         print(f&quot;{file_path} already exists. Skipping API call.&quot;)<br>  16   │         with open(file_path, &quot;r&quot;) as f:<br>  17   │             serverconfig = json.load(f)<br>  18   │     else:<br>  19   │         #serverconfig = discoverServerURLs()<br>  20   │         serverconfig = &quot;&quot;<br>  21   │     print(&quot;\nStarting NDT7 tests ...\n&quot;)<br>  22   │     asyncio.run(download_test(serverconfig))<br>  23   │     asyncio.run(upload_test(serverconfig))<br>  24   │     print(&quot;Finshed NDT7 tests\n&quot;) <br>  25   │ <br>  26   │ <br>───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────</pre><p>while the ndt-server runs on docker,execute your ndt7_test.py</p><pre>$python3 ndt7_test.py     <br><br>Starting NDT7 tests ...<br><br>Download: 2545.70 Mb/s<br><br>Upload: 2263.16 Mb/s<br><br>Finshed NDT7 tests</pre><p>Whole codebase is available here <a href="https://github.com/bipulkkuri/ndt7-measurement">https://github.com/bipulkkuri/ndt7-measurement</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0a7480209bc7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Star Wars on terminal]]></title>
            <link>https://bipulkkuri.medium.com/star-wars-on-terminal-f50b4815947b?source=rss-549610546ab5------2</link>
            <guid isPermaLink="false">https://medium.com/p/f50b4815947b</guid>
            <category><![CDATA[terminal]]></category>
            <category><![CDATA[star-wars]]></category>
            <category><![CDATA[shell]]></category>
            <category><![CDATA[bash]]></category>
            <dc:creator><![CDATA[Bipul Kuri]]></dc:creator>
            <pubDate>Mon, 14 Apr 2025 19:30:38 GMT</pubDate>
            <atom:updated>2025-04-14T19:30:38.456Z</atom:updated>
            <content:encoded><![CDATA[<p>Code base</p><pre>#!/bin/bash<br><br># ===== Configuration =====<br>BASHRC=&quot;$HOME/.bashrc&quot;<br>BACKUP_DIR=&quot;$HOME/bash_backups&quot;<br><br><br>backup_bashrc() {<br>    mkdir -p &quot;$BACKUP_DIR&quot;<br>    local backup_file=&quot;$BACKUP_DIR/.bashrc.backup.$(date +&quot;%F_%H%M%S&quot;)&quot;<br>    cp &quot;$BASHRC&quot; &quot;$backup_file&quot;<br>    echo &quot;🔹 Created backup: $backup_file&quot;<br>}<br><br><br># === Star Wars Bash Enhancer ===<br>echo &quot;🚀 Installing Star Wars terminal theme...&quot;<br><br>backup_bashrc <br><br> <br>#uninstall if already installed<br>#cp /etc/skel/.bashrc $BASHRC<br>if grep -q &quot;Star Wars Terminal Theme&quot; &quot;$BASHRC&quot;; then<br>    echo &quot;⚠️ Star Wars theme already installed. Uninstalling...&quot;<br>    sed -i &#39;/Star Wars Terminal Theme/,/Jedi Wisdom/d&#39; &quot;$BASHRC&quot;<br>    echo &quot;✅ Uninstalled. Please run the script again to reinstall.&quot;<br>    <br>else<br><br>cat &lt;&lt; &#39;EOF&#39; &gt;&gt; &quot;$BASHRC&quot;<br><br># Dynamic color scheme<br>DARK_SIDE=&#39;\033[38;5;160m&#39;   # Sith red<br>LIGHT_SIDE=&#39;\033[38;5;45m&#39;   # Jedi blue<br>ACCENT=&#39;\033[38;5;220m&#39;      # Lightsaber gold<br>SYSTEM=&#39;\033[38;5;87m&#39;       # System info cyan<br>NC=&#39;\033[0m&#39;                 # Reset<br><br># Get dynamic info<br>USER=$(whoami)<br>TIME=$(date +&quot;%H:%M&quot;)<br>DAY=$(date +&quot;%A&quot;)<br>CPU=$(grep &#39;cpu &#39; /proc/stat | awk &#39;{usage=($2+$4)*100/($2+$4+$5)} END {print int(usage)}&#39;)<br>MEM=$(free | awk &#39;/Mem/{printf(&quot;%.0f&quot;), $3/$2*100}&#39;)<br>IP=$(hostname -I | awk &#39;{print $1}&#39;)<br>HOST=$(hostname)<br>DISK=$(df -h / | awk &#39;NR==2{print $5}&#39;)<br><br><br># 🌌 Star Wars Terminal Theme 🌌<br><br> <br>echo -e &quot;${ACCENT}&quot;<br>echo -e &quot;   ███████╗████████╗ █████╗ ██████╗     ██╗    ██╗█████╗ ██████╗  ███████╗  &quot;<br>echo -e &quot;   ██╔════╝╚══██╔══╝██╔══██╗██╔══██╗    ██║    ██║██╔══██╗██╔══██╗██╔════╝  &quot;<br>echo -e &quot;   ███████╗   ██║   ███████║██████╔╝    ██║ █╗ ██║███████║██████╔╝███████╗  &quot;<br>echo -e &quot;   ╚════██║   ██║   ██╔══██║██╔══██╗    ██║███╗██║██╔══██║██╔══██╗╚════██║  &quot;<br>echo -e &quot;   ███████║   ██║   ██║  ██║██║  ██║    ╚███╔███╔╝██║  ██║██║  ██║███████║  &quot;<br>echo -e &quot;   ╚══════╝   ╚═╝   ╚═╝  ╚═╝╚═╝  ╚═╝     ╚══╝╚══╝  ╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝ &quot;<br>echo -e &quot;${SYSTEM}   System: ${USER}@${HOST}${NC}&quot;<br>echo -e &quot;${SYSTEM}   Time: ${TIME} on ${DAY} ${NC}&quot;<br>echo -e &quot;${SYSTEM}   CPU: ${CPU}%  |  RAM: ${MEM}%  | DISK: ${DISK} |  IP: ${IP}${NC} ${NC}&quot;<br>echo -e &quot;${ACCENT}    [${DARK_SIDE}⚔${ACCENT}] ${LIGHT_SIDE}Jedi Terminal ${ACCENT}|| ${DARK_SIDE}Sith Console${NC}&quot;<br>echo -e &quot;${ACCENT}   May the ${LIGHT_SIDE}Force${ACCENT} be with your ${SYSTEM}commands${NC}&quot;<br><br># Aliases with Star Wars flair<br>alias vader=&#39;sudo&#39;<br>alias useforce=&#39;sudo !!&#39;<br>alias lightsaber=&#39;rm -rf&#39;<br>alias hyperjump=&#39;cd ..&#39;<br>alias falcon=&#39;cd /var/www/html&#39;<br>alias c3po=&#39;ls -alh&#39;<br>alias obiwan=&#39;man&#39;<br>alias yoda=&#39;df -h&#39;<br>alias r2d2=&#39;top&#39;<br>alias stormtrooper=&#39;ping&#39;<br>alias lightspeed=&#39;wget&#39;<br>alias sith=&#39;kill&#39;<br>alias jedi=&#39;ps aux&#39;<br>alias deathstar=&#39;shutdown now&#39;<br>alias bb8=&#39;history&#39;<br><br># Rebel Prompt Theme<br>PS1=&#39;\[\033[1;36m\][\u@\h 🌌 \W]\$\[\033[0m\] &#39;<br><br># Random Jedi Wisdom<br>wisdoms=(<br>  &quot;Do. Or do not. There is no try.&quot;<br>  &quot;I have a bad feeling about this.&quot;<br>  &quot;Rebellions are built on hope.&quot;<br>  &quot;I find your lack of faith disturbing.&quot;<br>  &quot;Never tell me the odds!&quot;<br>  &quot;It&#39;s over, Anakin. I have the high ground.&quot;<br>  &quot;I&#39;m one with the Force. The Force is with me.&quot;<br>  &quot;The Force will be with you. Always.&quot;<br>  &quot;Your focus determines your reality.&quot;<br>  &quot;In my experience, there is no such thing as luck.&quot;<br>  &quot;You must unlearn what you have learned.&quot;<br>  &quot;Fear is the path to the dark side.&quot;<br>)<br>RANDOM_INDEX=$((RANDOM % ${#wisdoms[@]}))<br>echo -e &quot;\033[1;32m🧘 Jedi Wisdom: \&quot;${wisdoms[$RANDOM_INDEX]}\&quot;\033[0m&quot;<br><br>EOF<br><br>echo &quot;✅ Done! Reload your terminal or run: source ~/.bashrc&quot;<br>fi</pre><p>Install the theme</p><pre>apt update ;apt install curl -y;curl -L -o  $HOME/install_starwars_theme.sh  &quot;https://gist.githubusercontent.com/bipulkkuri/4a3b6f6a1739133df8fc932728b0dbbd/raw/97730f2e3fbee30bfc2eed266760c857d346a16d/install_starwars_theme.sh&quot;|chmod +x  $HOME/install_starwars_theme.sh ; . $HOME/install_starwars_theme.sh ; source  $HOME/.bashrc</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GkNQqle1zfFfWSztbbtLYQ.png" /></figure><p>fun aliases</p><pre>alias vader=&#39;sudo&#39;<br>alias useforce=&#39;sudo !!&#39;<br>alias lightsaber=&#39;rm -rf&#39;<br>alias hyperjump=&#39;cd ..&#39;<br>alias falcon=&#39;cd /var/www/html&#39;<br>alias c3po=&#39;ls -alh&#39;<br>alias obiwan=&#39;man&#39;<br>alias yoda=&#39;df -h&#39;<br>alias r2d2=&#39;top&#39;<br>alias stormtrooper=&#39;ping&#39;<br>alias lightspeed=&#39;wget&#39;<br>alias sith=&#39;kill&#39;<br>alias jedi=&#39;ps aux&#39;<br>alias deathstar=&#39;shutdown now&#39;<br>alias bb8=&#39;history&#39;</pre><p>commands</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tDKxit1S9Wam6zhktXyFDw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ANbuGA9cFBTIK7Kc7zscBw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f50b4815947b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Necmec API python wrapper]]></title>
            <link>https://bipulkkuri.medium.com/necmec-api-python-wrapper-d8da81899ee8?source=rss-549610546ab5------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8da81899ee8</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[necmec]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Bipul Kuri]]></dc:creator>
            <pubDate>Tue, 08 Apr 2025 21:34:45 GMT</pubDate>
            <atom:updated>2025-04-08T21:34:45.900Z</atom:updated>
            <content:encoded><![CDATA[<p>A Python client for interacting with the <strong>NECMEC API python wrapper</strong>. This API allows users to submit reports, upload files, and perform other operations necessary to complete the submission process. Base API docs <a href="https://exttest.cybertip.org/ispws/documentation/index.html#overview">https://exttest.cybertip.org/ispws/documentation/index.html#overview</a></p><ul><li><a href="https://github.com/bipulkkuri/necmec_api">GitHub - bipulkkuri/necmec_api: a necmec python wrapper</a></li><li><a href="https://pypi.org/project/necmec-api/">necmec-api</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8da81899ee8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mac notes]]></title>
            <link>https://bipulkkuri.medium.com/mac-notes-fbeb00a3d421?source=rss-549610546ab5------2</link>
            <guid isPermaLink="false">https://medium.com/p/fbeb00a3d421</guid>
            <category><![CDATA[mac]]></category>
            <dc:creator><![CDATA[Bipul Kuri]]></dc:creator>
            <pubDate>Mon, 07 Apr 2025 17:22:30 GMT</pubDate>
            <atom:updated>2025-04-07T17:22:30.831Z</atom:updated>
            <content:encoded><![CDATA[<p>Setting additional paths</p><pre>sudo vi /etc/paths</pre><p>add additional paths</p><pre>/usr/local/bin<br>/System/Cryptexes/App/usr/bin<br>/usr/bin<br>/bin<br>/usr/sbin<br>/sbin<br>{{add new path to binary}}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fbeb00a3d421" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A terminal gui tool for admins in Rust]]></title>
            <link>https://bipulkkuri.medium.com/a-terminal-gui-tool-for-admins-in-rust-44d922eb8c71?source=rss-549610546ab5------2</link>
            <guid isPermaLink="false">https://medium.com/p/44d922eb8c71</guid>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[privacy]]></category>
            <category><![CDATA[admin]]></category>
            <category><![CDATA[terminal]]></category>
            <dc:creator><![CDATA[Bipul Kuri]]></dc:creator>
            <pubDate>Fri, 04 Apr 2025 15:17:50 GMT</pubDate>
            <atom:updated>2025-04-08T21:32:04.967Z</atom:updated>
            <content:encoded><![CDATA[<p>There are situations when you don’t want to use encode/decode ,hash,conversion functions online for privacy</p><p><a href="https://github.com/bipulkkuri/radmintools-tui">https://github.com/bipulkkuri/radmintools-tui</a></p><p><a href="https://crates.io/crates/radmintools-tui">https://crates.io/crates/radmintools-tui</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44d922eb8c71" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Symphony of Silence — Automated Ad Muting System]]></title>
            <link>https://bipulkkuri.medium.com/symphony-of-silence-524f2af803d9?source=rss-549610546ab5------2</link>
            <guid isPermaLink="false">https://medium.com/p/524f2af803d9</guid>
            <category><![CDATA[tesseract]]></category>
            <category><![CDATA[home-assistant]]></category>
            <category><![CDATA[youtube-ads]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Bipul Kuri]]></dc:creator>
            <pubDate>Mon, 24 Mar 2025 20:59:30 GMT</pubDate>
            <atom:updated>2025-03-27T13:41:59.091Z</atom:updated>
            <content:encoded><![CDATA[<p>It was a quiet afternoon, and I was lounging in my room, ready to enjoy my favorite music. But as soon as I hit play on YouTube, the familiar pattern of annoyance began: the ads.Specially the long ads . <br>Every single time I settled in to enjoy my music, YouTube hit me with one ad after another,and I found myself desperately skipping through each one. I needed a solution and fast to target <strong><em>long sponsored ads</em></strong>.</p><p>But what if I told you that I could automate the process of muting YouTube ads and unmuting the sound when the ads were done, all with a little bit of tech magic? Enter my trusty Raspberry Pi with home asistant, an old iPhone, a bit of MacBook power, and the magic of Tesseract OCR (Optical Character Recognition). There are other solution like pihole I wanted to try something new</p><p>A High level view</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CQKD03SmenJWmd3JXQLcSw.png" /></figure><h3>Key Components</h3><ol><li><strong>Raspberry Pi</strong>: Central controller running Home Assistant for IoT automation, handling mute/unmute commands.</li><li><strong>iPhone</strong>: Acts as a Continuity Camera to capture TV screen images via macOS AirPlay, makes camera placement easy.(ios 16 or above)</li><li><strong>MacBook</strong>: Hosts Python scripts for image processing, Tesseract OCR, and logic to detect ad-related keywords (e.g., “Sponsored,” “Skip Ad”).</li><li><strong>Tesseract OCR</strong>: Open-source engine to extract on-screen text from iPhone-captured images.</li><li><strong>Home Assistant</strong>: Integrates with the TV (via smart home protocols) to execute audio muting/unmuting based on OCR results.</li></ol><h3>Workflow</h3><p><strong>Image Capture</strong>:</p><ul><li>Python script periodically captures screenshots of the YouTube playback via iphone</li><li>iPhone streams the TV screen to the MacBook via Continuity Camera.</li></ul><p><strong>OCR Processing</strong>:</p><ul><li>Tesseract OCR scans screenshots for predefined ad indicators (e.g., “Sponsored”).</li><li>Detection logic triggers a mute command via Home Assistant API.</li></ul><p><strong>Automation</strong>:</p><ul><li>When ad-related text appears (e.g., post-ad “Sponsored”), the script signals Home Assistant to unmute audio.</li><li>When ad-related text disappears (e.g., post-ad “Sponsored”), the script signals Home Assistant to unmute audio.</li></ul><p><strong>Logging &amp; Debugging</strong>:</p><ul><li>System logs mute/unmute events and OCR-detected text for validation (e.g., timestamps, keyword matches).</li></ul><p>I verified in my Home Assistant log</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8hlWz7mZIrx_i9uy8Lfweg.png" /></figure><p>and in program log</p><pre>$python3 uadmuter.py<br>2025-03-24 16:19:20.532 Python[59078:2811685] WARNING: AVCaptureDeviceTypeExternal is deprecated for Continuity Cameras. Please use AVCaptureDeviceTypeContinuityCamera and add NSCameraUseContinuityCameraDeviceType to your Info.plist.<br>Text found in the image --  Sponsored<br>Mute the video 2025-03-24 16:19:51<br>Text found in the image --  Sponsored<br>Text found in the image --  Sponsored<br>UnMute the video 2025-03-24 16:20:13<br>Text found in the image --  Sponsored<br>Mute the video 2025-03-24 16:20:20<br>Text found in the image --  Sponsored<br>Text found in the image --  Sponsored<br>Text found in the image --  Sponsored<br>Text found in the image --  Sponsored<br>Text found in the image --  Sponsored<br>Text found in the image --  Sponsored<br>Text found in the image --  Sponsored<br>Text found in the image --  Sponsored<br>UnMute the video 2025-03-24 16:21:21</pre><h3>Technical Implementation</h3><p><strong>Python Script</strong>:</p><ul><li>Manages screenshot capture, OCR analysis, and Home Assistant API calls running in a loop with fixed timed interval</li><li>Handles macOS Continuity Camera integration,</li></ul><p><strong>Home Assistant Configuration</strong>:</p><ul><li>Exposes RESTful endpoints to control TV audio state (mute/unmute).</li></ul><p><strong>OCR Tuning</strong>:</p><ul><li>Optimized to reduce false positives/negatives by iterating on keyword lists and image preprocessing (e.g., contrast adjustments).</li></ul><h3>Results</h3><p><strong>Proof of Concept</strong>:</p><p>From that moment on, I never had to worry about ads again. Each time one popped up, the system would detect it and mute the sound automatically. When the ad finished, the music would continue as though nothing had ever happened. It was like having my own personal assistant, one that knew exactly when to give me a moment of peace.</p><p>I was finally able to enjoy uninterrupted music, thanks to a combination of technology, a little creativity, and the power of Tesseract OCR. What started as a simple idea turned into a proof of concept solution, and I couldn’t have been more satisfied.</p><ul><li>Successfully muted/unmuted ads during YouTube playback, verified via logs (e.g., Sponsored detection at 16:19:51, unmute at 16:21:21).</li><li>Demo video (<a href="https://youtu.be/mlHj6uKP664">link</a>) shows mute triggers at 0:15 and 1:45.</li></ul><p>Muting : See iphone on bottom left capture screen and notification</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iHdvcFOP8ZP9b8Y-9-BctQ.png" /></figure><p>Unmute: See iphone on bottom left capture screen and notification</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gk9OM91flS16TYHKR-EvjA.png" /></figure><p><strong>Limitations</strong>:</p><ul><li>Latency in image processing and OCR accuracy under varying screen conditions.</li><li>Reliance on static text cues, which may become obsolete if YouTube’s UI changes.</li></ul><h3>Future Enhancements</h3><ol><li><strong>Hardware</strong>: Mount iPhone optimally to capture full-screen content.</li><li><strong>OCR Expansion</strong>: Detect additional keywords (e.g., “Continue Watching?”) for broader use cases.</li><li><strong>Machine Learning</strong>: Replace OCR with vision models for improved ad detection (e.g., logo recognition).</li><li><strong>Platform Extensibility</strong>: Adapt the system for other ad-supported platforms (e.g., Hulu, Twitch).</li></ol><h3>Code &amp; Resources</h3><ul><li><strong>GitHub Repository</strong>: <a href="https://github.com/bipulkkuri/uadmuter">uadmuter</a> (Python scripts, Home Assistant configurations).</li><li><strong>Tools</strong>: Tesseract OCR, Home Assistant, macOS Continuity Camera APIs.,Python env</li></ul><p><strong>Conclusion</strong><br>This project demonstrates a creative, hardware-agnostic approach to ad management using OCR and IoT automation. While not production-grade, it highlights the potential of integrating legacy devices and open-source tools to solve everyday annoyances. Future iterations could leverage machine learning for robustness across platforms.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=524f2af803d9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Prepping the pi]]></title>
            <link>https://bipulkkuri.medium.com/prepping-the-pi-986aed53bb71?source=rss-549610546ab5------2</link>
            <guid isPermaLink="false">https://medium.com/p/986aed53bb71</guid>
            <category><![CDATA[raspberry-pi]]></category>
            <dc:creator><![CDATA[Bipul Kuri]]></dc:creator>
            <pubDate>Wed, 12 Mar 2025 00:47:52 GMT</pubDate>
            <atom:updated>2025-03-12T00:47:52.144Z</atom:updated>
            <content:encoded><![CDATA[<p>So you got the shiny Pi, few things to do first after installing <a href="https://www.raspberrypi.com/software/">Raspberry Pi OS</a></p><p>Adjust screen for wide or vertical screens</p><pre>Resolution fix <br>==============<br>Click the Raspberry Pi icon in the top left corner of your desktop, navigate to &quot;Preferences&quot; and then select &quot;Screen Configuration.&quot;<br>Right Click on HDMU &gt;Resolution -&gt; select 1920X1080</pre><p>and update the world</p><pre>sudo apt update <br>apt list --upgradable<br>sudo apt -y full-upgrade --allow-downgrades<br>sudo rpi-eeprom-update -a</pre><p>Enable SSH</p><pre>sudo raspi-config<br>Interface Options &gt; SSH &gt; Yes</pre><p>Enable VNC on pi5 , if using Mac to connect use Tiger Vnc Viewer or Real VNC viewer</p><pre>sudo raspi-config<br>Interface Options &gt; VNC &gt; Yes</pre><p>Check webcam connected over USB is detected</p><pre><br>$sudo apt install fswebcam<br>$fswebcam -r 1280x720 --no-banner myimage.jpg</pre><p>Create a update script update.sh</p><pre>#!/bin/bash<br><br>sudo apt update <br>apt list --upgradable<br>sudo apt -y full-upgrade --allow-downgrades</pre><p>Place the update.sh in /etc/cron.daily</p><pre>chmod +x update.sh</pre><p>create post login overview in .bashrc file append at last</p><pre>screenfetch</pre><p>this will generate a nice post login stats</p><pre>Linux pi5.local 6.6.74+rpt-rpi-2712 #1 SMP PREEMPT Debian 1:6.6.74-1+rpt1 (2025-01-27) aarch64<br><br>The programs included with the Debian GNU/Linux system are free software;<br>the exact distribution terms for each program are described in the<br>individual files in /usr/share/doc/*/copyright.<br><br>Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent<br>permitted by applicable law.<br>Last login: Tue Mar 11 20:07:19 2025 from 192.168.1.14<br>         _,met$$$$$gg.           pi5@pi5.local<br>      ,g$$$$$$$$$$$$$$$P.        OS: Debian 12 bookworm<br>    ,g$$P&quot;&quot;       &quot;&quot;&quot;Y$$.&quot;.      Kernel: aarch64 Linux 6.6.74+rpt-rpi-2712<br>   ,$$P&#39;              `$$$.      Uptime: 1h 8m<br>  &#39;,$$P       ,ggs.     `$$b:    Packages: 1672<br>  `d$$&#39;     ,$P&quot;&#39;   .    $$$     Shell: bash 5.2.15<br>   $$P      d$&#39;     ,    $$P     Disk: 8.2G / 33G (27%)<br>   $$:      $$.   -    ,d$$&#39;     CPU: ARM Cortex-A76 @ 4x 2.4GHz<br>   $$\;      Y$b._   _,d$P&#39;      GPU: <br>   Y$$.    `.`&quot;Y$$$$P&quot;&#39;          RAM: 1012MiB / 8060MiB<br>   `$$b      &quot;-.__              <br>    `Y$$                        <br>     `Y$$.                      <br>       `$$b.                    <br>         `Y$$b.                 <br>            `&quot;Y$b._             <br>                `&quot;&quot;&quot;&quot;           <br><br>pi5@pi5:~ $</pre><p>Install some tools</p><pre>sudo apt install gparted btop screenfetch</pre><p>and pi Kiss</p><pre>curl -sSL https://git.io/JfAPE | bash</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=986aed53bb71" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Return to routine and a paw promise my AI story]]></title>
            <link>https://bipulkkuri.medium.com/return-to-routine-and-a-paw-promise-my-ai-story-004249128e14?source=rss-549610546ab5------2</link>
            <guid isPermaLink="false">https://medium.com/p/004249128e14</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[pets]]></category>
            <category><![CDATA[return-to-work]]></category>
            <category><![CDATA[mediapipe]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <dc:creator><![CDATA[Bipul Kuri]]></dc:creator>
            <pubDate>Tue, 11 Mar 2025 17:16:51 GMT</pubDate>
            <atom:updated>2025-03-12T00:48:14.040Z</atom:updated>
            <content:encoded><![CDATA[<p>A journey of work home paws and peace of mind. This is a story how I experimented with AI,raspberry pi to help my furry friend to be calm when I am not at home.</p><p>AI you say</p><figure><img alt="Charlie(Dog — Bernedoodle) Always watching and judging" src="https://cdn-images-1.medium.com/max/952/1*6QFLaEkvZQBo2hIvAx06XQ.png" /></figure><p>My Bernedoodle barks whenever he’s left alone. He hates being without anyone to cuddle and often gets anxious or bored when there’s no one around. To help keep him occupied, I’ve set up an AI-powered Raspberry Pi to play sounds for him while I’m away.</p><p>My Journey: Items needed for setup</p><ol><li>Modern HDMI enabled TV/Monitor or speakers</li><li><a href="https://www.raspberrypi.com/products/raspberry-pi-5/">Raspberry Pi5</a></li><li>Microphone HDMI enabled ,I used <a href="https://www.logitech.com/en-us/shop/p/brio-100-webcam.960-001580">https://www.logitech.com/en-us/shop/p/brio-100-webcam.960-001580</a></li><li>USB keyboard and mouse</li><li>Internet Connectivity</li><li>Basic Python know how</li></ol><p>Steps</p><p>Install <a href="https://www.raspberrypi.com/software/">Raspberry Pi OS</a> on SD card,Follow <a href="https://bipulkkuri.medium.com/prepping-the-pi-986aed53bb71">https://bipulkkuri.medium.com/prepping-the-pi-986aed53bb71</a></p><p>Connect keyboard mouse microphone/webcam(with microphone) to pi</p><p>Connect Pi5 to Monitor and enable SSH via</p><p><strong>Access configuration:</strong> Go to the start menu, then “Preferences” &gt; “Raspberry Pi Configuration”.</p><ul><li><strong>Navigate to Interfaces:</strong> Select the “Interfaces” tab.</li><li><strong>Enable SSH:</strong> Toggle the “SSH” option to “On</li></ul><p>Login to pi5 , via remote SSH and List sound devices on pi5</p><pre><br>mkdir rtopaws<br>cd rtopaws<br>sudo apt update<br>sudo apt-get install libportaudio2<br># Install Python dependencies.<br><br><br>python -m venv env<br>source env/bin/activate<br>echo &quot;mediapipe&quot; &gt; requirements.txt<br>python -m pip install pip --upgrade<br>python -m pip install -r requirements.txt</pre><p>Verify the devices are detected</p><pre>#listsounddevices.py <br>import sounddevice<br><br>devs = sounddevice.query_devices()<br>print(devs) # Shows current output and input as well with &quot;&lt;&quot; abd &quot;&gt;&quot; tokens<br>    <br>for dev in devs:<br>    print(dev[&#39;name&#39;])</pre><pre>pip install sounddevice</pre><p>Run to get the list of deviced detected</p><pre>python listsounddevices.py <br>  0 vc4-hdmi-0: MAI PCM i2s-hifi-0 (hw:0,0), ALSA (0 in, 2 out)<br>  1 Brio 100: USB Audio (hw:2,0), ALSA (1 in, 0 out)<br>  2 sysdefault, ALSA (0 in, 128 out)<br>  3 hdmi, ALSA (0 in, 2 out)<br>  4 pulse, ALSA (32 in, 32 out)<br>* 5 default, ALSA (32 in, 32 out)<br>vc4-hdmi-0: MAI PCM i2s-hifi-0 (hw:0,0)<br>Brio 100: USB Audio (hw:2,0)<br>sysdefault<br>hdmi<br>pulse<br>default</pre><p>Record your voice commands on raspberry pi , recorded 3 sec audio on Brio device <strong>(hw:2,0)</strong></p><pre>arecord -D plughw:2,0 --duration=3 goplace.wav</pre><p>This should create a wav file in current dir</p><p>Lets test out the recorded file to play from python</p><pre>#aplay.py <br>import pygame<br>from time import sleep<br>import pygame._sdl2.audio as sdl2_audio<br>import sys<br>pygame.mixer.init()<br>print(sdl2_audio.get_audio_device_names(False)) <br>devices=tuple(sdl2_audio.get_audio_device_names(False)) <br>#get the first device<br>device=devices[0]<br>print(device)<br>pygame.mixer.quit()<br><br>pygame.mixer.init(devicename=device)<br>filetoPlay=sys.argv[1]<br>pygame.mixer.music.load(filetoPlay)<br>pygame.mixer.music.play()<br>sleep(2) <br>pygame.mixer.quit()</pre><p>Play the file</p><pre>python aplay.py goplace.wav <br>pygame 2.6.1 (SDL 2.28.4, Python 3.11.2)<br>Hello from the pygame community. https://www.pygame.org/contribute.html<br>[&#39;Built-in Audio Digital Stereo (HDMI)&#39;]<br>Built-in Audio Digital Stereo (HDMI)</pre><p>Next lets use <a href="https://developers.googleblog.com/en/mediapipe-for-raspberry-pi-and-ios/">mediapipe </a>from google to do bark detection i.e (audio classification),Download the yamnet.tflite model</p><pre>wget -O yamnet.tflite -q https://storage.googleapis.com/mediapipe-models/audio_classifier/yamnet/float32/1/yamnet.tflite</pre><p>Here is the code which does classification</p><pre># Copyright 2023 The MediaPipe Authors. All Rights Reserved.<br>#<br># Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);<br># you may not use this file except in compliance with the License.<br># You may obtain a copy of the License at<br>#<br>#     http://www.apache.org/licenses/LICENSE-2.0<br>#<br># Unless required by applicable law or agreed to in writing, software<br># distributed under the License is distributed on an &quot;AS IS&quot; BASIS,<br># WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<br># See the License for the specific language governing permissions and<br># limitations under the License.<br>&quot;&quot;&quot;Main scripts to run audio classification.&quot;&quot;&quot;<br><br>import argparse<br>import time<br>import subprocess<br>import sys<br><br>from mediapipe.tasks import python<br>from mediapipe.tasks.python.audio.core import audio_record<br>from mediapipe.tasks.python.components import containers<br>from mediapipe.tasks.python import audio<br>#from utils import Plotter<br><br>def run(pet:str,fileToPlay:str,sensitiveLevel: float ,model: str, max_results: int, score_threshold: float,<br>        overlapping_factor: float) -&gt; None:<br>  &quot;&quot;&quot;Continuously run inference on audio data acquired from the device.<br><br>  Args:<br>    model: Name of the TFLite audio classification model.<br>    max_results: Maximum number of classification results to display.<br>    score_threshold: The score threshold of classification results.<br>    overlapping_factor: Target overlapping between adjacent inferences.<br>  &quot;&quot;&quot;<br><br>  if (overlapping_factor &lt; 0) or (overlapping_factor &gt;= 1.0):<br>    raise ValueError(&#39;Overlapping factor must be between 0.0 and 0.9&#39;)<br><br>  if (score_threshold &lt; 0) or (score_threshold &gt; 1.0):<br>    raise ValueError(&#39;Score threshold must be between (inclusive) 0 and 1.&#39;)<br><br>  # Initialize a plotter instance to display the classification results.<br>  #plotter = Plotter()<br><br>  classification_result_list = []<br><br>  def save_result(result: audio.AudioClassifierResult, timestamp_ms: int):<br>    result.timestamp_ms = timestamp_ms<br>    classification_result_list.append(result)<br><br>  # Initialize the audio classification model.<br>  base_options = python.BaseOptions(model_asset_path=model)<br>  options = audio.AudioClassifierOptions(<br>      base_options=base_options, running_mode=audio.RunningMode.AUDIO_STREAM,<br>      max_results=max_results, score_threshold=score_threshold,<br>      result_callback=save_result)<br>  classifier = audio.AudioClassifier.create_from_options(options)<br><br>  # Initialize the audio recorder and a tensor to store the audio input.<br>  # The sample rate may need to be changed to match your input device.<br>  # For example, an AT2020 requires sample_rate 44100.<br>  buffer_size, sample_rate, num_channels = 15600, 16000, 1<br>  audio_format = containers.AudioDataFormat(num_channels, sample_rate)<br>  record = audio_record.AudioRecord(num_channels, sample_rate, buffer_size)<br>  audio_data = containers.AudioData(buffer_size, audio_format)<br><br>  # We&#39;ll try to run inference every interval_between_inference seconds.<br>  # This is usually half of the model&#39;s input length to create an overlapping<br>  # between incoming audio segments to improve classification accuracy.<br>  input_length_in_second = float(len(<br>      audio_data.buffer)) / audio_data.audio_format.sample_rate<br>  interval_between_inference = input_length_in_second * (1 - overlapping_factor)<br>  pause_time = interval_between_inference * 0.1<br>  last_inference_time = time.time()<br><br>  # Start audio recording in the background.<br>  record.start_recording()<br><br>  # Loop until the user close the classification results plot.<br>  while True:<br>    # Wait until at least interval_between_inference seconds has passed since<br>    # the last inference.<br>    now = time.time()<br>    diff = now - last_inference_time<br>    if diff &lt; interval_between_inference:<br>      time.sleep(pause_time)<br>      continue<br>    last_inference_time = now<br><br>    # Load the input audio from the AudioRecord instance and run classify.<br>    data = record.read(buffer_size)<br>    # audio_data.load_from_array(data.astype(np.float32))<br>    audio_data.load_from_array(data)<br>    classifier.classify_async(audio_data, time.time_ns() // 1_000_000)<br><br>    # Plot the classification results.<br>    if classification_result_list:<br>      #print(classification_result_list)<br>      top_category=classification_result_list[0].classifications[0].categories[0]<br>      if(top_category.category_name==pet and top_category.score&gt;sensitiveLevel):<br>        print(f&#39; === found: {top_category.category_name} Score: {top_category.score:.2f}&#39;)<br>        subprocess.run([&#39;python&#39;,&#39;aplay.py&#39;,fileToPlay])<br>      #plotter.plot(classification_result_list[0])<br>      classification_result_list.clear()<br><br><br>def main():<br>  parser = argparse.ArgumentParser(<br>      formatter_class=argparse.ArgumentDefaultsHelpFormatter)<br>  parser.add_argument(<br>      &#39;--pet&#39;,<br>      help=&#39;Pet catagory&#39;,<br>      required=False,<br>      default=&#39;Dog&#39;)<br>  parser.add_argument(<br>      &#39;--playfile&#39;,<br>      help=&#39;Pet command&#39;,<br>      required=False,<br>      default=&#39;goplace.wav&#39;)    <br>  parser.add_argument(<br>      &#39;--sensitive&#39;,<br>      help=&#39;sensitive level&#39;,<br>      required=False,<br>      default=&#39;0.6&#39;)        <br>  parser.add_argument(<br>      &#39;--model&#39;,<br>      help=&#39;Name of the audio classification model.&#39;,<br>      required=False,<br>      default=&#39;yamnet.tflite&#39;)<br>  parser.add_argument(<br>      &#39;--maxResults&#39;,<br>      help=&#39;Maximum number of results to show.&#39;,<br>      required=False,<br>      default=5)<br>  parser.add_argument(<br>      &#39;--overlappingFactor&#39;,<br>      help=&#39;Target overlapping between adjacent inferences. Value must be in (0, 1)&#39;,<br>      required=False,<br>      default=0.5)<br>  parser.add_argument(<br>      &#39;--scoreThreshold&#39;,<br>      help=&#39;The score threshold of classification results.&#39;,<br>      required=False,<br>      default=0.0)<br>  args = parser.parse_args()<br><br>  run(args.pet,args.playfile,float(args.sensitive),args.model, int(args.maxResults), float(args.scoreThreshold),<br>      float(args.overlappingFactor))<br><br><br>if __name__ == &#39;__main__&#39;:<br>  main()</pre><p>Key thing in the code ,when category is dog and sensitive level is greater than 0.6 play the wav file as a subprocess run this in loop</p><pre>if(top_category.category_name==pet and top_category.score&gt;sensitiveLevel):<br>        print(f&#39; === found: {top_category.category_name} Score: {top_category.score:.2f}&#39;)<br>        subprocess.run([&#39;python&#39;,&#39;aplay.py&#39;,fileToPlay])</pre><p>Running the code , with a dog bark</p><pre>python  classify.py <br>Error in cpuinfo: prctl(PR_SVE_GET_VL) failed<br>INFO: Created TensorFlow Lite XNNPACK delegate for CPU.<br>WARNING: All log messages before absl::InitializeLog() is called are written to STDERR<br>W0000 00:00:1741712430.671910   16620 inference_feedback_manager.cc:114] Feedback manager requires a model with a single signature inference. Disabling support for feedback tensors.<br>W0000 00:00:1741712431.707948   16620 time_series_util.cc:52] Timestamp 1741712431.707000 not consistent with number of samples 15600 and initial timestamp 1741712431217000.  Expected timestamp: 1741712432.192000 Timestamp difference: -0.485000 sample_rate: 16000.000000<br> === found: Dog Score: 0.94<br>pygame 2.6.1 (SDL 2.28.4, Python 3.11.2)<br>Hello from the pygame community. https://www.pygame.org/contribute.html<br>[&#39;Built-in Audio Digital Stereo (HDMI)&#39;]<br>Built-in Audio Digital Stereo (HDMI)<br></pre><p>and system usage, you can see both aplay and classify python files executing with near 0 and 0.5% CPU usage</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*22kmiqmDX52bZj_knC3_BA.png" /></figure><p>This can be enhanced to play calming music via youtube api or treat disposal, trigger call to Pet sitter</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=004249128e14" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spring boot kafka docker]]></title>
            <link>https://bipulkkuri.medium.com/spring-boot-kafka-docker-83daec91b473?source=rss-549610546ab5------2</link>
            <guid isPermaLink="false">https://medium.com/p/83daec91b473</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[spring-boot]]></category>
            <dc:creator><![CDATA[Bipul Kuri]]></dc:creator>
            <pubDate>Fri, 06 Sep 2024 22:12:35 GMT</pubDate>
            <atom:updated>2024-09-30T19:10:55.215Z</atom:updated>
            <content:encoded><![CDATA[<p>Spring boot kafka docker</p><p>Lets put Docker in our local env.Make sure you have Docker desktop running, we are opening port 9092 for host laptop so communication is open.</p><pre>%docker run -d -p 9092:9092 --name broker apache/kafka:latest</pre><p>Test it</p><pre>%docker exec --workdir /opt/kafka/bin/ -it broker sh<br><br>/opt/kafka/bin $ ./kafka-topics.sh --bootstrap-server localhost:9092 --create --topic test-topic<br>Created topic test-topic.<br>/opt/kafka/bin $ ./kafka-console-producer.sh --bootstrap-server localhost:9092 --topic test-topic<br>hello-world<br>&gt;^C/opt/kafka/bin $ ./kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test-topic --from-beginning<br><br>hello-world<br>^CProcessed a total of 1 messages</pre><p>Spring boot kafka demo</p><p>Start with Maven install ,this will be our build and dependency management starting point</p><pre>%brew install maven</pre><p>Spring Boot CLI install</p><pre>% brew tap spring-io/tap<br><br>==&gt; Tapping spring-io/tap<br>Cloning into &#39;/opt/homebrew/Library/Taps/spring-io/homebrew-tap&#39;...<br>remote: Enumerating objects: 439, done.<br>remote: Counting objects: 100% (48/48), done.<br>remote: Compressing objects: 100% (35/35), done.<br>remote: Total 439 (delta 14), reused 47 (delta 13), pack-reused 391 (from 1)<br>Receiving objects: 100% (439/439), 63.10 KiB | 1.58 MiB/s, done.<br>Resolving deltas: 100% (137/137), done.<br>Tapped 1 formula (13 files, 80.7KB).<br> % brew install spring-boot<br>==&gt; Downloading https://formulae.brew.sh/api/formula.jws.json<br>######################################################################################################################################### 100.0%<br>==&gt; Downloading https://formulae.brew.sh/api/cask.jws.json<br>######################################################################################################################################### 100.0%<br>==&gt; Fetching spring-io/tap/spring-boot<br>==&gt; Downloading https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-cli/3.3.3/spring-boot-cli-3.3.3-bin.tar.gz<br>######################################################################################################################################### 100.0%<br>==&gt; Installing spring-boot from spring-io/tap<br>==&gt; Caveats<br>zsh completions have been installed to:<br>  /opt/homebrew/share/zsh/site-functions<br>==&gt; Summary<br>🍺  /opt/homebrew/Cellar/spring-boot/3.3.3: 8 files, 6MB, built in 2 seconds<br>==&gt; Running `brew cleanup spring-boot`...<br>Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.<br>Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).<br>%</pre><p>Create a pom.xml</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;<br> xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;<br> &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;<br><br> &lt;groupId&gt;com.example&lt;/groupId&gt;<br> &lt;artifactId&gt;mySbKafkaProject&lt;/artifactId&gt;<br> &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;<br><br> &lt;parent&gt;<br>  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>  &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;<br>  &lt;version&gt;3.3.3&lt;/version&gt;<br> &lt;/parent&gt;<br><br> &lt;!-- Additional lines to be added here... --&gt;<br>  <br>  &lt;properties&gt;<br>    &lt;java.version&gt;17&lt;/java.version&gt;<br>  &lt;/properties&gt;<br>  &lt;dependencies&gt;<br>    &lt;dependency&gt;<br>      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>      &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;<br>    &lt;/dependency&gt;<br><br>    &lt;dependency&gt;<br>      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>      &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;<br>      &lt;scope&gt;test&lt;/scope&gt;<br>    &lt;/dependency&gt;<br>  &lt;/dependencies&gt;<br><br>&lt;build&gt;<br>    &lt;plugins&gt;<br>      &lt;plugin&gt;<br>        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>        &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;<br>      &lt;/plugin&gt;<br>    &lt;/plugins&gt;<br>  &lt;/build&gt;<br>&lt;/project&gt;</pre><p>Create a folder structure for maven project, Can be done via archtype too</p><pre>%mkdir -p src/main/java;mkdir -p src/main/resources;mkdir -p src/test<br>%touch src/main/resources/application.properties<br>%mkdir -p src/main/java/com/example/my-springboot-Kafka-project</pre><p>Add the application code in folder</p><pre>src/main/java/com/example/mySbKafkaProject/MyApplication.java</pre><pre>package com.example.mySbKafkaProject;<br> <br>import org.springframework.boot.SpringApplication;<br>import org.springframework.boot.autoconfigure.SpringBootApplication;<br>import org.springframework.web.bind.annotation.RequestMapping;<br>import org.springframework.web.bind.annotation.RestController;<br><br>@RestController<br>@SpringBootApplication<br>public class MyApplication {<br><br> @RequestMapping(&quot;/&quot;)<br> String home() {<br>  return &quot;Hello World!&quot;;<br> }<br><br> public static void main(String[] args) {<br>  SpringApplication.run(MyApplication.class, args);<br> }<br><br>}</pre><p>Test</p><pre>%mvn spring-boot:run</pre><p>in a different shell</p><pre>% curl http://localhost:8080/<br>Hello World!%                      </pre><p>Now we have a running spring boot web application</p><p>Lets start doing Kafka integration .</p><p>Simple USE CASE:</p><p>Send print timestamps root api was called</p><p>Add package for kafkaservice kafkaProducer and kafkaConsumer.</p><pre>package com.example.mySbKafkaProject.kafkaProducer;<br><br>import org.springframework.beans.factory.annotation.Autowired;<br>import org.springframework.kafka.core.KafkaTemplate;<br>import org.springframework.stereotype.Component;<br><br>@Component<br>public class MessageProducer {<br><br>    @Autowired<br>    private KafkaTemplate&lt;String, String&gt; kafkaTemplate;<br><br>    public void sendMessage(String topic, String message) {<br>        kafkaTemplate.send(topic, message);<br>    }<br><br>}</pre><p>and</p><pre>package com.example.mySbKafkaProject.kafkaProducer;<br><br>import org.apache.kafka.clients.producer.ProducerConfig;<br>import org.apache.kafka.common.serialization.StringSerializer;<br>import org.springframework.context.annotation.Bean;<br>import org.springframework.context.annotation.Configuration;<br>import org.springframework.kafka.core.DefaultKafkaProducerFactory;<br>import org.springframework.kafka.core.KafkaTemplate;<br>import org.springframework.kafka.core.ProducerFactory;<br>import java.util.HashMap;<br>import java.util.Map;<br>@Configuration<br>public class KafkaProducerConfig {<br>    @Bean<br>    public ProducerFactory&lt;String, String&gt; producerFactory() {<br>        Map&lt;String, Object&gt; configProps = new HashMap&lt;&gt;();<br>        configProps.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, &quot;localhost:9092&quot;);<br>        configProps.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);<br>        configProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class);<br>        return new DefaultKafkaProducerFactory&lt;&gt;(configProps);<br>    }<br>    @Bean<br>    public KafkaTemplate&lt;String, String&gt; kafkaTemplate() {<br>        return new KafkaTemplate&lt;&gt;(producerFactory());<br> }<br>}<br><br></pre><p>Modify the main application code</p><pre>package com.example.mySbKafkaProject;<br> <br>import java.text.Format;<br>import java.text.SimpleDateFormat;<br><br>import org.springframework.beans.factory.annotation.Autowired;<br>import org.springframework.boot.SpringApplication;<br>import org.springframework.boot.autoconfigure.SpringBootApplication;<br>import org.springframework.web.bind.annotation.RequestMapping;<br>import org.springframework.web.bind.annotation.RestController;<br><br>import com.example.mySbKafkaProject.kafkaProducer.*;<br><br>@RestController<br>@SpringBootApplication<br>public class MyApplication {<br><br> @Autowired<br>    private MessageProducer messageProducer;<br><br> @RequestMapping(&quot;/&quot;)<br> String home() {<br>  Format formatter = new SimpleDateFormat(&quot;yyyy-MM-dd HH:mm:ss&quot;);<br>  String datestring = formatter.format(new java.util.Date());<br><br>  messageProducer.sendMessage(&quot;my-topic&quot;, datestring);<br>  return &quot;Hello World!&quot;;<br> }<br><br> public static void main(String[] args) {<br>  SpringApplication.run(MyApplication.class, args);<br> }<br><br>}</pre><p>Test the integration</p><pre>% mvn spring-boot:run</pre><p>and call the root api</p><pre>%curl http://localhost:8080/<br>Hello World!%</pre><p>in the docker side command line run a listener</p><pre> % docker exec --workdir /opt/kafka/bin/ -it broker sh<br><br>/opt/kafka/bin $ ./kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test-topic --from-beginning<br><br>[2024-09-06 20:35:57,359] WARN [Consumer clientId=console-consumer, groupId=console-consumer-13364] Error while fetching metadata with correlation id 2 : {test-topic=UNKNOWN_TOPIC_OR_PARTITION} (org.apache.kafka.clients.NetworkClient)<br>^CProcessed a total of 0 messages<br>/opt/kafka/bin $ ./kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic my-topic --from-beginning<br>[2024-09-06 20:36:22,367] WARN [Consumer clientId=console-consumer, groupId=console-consumer-86269] Error while fetching metadata with correlation id 2 : {my-topic=UNKNOWN_TOPIC_OR_PARTITION} (org.apache.kafka.clients.NetworkClient)<br><br>2024-09-06 16:36:29</pre><p>Time to integrate Kafka Consumer</p><pre>package com.example.mySbKafkaProject.kafkaConsumer;<br><br>import org.apache.kafka.clients.consumer.ConsumerConfig;<br>import org.apache.kafka.common.serialization.StringDeserializer;<br>import org.springframework.context.annotation.Bean;<br>import org.springframework.context.annotation.Configuration;<br>import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory;<br>import org.springframework.kafka.core.ConsumerFactory;<br>import org.springframework.kafka.core.DefaultKafkaConsumerFactory;<br><br>import java.util.HashMap;<br>import java.util.Map;<br><br>@Configuration<br>public class KafkaConsumerConfig {<br><br>    @Bean<br>    public ConsumerFactory&lt;String, String&gt; consumerFactory() {<br>        Map&lt;String, Object&gt; configProps = new HashMap&lt;&gt;();<br>        configProps.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, &quot;localhost:9092&quot;);<br>        configProps.put(ConsumerConfig.GROUP_ID_CONFIG, &quot;my-group-id&quot;);<br>        configProps.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);<br>        configProps.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);<br>        return new DefaultKafkaConsumerFactory&lt;&gt;(configProps);<br>    }<br><br>    @Bean<br>    public ConcurrentKafkaListenerContainerFactory&lt;String, String&gt; kafkaListenerContainerFactory() {<br>        ConcurrentKafkaListenerContainerFactory&lt;String, String&gt; factory = new ConcurrentKafkaListenerContainerFactory&lt;&gt;();<br>        factory.setConsumerFactory(consumerFactory());<br>        return factory;<br>    }<br><br>}</pre><p>and the consumer</p><pre>package com.example.mySbKafkaProject.kafkaConsumer;<br><br>import org.springframework.kafka.annotation.KafkaListener;<br>import org.springframework.stereotype.Component;<br><br>@Component<br>public class MessageConsumer {<br><br>    @KafkaListener(topics = &quot;my-topic&quot;, groupId = &quot;my-group-id&quot;)<br>    public void listen(String message) {<br>        System.out.println(&quot;Received message: &quot; + message);<br>       <br>    }<br>    <br>}<br><br></pre><p>on main application MyApplication.java side nothing changes</p><p>on calling the REST API</p><pre>% curl http://localhost:8080/<br>Hello World!%                       </pre><p>from Spring boot side</p><pre>2024-09-06T17:05:57.212-04:00  INFO 84331 --- [nio-8080-exec-1] o.a.k.c.t.i.KafkaMetricsCollector        : initializing Kafka metrics collector<br>2024-09-06T17:05:57.217-04:00  INFO 84331 --- [nio-8080-exec-1] o.a.k.clients.producer.KafkaProducer     : [Producer clientId=producer-1] Instantiated an idempotent producer.<br>2024-09-06T17:05:57.223-04:00  INFO 84331 --- [nio-8080-exec-1] o.a.kafka.common.utils.AppInfoParser     : Kafka version: 3.7.1<br>2024-09-06T17:05:57.223-04:00  INFO 84331 --- [nio-8080-exec-1] o.a.kafka.common.utils.AppInfoParser     : Kafka commitId: e2494e6ffb89f828<br>2024-09-06T17:05:57.223-04:00  INFO 84331 --- [nio-8080-exec-1] o.a.kafka.common.utils.AppInfoParser     : Kafka startTimeMs: 1725656757223<br>2024-09-06T17:05:57.255-04:00  INFO 84331 --- [ad | producer-1] org.apache.kafka.clients.Metadata        : [Producer clientId=producer-1] Cluster ID: 5L6g3nShT-eMCtK--X86sw<br>2024-09-06T17:05:57.258-04:00  INFO 84331 --- [ad | producer-1] o.a.k.c.p.internals.TransactionManager   : [Producer clientId=producer-1] ProducerId set to 1 with epoch 0<br>Received message: 2024-09-06 17:05:57</pre><p>Further enhancement can be done via ReplyingKafkaTemplate and @ GetMapping to respond within the rest calls</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=83daec91b473" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HAproxy lua openssl3 build on rockylinux 8]]></title>
            <link>https://bipulkkuri.medium.com/haproxy-lua-openssl3-build-on-rockylinux-8-de36349dc825?source=rss-549610546ab5------2</link>
            <guid isPermaLink="false">https://medium.com/p/de36349dc825</guid>
            <category><![CDATA[rockylinux]]></category>
            <category><![CDATA[lua]]></category>
            <category><![CDATA[multithreading]]></category>
            <category><![CDATA[haproxy]]></category>
            <category><![CDATA[openssl-3]]></category>
            <dc:creator><![CDATA[Bipul Kuri]]></dc:creator>
            <pubDate>Thu, 21 Dec 2023 14:27:24 GMT</pubDate>
            <atom:updated>2023-12-21T14:27:24.724Z</atom:updated>
            <content:encoded><![CDATA[<p>Here are the steps needed for installing HAProxy with lua and multi threading support with openssl 3</p><p>First install all required libs as root</p><pre>openssl version -a<br>dnf remove openssl<br>dnf -y groupinstall &quot;Development Tools&quot;<br>dnf -y install perl-IPC-Cmd  perl-Pod-Html<br>yum install perl-core zlib-devel -y</pre><p>Build openssl3 with static build</p><pre>wget https://www.openssl.org/source/openssl-3.2.0.tar.gz <br>tar zxf openssl-3.2.0.tar.gz <br>cd openssl-3.2.0<br>./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl static zlib<br>make -j $(nproc)<br>make install<br>ldconfig<br>tee /etc/profile.d/openssl.sh&lt;&lt;EOF<br>export PATH=/usr/local/openssl/bin:\$PATH<br>export LD_LIBRARY_PATH=/usr/local/openssl/lib:/usr/local/openssl/lib64:\$LD_LIBRARY_PATH<br>EOF<br><br>source /etc/profile.d/openssl.sh<br><br>openssl version -a</pre><p>Build LUA</p><pre><br>wget --no-check-certificate https://www.lua.org/ftp/lua-5.4.6.tar.gz<br>tar zxf  lua-5.4.6.tar.gz <br>cd  lua-5.4.6 <br>make linux install<br>lua -v</pre><p>Build HAproxy 2.8.5, follow documentation <a href="http://git.haproxy.org/?p=haproxy-2.8.git;a=blob_plain;f=INSTALL;hb=HEAD">http://git.haproxy.org/?p=haproxy-2.8.git;a=blob_plain;f=INSTALL;hb=HEAD</a></p><pre>wget http://www.haproxy.org/download/2.8/src/haproxy-2.8.5.tar.gz<br>tar zxf  haproxy-2.8.5.tar.gz <br>cd haproxy-2.8.5<br>make clean<br>make   TARGET=linux-glibc USE_PCRE=1 USE_PCRE_JIT=1 USE_OPENSSL=1 USE_ZLIB=1 USE_LINUX_TPROXY=1 USE_REGPARM=1 USE_LUA=1 USE_THREAD=1 USE_TFO=1   SSL_INC=/usr/local/openssl/include SSL_LIB=/usr/local/openssl/lib64<br>make install <br>haproxy -vvv</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de36349dc825" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>