<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: vatana7</title>
    <description>The latest articles on DEV Community by vatana7 (@vatana7).</description>
    <link>https://dev.to/vatana7</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F686845%2Fd945795c-59b1-4c88-921b-b61485c85518.png</url>
      <title>DEV Community: vatana7</title>
      <link>https://dev.to/vatana7</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vatana7"/>
    <language>en</language>
    <item>
      <title>Implementing Recaptcha V3 on Flutter | Flutter Recaptcha V3</title>
      <dc:creator>vatana7</dc:creator>
      <pubDate>Thu, 18 Sep 2025 16:12:29 +0000</pubDate>
      <link>https://dev.to/vatana7/implementing-recaptcha-v3-on-flutter-flutter-recaptcha-v3-144d</link>
      <guid>https://dev.to/vatana7/implementing-recaptcha-v3-on-flutter-flutter-recaptcha-v3-144d</guid>
      <description>&lt;h3&gt;
  
  
  Implementing Google reCAPTCHA v3 in Flutter (Mobile)
&lt;/h3&gt;

&lt;p&gt;I spent hours debugging and researching, only to find the solution was much simpler than I thought. To save you the headache, here’s a step-by-step guide on how to integrate &lt;strong&gt;Google reCAPTCHA v3&lt;/strong&gt; into a Flutter mobile application.&lt;/p&gt;




&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;site key&lt;/strong&gt; from your backend (ask your backend dev or generate one yourself in the &lt;a href="https://www.google.com/recaptcha/admin" rel="noopener noreferrer"&gt;reCAPTCHA admin console&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;Clarify with your backend whether you’re using &lt;strong&gt;Enterprise&lt;/strong&gt; or &lt;strong&gt;Standard (v2/v3)&lt;/strong&gt; reCAPTCHA.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Choosing the Right Package
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Enterprise reCAPTCHA&lt;/strong&gt; → use &lt;a href="https://pub.dev/packages/recaptcha_enterprise_flutter" rel="noopener noreferrer"&gt;&lt;code&gt;recaptcha_enterprise_flutter&lt;/code&gt;&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Standard v2/v3 reCAPTCHA&lt;/strong&gt; → use &lt;a href="https://pub.dev/packages/flutter_gcaptcha_v3" rel="noopener noreferrer"&gt;&lt;code&gt;flutter_gcaptcha_v3&lt;/code&gt;&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This tutorial focuses on &lt;strong&gt;Standard v3&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why You Need a Hosted HTML
&lt;/h2&gt;

&lt;p&gt;Unlike browsers, Flutter apps don’t have a domain. If you try to run reCAPTCHA directly inside a WebView, the domain becomes &lt;code&gt;about:blank&lt;/code&gt;, which Google doesn’t accept.&lt;/p&gt;

&lt;p&gt;The trick:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Host a simple HTML file that loads reCAPTCHA and generates a token.&lt;/li&gt;
&lt;li&gt;Load that HTML inside Flutter’s WebView.&lt;/li&gt;
&lt;li&gt;Pass the generated token back into Flutter.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 You can self-host &lt;a href="https://raw.githubusercontent.com/basnetjiten/flutter_gcaptcha_v3/refs/heads/master/lib/assets/index.html" rel="noopener noreferrer"&gt;this HTML template&lt;/a&gt; or use the demo page at &lt;a href="https://emerald-eran-52.tiiny.site" rel="noopener noreferrer"&gt;https://emerald-eran-52.tiiny.site&lt;/a&gt;.&lt;br&gt;
&lt;em&gt;I recommend self-hosting so you’re not dependent on a third-party site.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;⚠️ Don’t forget to &lt;strong&gt;whitelist your hosted domain&lt;/strong&gt; in the &lt;a href="https://www.google.com/recaptcha/admin" rel="noopener noreferrer"&gt;Google reCAPTCHA admin console&lt;/a&gt;, otherwise tokens will always be invalid.&lt;/p&gt;


&lt;h2&gt;
  
  
  Step 1: Initialize Your Site Key
&lt;/h2&gt;

&lt;p&gt;Place this in your app initialization (e.g. &lt;code&gt;main.dart&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="n"&gt;RecaptchaHandler&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;instance&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setupSiteKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nl"&gt;dataSiteKey:&lt;/span&gt; &lt;span class="n"&gt;AppConstants&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;dataSiteKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 2: Add the Hidden WebView
&lt;/h2&gt;

&lt;p&gt;In your widget tree, include a hidden &lt;code&gt;ReCaptchaWebView&lt;/code&gt; that points to your hosted HTML:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="n"&gt;SizedBox&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nl"&gt;width:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;height:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;Opacity&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nl"&gt;opacity:&lt;/span&gt; &lt;span class="mf"&gt;0.01&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// don’t set 0 (may cull rendering)&lt;/span&gt;
    &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;IgnorePointer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="nl"&gt;ignoring:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;ReCaptchaWebView&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nl"&gt;width:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nl"&gt;height:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nl"&gt;url:&lt;/span&gt; &lt;span class="n"&gt;selfHostedRecaptchaHtml&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// e.g. https://yourdomain.com/recaptcha.html&lt;/span&gt;
        &lt;span class="nl"&gt;onTokenReceived:&lt;/span&gt; &lt;span class="n"&gt;_onTokenReceived&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Handle tokens like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;_onTokenReceived&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Do something with the token (e.g. send to backend)&lt;/span&gt;
  &lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Got reCAPTCHA token: &lt;/span&gt;&lt;span class="si"&gt;$token&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 3: Trigger reCAPTCHA Execution
&lt;/h2&gt;

&lt;p&gt;Whenever you need a fresh token (e.g. on registration, OTP, etc.), call:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="n"&gt;RecaptchaHandler&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;executeV3&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;action:&lt;/span&gt; &lt;span class="s"&gt;'register'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This triggers &lt;code&gt;grecaptcha.execute()&lt;/code&gt; inside your hosted HTML, which passes the token back to Flutter via the WebView → &lt;code&gt;_onTokenReceived&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Wrap-Up
&lt;/h2&gt;

&lt;p&gt;And that’s it — your Flutter app can now generate &lt;strong&gt;Google reCAPTCHA v3 tokens&lt;/strong&gt;!&lt;/p&gt;

&lt;p&gt;✅ Key takeaways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Know if your backend is &lt;strong&gt;Enterprise&lt;/strong&gt; or &lt;strong&gt;Standard&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Always &lt;strong&gt;whitelist your HTML domain&lt;/strong&gt; in Google’s console.&lt;/li&gt;
&lt;li&gt;Self-host the HTML for reliability.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With this setup, you’ll have a secure and smooth reCAPTCHA v3 flow running natively in your Flutter mobile app.&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>dart</category>
      <category>recaptcha</category>
      <category>programming</category>
    </item>
    <item>
      <title>Fixing Aapt2Exception: RES_TABLE_TYPE_TYPE entry offsets overlap actual entry data on Android 35</title>
      <dc:creator>vatana7</dc:creator>
      <pubDate>Mon, 08 Sep 2025 07:22:31 +0000</pubDate>
      <link>https://dev.to/vatana7/fixing-aapt2exception-restabletypetype-entry-offsets-overlap-actual-entry-data-on-android-35-43mg</link>
      <guid>https://dev.to/vatana7/fixing-aapt2exception-restabletypetype-entry-offsets-overlap-actual-entry-data-on-android-35-43mg</guid>
      <description>&lt;p&gt;I spent 5 hours scratching my head over this error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Caused by: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed  
aapt2 E LoadedArsc.cpp:94] RES_TABLE_TYPE_TYPE entry offsets overlap actual entry data.  
aapt2 E ApkAssets.cpp:149] Failed to load resources table in APK '/Users/xxx/Library/Android/sdk/platforms/android-35/android.jar'.  
error: failed to load include path /Users/xxx/Library/Android/sdk/platforms/android-35/android.jar.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even “vibe coding” couldn’t save me 😅, so I dug through StackOverflow and finally found a fix. Sharing it here to save you the pain.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why this happens&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Android SDK 35 ships a different android.jar. Older Gradle/AGP versions can’t parse it properly with the bundled aapt2, so resource linking fails.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Fix&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Open your gradle.properties in the Flutter project root.&lt;/p&gt;

&lt;p&gt;Add the following line (replace /Users/xxx with your SDK path):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;android.aapt2FromMavenOverride=/Users/xxx/Library/Android/sdk/build-tools/35.0.0/aapt2  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Clean and rebuild:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Then you simply run the application on your app and try to rebuild again &lt;/p&gt;

&lt;p&gt;🎉 That’s it! After adding this, my Flutter app built successfully again on Android 35.&lt;/p&gt;

&lt;p&gt;If you hit this error, give it a try. And if you discover another workaround, share it below so others can benefit!&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>programming</category>
      <category>tutorial</category>
      <category>android</category>
    </item>
    <item>
      <title>The Unexpected Struggle of Implementing Custom CAPTCHA on Linux</title>
      <dc:creator>vatana7</dc:creator>
      <pubDate>Thu, 06 Feb 2025 04:51:40 +0000</pubDate>
      <link>https://dev.to/vatana7/the-unexpected-struggle-of-implementing-custom-captcha-on-linux-1kh6</link>
      <guid>https://dev.to/vatana7/the-unexpected-struggle-of-implementing-custom-captcha-on-linux-1kh6</guid>
      <description>&lt;p&gt;Last week, my boss assigned me a seemingly simple task: implement custom CAPTCHA validation for our internal Sales Portal login page. He specifically requested that we avoid Google’s ReCAPTCHA due to regional policies (or whatever reason he had). The requirements were straightforward:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Display a &lt;strong&gt;300px × 76px CAPTCHA image&lt;/strong&gt; with random text and distortion.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Choosing the Right CAPTCHA Solution
&lt;/h3&gt;

&lt;p&gt;I immediately jumped into research mode, looking for a solution. After some time, I stumbled upon &lt;strong&gt;CaptchaGen&lt;/strong&gt;, a handy NuGet package that could generate distorted text images with minimal effort. It seemed like the perfect fit!  &lt;/p&gt;

&lt;p&gt;I quickly implemented it, ran some tests locally, and deployed it to our SIT (System Integration Testing) environment. Everything seemed fine—until I actually tried to use it.  &lt;/p&gt;

&lt;h3&gt;
  
  
  The First Unexpected Issue: 401 Unauthorized
&lt;/h3&gt;

&lt;p&gt;The first thing I noticed after deployment was that calling the CAPTCHA generation endpoint returned a &lt;code&gt;401 Unauthorized&lt;/code&gt; error.  &lt;/p&gt;

&lt;p&gt;Confused, I double-checked my controller—there was no &lt;code&gt;[Authorize]&lt;/code&gt; attribute anywhere. So why was it rejecting unauthenticated requests?  &lt;/p&gt;

&lt;p&gt;After digging through the Jenkins logs, I found the real culprit:  &lt;/p&gt;

&lt;h3&gt;
  
  
  The Hidden Dependency on &lt;code&gt;System.Drawing&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Turns out, &lt;code&gt;CaptchaGen&lt;/code&gt; relies on &lt;code&gt;System.Drawing&lt;/code&gt;, a package that is not supported on Linux—which was a problem because our AKS (Azure Kubernetes Service) environment runs on Linux containers.&lt;/p&gt;

&lt;p&gt;Microsoft officially recommends avoiding &lt;code&gt;System.Drawing&lt;/code&gt; in non-Windows environments starting from .NET 6 because it depends on GDI+, which is Windows-specific.  &lt;/p&gt;

&lt;h3&gt;
  
  
  Switching to a Linux-Friendly Alternative
&lt;/h3&gt;

&lt;p&gt;With that in mind, I had to look for an alternative. After some research, I found &lt;strong&gt;ImageSharp by SixLabors&lt;/strong&gt;—a powerful image processing library that works across different platforms without relying on &lt;code&gt;System.Drawing&lt;/code&gt;.  &lt;/p&gt;

&lt;p&gt;I refactored my implementation using ImageSharp, deployed it, and… hit another frustrating issue.  &lt;/p&gt;

&lt;h3&gt;
  
  
  The Second Issue: Missing Arial Font on Linux
&lt;/h3&gt;

&lt;p&gt;This time, the error said:  &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;CreateFont()&lt;/code&gt; cannot find Arial font on the system.  &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;My first reaction? Huh? Why wouldn’t Arial exist?  &lt;/p&gt;

&lt;p&gt;In my mind, Arial is a universal font—it should be available everywhere, right? Well, turns out, Linux doesn’t come with Arial pre-installed.  &lt;/p&gt;

&lt;p&gt;Here’s the problematic code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;DrawText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;SystemFonts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;CreateFont&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Arial"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fontSize&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;Color&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Gray&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PointF&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;80&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;20&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since Linux lacks Arial by default, &lt;code&gt;SystemFonts.CreateFont("Arial", fontSize)&lt;/code&gt; simply failed to find the font, causing the error.  &lt;/p&gt;

&lt;p&gt;I tried manually installing Arial on AKS, but no luck. After hours of troubleshooting and frustration, I almost gave up—until I stumbled upon the missing piece of the puzzle.  &lt;/p&gt;

&lt;h3&gt;
  
  
  The Solution: Embedding the Font in the Project
&lt;/h3&gt;

&lt;p&gt;The problem was that I was using &lt;code&gt;SystemFonts&lt;/code&gt; instead of loading a custom font file. The solution? Embed the Arial font inside the project** and load it manually.  &lt;/p&gt;

&lt;p&gt;Following &lt;a href="https://docs.sixlabors.com/articles/fonts/gettingstarted.html#loading-fonts" rel="noopener noreferrer"&gt;this official documentation&lt;/a&gt;, I fixed my code by explicitly loading the font from a file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;fontCollection&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;FontCollection&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;fontFamily&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fontCollection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"path/to/arial.ttf"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;font&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fontFamily&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;CreateFont&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fontSize&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;DrawText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;font&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Color&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Gray&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PointF&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;80&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;20&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this approach, the CAPTCHA finally worked flawlessly. 🎉  &lt;/p&gt;

&lt;h3&gt;
  
  
  Lessons Learned
&lt;/h3&gt;

&lt;p&gt;This seemingly simple task turned into an unexpected debugging marathon. But I walked away with a few valuable lessons:  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;em&gt;Read the documentation carefully.&lt;/em&gt;* I wasted time due to my rookie mistake of overlooking compatibility issues.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Linux-based environments handle fonts differently.&lt;/strong&gt; Never assume a font exists—always package the required font with your app if you need it.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Avoid &lt;code&gt;System.Drawing&lt;/code&gt; in non-Windows environments.&lt;/strong&gt; Libraries like &lt;strong&gt;ImageSharp&lt;/strong&gt; are much safer and more portable.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;At the end of the day, I got CAPTCHA working—but not without a battle. Hopefully, this post saves someone else the same headache. 😉  &lt;/p&gt;

</description>
      <category>csharp</category>
      <category>aspdotnet</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>A timezone problem on react-native-paper-date (1day-off)</title>
      <dc:creator>vatana7</dc:creator>
      <pubDate>Mon, 15 Jul 2024 15:09:17 +0000</pubDate>
      <link>https://dev.to/vatana7/a-timezone-problem-on-react-native-paper-date-1day-off-21g5</link>
      <guid>https://dev.to/vatana7/a-timezone-problem-on-react-native-paper-date-1day-off-21g5</guid>
      <description>&lt;p&gt;Today problem is that I encountered an issue while using &lt;code&gt;react-native-paper-dates&lt;/code&gt; and the weekdays appear on the Calendar Modal was not correct. It was off by 1 day, for example today is 15th July 2024 and the 15th was supposed to appear on Monday column but instead it was on the Sunday column instead. &lt;/p&gt;

&lt;p&gt;Eventually I figure out that the problem had something to do with &lt;code&gt;Intl.DateTimeFormat&lt;/code&gt; because I’ve tried running the below code on 2 environment; mine and a Javascript runtime on &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat" rel="noopener noreferrer"&gt;Mozilla.dev&lt;/a&gt; (I know it’s so silly but I tried lol).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Intl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;DateTimeFormat&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;resolvedOptions&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;timeZone&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;//"UTC" on my local development env&lt;/span&gt;
&lt;span class="c1"&gt;//"Asia/Phnom_Penh" on Mozilla.dev&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now I got my clue, so I whine to my co-worker and he mentioned that Javascript’s &lt;code&gt;Intl&lt;/code&gt; isn’t stable for our app. So he sent me this &lt;a href="https://formatjs.io/docs/polyfills/intl-datetimeformat/" rel="noopener noreferrer"&gt;formatjs link&lt;/a&gt; here that mentioned Javascript’s Engine does not expose default timezone so there’s no way to get default timezone from it; and our React native app is using &lt;strong&gt;Hermes Engine&lt;/strong&gt;, which I assume it doesn’t expose anything about timezone to Javascript’s Intl so that’s why it always default to “UTC” when I try to run &lt;code&gt;console.log(Intl.DateTimeFormat().resolvedOptions().timeZone)&lt;/code&gt; . &lt;/p&gt;

&lt;p&gt;Now that I got my answer; I simply try the code below and the issue is resolved. By having a proper timezone, the weekdays are now correct on every column on the Calendar Modal.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@formatjs/intl-datetimeformat/polyfill&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@formatjs/intl-datetimeformat/add-all-tz.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="c1"&gt;//If this statement doesn't work, use expo-localization's getCalendar()&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;timezone&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Intl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;DateTimeFormat&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;resolvedOptions&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;timeZone&lt;/span&gt;

&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;__setDefaultTimeZone&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nx"&gt;Intl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DateTimeFormat&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;Intl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DateTimeFormat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;__setDefaultTimeZone&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;America/Los_Angeles&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;//For my case, I have to use expo-localization&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;timezone&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Localization&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getCalendars&lt;/span&gt;&lt;span class="p"&gt;()[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;timezone&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>reactnative</category>
      <category>javascript</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>how to remove .DS_Store from repository</title>
      <dc:creator>vatana7</dc:creator>
      <pubDate>Fri, 29 Mar 2024 08:06:48 +0000</pubDate>
      <link>https://dev.to/vatana7/how-to-remove-dsstore-2iii</link>
      <guid>https://dev.to/vatana7/how-to-remove-dsstore-2iii</guid>
      <description>&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;Just as you know if you develop your application on MacOS, at one point you will accidentally add this annoying file into your &lt;strong&gt;Github&lt;/strong&gt; repository. &lt;/p&gt;

&lt;p&gt;To get rid of it just head onto your repository using any terminal and then run below command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After this, make sure you &lt;code&gt;git ammend&lt;/code&gt; the last commit and &lt;code&gt;git push --force&lt;/code&gt; to remove &lt;code&gt;.DS_Store&lt;/code&gt; successfully. &lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>tutorial</category>
      <category>javascript</category>
    </item>
    <item>
      <title>PostgreSQL setup via homebrew for junior devs</title>
      <dc:creator>vatana7</dc:creator>
      <pubDate>Wed, 27 Mar 2024 04:54:49 +0000</pubDate>
      <link>https://dev.to/vatana7/postgresql-setup-via-homebrew-for-junior-devs-13pn</link>
      <guid>https://dev.to/vatana7/postgresql-setup-via-homebrew-for-junior-devs-13pn</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;No need to stress it out if you are trying to set up &lt;code&gt;PostgreSQL&lt;/code&gt; on your machine. Just simply follow this guide, you'll be ready in no time.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This guide assumed that you have &lt;code&gt;homebrew&lt;/code&gt; installed already in your terminal. So if you don't please install it and come back to this guide.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Getting PostgreSQL
&lt;/h2&gt;

&lt;p&gt;Run &lt;code&gt;brew install PostgreSQL&lt;/code&gt; then wait for it to finish.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Make sure that you restart your terminal&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Running PostgreSQL in background
&lt;/h2&gt;

&lt;p&gt;Run &lt;code&gt;brew services start PostgreSQL&lt;/code&gt; to start PostgreSQL service. &lt;br&gt;
You only have to run this once because now PostgreSQL will boot up every time you turn on your laptop.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create a database and a superuser
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;To create database, run &lt;code&gt;createdb dbname&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;To create a superuser, run &lt;code&gt;createuser -s postgres&lt;/code&gt;.
Here &lt;code&gt;-s&lt;/code&gt; flag indicate that we're create a superuser.
&lt;code&gt;postgres&lt;/code&gt; is the name that we're giving to the user.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Accessing PostgreSQL
&lt;/h2&gt;

&lt;p&gt;Run &lt;code&gt;psql -U postgres&lt;/code&gt; in your terminal to interact with PostgreSQL. Here &lt;code&gt;-U postgres&lt;/code&gt; indicate that we're interacting as User with the name postgres that we have just created with superuser role.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start interacting with PostgreSQL
&lt;/h2&gt;

&lt;p&gt;Run &lt;code&gt;\l&lt;/code&gt; to list all database or &lt;code&gt;\du&lt;/code&gt; to list all users. To quit PostgreSQL interactive mode simly run &lt;code&gt;\q&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F651hj5f511vnd69a2x5l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F651hj5f511vnd69a2x5l.png" alt=" " width="800" height="188"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's it folks, thank you for reading my post!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>webdev</category>
      <category>database</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>react-native-collapsable-tab-view onScroll not working</title>
      <dc:creator>vatana7</dc:creator>
      <pubDate>Mon, 25 Mar 2024 08:30:10 +0000</pubDate>
      <link>https://dev.to/vatana7/react-native-collapsable-tab-view-onscroll-not-working-2gl0</link>
      <guid>https://dev.to/vatana7/react-native-collapsable-tab-view-onscroll-not-working-2gl0</guid>
      <description>&lt;p&gt;I've been working on a React Native project for about six months. Despite this time, I'm continuously learning and encountering new challenges, underscoring that there's always more to master&lt;/p&gt;

&lt;p&gt;One problem I encountered was a bug in the &lt;code&gt;react-native-collapsible-tab-view&lt;/code&gt; package, specifically related to callback props like &lt;code&gt;onScroll&lt;/code&gt;, &lt;code&gt;onScrollEndDrag&lt;/code&gt;, among others&lt;/p&gt;

&lt;p&gt;Initially I tried to extract the &lt;code&gt;nativeEvent&lt;/code&gt; from onScrollEndDrag inside &lt;code&gt;&amp;lt;Tabs.ScrollView onScrollEndDrag={callback} /&amp;gt;&lt;/code&gt; but it return nothing and I tried everything but I didn't seem to work.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution 1
&lt;/h2&gt;

&lt;p&gt;By using &lt;code&gt;usCurrentTabScrollY()&lt;/code&gt; directly from the package and &lt;code&gt;useAnimatedReaction&lt;/code&gt; from &lt;code&gt;react-native-animated&lt;/code&gt;, you can extract the onScroll's native event value from it by following below code. P.S: This approach only work if you are using that hook separately in a standalone component and it's wrapped by &lt;code&gt;&amp;lt;Tabs.Container&amp;gt;&lt;/code&gt; from &lt;code&gt;react-native-collapsable-tab-view&lt;/code&gt; package.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;scrollY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useCurrentTabScrollY&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="c1"&gt;//Function to extra &lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;scrollHandler&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useCallback&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;//Execute statement with scrollEvent value here&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[]);&lt;/span&gt;

  &lt;span class="nf"&gt;useAnimatedReaction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;scrollY&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;runOnJS&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;scrollHandler&lt;/span&gt;&lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;[],&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Solution 2
&lt;/h2&gt;

&lt;p&gt;Finally, I decided to assign an empty function &lt;code&gt;() =&amp;gt; {}&lt;/code&gt; to &lt;code&gt;onScroll&lt;/code&gt;. After this adjustment, I found that only &lt;code&gt;onScrollEndDrag&lt;/code&gt; callbacks inside &lt;code&gt;&amp;lt;Tabs.ScrollView /&amp;gt;&lt;/code&gt; work and it started to return nativeEvent as expected and functioned properly.&lt;/p&gt;

&lt;p&gt;I hope my experience can offer some guidance. Thank you for reading&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>react</category>
      <category>javascript</category>
      <category>mobile</category>
    </item>
    <item>
      <title>Opensource NextJS Project | Great For Beginner!</title>
      <dc:creator>vatana7</dc:creator>
      <pubDate>Fri, 18 Aug 2023 02:55:00 +0000</pubDate>
      <link>https://dev.to/vatana7/opensource-nextjs-project-great-for-beginner-764</link>
      <guid>https://dev.to/vatana7/opensource-nextjs-project-great-for-beginner-764</guid>
      <description>&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;Recently I have created an open source project that implemented the latest cutting edge technology and packages in order to make myself learn and expand my knowledge overall. &lt;/p&gt;

&lt;p&gt;I am super excited to share this projects with all the people that have started their programming journey. &lt;/p&gt;

&lt;p&gt;Here is the project: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/vatana7/prompt.io" rel="noopener noreferrer"&gt;Project&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Be sure to check it out guys! Thanks&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>nextjs</category>
      <category>typescript</category>
      <category>react</category>
    </item>
    <item>
      <title>Improving Serverless Function response time on Vercel</title>
      <dc:creator>vatana7</dc:creator>
      <pubDate>Thu, 17 Aug 2023 07:47:02 +0000</pubDate>
      <link>https://dev.to/vatana7/improving-serverless-function-on-vercel-response-time-3n8c</link>
      <guid>https://dev.to/vatana7/improving-serverless-function-on-vercel-response-time-3n8c</guid>
      <description>&lt;h3&gt;
  
  
  Introduction &amp;amp; Problem
&lt;/h3&gt;

&lt;p&gt;So I have built a side project in my free time to expand my knowledge on NextJs, the problem that I have found is that when I navigate to my website the first time, I have noticed that the loading time to load data from MongoDB was incredibly slow. Knowing that MongoDb query is fast, I understand that the problem itself was not with MongoDB but it definitely has something to do from my side of development. &lt;/p&gt;

&lt;h3&gt;
  
  
  The Reason
&lt;/h3&gt;

&lt;p&gt;There is a guide on Vercel's webpage explaining why the initial load take time ranging from under 100ms to over 1 seconds because of the fact that every time you load your webpage that isn't visited often (no traffic, only visit by you), your serverless function cease to exist and has to be newly created every time you visit the webpage once in a while. &lt;/p&gt;

&lt;p&gt;This process also known as &lt;strong&gt;(Cold Boot)&lt;/strong&gt;. Any subsequence request after the Cold Boot are going to be much faster and quicker.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feptsbg7pu9yfcgqwf4ly.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feptsbg7pu9yfcgqwf4ly.png" alt="Serverless Function Diagram" width="800" height="177"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see in the diagram, the first two step (Cold Boot) will involve taking time to firing up at the cost of delayed response. &lt;/p&gt;

&lt;h3&gt;
  
  
  Solutions
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;So what should be the solution to the problem? Well the first answer should be obvious to you already. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Your webpage should have moderate traffic to keep the serverless function alive and avoid Cold Boot&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Another solution to change the region that is used to deploy your serverless function in near your database region. In default deployment, your serverless function is deployed in &lt;code&gt;iad1&lt;/code&gt; which is &lt;strong&gt;US, Washington DC&lt;/strong&gt;. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;So in this case, for example if I have my MongoDb instance deployed at &lt;strong&gt;Singapore&lt;/strong&gt; I wouldn't want my serverless function to be deployed at US, the answer should be obvious, of course it has to be the same as Singapore too.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5vm4hx1d8z47fsofw5o3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5vm4hx1d8z47fsofw5o3.png" alt="Available Regions on Vercel Deployment" width="680" height="1062"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Another available solution which is newly introduced into the world of Web Development is &lt;strong&gt;Vercel's Edge Runtime&lt;/strong&gt;. They claimed that it's very fast in the Response time department. I have tried to connect to MongoDB with Edge Runtime but because my app use MongoDB and &lt;a href="https://mongoosejs.com/docs/nextjs.html#nextjs-edge-runtime" rel="noopener noreferrer"&gt;Mongoose doesn't support Edge&lt;/a&gt; yet I have to rely on the region solution as of now.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I hope you learn something new from this article and thank you for reading.&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>typescript</category>
      <category>javascript</category>
      <category>react</category>
    </item>
    <item>
      <title>How to send Email In SpringBoot | SpringBoot Tutorial</title>
      <dc:creator>vatana7</dc:creator>
      <pubDate>Fri, 09 Jun 2023 07:20:20 +0000</pubDate>
      <link>https://dev.to/vatana7/how-to-send-email-in-springboot-springboot-tutorial-4jjm</link>
      <guid>https://dev.to/vatana7/how-to-send-email-in-springboot-springboot-tutorial-4jjm</guid>
      <description>&lt;p&gt;This is a latest guide on how to send Email in your SpringBoot Application. Simply follow these steps to make your Spring Application be able to send Email.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Add Project Dependency
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;dependency&amp;gt;&lt;/span&gt;
 &lt;span class="nt"&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;org.springframework.boot&lt;span class="nt"&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
 &lt;span class="nt"&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;spring-boot-starter-mail&lt;span class="nt"&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/dependency&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Set up App Password inside your Google Account
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Go to (Google Account)[&lt;a href="https://myaccount.google.com" rel="noopener noreferrer"&gt;https://myaccount.google.com&lt;/a&gt;]&lt;/li&gt;
&lt;li&gt;On Search Bar, search for App Passwords then you should see &lt;strong&gt;App Passwords&lt;/strong&gt; with &lt;strong&gt;Security&lt;/strong&gt; under it&lt;/li&gt;
&lt;li&gt;Under &lt;strong&gt;Select App&lt;/strong&gt;, find &lt;strong&gt;Other (Custom Name)&lt;/strong&gt;, input your desired name then click &lt;strong&gt;Generate&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Copy the password we will use it later&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 3: Set up Application.properties
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;spring.mail.username=youremail@gmail.com
spring.mail.properties.mail.smtp.starttls.required=true
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.password=Copied Password From App Password
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.transport.protocol=smtp
spring.mail.properties.mail.smtp.starttls.enable=true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 4: Configure Bean for JavaMailSender
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Configuration&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MailConfiguration&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="nd"&gt;@Bean&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;JavaMailSender&lt;/span&gt; &lt;span class="nf"&gt;getJavaMailSender&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;JavaMailSenderImpl&lt;/span&gt; &lt;span class="n"&gt;mailSender&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;JavaMailSenderImpl&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
        &lt;span class="n"&gt;mailSender&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setHost&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"smtp.gmail.com"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;mailSender&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setPort&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;587&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

        &lt;span class="n"&gt;mailSender&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setUsername&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"your@gmail.com"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;mailSender&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setPassword&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"copiedPassword"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

        &lt;span class="nc"&gt;Properties&lt;/span&gt; &lt;span class="n"&gt;props&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mailSender&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getJavaMailProperties&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
        &lt;span class="n"&gt;props&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;put&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"mail.transport.protocol"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"smtp"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;props&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;put&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"mail.smtp.auth"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"true"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;props&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;put&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"mail.smtp.starttls.enable"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"true"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;props&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;put&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"mail.debug"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"true"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;mailSender&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 5: Implement MailSenderService
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Service&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MailSenderService&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nd"&gt;@Autowired&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;JavaMailSender&lt;/span&gt; &lt;span class="n"&gt;mailSender&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;sendNewMail&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;subject&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;SimpleMailMessage&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;SimpleMailMessage&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
        &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setTo&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setSubject&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;subject&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setText&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;mailSender&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;send&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 6: Start sending email
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="nc"&gt;MailSenderService&lt;/span&gt; &lt;span class="n"&gt;mailService&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;Foo&lt;/span&gt;&lt;span class="o"&gt;(){&lt;/span&gt;
 &lt;span class="n"&gt;mailService&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;sendNewMail&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"test@gmail.com"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Subject right here"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Body right there!"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I hope this guide will help you. Thanks for reading!&lt;/p&gt;

</description>
      <category>spring</category>
      <category>springboot</category>
      <category>java</category>
      <category>programming</category>
    </item>
    <item>
      <title>Localhost:5000 Access Denied on MacOS | How do you fix it?</title>
      <dc:creator>vatana7</dc:creator>
      <pubDate>Fri, 09 Jun 2023 06:49:43 +0000</pubDate>
      <link>https://dev.to/vatana7/localhost5000-access-denied-on-macos-how-do-you-fix-it-e8o</link>
      <guid>https://dev.to/vatana7/localhost5000-access-denied-on-macos-how-do-you-fix-it-e8o</guid>
      <description>&lt;p&gt;In order to fix above issue, you simply have to turn off Airplay Receiver inside your macBook's System Preference.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2g0lcp9pyrhr5kg3rnyx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2g0lcp9pyrhr5kg3rnyx.png" alt=" " width="800" height="649"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It turns out that Airplay Receiver is using Port 5000 for whatever reason it has. I hope this will fix your current issue. &lt;/p&gt;

&lt;p&gt;Thanks!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>tutorial</category>
      <category>codenewbie</category>
      <category>programming</category>
    </item>
    <item>
      <title>How to fix IntelliJ debugger trigger breakpoint only once until restart Server/Application</title>
      <dc:creator>vatana7</dc:creator>
      <pubDate>Sun, 28 May 2023 09:27:49 +0000</pubDate>
      <link>https://dev.to/vatana7/how-to-fix-intellij-debugger-trigger-breakpoint-only-once-until-restart-serverapplication-ggc</link>
      <guid>https://dev.to/vatana7/how-to-fix-intellij-debugger-trigger-breakpoint-only-once-until-restart-serverapplication-ggc</guid>
      <description>&lt;h2&gt;
  
  
  Problem:
&lt;/h2&gt;

&lt;p&gt;I would say I debug a lot of the time but I am not really an expert on how to use the debugger tool to its full potential so there's some knowledge limitation to how I can use the debugger.&lt;/p&gt;

&lt;p&gt;I was developing Java application and I used Jboss EAP for web server for my Java application to run but as I debug the application I always finish the debug by using &lt;strong&gt;the Run to caret position&lt;/strong&gt; button and the breakpoint was never trigger ever again until I restart the server.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution to the problem:
&lt;/h2&gt;

&lt;p&gt;This is my current version of IntelliJ Idea:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;IntelliJ IDEA 2022.3.3 (Ultimate Edition)
Build #IU-223.8836.41, built on March 10, 2023
Runtime version: 17.0.6+1-b653.34 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 13.4
Kotlin: 223-1.8.0-release-345-IJ8836.41
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For you to hit the breakpoint as many time as you want, you would have to click on &lt;strong&gt;Resume Program Execution&lt;/strong&gt; after your debug session. (Red Circle)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm8ghhx50xentuladdj35.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm8ghhx50xentuladdj35.png" alt="Resume Program Execution" width="800" height="238"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you click on &lt;strong&gt;Run to where caret is&lt;/strong&gt;, the debugger won't be able to re-hit the breakpoint again until you restart your server or application. (Red Circle)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyfmbyf0t7jiznsrbw096.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyfmbyf0t7jiznsrbw096.png" alt="Run to where caret is" width="800" height="211"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hope this help&lt;/p&gt;

</description>
      <category>java</category>
      <category>beginners</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
