<?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 thewh1teagle on Medium]]></title>
        <description><![CDATA[Stories by thewh1teagle on Medium]]></description>
        <link>https://medium.com/@thewh1teagle?source=rss-11cc17f05a25------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*2FW0cw5HdJ7xjbGg5jSWOg.jpeg</url>
            <title>Stories by thewh1teagle on Medium</title>
            <link>https://medium.com/@thewh1teagle?source=rss-11cc17f05a25------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 23:06:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@thewh1teagle/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[Logging in NodeJS that make sense]]></title>
            <link>https://medium.com/@thewh1teagle/logging-in-nodejs-that-make-sense-127738d89a86?source=rss-11cc17f05a25------2</link>
            <guid isPermaLink="false">https://medium.com/p/127738d89a86</guid>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[thewh1teagle]]></dc:creator>
            <pubDate>Thu, 19 Sep 2024 16:29:42 GMT</pubDate>
            <atom:updated>2024-09-19T16:31:13.981Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7czSGE07FIYhsQQ1" /><figcaption>Photo by <a href="https://unsplash.com/@lucabravo?utm_source=medium&amp;utm_medium=referral">Luca Bravo</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Short tutorial for simple yet essential logging setup in NodeJS.</p><p>My goal was to configure NodeJS to log just like with Rust.</p><ul><li>Show file and line numbers</li><li>Control level by env variable</li></ul><p>Here are the steps</p><p>Use tslog library:</p><pre>npm install tslog</pre><p>Create log.ts</p><pre>import { ILogObj, Logger } from &quot;tslog&quot;;<br><br>const minLevelMap: { [key: string]: number } = {<br>  silly: 0,<br>  trace: 1,<br>  debug: 2,<br>  info: 3,<br>  warn: 4,<br>  error: 5,<br>  fatal: 6,<br>};<br><br>const defaultLevel: number = 3;<br>const logLevel: number =<br>  minLevelMap[process.env.LOG_LEVEL?.toLowerCase() || &quot;info&quot;] ?? defaultLevel;<br><br>const log: Logger&lt;ILogObj&gt; = new Logger({ minLevel: logLevel });<br><br>export default log;</pre><p>Use in other files</p><pre>import log from &#39;./log&#39;<br><br>log.info(&#39;Finally useful logging&#39;, &#39;with chaining&#39;, 1, 2, 3)<br>log.debug(&#39;With levels controlled by LOG_LEVEL env&#39;)</pre><p>This will produce:</p><pre>2024-09-19 16:27:44.171 DEBUG   /another.js:3   hello from another file<br>2024-09-19 16:27:44.178 INFO    /index.js:6     Finally useful logging with chaining 1 2 3<br>2024-09-19 16:27:44.178 DEBUG   /index.js:7     With levels controlled by LOG_LEVEL env</pre><p>For controlling the logging, just set the environment variable LOG_LEVEL to one of SILLY TRACE DEBUG INFO WARN ERROR FATAL</p><p>In case you working on repository which includes bundling into single file, you still can use it. just set inlineSourceMap to true inside tsconfig.json under compilerOptions .</p><p>I really hope that NodeJS ecosystem will start gather Rust ideas more…</p><p>Happy logging!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=127738d89a86" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Git commit signing made easy]]></title>
            <link>https://medium.com/@thewh1teagle/git-commit-signing-made-easy-8ca26a79c962?source=rss-11cc17f05a25------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ca26a79c962</guid>
            <dc:creator><![CDATA[thewh1teagle]]></dc:creator>
            <pubDate>Thu, 11 Jul 2024 13:03:32 GMT</pubDate>
            <atom:updated>2024-11-07T12:29:13.039Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Rvs_UN-yCitg4f2t" /><figcaption>Photo by <a href="https://unsplash.com/@synkevych?utm_source=medium&amp;utm_medium=referral">Roman Synkevych</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Hey everyone! All the tutorials I found on setting up Git commit signing were very complicated, so here’s a simple and straightforward guide to get you started.</p><p>Prerequisites:</p><p>1. Install <a href="https://gpgtools.org/">gpgtools</a> on macOS and <a href="https://git-scm.com/downloads">git</a> on Windows or <em>sudo apt-get install gpa seahorse git</em> on Linux.<br>2. Open <em>notepad.exe</em><br>3. Open <a href="https://github.com/settings/emails">github.com/settings/emails</a><br>4. Copy your Github email to notepad (ends with <em>@users.noreply.github</em>)<br>5. Open <em>terminal</em><br>6. Create new ssh key</p><pre>ssh-keygen -t ed25519 -C &quot;{email}&quot;<br>You can press enter in the prompts.</pre><p>6. Open both public and private key files in text editor and then paste them to <em>notepad</em><br>7. Open <a href="https://github.com/settings/ssh/new">github.com/settings/ssh/new</a><br>8. Set title to <em>{Year/Month/Day}</em>, value to public key value, key type to <em>signingKey</em><br>9. Configure <em>git</em></p><pre>git config --global user.name &quot;{username}&quot;<br>git config --global user.email &quot;{email}&quot;<br>git config --global user.signingkey &quot;C:\Users\{username}\.ssh\{private_key}&quot;<br>git config --global commit.gpgsign true<br>git config --global gpg.format ssh</pre><p>That’s it 👍🏼😊</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ca26a79c962" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating Vibe: Multilingual Audio Transcription]]></title>
            <link>https://medium.com/@thewh1teagle/creating-vibe-multilingual-audio-transcription-872ab6d9dbb0?source=rss-11cc17f05a25------2</link>
            <guid isPermaLink="false">https://medium.com/p/872ab6d9dbb0</guid>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[podcast]]></category>
            <category><![CDATA[audio]]></category>
            <dc:creator><![CDATA[thewh1teagle]]></dc:creator>
            <pubDate>Wed, 24 Jan 2024 12:24:23 GMT</pubDate>
            <atom:updated>2024-02-05T18:24:21.062Z</atom:updated>
            <content:encoded><![CDATA[<h3><em>The Cry for Help</em></h3><p>It all started with a simple plea from a friend who missed crucial classes. He needed transcriptions, and I was determined to find an open-source solution to make the process painless. Little did I know, this quest would lead to the creation of <a href="https://thewh1teagle.github.io/vibe">Vibe</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*F1oPTcuRWrSiqhgK" /></figure><h3><em>The Void in the Open Source Landscape</em></h3><p>My search for a user-friendly, open-source transcription tool left me empty-handed. Frustrated by the lack of options that suited my friend’s needs, the idea dawned on me — why not build one myself?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*Lrhjszi8mB3Em1yb.jpg" /></figure><h3><em>The Foundation: whisper.cpp and Rust Bindings</em></h3><p>To kickstart the project, I turned to the robust whisper.cpp, an open-source gem. Given my affinity for Rust, I seamlessly integrated its bindings, laying the groundwork for what would become ‘Vibe.’</p><h3><em>Crafting a Tauri Desktop Experience</em></h3><p>Being a fan of Tauri desktop apps, I decided to harness their power in crafting a sleek and user-friendly interface for Vibe. The marriage of whisper-bindings and Tauri gave birth to an application that was as elegant as it was functional.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-My396xHaZ_IoDru.png" /></figure><h3><em>Expanding Horizons: Compiling for MacOS, Linux, and Windows</em></h3><p>Ensuring accessibility for users across different operating systems became a priority. Through meticulous effort, I compiled Vibe for MacOS, Linux, and Windows, widening its reach and potential impact.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dHH3JkgWo8gJjBq8.jpg" /></figure><h3><em>Turbocharging Performance: CPU and GPU Optimization</em></h3><p>The quest for perfection didn’t end with basic functionality. To elevate Vibe’s performance, I delved into CPU optimization with openBLAS and tapped into GPU power with opencore. The results were astounding — a 30x speed boost that transformed Vibe into a powerhouse.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HzS7Gw1Dk-rvCffbF_yY3g.png" /></figure><h3><em>Vibe — More Than Just Transcription</em></h3><p>What began as a response to a friend’s plea evolved into ‘Vibe’ — a multifaceted tool that not only bridges the transcription gap but does so with speed and elegance. The journey was challenging, filled with learning curves and triumphs, but Vibe now stands as a testament to the possibilities that arise when necessity meets creativity in the world of open source.</p><p><a href="https://thewh1teagle.github.io/vibe/">Vibe.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=872ab6d9dbb0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Whitelist IP Addresses by Country on a Linux Server]]></title>
            <link>https://medium.com/@thewh1teagle/whitelist-ip-addresses-by-country-on-a-linux-server-4ee464f5e1b5?source=rss-11cc17f05a25------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ee464f5e1b5</guid>
            <category><![CDATA[sysadmin]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[iptables]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[thewh1teagle]]></dc:creator>
            <pubDate>Sun, 22 Oct 2023 20:34:31 GMT</pubDate>
            <atom:updated>2023-10-22T21:02:56.153Z</atom:updated>
            <content:encoded><![CDATA[<p>In this post I will explain how to configure iptables on Linux server to allow incoming connectins only from specific country</p><ol><li>First let’s start by backup, we want to easily restore things if something is broken after these changes</li></ol><p>Create new folder to store the files in home</p><pre>mkdir iptables_rules &amp;&amp; cd iptables_rules<br>sudo iptables-save &gt; iptables-backup.txt</pre><p>2. Grab the ips ranges from</p><p><a href="https://www.ip2location.com/free/visitor-blocker">Block Visitors by Country | IP2Location</a></p><p>Select the countries you would like to whitelist,</p><p>this is the countries that you will allow clients to connect from</p><p>other countries will not be able to connect</p><p>Select CIDR format and download</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M7Zf-Hbvi4KF5kMLsd7xiw.png" /></figure><p>3. Upload the list to the server, you can use sftp or winscp</p><p>4. install packages and start iptables</p><pre>sudo apt install iptables ipset -y<br>sudo service iptables start</pre><p>5. create new script apply.sh</p><pre>#!/bin/bash<br><br># Flush existing rules<br>iptables -F<br><br># Allow incoming SSH traffic (change the port if needed)<br>iptables -A INPUT -p tcp --dport 22 -j ACCEPT<br><br># Create an IPSet to store the whitelisted IP ranges<br>ipset create whitelist hash:net<br><br># Read the CIDR file and add the IP ranges to the IPSet<br>while read line; do ipset add whitelist $line; done &lt; firewall.txt<br><br># Allow incoming connections from the whitelisted IP addresses<br>iptables -A INPUT -m set --match-set whitelist src -j ACCEPT<br><br># Allow established and related connections<br>iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT<br><br># Allow all loopback traffic<br>iptables -I INPUT 1 -i lo -j ACCEPT<br><br># Drop all other incoming connections<br>iptables -A INPUT -j DROP</pre><p>rename the txt file you uploaded to firewall.txt</p><p>6. Execute the script</p><pre>chmod +x apply.sh &amp;&amp; ./apply.sh</pre><p>That’s all!</p><p>Now incoming connections will allowed only from the country you choosed.</p><p>In case you would like to restore the iptables backup simply execute</p><pre>sudo iptables-restore &lt; iptables-backup.txt</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ee464f5e1b5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Uploading Files to S3 Using Fetch API]]></title>
            <link>https://medium.com/@thewh1teagle/uploading-files-to-s3-using-fetch-api-9e8834310043?source=rss-11cc17f05a25------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e8834310043</guid>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[s3-bucket]]></category>
            <category><![CDATA[vitejs]]></category>
            <dc:creator><![CDATA[thewh1teagle]]></dc:creator>
            <pubDate>Tue, 18 Jul 2023 15:12:47 GMT</pubDate>
            <atom:updated>2023-09-12T10:19:30.213Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*r3lYgByCdEuaCgGp" /><figcaption>Photo by <a href="https://unsplash.com/@growtika?utm_source=medium&amp;utm_medium=referral">Growtika</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In this post I will introduce an afficient pattern for your full stack app, to upload files directly from client side in secure way.</p><h3>The pattern</h3><ol><li>You have form with file input</li><li>User select file and submit the form</li><li>Instead of sending the files itself</li></ol><p>we request from the server to generate signed temporary URL which allows us to upload directly into S3 bucket</p><p>4. We upload the file to S3 and get the URL</p><p>5. We send the form with the URL of the image</p><p>Now we have the reference for our file in our server!</p><h3>Diving into it</h3><p>We will create Express.JS server and React.JS client for trying this pattern</p><p>I’m assuming you already have S3 Object Storage</p><p>In my case I used S3 equivalent from Linode</p><p>access key secret key</p><p>and url for your object storage</p><p>and Of course NodeJS installed.</p><h3>Setup the server</h3><p>Create new TypeScript project</p><pre>npm init -y<br>npm i -D typescript @types/node<br>npx tsc --init</pre><p>Open package.json and change scripts as follow</p><pre>{<br>  ...<br>  &quot;scripts&quot;: {<br>    &quot;start&quot;: &quot;tsc &amp;&amp; node server.js&quot;,<br>  },<br>}</pre><p>Install dependencies</p><pre>npm i express cors uuid dotenv  @aws-sdk/client-s3 @aws-sdk/s3-request-presigner aws-sdk<br>npm i -D @types/cors @types/express @types/node @types/uuid</pre><p>Create new file called server.ts and put the following</p><pre>import express from &#39;express&#39;<br>import cors from &#39;cors&#39;<br>import { Credentials } from &#39;aws-sdk&#39;;<br>import { S3Client, ListBucketsCommand, PutObjectCommand, DeleteObjectCommand  } from &#39;@aws-sdk/client-s3&#39;;<br>import { getSignedUrl } from &#39;@aws-sdk/s3-request-presigner&#39;<br>import dotenv from &#39;dotenv&#39;<br>import { v4 as uuid } from &#39;uuid&#39;;<br><br>dotenv.config()<br><br>const s3Client = new S3Client({<br>    region: process.env.OBJECT_STORAGE_REGION,<br>    endpoint: process.env.OBJECT_STORAGE_ENDPOINT,<br>    credentials: new Credentials({<br>        accessKeyId: process.env.OBJECT_STORAGE_ACCESS_KEY_ID!,<br>        secretAccessKey: process.env.OBJECT_STORAGE_SECRET_ACCESS_KEY!,<br>    }),<br>})<br><br>async function deleteObject(key: string) {<br>    const res = await s3Client.send(new DeleteObjectCommand({<br>        Bucket: process.env.OBJECT_STORAGE_BUCKET!, Key: key<br>    }))<br>    return res<br>}<br><br>async function generateSignedURL(key: string) {<br>    const expireSeconds = 60 * 5 // 5 mintues<br>    const signedURL = await getSignedUrl(s3Client, new PutObjectCommand({Bucket: process.env.OBJECT_STORAGE_BUCKET!, Key: key}), {expiresIn: expireSeconds})<br>    return signedURL<br>}<br><br>const app = express()<br>app.use(express.json())<br>app.use(cors())<br><br><br>app.get(&#39;/requestUpload&#39;, async (req, res) =&gt; {<br>    const url = await generateSignedURL(uuid())<br>    return res.json({url})<br>})<br><br>app.listen(3000, () =&gt; {<br>    console.log(&#39;app listening on http://localhost:3000&#39;)<br>})</pre><p>create new .env file and put the values of your S3</p><pre>OBJECT_STORAGE_REGION=&quot;...&quot;<br>OBJECT_STORAGE_ENDPOINT=&quot;...&quot;<br>OBJECT_STORAGE_ACCESS_KEY_ID=&quot;...&quot;<br>OBJECT_STORAGE_SECRET_ACCESS_KEY=&quot;...&quot;<br>OBJECT_STORAGE_BUCKET=&quot;...&quot;</pre><ul><li>Endpoint should start with https://</li><li>Region should be something like eu-central-1</li></ul><p>Run the server</p><pre>npm start</pre><h3>Setup the client</h3><p>create new vite project</p><pre>npm create vite@latest</pre><ul><li>Framework should be React</li><li>Variant should be TypeScript + SWC</li></ul><p>Install dependencies</p><pre>npm i</pre><p>Open App.tsx and copy and paste from here</p><pre>/* eslint-disable @typescript-eslint/no-unsafe-member-access */<br>/* eslint-disable @typescript-eslint/no-unsafe-assignment */<br>import { useState } from &quot;react&quot;;<br>export default function Upload() {<br>  const [file, setfile] = useState&lt;File&gt;();<br><br>  async function handleUpload(event: React.FormEvent&lt;HTMLFormElement&gt;) {<br>    event?.preventDefault();<br>    const res = await fetch(&#39;http://localhost:3000/requestUpload&#39;)<br>    const data = await res.json()<br>    const signedURL = data?.url as string<br><br>    const headers: any = {}<br>    if (file?.type) {<br>      headers[&#39;Content-Type&#39;] = file!.type<br>    }<br>      <br>    const uploaded = await fetch(signedURL, {<br>      method: &quot;PUT&quot;,<br>      body: file,<br>      headers,<br>    });<br>    if (uploaded.status == 200) {<br>      // Successfully uploaded image<br>      alert(&#39;Uploaded successfuly to &#39; + signedURL)<br>    } else {<br>      alert(&#39;failed to upload&#39;)<br>    }<br>  }<br><br>  const handleChange = (e: React.ChangeEvent&lt;HTMLInputElement&gt;) =&gt; {<br>    const file = e?.target?.files?.[0];<br>    setfile(file);<br>  };<br>  <br>  return (<br>    &lt;form onSubmit={handleUpload}&gt;<br>      &lt;input type=&quot;file&quot; onChange={handleChange} /&gt;<br>      &lt;button type=&quot;submit&quot;&gt;Upload&lt;/button&gt;<br>    &lt;/form&gt;<br>  );<br>}</pre><p>As you can see, we use signedURL which our server sign,</p><p>and that’s because we don’t want to expose S3 secrets for client side</p><p>Now open <a href="http://localhost:5173/">http://localhost:5173</a> and upload some file.</p><h3>Gotachs</h3><h4>Can’t upload files with cors errors</h4><p>If you use amazon s3 for that, you will probably need to configure cors</p><p>Open permissions tab of s3 in amazon management website</p><p>and add this CORS policy:</p><pre>[{<br> &quot;AllowedHeaders&quot;: [<br>  &quot;*&quot;,<br>        &quot;Content-Type&quot;<br> ],<br> &quot;AllowedMethods&quot;: [<br>  &quot;PUT&quot;,<br>  &quot;POST&quot;,<br>  &quot;DELETE&quot;,<br>  &quot;GET&quot;<br> ],<br> &quot;AllowedOrigins&quot;: [<br>  &quot;*&quot;<br> ],<br> &quot;ExposeHeaders&quot;: [<br>  &quot;Access-Control-Allow-Origin&quot;<br> ]<br>}]</pre><p>Don’t forget to change it on production environment!</p><h4><strong>Can’t Access files for reading publicly</strong></h4><p>You need to configure <strong>bucket policy </strong>to allow public reading of objects.</p><p>Open permission tab in bucket settings, and paste it there in <strong>bucket policy </strong>section</p><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Principal&quot;: &quot;*&quot;,<br>            &quot;Action&quot;: &quot;s3:GetObject&quot;,<br>            &quot;Resource&quot;: &quot;arn:aws:s3:::&lt;bucket_name&gt;/*&quot;<br>        }<br>    ]<br>}</pre><h3>Well done</h3><p>You learned how to upload files to S3 directly from client side using fetchAPI</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e8834310043" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>