<?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 Paween Pongthong on Medium]]></title>
        <description><![CDATA[Stories by Paween Pongthong on Medium]]></description>
        <link>https://medium.com/@paween-p?source=rss-51bab31ea05c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Ze7u99mdHbSNmzMX.</url>
            <title>Stories by Paween Pongthong on Medium</title>
            <link>https://medium.com/@paween-p?source=rss-51bab31ea05c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 05:48:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@paween-p/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[Stop Rendering the DOM: The Ultimate Hack for Enterprise Angular Testing]]></title>
            <link>https://paween-p.medium.com/stop-rendering-the-dom-the-ultimate-hack-for-enterprise-angular-testing-57475f882296?source=rss-51bab31ea05c------2</link>
            <guid isPermaLink="false">https://medium.com/p/57475f882296</guid>
            <category><![CDATA[unit-testing]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[performance-optimization]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Paween Pongthong]]></dc:creator>
            <pubDate>Tue, 09 Jun 2026 06:54:50 GMT</pubDate>
            <atom:updated>2026-06-09T07:19:26.276Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8DH205VdpayKcmnddOCafA.jpeg" /></figure><p>When your Angular project scales to the enterprise level, one thing that inevitably scales with it is your unit test suite — growing from hundreds to tens of thousands of cases. When you hit that point, <strong>“speed”</strong> becomes a critical metric for Developer Experience (DX).</p><p>Many teams struggle with CI/CD pipelines that take 30 minutes or more just to run unit tests. But what if you could execute <strong>over 20,000 test cases in just over a minute?</strong></p><p>This article dives into a <strong>pragmatic hack</strong> for writing Angular tests. By changing our mindset and completely bypassing the UI/DOM creation process, we can speed up test execution by 10x!</p><blockquote><em>“In large-scale systems, every millisecond saved per test case — multiplied by tens of thousands — translates to hours of engineering time reclaimed to focus on actual development.”</em></blockquote><h3>The Overhead of the Standard Approach: TestBed.createComponent()</h3><p>Typically, the standard way to write Angular Component tests (as seen in the official docs) is by using TestBed.createComponent(). The underlying process for this is quite heavyweight because Angular has to:</p><ol><li>Compile the HTML Template and parse the CSS Styles of the component.</li><li>Create a simulated DOM Tree in memory.</li><li>Set up Data Binding and prepare the Change Detection system.</li></ol><p>If your components contain complex business logic and you have a massive test suite, carrying the overhead of DOM creation and UI management in every single beforeEach block will skyrocket your execution time from a few milliseconds to tens or hundreds of milliseconds per test.</p><h3>The Logic-Only Alternative: TestBed.inject(Component)</h3><p>If your team has agreed that <strong>“for this specific unit test suite, we only want to test the business logic, variables, and conditions inside the TypeScript class, without caring about the UI rendering,”</strong> then letting Angular build the UI is unnecessary overhead.</p><p>Angular’s Dependency Injection (DI) system essentially views a Component as a standard Class with metadata. Therefore, we can use the TestBed.inject(Component) command to grab the pure Class Instance directly, completely skipping the HTML/DOM process.</p><h3>Code Comparison: Traditional vs. Fast Inject</h3><h3>1. The Traditional Approach (UI/DOM Included)</h3><p>TypeScript</p><pre>describe(&#39;BilledInfoComponent (Traditional)&#39;, () =&gt; {<br>  let component: BilledInfoComponent;<br>  let fixture: ComponentFixture&lt;BilledInfoComponent&gt;;<br><br>  beforeEach(async () =&gt; {<br>    await TestBed.configureTestingModule({<br>      declarations: [ BilledInfoComponent ],<br>      providers: [ { provide: BillingService, useValue: mockBillingService } ]<br>    }).compileComponents();<br>    // ❌ Wastes time creating the DOM, parsing Templates, and CSS here<br>    fixture = TestBed.createComponent(BilledInfoComponent);<br>    component = fixture.componentInstance;<br>    fixture.detectChanges(); <br>  });<br>  it(&#39;should calculate total amount correctly&#39;, () =&gt; {<br>    component.items = [{ price: 100 }, { price: 200 }];<br>    component.calculateTotal();<br>    expect(component.totalAmount).toBe(300);<br>  });<br>});</pre><h3>2. The New Approach using inject() (Logic Focused)</h3><p>TypeScript</p><pre>describe(&#39;BilledInfoComponent (Fast Inject)&#39;, () =&gt; {<br>  let component: BilledInfoComponent;<br>  beforeEach(() =&gt; {<br>    TestBed.configureTestingModule({<br>      // ✅ No need to put the Component in &#39;declarations&#39;; put it in &#39;providers&#39; instead<br>      providers: [<br>        BilledInfoComponent, <br>        { provide: BillingService, useValue: mockBillingService }<br>      ]<br>    });<br>    // ⚡️ Grab the Class Instance directly. 10x faster!<br>    component = TestBed.inject(BilledInfoComponent);<br>  });<br>  it(&#39;should calculate total amount correctly&#39;, () =&gt; {<br>    // The logic test remains exactly the same<br>    component.items = [{ price: 100 }, { price: 200 }];<br>    component.calculateTotal();<br>    expect(component.totalAmount).toBe(300);<br>  });<br>});</pre><h3>Feature Comparison Summary</h3><p><strong>FeatureTestBed.createComponent()TestBed.inject(Component)Primary Use Case</strong>Full Component Testing (Logic + UI)Testing Business Logic (Class only)<strong>HTML/DOM Creation</strong>Fully built with data bindingNone. Returns a raw TypeScript class<strong>Execution Speed</strong>Slower (tens to hundreds of ms/case)Blistering Fast (~1–4 ms/case)<strong>Change Detection</strong>Automatic / Triggered via fixtureNo Change Detection system<strong>Lifecycle Hooks</strong>Runs automatically (on detectChanges)Must be called manually</p><h3>Why This Switch is Worth It</h3><ul><li><strong>Blistering Fast Performance:</strong> Cutting out the DOM overhead reduces test execution time to just 3–4 ms per case. When paired with a modern test runner like Vitest, you can breeze through 20,000+ tests in just over a minute.</li><li><strong>Cleaner, Organized Code:</strong> While manually using new Component() is also fast, it becomes a nightmare if your component has many services injected via the constructor. TestBed.inject() leverages Angular&#39;s DI to automatically supply your mock objects, keeping your setup code clean.</li><li><strong>Exceptional Developer Experience:</strong> Faster tests mean developers will run them more frequently during development (shortening the feedback loop), which noticeably reduces the rate of regression bugs.</li></ul><h3>The Trade-offs (What You Need to Watch Out For)</h3><p>No solution is 100% perfect. Opting for the inject() hack comes with a few caveats that your team must be aware of:</p><ul><li><strong>Manual Lifecycle Hooks:</strong> Functions like ngOnInit() or ngOnDestroy() will not trigger automatically. You must call them explicitly in your tests before evaluating your logic (e.g., component.ngOnInit();).</li><li><strong>Mocking </strong><strong>ngOnChanges:</strong> You cannot trigger changes by binding variables to a template. If you rely on ngOnChanges, you will need to manually construct and pass a SimpleChanges object into the hook.</li><li><strong>Zero Template Bug Detection:</strong> If a developer makes a typo in a variable name in the HTML file, this test approach will never catch it. To mitigate this, your team must ensure robust <strong>E2E Testing</strong> or <strong>Integration Testing</strong> is in place to verify the UI layer.</li></ul><p><strong>Conclusion:</strong></p><p>Choosing to use TestBed.inject(Component) is a decisive <strong>Architectural Trade-off</strong> for large-scale projects. Sacrificing UI validation at the Unit Test level in exchange for a CI/CD pipeline that runs 10x faster drastically improves agility and builds a sustainable testing culture within the engineering team!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57475f882296" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How 402 LESS Imports Were Slowing Down Our Angular 21 Build]]></title>
            <link>https://paween-p.medium.com/how-402-less-imports-were-slowing-down-our-angular-21-build-e3bad9f944ac?source=rss-51bab31ea05c------2</link>
            <guid isPermaLink="false">https://medium.com/p/e3bad9f944ac</guid>
            <category><![CDATA[css]]></category>
            <category><![CDATA[frontend-architecture]]></category>
            <category><![CDATA[build-optimization]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[performance]]></category>
            <dc:creator><![CDATA[Paween Pongthong]]></dc:creator>
            <pubDate>Mon, 08 Jun 2026 00:57:30 GMT</pubDate>
            <atom:updated>2026-06-09T07:07:06.097Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aT1wSMsQl0HkgLdgIP62yQ.jpeg" /></figure><p>How a seemingly harmless @import &#39;styles.less&#39; pattern added unnecessary work to every Angular build and test run.</p><p>After upgrading a large Angular application to Angular 21, we started noticing something unusual.</p><p>Our builds were getting slower, our test pipeline was spending an excessive amount of time in the build phase, and occasionally we encountered cryptic build errors such as:</p><pre>Maximum call stack size exceeded</pre><p>At first, the stack trace wasn’t very helpful:</p><pre>RangeError: Maximum call stack size exceeded<br>    at executeBuild<br>    at watch<br>    at Task.task</pre><p>The error pointed to Angular’s new build system:</p><pre>@angular/build/src/builders/application/execute-build.js</pre><p>The failure happened before Karma even started running tests.</p><p>What initially looked like an Angular or test runner problem eventually led us to an architectural issue hidden in our stylesheet organization.</p><h3>The Environment</h3><p>We were running:</p><pre>Angular CLI : 21.2.x<br>Angular     : 21.2.x<br>TypeScript  : 5.9.x<br>Node.js     : 24.x</pre><p>Our test command looked similar to:</p><pre>ng test --watch=false --code-coverage</pre><p>The application itself was large, containing hundreds of Angular components and a centralized LESS-based design system.</p><h3>Looking Beyond the Stack Trace</h3><p>The stack trace pointed somewhere deep inside Angular’s build pipeline.</p><p>One of the reported locations was:</p><pre>executionResult.outputFiles.push(...outputFiles);</pre><p>That line itself wasn’t the problem.</p><p>It simply indicated that Angular had already spent significant effort processing build artifacts before eventually failing.</p><p>Rather than focusing exclusively on the stack trace, we decided to inspect the build inputs.</p><h3>A Surprising Discovery</h3><p>Many of our component stylesheets contained:</p><pre>@import &#39;styles.less&#39;;</pre><p>At first glance this seemed harmless.</p><p>The intention was simple:</p><blockquote><em>Import global variables, mixins, typography helpers, and reusable styling utilities.</em></blockquote><p>But how widespread was this pattern?</p><p>We checked:</p><pre>egrep -R &quot;@import.*styles.less&quot; src/app | wc -l</pre><p>Result:</p><pre>402</pre><p>Four hundred and two component stylesheets were importing the application’s global stylesheet.</p><h3>The Global Stylesheet</h3><p>Our global stylesheet looked roughly like this:</p><pre>@import &#39;./styles/typography.less&#39;;<br>@import &#39;./styles/color.less&#39;;<br>@import &#39;./styles/mixin.less&#39;;<br>@import &#39;./styles/icon.less&#39;;<br>@import &#39;./styles/shadow.less&#39;;<br>@import &#39;./styles/button.less&#39;;<br>@import &#39;./styles/input.less&#39;;<br>@import &#39;./styles/table.less&#39;;<br>@import &#39;./styles/modal.less&#39;;</pre><pre>html,<br>body {<br>  height: 100%;<br>}</pre><pre>body {<br>  font-family: ...<br>}</pre><pre>:root {<br>  --color-bg1: rgb(255, 255, 255);<br>  ...<br>}</pre><pre>.cdk-drag-preview {<br>  ...<br>}</pre><p>This file wasn’t just a collection of mixins.</p><p>It contained:</p><ul><li>Variables</li><li>Mixins</li><li>Typography helpers</li><li>Global selectors</li><li>Theme definitions</li><li>Utility classes</li><li>Component styling rules</li></ul><p>In other words, every component importing this file was effectively pulling in the entire design system.</p><h3>Why This Hurts Build Performance</h3><p>The dependency graph looked something like this:</p><pre>402 component styles<br>        ↓<br>    styles.less<br>        ↓<br>    20+ LESS files<br>        ↓<br>Variables, Mixins, Themes, Global CSS</pre><p>Every time Angular compiled a component stylesheet, it had to traverse that dependency graph again.</p><p>While older Angular versions tolerated this reasonably well, Angular 21’s build pipeline is significantly different and more aggressive in its stylesheet processing.</p><p>The result was a large amount of unnecessary work being repeated hundreds of times.</p><h3>The Solution: Separate Global CSS from Reusable LESS Symbols</h3><p>The root problem was that components needed:</p><pre>Variables<br>Mixins<br>Functions</pre><p>but they did <strong>not</strong> need:</p><pre>body {}<br>html {}<br>:root {}<br>Global utility selectors<br>Theme CSS</pre><p>We introduced a dedicated file:</p><pre>// global-mixins.less</pre><pre>@import (reference) &#39;./styles.less&#39;;</pre><p>Then components changed from:</p><pre>@import &#39;styles.less&#39;;</pre><p>to:</p><pre>@import &#39;global-mixins.less&#39;;</pre><h3>Why (reference) Is Important</h3><p>LESS provides a special import mode:</p><pre>@import (reference) &#39;styles.less&#39;;</pre><p>This exposes:</p><ul><li>Variables</li><li>Mixins</li><li>Functions</li></ul><p>without emitting global CSS rules into every component compilation.</p><p>That meant components could continue using shared mixins:</p><pre>.button {<br>  .button-primary();<br>}</pre><p>without forcing Angular to repeatedly process the entire global stylesheet output.</p><h3>An Additional Optimization for Unit Tests</h3><p>During the investigation we also discovered that our unit tests were unnecessarily compiling global LESS assets.</p><p>For test execution, many of these styles were completely irrelevant.</p><p>We updated our Angular test configuration to stop pulling in global stylesheet dependencies during unit test builds.</p><p>By reducing the amount of stylesheet processing required by the test builder, we further reduced build overhead.</p><p>This optimization had no impact on test behavior while noticeably improving execution time.</p><h3>The Results</h3><p>The impact was immediate.</p><h3>Before</h3><pre>ng build ≈ 90 seconds<br>ng test  ≈ 90 seconds</pre><h3>After</h3><pre>ng build ≈ 60 seconds<br>ng test  ≈ 60 seconds</pre><p>A reduction of roughly:</p><pre>~33% faster builds</pre><p>without changing application functionality.</p><p>More importantly:</p><ul><li>Build stability improved</li><li>LESS dependency complexity was reduced</li><li>Angular’s build system performed significantly less redundant work</li></ul><h3>Lessons Learned</h3><h3>Global styles should remain global</h3><p>A component should not import the application’s entire stylesheet just to access a few mixins.</p><h3>Create dedicated styling entry points</h3><p>Reusable styling utilities deserve their own entry point separate from global CSS.</p><h3>Build performance issues are often architectural</h3><p>Not every performance problem is caused by framework upgrades.</p><p>Sometimes the upgrade simply exposes inefficiencies that were already present.</p><h3>Measure first</h3><p>One command completely changed our investigation:</p><pre>egrep -R &quot;@import.*styles.less&quot; src/app | wc -l</pre><p>Finding 402 imports immediately highlighted an architectural smell.</p><h3>Final Thoughts</h3><p>The most interesting performance problems are often hidden in places developers rarely inspect.</p><p>In our case, the issue wasn’t Angular itself.</p><p>It wasn’t Karma.</p><p>It wasn’t TypeScript.</p><p>It was a stylesheet architecture that had gradually evolved over time until hundreds of components were importing the entire design system.</p><p>By separating reusable LESS symbols from global CSS and simplifying the unit test build process, we achieved:</p><ul><li>Faster builds</li><li>Faster test execution</li><li>Cleaner style dependencies</li><li>Better maintainability</li></ul><p>Sometimes the best optimization isn’t adding more hardware or tweaking build flags.</p><p>It’s reducing the amount of work your build system needs to do in the first place.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e3bad9f944ac" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Golang: Acquiring Google OAuth2 Tokens Behind a Proxy]]></title>
            <link>https://paween-p.medium.com/how-to-request-google-token-via-proxy-with-golang-dfc73ce56da2?source=rss-51bab31ea05c------2</link>
            <guid isPermaLink="false">https://medium.com/p/dfc73ce56da2</guid>
            <category><![CDATA[http-proxy]]></category>
            <category><![CDATA[oauth2]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[idtoken]]></category>
            <dc:creator><![CDATA[Paween Pongthong]]></dc:creator>
            <pubDate>Fri, 10 Jan 2025 10:47:55 GMT</pubDate>
            <atom:updated>2025-01-10T11:40:56.456Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FPyCKzZTPR7RAHEJ9SzG0w.png" /></figure><p>We have leveraged the ‘google.golang.org/api/idtoken’ package to develop a REST API that interfaces with Google Cloud Platform services. This implementation is designed to operate within a constrained intranet environment, where outbound traffic is routed through an HTTP proxy to facilitate authentication token acquisition.</p><pre>import &quot;google.golang.org/api/idtoken&quot;<br><br><br>ctx := context.Background()<br>tokenSource, err := idtoken.NewTokenSource(ctx, audience, idtoken.WithCredentialsFile(credentialsFile))</pre><p>To acquire tokens using this library function, it is necessary to establish an HTTP client configured with a proxy.</p><pre>proxy, err := url.Parse(proxyURL)<br>if err != nil {<br> return fmt.Errorf(&quot;invalid proxy URL: %v&quot;, err)<br>}<br><br>httpClient := &amp;http.Client{<br> Transport: &amp;http.Transport{<br>  Proxy: http.ProxyURL(proxy),<br> },<br>}</pre><p>Inject the http client into the context.</p><pre>ctx1 := context.Background()<br>ctx2 := context.WithValue(ctx1, oauth2.HTTPClient, httpClient)</pre><p>Here is the full code.</p><pre>import &quot;google.golang.org/api/idtoken&quot;<br><br><br>proxy, err := url.Parse(proxyURL)<br>if err != nil {<br> return fmt.Errorf(&quot;invalid proxy URL: %v&quot;, err)<br>}<br><br>httpClient := &amp;http.Client{<br> Transport: &amp;http.Transport{<br>  Proxy: http.ProxyURL(proxy),<br> },<br>}<br><br>ctx1 := context.Background()<br>ctx2 := context.WithValue(ctx1, oauth2.HTTPClient, httpClient)<br>tokenSource, err := idtoken.NewTokenSource(ctx2, audience, idtoken.WithCredentialsFile(credentialsFile))</pre><p>This code demonstrates how to authenticate with Google Cloud using the provided credentials and configure the HTTP client to work through an HTTP proxy.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dfc73ce56da2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Macbook M Series and Keyboard Brightness]]></title>
            <link>https://paween-p.medium.com/macbook-m-series-and-keyboard-brightness-fa0e661ce4e6?source=rss-51bab31ea05c------2</link>
            <guid isPermaLink="false">https://medium.com/p/fa0e661ce4e6</guid>
            <category><![CDATA[apple-silicon]]></category>
            <category><![CDATA[keyboard-backlight]]></category>
            <category><![CDATA[macbook]]></category>
            <dc:creator><![CDATA[Paween Pongthong]]></dc:creator>
            <pubDate>Sat, 27 Jul 2024 08:08:07 GMT</pubDate>
            <atom:updated>2024-07-27T08:08:40.366Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Macbook Keyboard Backlight" src="https://cdn-images-1.medium.com/max/768/1*QB-ZmS_2Y0qLW8iKZouxTQ.png" /></figure><p>Create a new plist file in `~/Library/LaunchAgents` named `com.local.KeyRemapping.plist` and add the code below. Save the file and reboot. F5 and F6 will now work as keyboard brightness up/down keys (after you log in for the first time after rebooting).</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>&lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;<br>&lt;plist version=&quot;1.0&quot;&gt;<br>&lt;dict&gt;<br>    &lt;key&gt;Label&lt;/key&gt;<br>    &lt;string&gt;com.local.KeyRemapping&lt;/string&gt;<br>    &lt;key&gt;ProgramArguments&lt;/key&gt;<br>    &lt;array&gt;<br>        &lt;string&gt;/usr/bin/hidutil&lt;/string&gt;<br>        &lt;string&gt;property&lt;/string&gt;<br>        &lt;string&gt;--set&lt;/string&gt;<br>        &lt;string&gt;{&quot;UserKeyMapping&quot;:[<br>            {<br>              &quot;HIDKeyboardModifierMappingSrc&quot;: 0xC000000CF,<br>              &quot;HIDKeyboardModifierMappingDst&quot;: 0xFF00000009<br>            },<br>            {<br>              &quot;HIDKeyboardModifierMappingSrc&quot;: 0x10000009B,<br>              &quot;HIDKeyboardModifierMappingDst&quot;: 0xFF00000008<br>            }<br>        ]}&lt;/string&gt;<br>    &lt;/array&gt;<br>    &lt;key&gt;RunAtLoad&lt;/key&gt;<br>    &lt;true/&gt;<br>&lt;/dict&gt;<br>&lt;/plist&gt;</pre><p>ref: <a href="https://www.reddit.com/r/MacOS/comments/jy5ry8/m1_macbook_air_keysshortcut_for_keyboard/">M1 MacBook Air — Keys/shortcut for keyboard brightness : r/MacOS (reddit.com)</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fa0e661ce4e6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Springboot 3 + spring-boot-starter-actuator 3 + Basic Authentication]]></title>
            <link>https://paween-p.medium.com/springboot-3-spring-boot-starter-actuator-3-basic-authentication-d84cccd5f384?source=rss-51bab31ea05c------2</link>
            <guid isPermaLink="false">https://medium.com/p/d84cccd5f384</guid>
            <category><![CDATA[http-basic-authentication]]></category>
            <category><![CDATA[spring-boot-actuator]]></category>
            <category><![CDATA[spring-boot]]></category>
            <dc:creator><![CDATA[Paween Pongthong]]></dc:creator>
            <pubDate>Thu, 17 Aug 2023 04:34:20 GMT</pubDate>
            <atom:updated>2023-08-17T04:34:20.309Z</atom:updated>
            <content:encoded><![CDATA[<p>We are newbies for Springboot. <em>Our requirement is any work service should have basic authentication but actuator/health</em>. Here is our works:-</p><ul><li>spring.config.location (.yml)</li></ul><pre>spring:<br>  security:<br>    user:<br>      name: admin<br>      password: admin123<br><br>management:<br>  web:<br>    exposure:<br>      include: health</pre><ul><li>SpringSecurityConfig.java</li></ul><pre>@Configuration<br>@EnableWebSecurity<br>public class SpringSecurityConfig {<br><br>    @Bean<br>    public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {<br>        http<br>                .csrf(csrf -&gt; csrf.disable())<br>                .authorizeHttpRequests(<br>                        authorize -&gt; authorize<br>                                .requestMatchers(EndpointRequest.to(&quot;health&quot;)).permitAll()<br>                                .anyRequest().authenticated()<br>                )<br>                .httpBasic(Customizer.withDefaults());<br><br>        return http.build();<br>    }<br>}ja</pre><p>When we request to <a href="http://localhost:7001/actuator/health">http://localhost:7001/actuator/health</a> without any authentication. We get HTTP status 200 and {“status”: “UP”}.</p><p>When we request to <a href="http://localhost:7001/service1">http://localhost:7001/service1</a> without any authentication. We get HTTP status 401. But if we put basic authentication “admin:admin123”. The service responds HTTP 200 as we need.</p><p>We hope this story will guide you to set Springboot authentication.</p><p>Enjoy!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d84cccd5f384" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[chromedriver 115 needs Chrome for Testing]]></title>
            <link>https://paween-p.medium.com/chromedriver-115-needs-chrome-for-testing-ada09f5e4dc8?source=rss-51bab31ea05c------2</link>
            <guid isPermaLink="false">https://medium.com/p/ada09f5e4dc8</guid>
            <category><![CDATA[chromedriver]]></category>
            <category><![CDATA[chrome]]></category>
            <category><![CDATA[chrome-for-testing]]></category>
            <category><![CDATA[robot-framework]]></category>
            <dc:creator><![CDATA[Paween Pongthong]]></dc:creator>
            <pubDate>Thu, 03 Aug 2023 10:22:18 GMT</pubDate>
            <atom:updated>2023-08-03T10:41:14.604Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*B9MiKQ8bfsQwYDqe93syKg.png" /><figcaption>Google Chrome for Testing</figcaption></figure><p>After We updated chromedriver 115 on our MacBook with</p><pre>brew upgrade chromedriver</pre><p>We cannot run robot framework anymore. It said “No browser is open” or something. But we heard there is something new about Chrome for Testing that be designed by Automate Testing…BRA BRA BRA…</p><p>TLDR: chromedriver 115 needs Chrome for Testing</p><p>How to fix it</p><ul><li>Download Chrome for Testing ( ref1: <a href="https://github.com/GoogleChromeLabs/chrome-for-testing">https://github.com/GoogleChromeLabs/chrome-for-testing</a> , ref2: <a href="https://developer.chrome.com/blog/chrome-for-testing/">https://developer.chrome.com/blog/chrome-for-testing/</a> )</li></ul><pre>npx @puppeteer/browsers install chrome@stable</pre><p>It will download latest version of Chrome for Testing at ./chrome folder.</p><ul><li>Copy/Cut “Google Chrome for Testing.app” into /Application</li><li>Fix some MacOS permission about Networking</li></ul><pre>xattr -csr &#39;Google Chrome for Testing.app&#39;</pre><p>Try upper command first. Run Robot again. If it’s not work (like ours) try more command with…</p><pre>sudo codesign --force --deep --sign - &#39;Google Chrome for Testing.app&#39;</pre><p>We work here. (ref: <a href="https://apple.stackexchange.com/questions/394986/macos-firewall-do-you-want-the-application-google-chrome-app-to-accept-incom">https://apple.stackexchange.com/questions/394986/macos-firewall-do-you-want-the-application-google-chrome-app-to-accept-incom</a> )</p><ul><li>Allow some MacOS permission about Files and Folders that you can click Allow button on Popup Window.</li></ul><p>We hope you can run Robot Framework again.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ada09f5e4dc8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular: The Input NumbersOnly Directive]]></title>
            <link>https://paween-p.medium.com/angular-the-input-numbersonly-directive-d0b0525f7031?source=rss-51bab31ea05c------2</link>
            <guid isPermaLink="false">https://medium.com/p/d0b0525f7031</guid>
            <category><![CDATA[angular-13]]></category>
            <category><![CDATA[angular-directive]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Paween Pongthong]]></dc:creator>
            <pubDate>Thu, 23 Jun 2022 11:00:40 GMT</pubDate>
            <atom:updated>2022-06-23T11:05:24.674Z</atom:updated>
            <content:encoded><![CDATA[<p>On our search the input numbersOnly directive in Angular13, We found many answers. But none of them doesn’t work perfectly. So we modify and the result is:-</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/48ee1ccfbc870fc682e49acd6a58f345/href">https://medium.com/media/48ee1ccfbc870fc682e49acd6a58f345/href</a></iframe><p>We hope it help you!</p><p>Reference: <a href="https://stackoverflow.com/questions/41465542/angular2-input-field-to-accept-only-numbers">https://stackoverflow.com/questions/41465542/angular2-input-field-to-accept-only-numbers</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d0b0525f7031" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to change the Environment after build Angular 13]]></title>
            <link>https://paween-p.medium.com/how-to-change-the-environment-after-build-angular-13-ca1881167034?source=rss-51bab31ea05c------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca1881167034</guid>
            <category><![CDATA[docker-image]]></category>
            <category><![CDATA[angular-13]]></category>
            <dc:creator><![CDATA[Paween Pongthong]]></dc:creator>
            <pubDate>Mon, 27 Dec 2021 01:46:31 GMT</pubDate>
            <atom:updated>2021-12-27T01:51:06.576Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/859/1*t83bYsMadDn_Vx_Wn6BAcg.png" /><figcaption>ng build, we copy image from <a href="https://medium.com/@tovmassian?source=post_page-----981eeefcbab8-----------------------------------">Khachatur Tovmassian</a>, ngBuilding your app with Angular CLI, 2019</figcaption></figure><p>When we use the environment variables in environment.ts, we have to choose env, such as develop, test, and production at build the project time.</p><p>ng build -c local</p><p>ng build -c test</p><p>ng build -c production</p><p>But if we needs to change the environment after the build to prevent the details of environment e.g. API host name, some API key of production. Those details should not keep in the project.</p><p>After we searched then we found the solution from <a href="https://github.com/angular/angular-cli/issues/4318#issuecomment-310643312">michaelarnauts commented on Jun 23, 2017</a>. And we keep some our details here.</p><p>Update default environment for local development, src/environments/environment.ts</p><blockquote>export const environment = {<br>production: false,<br>apiHostName: (window as any).env_vars.apiHostName<br>};</blockquote><p>Update production environment, src/environments/environment.prod.ts</p><blockquote>export const environment = {<br>production: true,<br>apiHostName: (window as any).env_vars.apiHostName<br>};</blockquote><p>Create new env.js file for local development, src/assets/config/env.js</p><blockquote>window.env_vars = {<br>apiHostName: ‘<a href="https://api.servicehost.dev&/#39;">https://api.servicehost.dev&#39;</a><br>};</blockquote><p>Insert this line for load env.js when project run into, src/index.html</p><blockquote>…<br>&lt;script src=“/assets/config/env.js”&gt;&lt;/script&gt;<br>…</blockquote><p>Insert the line for load env.js every tests run.</p><blockquote>import ‘./assets/config/env.js’;</blockquote><p>Everything up there shall be added into the project files. When we build we can use common command ng build -c production for test or production file pack. And then we prepare env.js for each our the environment.</p><p>Create new env.prod.js file for production environment.</p><blockquote>window.env_vars = {<br>apiHostName: ‘<a href="https://api.servicehost.prod&/#39;">https://api.servicehost.prod&#39;</a><br>};</blockquote><p>We just copy env.prod.js to build pack dist/{our project name}/asserts/config/env.js. Or we can create any environment file any we need. Just copy to this file path.</p><p>For all of that we write down the our chosen way to change the environment in Angular13 project. We think this way is less impact for our project codes. And use this solution to create docker image once then use the image to every the environments. We hope this solution to help you too.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca1881167034" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Staresso Coffee Maker]]></title>
            <link>https://paween-p.medium.com/staresso-coffee-maker-a3c8f178657e?source=rss-51bab31ea05c------2</link>
            <guid isPermaLink="false">https://medium.com/p/a3c8f178657e</guid>
            <category><![CDATA[latte]]></category>
            <category><![CDATA[staresso]]></category>
            <category><![CDATA[coffee]]></category>
            <dc:creator><![CDATA[Paween Pongthong]]></dc:creator>
            <pubDate>Mon, 18 Jan 2021 09:26:38 GMT</pubDate>
            <atom:updated>2021-01-18T09:26:38.078Z</atom:updated>
            <content:encoded><![CDATA[<p>โดยส่วนตัวผมเป็นคนชอบกาแฟสดแนวใส่นมมาตลอด ก็เคยลองเล่นเครื่องทำกาแฟต่าง ๆ ไปเรื่อย เริ่มตั้งแต่เครื่องทำกาแฟใส่กระดาษกรองที่บดเมล็ดกาแฟเอง ที่ใส่นมแล้วก็ทำให้กาแฟจืดลง แถมยังชอบใส่น้ำแข็งด้วย มันก็เลยจื้ดจืด</p><p>ยุคถัดมาก็มาได้ลองใช้ Moka Pot ซึ่งทำให้ระดับความเข้มของกาแฟนั้นได้ แต่ว่ากลิ่นของกาแฟที่เราชอบนั้นได้ไม่เต็มที่ (ยังชอบใส่นมและน้ำแข็งเหมือนเดิม) ถึงกับลงทุนซื้อเตาไฟฟ้า Rommelsbacher ของเยอรมัน (แต่ made in China หรือเปล่าไม่แน่ใจ) มาใช้ชงกับ Moka Pot ที่ออฟฟิสเลยด้วย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/406/1*kFfOla_mBvKOFed6vJcdGw.png" /></figure><p>เป็นเพราะผมโหยหากลิ่นของกาแฟมาตลอด เคยทั้งสั่งเมล็ดกาแฟแบบแพง ๆ มาใช้กับ Moka Pot แล้วชงได้แบบติด critical เลยก็มี มันเป็นยังไงน่ะเหรอ คือแบบทั้งความเข้มและกลิ่นเวลาฮุบกาแฟใส่นมใส่น้ำแข็งในคำแรก มันมาเต็ม ๆ โดยเฉพาะกลิ่น ซึ่งหลายครั้งเคยไปซื้อกาแฟที่ร้านแพง ๆ กินก็ยังไม่ได้ระดับนี้ แต่การจะชงได้ระดับนี้ก็นาน ๆ ครั้ง จะบอกว่าชงสัก 20–30 ทีได้แบบนี้สักทีหนึ่งก็ว่าได้</p><p>จนมาถึงยุคล่าสุดเครื่องชงกาแฟ Staresso เป็นเครื่องชงมือแบบเทน้ำร้อนต้มเองลง โดยใช้รุ่น sp-200 ที่ได้น้ำกาแฟออกมา 50 มล. ซึ่งก็ประทับพอควร เพราะได้ทั้งความเข้มและกลิ่นที่ถูกใจ และส่วนใหญ่ก็ได้แบบตามที่ต้องการอยู่เสมอ เอาเป็นว่าถูกใจว่าใช้ Moka Pot ชงก็แล้วกัน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/414/1*6plOBBU9dnocvCceJD60ug.png" /><figcaption>Staresso SP-200</figcaption></figure><p>ณ ตรงนี้ขอจดวิธีที่ลองผิดลองถูกกับเครื่องนี้มาเกือบ 2 ปีไว้หน่อย</p><ul><li>บดเมล็ดกาแฟต้องละเอียดพอควร ระดับเกลือละเอียดเลย ผมใช้เครื่องบดมือ Hario อันนี้ดี เพราะปรับความละเอียดได้ แถมทนทานใช้มานานแล้ว</li><li>ปริมาณเมล็ดกาแฟที่ใช้ก็ไม่ต้องเต็มกระเปาะ (มันเรียกอะไรหว่า?) สัก 2 ใน 3 ก็ได้ ถ้าจำไม่ผิดสัก 7 กรัมได้</li><li>กดผงกาแฟให้แน่น ๆ โดยใช้ช้านตักที่มันแถมมานั่นแหละ (พึ่งรู้ว่าใช้ด้านที่กดแรงดันกดกาแฟแทนได้ด้วย สมแล้วที่ได้รางวัล reddot จริง ๆ)</li><li>ต้มน้ำให้ร้อนจัด ๆ เคยใช้ที่กดน้ำร้อนที่อุณหภูมิไม่ 100 องศา น้ำกาแฟที่ได้ไม่ใช่จริง ๆ อันนี้สำคัญ ของผมใช้กาต้มน้ำไฟฟ้าแบบเหนี่ยวนำ ไม่รู้แถมมาจากไหนจำไม่ได้ แต่ใช้ดีจริง ๆ</li><li>เทน้ำเดือดลงไป 70 มล. ในส่วนที่เก็บน้ำร้อนลงไปเลย ไม่ต้องรอให้น้ำลดอุณหภูมิลง เพราะคิดว่าเวลาน้ำร้อนไปสัมผัสโดยพวก ตัวถังคือก้านกดความดันอุณหภูมิของน้ำมันก็ลดลงไปเองอยู่แล้ว</li><li>ใช้มือปั้ม กด กด กด จนก้านปั้มที่ตึงมืออยู่นั้น หมดแรงต้านเพราะน้ำในตัวถังมันออกมาจนหมด</li><li>น้ำกาแฟที่ออกมาจะได้ราว ๆ 45 มล.</li><li>ผมเอาไปผสมกับนมจืดเมจิสัก 80–90 มล.</li><li>ส่วนน้ำเชื่อมผมใช้ของมิตรผลใส่ไปสัก 10 ม.ล. (เคยเสี้ยนต้มน้ำเชื่อมเองเหมือนกัน เอาน้ำตาลทรายมาเคี่ยวเองเลย แต่พบว่าอยู่ได้สัก 2 อาทิตย์ราขึ้นจ้า)</li><li>เรียบร้อยได้กาแฟลาเต้สูตรของผมเอง ใส่น้ำแข็งได้ด้วย</li></ul><p>หลังจากที่เพลิดเพลินกับมันอยู่กว่า 2 ปี ก็รู้สึกมาตลอดว่าปริมาณกาแฟที่ได้มันน้อยไป ยังกินไม่สะใจเลยหมดซะก่อน ครั้นจะชงสัก 2 รอบก็ขี้เกียจล้าง เมื่อปลายปีก่อนเลยจัดรุ่นใหญ่มาซะ SP-300</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/306/1*4OhO8K9Hkh77Ho8LPgu20A.png" /><figcaption>Staresso SP-300</figcaption></figure><p>เครื่องนี้โดยรวมคือจะได้น้ำกาแฟมากขึ้นอีกเท่าตัว คิดว่าน่าจะกินได้สาแก่ใจกว่า แต่แน่นอนว่ามันเป็นเครื่องใหม่ วิธีการชง ปริมาณกาแฟ ปริมาณน้ำ ปรับความดัน เราก็ต้องทดลองไปเรื่อย ๆ จนแค่ครั้งที่ 2 ก็ได้น้ำกาแฟที่สกัดกลิ่นได้เทพกว่าเครื่องเล็กเสียอีก แถมยังพบว่าเราประกอบตรงจุกปรับแรงดันผิดด้าน ไม่ได้สิครั้งหน้าเราต้องประกอบให้ถูกต้องตามคู่มือ</p><p>ครั้งที่ 3 ประกอบถูกต้อง จนได้น้ำกาแฟครีมม่ามาเต็ม แต่…กลิ่นมันไม่ได้เหมือนครั้งที่ 2 ไม่ได้ลองใหม่… ลองไปอีก 10 กว่าครั้ง ลองประกอบให้จุกแรงดันกลับด้านผิดเหมือนครั้งที่สองด้วย มันก็ไม่ได้กลิ่นเหมือนเดิมเลย กลุ้มใจ</p><p>แต่ล่าสุดลองปรับการบดเมล็ดกาแฟให้ละเอียดขึ้น กดผงกาแฟให้แน่น ๆ ๆ ๆ ระหว่างที่ปั้มเนื่องจากกดกาแฟแน่นเกินไป น้ำกาแฟจึงออกไม่ค่อยดี แต่ได้กลิ่นหอมหวานในระหว่างการปั้ม ในใจก็คิดว่าครั้งนี้แหละมันต้องได้แน่นอน สุดท้ายก็สำเร็จตามที่ต้องการครับ จึงขอจดวิธีไว้ตรงนี้ก่อน</p><ul><li>ใช้กาแฟ 16 กรัม</li><li>บดละเอียดมาก เกือบเป็นแป้ง</li><li>น้ำ 130 มล.</li><li>กดกาแฟจนแน่นมาก</li><li>ใส่จุกปรับแรงดันผิดด้าน</li></ul><p>ไว้ครั้งหน้ามาลองใหม่ครับ ว่าจะยังได้กลิ่นออกมาเหมือนเดิมหรือเปล่า</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a3c8f178657e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Enable HTTP Keep Alive in Go]]></title>
            <link>https://paween-p.medium.com/how-to-enable-http-keep-alive-in-go-581868392bad?source=rss-51bab31ea05c------2</link>
            <guid isPermaLink="false">https://medium.com/p/581868392bad</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[http-request]]></category>
            <dc:creator><![CDATA[Paween Pongthong]]></dc:creator>
            <pubDate>Thu, 29 Nov 2018 09:16:40 GMT</pubDate>
            <atom:updated>2018-12-03T07:28:49.272Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x90P_g0161AngYDYRa219Q.jpeg" /></figure><ul><li>Share http transport — you can new http client every request but http transport must be shared.</li><li>Read all response body.</li></ul><p>io.Copy(ioutil.Discard, resp.Body)</p><ul><li>Response body must be closed.</li></ul><p>resp.Body.Close()</p><ul><li>Set http header with “Connection: keep-alive”.</li></ul><p>req.Header.Set(&quot;Connection&quot;, &quot;keep-alive&quot;)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=581868392bad" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>