<?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 Pansakorn Phothidaen on Medium]]></title>
        <description><![CDATA[Stories by Pansakorn Phothidaen on Medium]]></description>
        <link>https://medium.com/@pansakornphothidaen?source=rss-84772e96e7ad------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*uhpV7S1IHhgowxe4kpOnNA.png</url>
            <title>Stories by Pansakorn Phothidaen on Medium</title>
            <link>https://medium.com/@pansakornphothidaen?source=rss-84772e96e7ad------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 12:45:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pansakornphothidaen/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[RxJS วิธีการแก้ Error: rxjs has no exported member ด้วย rxjs-compat]]></title>
            <link>https://medium.com/@pansakornphothidaen/rxjs-%E0%B8%A7%E0%B8%B4%E0%B8%98%E0%B8%B5%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B9%81%E0%B8%81%E0%B9%89-error-rxjs-has-no-exported-member-%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2-rxjs-compat-f4d01579195?source=rss-84772e96e7ad------2</link>
            <guid isPermaLink="false">https://medium.com/p/f4d01579195</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[rxjs]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Pansakorn Phothidaen]]></dc:creator>
            <pubDate>Fri, 25 Jan 2019 10:23:02 GMT</pubDate>
            <atom:updated>2019-01-25T10:23:02.804Z</atom:updated>
            <content:encoded><![CDATA[<p>RxJS วิธีการแก้ Error: rxjs has no exported member ด้วย rxjs-compat</p><p>เริ่มจากการมีการติดตั้ง <a href="https://www.npmjs.com/package/rxjs">RxJS</a> หลังจากนั้นเมื่อมีการ Compile จะพบ Error ตามด้านล่าง</p><pre>..<br>node_modules/rxjs/... error TS2305: ...has no exported member ...<br>node_modules/@angular/... error TS2305: ... has no exported member ...<br>node_modules/rxjs/... : error TS2307: Cannot find module ...</pre><p>พิมพ์คำสั่งตามลำดับ 1–5 ตามด้านล่าง</p><pre>1. npm i --save rxjs<br>2. npm i --save rxjs-compat<br>3. npm cache clean --force<br>4. rm -rf node_modules<br>5. npm install</pre><p>หลังจากนั้นให้รันคำสั่งตามปกติ เช่น npm start</p><p>อ้างอิง:</p><p><a href="https://www.npmjs.com/package/rxjs">https://www.npmjs.com/package/rxjs</a></p><p><a href="https://www.npmjs.com/package/rxjs-compat">https://www.npmjs.com/package/rxjs-compat</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4d01579195" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[การทำ Angular Testing ผ่าน Puppeteer-Headless Browser]]></title>
            <link>https://medium.com/@pansakornphothidaen/%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%97%E0%B8%B3-angular-testing-%E0%B8%9C%E0%B9%88%E0%B8%B2%E0%B8%99-puppeteer-headless-browser-2a7d8e4bd0fa?source=rss-84772e96e7ad------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a7d8e4bd0fa</guid>
            <category><![CDATA[puppeteer]]></category>
            <category><![CDATA[e2e-testing]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[unittest]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Pansakorn Phothidaen]]></dc:creator>
            <pubDate>Thu, 24 Jan 2019 07:55:25 GMT</pubDate>
            <atom:updated>2019-01-24T07:55:25.467Z</atom:updated>
            <content:encoded><![CDATA[<p>บทความนี้จะสอนวิธีการทำ <strong>UnitTest ด้วย Karma</strong> และ <strong>E2E ด้วย Protractor</strong> ผ่าน <strong>Puppeteer</strong> ตามลำดับ</p><p><strong>ติดตั้ง Puppeteer</strong></p><blockquote>npm install — save-dev puppeteer</blockquote><h3>UnitTest: Karma-Jasmine</h3><p><strong>การตั้งค่า configulation เพื่อใช้งาน Karma</strong></p><ol><li>เพิ่มคำสั่งที่บรรทัดแรกของ karma.conf.js</li></ol><blockquote>process.env.CHROME_BIN = require(‘puppeteer’).executablePath();</blockquote><p>2. คำสั่งในการทำงาน</p><blockquote>ng test — browsers=ChromeHeadless — watch=false</blockquote><p>หมายเหตุ:</p><p>ในบางครั้งที่มีปัญหาการใช้งานบน UNIX ให้ใช้ --no-sandbox flag ตามตัวอย่างด้านล่าง</p><pre><br><br>process.env.CHROME_BIN = require(&#39;puppeteer&#39;).executablePath()<br><br>module.exports = function (config) {<br>  config.set({<br>    basePath: &#39;&#39;,<br>    frameworks: [&#39;jasmine&#39;, &#39;@angular-devkit/build-angular&#39;],<br>    plugins: [<br>      require(&#39;karma-jasmine&#39;),<br>      require(&#39;karma-chrome-launcher&#39;),<br>      require(&#39;karma-jasmine-html-reporter&#39;),<br>      require(&#39;karma-coverage-istanbul-reporter&#39;),<br>      require(&#39;@angular-devkit/build-angular/plugins/karma&#39;)<br>    ],<br>    client: {<br>      clearContext: false // leave Jasmine Spec Runner output visible in browser<br>    },<br>    coverageIstanbulReporter: {<br>      dir: require(&#39;path&#39;).join(__dirname, &#39;../coverage&#39;),<br>      reports: [&#39;html&#39;, &#39;lcovonly&#39;],<br>      fixWebpackSourcePaths: true<br>    },<br>    reporters: [&#39;progress&#39;, &#39;kjhtml&#39;],<br>    port: 9876,<br>    colors: true,<br>    logLevel: config.LOG_INFO,<br>    autoWatch: true,<br>    <strong>browsers: [&#39;ChromeHeadlessNoSandbox&#39;],<br>    customLaunchers: {<br>      ChromeHeadlessNoSandbox: {<br>        base: &#39;ChromeHeadless&#39;,<br>        flags: [&#39;--no-sandbox&#39;]<br>      }<br>    },</strong><br>    singleRun: false<br>  });<br>};</pre><p>คำสั่งในการทำงาน</p><blockquote>ng test — browsers=<strong>ChromeHeadlessNoSandbox</strong> — watch=false</blockquote><p><strong>การประยุกต์เพื่อนำไปใช้งาน CI Pipeline</strong></p><pre>npm install<br>ng test --watch=false</pre><p><strong>การนำไปใช้ใน CentOS</strong></p><p>เราสามารถนำไปใช้ได้ทั้ง CentOS และ ​Linux</p><pre>curl –silent –location https://rpm.nodesource.com/setup_9.x | sudo bash<br>sudo yum remove -y nodejs npm<br>sudo yum install -y nodejs<br>sudo yum install pango.x86_64 libXcomposite.x86_64 libXcursor.x86_64 \<br>  libXdamage.x86_64 libXext.x86_64 libXi.x86_64 libXtst.x86_64 \<br>  cups-libs.x86_64 libXScrnSaver.x86_64 libXrandr.x86_64 GConf2.x86_64 \<br>  alsa-lib.x86_64 atk.x86_64 gtk3.x86_64 ipa-gothic-fonts \<br>  xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi xorg-x11-utils \<br>  xorg-x11-fonts-cyrillic xorg-x11-fonts-Type1 xorg-x11-fonts-misc -y<br>npm i -g @angular/cli</pre><p>หมายเหตุ:</p><p>เมื่อ Chromium เริ่มทำงานถ้าเจอ error ตามด้านล่าง</p><blockquote>error while loading shared libraries: libx11.so.6: cannot open shared object file: no such file or directory</blockquote><p>ให้ทำการเพิ่มคำสั่งสำหรับ Puppeteer ตามด้านล่าง</p><pre>ng new puppeteer-test<br>cd puppeteer-test<br>npm i --save-dev puppeteer<br>CONF=&quot;src/karma.conf.js&quot;<br>if [ $(cat src/karma.conf.js | grep &#39;^process.env.CHROME_BIN&#39; | wc -l) == 0 ]; then<br>  echo -e &quot;process.env.CHROME_BIN = require(&#39;puppeteer&#39;).executablePath()\n$(cat ${CONF})&quot; &gt; ${CONF}<br>fi<br>if [ $(cat src/karma.conf.js | grep &#39;ChromeHeadlessNoSandbox&#39; | wc -l) == 0 ]; then<br>  sed -i -e &#39;s/browsers:.*\[.*\],/browsers: [&#39;\&#39;&#39;ChromeHeadlessNoSandbox&#39;\&#39;&#39;], customLaunchers: { ChromeHeadlessNoSandbox: { base: &#39;\&#39;&#39;ChromeHeadless&#39;\&#39;&#39;, flags: [&#39;\&#39;&#39;--no-sandbox&#39;\&#39;&#39;] } },/g&#39; $CONF<br>fi</pre><p>คำสั่งให้ทำงานบน Linux</p><blockquote>ng test — watch=false</blockquote><h3>E2E: Protractor</h3><p><strong>การตั้งค่า configulation เพื่อใช้งาน Protractor</strong></p><ol><li>ตั้งค่าใน protractor.conf.js</li></ol><pre><strong>process.env.CHROME_BIN = require(&#39;puppeteer&#39;).executablePath();</strong><br>const { SpecReporter } = require(&#39;jasmine-spec-reporter&#39;);<br><br>exports.config = {<br>  allScriptsTimeout: 11000,<br>  specs: [<br>    &#39;./e2e/**/*.e2e-spec.ts&#39;<br>  ],<br>  <strong>capabilities: {<br>    &#39;browserName&#39;: &#39;chrome&#39;,<br>    chromeOptions: {<br>      binary: process.env.CHROME_BIN,<br>      args: [&#39;--headless&#39;, &#39;--disable-gpu&#39;, &#39;--window-size=800,600&#39;, &#39;--no-sandbox&#39;]<br>    }<br>  },</strong><br>  directConnect: true,<br>  baseUrl: &#39;http://localhost:4200/&#39;,<br>  framework: &#39;jasmine&#39;,<br>  jasmineNodeOpts: {<br>    showColors: true,<br>    defaultTimeoutInterval: 30000,<br>    print: function () { }<br>  },<br>  onPrepare () {<br>    require(&#39;ts-node&#39;).register({<br>      project: &#39;e2e/tsconfig.e2e.json&#39;<br>    });<br>    jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));<br>  }<br>};</pre><p>2. คำสั่งในการทำงาน</p><blockquote>ng e2e</blockquote><p><strong>ในกรณีทำงานพร้อม UI</strong></p><ol><li>ให้ทำการสร้างไฟล์ใหม่ protractor.ui.conf.js</li></ol><pre>var config = exports.config = require(&#39;./protractor.conf.js&#39;).config;<br><br>config.capabilities.chromeOptions.args = [&#39;--window-size=800,600&#39;, &#39;--no-sandbox&#39;];</pre><p>2. คำสั่งในการทำงาน</p><blockquote>ng e2e — protractor-config=./e2e/protractor.ui.conf.js</blockquote><p>หรือ</p><blockquote>npm run e2e — — protractor-config=./e2e/protractor.ui.conf.js</blockquote><p><strong>สรุป</strong></p><p>การใช้งาน Puppeteer ใน CI Pipeline ช่วยในเรื่อง Speed, Reliability และ Consistency เช่น ช่วยลดขนาดในการดาวน์โหลดของ Chrome binary ทำให้ช่วยประหยัดเวลา และ ลดปัญหาต่างๆเช่น Cookies, extensions และ อื่นๆ รวมทั้งสามารถใช้งานได้บน Linux และ CentOS</p><p>อ้างอิงข้อมูล: https://github.com/GoogleChrome/puppeteer/issues/391#issuecomment-325420271</p><p>https://brendonthiede.github.io/devops/2018/09/18/puppeteer-with-angular.html</p><p>https://www.sitepen.com/blog/browser-automation-with-puppeteer/</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a7d8e4bd0fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 วิธีในการทำ Database Scaling]]></title>
            <link>https://medium.com/@pansakornphothidaen/5-%E0%B8%A7%E0%B8%B4%E0%B8%98%E0%B8%B5%E0%B9%83%E0%B8%99%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%97%E0%B8%B3-database-scaling-b0dbfb4f92d7?source=rss-84772e96e7ad------2</link>
            <guid isPermaLink="false">https://medium.com/p/b0dbfb4f92d7</guid>
            <category><![CDATA[relational-databases]]></category>
            <category><![CDATA[nosql]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Pansakorn Phothidaen]]></dc:creator>
            <pubDate>Tue, 08 Jan 2019 08:39:58 GMT</pubDate>
            <atom:updated>2019-01-08T08:39:58.525Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>1. พยายามหาสาเหตุของปัญหา</strong></p><p>สิงแรกที่เราสมควรทำคือ ให้เราพยายามหา Bottole neck และหาจุดที่ทำให้มันช้า หรือหยุดการทำงาน และหลายครั้งปัญหาไม่ได้เกิดจาก Database แต่เกิดจาก Source code, SQL query และ Stored procedure</p><p><strong>2. เพิ่ม Memory</strong></p><p>แนะนำให้คุณเพิ่ม memory หากคุณพบว่า bottle neck นั่นเกิดจากจัดเก็บข้อมูล</p><p><strong>3. ใช้ Vertical scaling tools มาช่วย</strong></p><p>สิ่งที่เป็นที่นิยมในการเอามาช่วยในการเพิ่ม cached database ก็คือ Memcached</p><p>ในที่นี้ Jake Robinson ได้กล่าวไว้ว่า “ การเพิ่ม memory และ การเพิ่มทรัพยากรต่างๆ ถือว่าทั้งหมดเป็น vertical scaling ”</p><p><strong>4. ไม่แนะนำให้แยก Database เป็นส่วนย่อยๆ</strong></p><p>บางคนแยก Database ออกเป็นหลายๆส่วนซึ่งมันเป็นการเพิ่มความเสี่ยง และความซับซ้อนซึ่งไม่ควรทำเพราะมันมีวิธีอื่นๆที่ดีกว่า</p><p><strong>5. ลองหาวิธีการใหม่ๆ</strong></p><p>วิธีการใหม่ที่นิยมในการทำ Database scaling ด้วยการใช้ Memory database และ NoSQL system ตัวอย่างเช่น Cassandra และ Mongo DB ไปพร้อมๆกัน</p><p>นอกจากสองวิธีข้างต้นยังมีทางเลือกอื่นซึ่งอยู่กึ่งกลางระหว่างวิธีทั้งสองก็คือ SQLFire สำหรับคนที่ยังไม่พร้อมไป NoSQL</p><p>อ้างอิง: <a href="https://www.bluelock.com/blog/5-best-practices-database-scaling/">https://www.bluelock.com/blog/5-best-practices-database-scaling/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b0dbfb4f92d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular 6 with Headless browser between Headless Chrome and PhantomJS Benchmark]]></title>
            <link>https://medium.com/@pansakornphothidaen/headless-chrome-vs-phantomjs-benchmark-41fd4486d6d6?source=rss-84772e96e7ad------2</link>
            <guid isPermaLink="false">https://medium.com/p/41fd4486d6d6</guid>
            <category><![CDATA[angular-6]]></category>
            <category><![CDATA[phantomjs]]></category>
            <category><![CDATA[headless-chrome]]></category>
            <category><![CDATA[headless]]></category>
            <category><![CDATA[continuous-integration]]></category>
            <dc:creator><![CDATA[Pansakorn Phothidaen]]></dc:creator>
            <pubDate>Tue, 07 Aug 2018 09:41:49 GMT</pubDate>
            <atom:updated>2018-08-07T12:06:22.697Z</atom:updated>
            <content:encoded><![CDATA[<p>ผลเปรียบเทียบการทำงานระหว่าง Chrome Headless และ PhantomJS ส่วนตัวได้ทำการทดสอบ 3 test cases กับ Angular 6 ใช้เวลาในการทำงาน</p><p>Headless Chrome: 0.22 sec</p><p>PhantomJS: 0.54 sec</p><p>ผลการทดสอบ Performance ดีขึ้นประมาณ 60%</p><p>หลังจากนั้นผมได้ทำการหาข้อมูลเพิ่มเติมจากการทดสอบจากผู้ใช้อื่นพบได้ว่ามีผลลัพธ์ไปทิศทางเดียวกัน ทั้งเวลาในการทำงาน และmemoryที่ใช้ ดังข้อมูลด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*SKnPOwLkZ5503f-jS8ZlEA@2x.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*Mu196I8L8cL7xorsboZuZQ@2x.jpeg" /></figure><p>สรุปได้ว่า Chrome Headless ทำงานได้เร็วกว่า และใช้ Memory ที่น้อยกว่าบน environment เดียวกัน</p><p>ปล. ข้อมูลที่ได้นี้น่าจะเป็นประโยชน์สำหรับการนำไปทำ CI/CD ของ Frontend.</p><p>Credits: <a href="https://hackernoon.com/benchmark-headless-chrome-vs-phantomjs-e7f44c6956c">https://hackernoon.com/benchmark-headless-chrome-vs-phantomjs-e7f44c6956c</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41fd4486d6d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular: Component VS Directive]]></title>
            <link>https://medium.com/@pansakornphothidaen/angular-component-vs-directive-9ce416e99f81?source=rss-84772e96e7ad------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ce416e99f81</guid>
            <category><![CDATA[components]]></category>
            <category><![CDATA[angular-directive]]></category>
            <category><![CDATA[thai-web-developer]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Pansakorn Phothidaen]]></dc:creator>
            <pubDate>Sat, 21 Jul 2018 09:23:08 GMT</pubDate>
            <atom:updated>2018-07-21T09:23:08.078Z</atom:updated>
            <content:encoded><![CDATA[<p>Component ใช้ตอนที่ต้องการ Reuse UI ที่ประกอบด้วย DOM element และ Behavior ในรูปแบบต่างๆ เช่น การทำ Upload File</p><p>Directive ใช้ตอนที่ต้องการปรับปรุงแก้ไขเกี่ยวกับ Behavior ของ DOM element ที่มีอยู่แล้ว และไม่มี template ตัวอย่างเช่น phone number Validation</p><p>#angular #angular-Component #angular-Directive #component #directive #Thaiwebdeveloper</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ce416e99f81" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[3 สิ่งที่ควรระวังของ Bad design]]></title>
            <link>https://medium.com/@pansakornphothidaen/3-%E0%B8%AA%E0%B8%B4%E0%B9%88%E0%B8%87%E0%B8%97%E0%B8%B5%E0%B9%88%E0%B8%84%E0%B8%A7%E0%B8%A3%E0%B8%A3%E0%B8%B0%E0%B8%A7%E0%B8%B1%E0%B8%87%E0%B8%82%E0%B8%AD%E0%B8%87-bad-design-d17bb36d787d?source=rss-84772e96e7ad------2</link>
            <guid isPermaLink="false">https://medium.com/p/d17bb36d787d</guid>
            <category><![CDATA[ood]]></category>
            <category><![CDATA[bad-design]]></category>
            <category><![CDATA[coding-style]]></category>
            <category><![CDATA[object-oriented-design]]></category>
            <category><![CDATA[best-practices]]></category>
            <dc:creator><![CDATA[Pansakorn Phothidaen]]></dc:creator>
            <pubDate>Thu, 12 Jul 2018 04:37:28 GMT</pubDate>
            <atom:updated>2018-07-12T04:38:36.766Z</atom:updated>
            <content:encoded><![CDATA[<ul><li>มีความซับซ้อนของการออกแบบทำให้ยากต่อการปรับปรุงแก้ไข</li><li>ไม่สามารถคาดเดาผลกระทบได้หลังจากทำการปรับปรุงแก้ไข</li><li>ไม่เป็นอิสระจนยากต่อการนำไปใช้ในแอพพลิเคชั่นอื่นๆ เพราะมีความซับซ้อนจนยากที่จะแยกการทำงานออกจากแอพพลิเคชั่นเดิม ปล. ต้นฉบับอยู่ด้านล่าง แปลเองจะเพี้ยนๆหน่อย น่ะสำหรับคนที่เข้ามาอ่าน</li></ul><p>Fb: <a href="http://www.facebook.com/notes/phothidaen-pansakorn/3-%E0%B8%AA%E0%B8%B4%E0%B9%88%E0%B8%87%E0%B8%97%E0%B8%B5%E0%B9%88%E0%B8%84%E0%B8%A7%E0%B8%A3%E0%B8%A3%E0%B8%B0%E0%B8%A7%E0%B8%B1%E0%B8%87%E0%B8%82%E0%B8%AD%E0%B8%87-bad-design/1660861640629886/">facebook.com/notes/phothidaen-pansakorn/3-สิ่งที่ควรระวังของ-bad-design/1660861640629886/</a></p><p>Three important characteristics of a bad design that should be avoided:</p><ul><li>Rigidity — It is hard to change because every change affects too many other parts of the system.</li><li>Fragility — When you make a change, unexpected parts of the system break.</li><li>Immobility — It is hard to reuse in another application because it cannot be disentangled from the current application.</li></ul><p>Credit: Robert Martin</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d17bb36d787d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>