<?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[AMPOS Developers - Medium]]></title>
        <description><![CDATA[Knowledge sharing hub for AMPOS developers - Medium]]></description>
        <link>https://medium.com/ampos-mobile?source=rss----7d32d2560705---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>AMPOS Developers - Medium</title>
            <link>https://medium.com/ampos-mobile?source=rss----7d32d2560705---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 22:21:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/ampos-mobile" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Deploy Dash-Cytoscape app for demo]]></title>
            <link>https://medium.com/ampos-mobile/deploy-dash-cytoscape-app-for-demo-479ba1008eb9?source=rss----7d32d2560705---4</link>
            <guid isPermaLink="false">https://medium.com/p/479ba1008eb9</guid>
            <dc:creator><![CDATA[Pun Pakorn]]></dc:creator>
            <pubDate>Fri, 29 Apr 2022 05:46:35 GMT</pubDate>
            <atom:updated>2022-04-29T05:46:35.572Z</atom:updated>
            <content:encoded><![CDATA[<p>หลังจากใช้ library dash-cytoscape มาสักพัก เมื่อวานก็มีโอกาสได้ลองไป demo ให้ลูกค้าดูจริงๆ ก็เลยต้องหาทาง deploy ขึ้นไปให้พี่บีมและคุณแป้งสามารถเข้าไปกดเล่นได้</p><p>ตามแผนจริงๆ ก็จะ pack code ขึ้นไปเป็น docker container และรันบน ecs แต่ด้วยความรู้ docker ของเราตอนนี้คงไม่สามารถทำเสร็จให้พี่บีม demo พรุ่งนี้ได้ เลยต้องหาทางอื่นที่จะ deploy ได้เร็วที่สุด</p><p>ขอบคุณ blog นี้ที่ช่วยชี้ทางสว่าง<br><a href="https://towardsdatascience.com/the-easiest-way-to-deploy-your-dash-app-for-free-f92c575bb69e">https://towardsdatascience.com/the-easiest-way-to-deploy-your-dash-app-for-free-f92c575bb69e</a></p><h3>สร้าง simple python web app</h3><ol><li>สมัคร pythonanywhere.com เป็นแบบ Beginner Account (ฟรี)</li><li>ตรงขวาบนไปที่ tab Web -&gt; Add a new web app</li><li>Next</li><li>เลือก Flask (Dash สร้าง on top Flask)</li><li>เลือก python version</li><li>Next</li></ol><p>เราจะได้หน้าเว็บและ url มาแล้ว เข้าและ share ให้คนอื่นได้จาก url ตรงนี้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gI7R1I43fHabug_B_D5CfA.png" /></figure><p>ตอนนี้จะเป็นหน้าเว็บของ default Flask อยู่ ต่อไปเราจะเอา app ของเราขึ้นละ</p><h3>Upload code</h3><ol><li>ด้านขวาบน ไปที่ tab Flies</li><li>ไปที่ directory mysite จะเจอ flask_app.py เป็น default หน้าเว็บที่เราเห็นเมื่อกี้ ลบทิ้งได้เลย</li><li>Upload code กรณีนี้คือ app.py และไฟล์ data เป็น csv</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RaEZfQHslaIEGx8avM4rYw.png" /></figure><p>4. แก้ path ในการ reference ถึง csv files ใน app.py (กด edit บนเว็บได้เลย)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/1*rLSlxt0gTr-XNRiVfnDcZA.png" /></figure><h3>Install libraries</h3><p>ในโค้ด app.py ของเรา ต้องใช้ lib ที่ต้องลงเพิ่ม 3 ตัวคือ pandas, dash และ dash-cytoscape เพราะฉะนั้นเราต้องมา pip install กัน</p><p>ขวาบนไปที่ tab Consoles เลือก Start Bash console</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*SKIRl-0zaIWgjLQk4HZuZA.png" /></figure><ol><li>เช็ค version ของ pip และ python ของ console ก่อน pip --version</li><li>pip install pandas</li><li>pip install dash</li><li>dash-cytoscape จะพิเศษหน่อยตรงที่เราอยากจะใช้ layout ‘fcose’ ซึ่งไม่อยู่ใน version ล่าสุดของ dash-cytoscape แต่อยู่ใน code master branch เรียบร้อยแล้ว (ยังไม่ได้ publish) เราเลยจะ install ผ่าน git แทน public pypi<br>pip install git+https://github.com/plotly/dash-cytoscape</li></ol><h3>Config ให้เว็บมาใช้ไฟล์ app.py</h3><ol><li>ขวาบนไปที่ tab Web</li><li>ตรง section Code เราจะ edit WSGI configuration file</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YmOhUHwzlxNTEocVeNZLlQ.png" /></figure><p>3. ลบ</p><blockquote>from flask_app import app as application</blockquote><p>เปลี่ยนเป็น</p><blockquote>from app import app<br>application = app.server</blockquote><p>from app import app คือหา variable app ในไฟล์ app.py และให้ app.server คือ application ของ web</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/312/1*fgtR60wd2ZKG9izyJ7ni0Q.png" /><figcaption>ใน app.py มี variable app อยู่ ให้ใช้สิ่งนี้เป็น server</figcaption></figure><p><strong>Note:</strong> ปกติเวลารัน dash บน local จะใช้ app.run_server พอมา deploy เป็น web app จริงก็ไม่ต้องสั่ง run_server แล้ว แค่ส่ง server ให้ไปรัน</p><h3><strong>Done กราฟขึ้นอย่างสวยงาม</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-bg2FM1go8xVqn56SNjx5g.png" /></figure><h3>ถ้า Error หรือหน้าเว็บไม่ขึ้น</h3><p>ไปดูที่ Error Log และ Server Log ที่ tab Web ใต้ section Log files (ต้องใช้ไปหลายสิบรอบอยู่เหมือนกัน)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*P9PE9yuD9CXeIs6dha3q0w.png" /></figure><p>Reference:</p><ul><li><a href="https://dash.plotly.com/introduction">https://dash.plotly.com/introduction</a></li><li><a href="https://dash.plotly.com/cytoscape">https://dash.plotly.com/cytoscape</a></li><li><a href="https://towardsdatascience.com/the-easiest-way-to-deploy-your-dash-app-for-free-f92c575bb69e">https://towardsdatascience.com/the-easiest-way-to-deploy-your-dash-app-for-free-f92c575bb69e</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=479ba1008eb9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ampos-mobile/deploy-dash-cytoscape-app-for-demo-479ba1008eb9">Deploy Dash-Cytoscape app for demo</a> was originally published in <a href="https://medium.com/ampos-mobile">AMPOS Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[เข้าใจ Null Safety ใน Dart 2 (EP1)]]></title>
            <link>https://medium.com/ampos-mobile/%E0%B9%80%E0%B8%82%E0%B9%89%E0%B8%B2%E0%B9%83%E0%B8%88-null-safety-%E0%B9%83%E0%B8%99-dart-2-ep1-665d49d1c9c1?source=rss----7d32d2560705---4</link>
            <guid isPermaLink="false">https://medium.com/p/665d49d1c9c1</guid>
            <category><![CDATA[flutterth]]></category>
            <category><![CDATA[null-safety]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[dart-null-safety]]></category>
            <dc:creator><![CDATA[Pimorn Senakat]]></dc:creator>
            <pubDate>Mon, 25 Oct 2021 03:00:36 GMT</pubDate>
            <atom:updated>2021-10-25T03:00:36.821Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3gwrTw6fylg8DwvL" /><figcaption>Photo by <a href="https://unsplash.com/@visualsbyroyalz?utm_source=medium&amp;utm_medium=referral">Anastase Maragos</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>ทำไมต้อง null safety</h3><p>ปัญหาที่พบได้บ่อยในการเขียนโปรแกรมคือ โปรแกรม crash จากการเรียก method ผ่านตัวแปรที่มีค่าเป็น null ซึ่งอาจมาจากการลืม initialize ค่า หรือ ส่งค่า null เข้ามาใน function</p><pre>// Without null safety:<br>bool isEmpty(String string) =&gt; string.length == 0;<br><br>main() {<br>  final String someString;  // someString is null<br>  isEmpty(someString);<br>}</pre><p>เมื่อ run code ชุดนี้ จะเกิด exceptionNoSuchMethodErrorเนื่องจากตัวแปรที่ถูกส่งเข้าไปใน functionisEmptyยังไม่ได้มีการ initialize ค่า โดยค่า default มีค่าเป็น null เมื่อ function isEmpty เรียก .length จึงเป็นการเรียก length method ผ่าน Null ซึ่ง .lengthเป็น method ที่ไม่มีใน Null ทำให้เกิด exception ขึ้น</p><p>ดั้งนั้นการที่ Dart 2.12 ได้เปลี่ยนมาเป็น null safety จะทำให้ compiler สามารถตรวจสอบความผิดพลาดที่จะเกิด null exception ได้ก่อนที่จะ run code จริง คือเปลี่ยนจากการเจอปัญหาตอน runtime มาเป็น compile time แทน ซึ่งทำให้สามารถเจอปัญหาในตอน development แทนที่จะไปเจอเมื่อใช้งานโปรแกรม</p><p><a href="https://medium.com/dartlang/announcing-dart-2-12-499a6e689c87">Announcing Dart 2.12</a></p><h3>หลักการออกแบบ null safety ใน Dart</h3><ul><li><strong>Code should be safe by default<br></strong>คือถ้าเขียน Dart code ปกติธรรมดาไม่ได้ใช้ explicit unsafe feature ใด ๆ โปรแกรมจะต้องไม่ throw exception ตอน runtime และโอกาสที่จะทำให้เกิด null exception จะต้องโดยจับได้ใน compile time</li><li><strong>Null safe code should be easy to write</strong><br>จะต้องง่ายต่อการเขียน ไม่ได้เปลี่ยนแปลงไปจากเดิม และต้องไม่ทำให้เขียนยากขึ้นเพื่อแลกกับการเป็น null safety</li><li><strong>The resulting null safe code should be fully sound</strong><br>Code จะต้องปลอดภัยอย่างสมบูรณ์ คือถ้า type ไหนที่ไม่สามารถเป็น null ได้ Dart จะต้องไม่อนุญาตให้ใส่ค่า null หรือทำให้เกิดการ evaluate ค่านั้นเป็น null ได้ โดย Dart จะการันตีผ่านทางการทำ static check และ runtime check ร่วมด้วยในบางกรณี</li></ul><h3>Null typeใน Dart type system</h3><p>ใน version Dart 1.x ก่อนที่ Dart จะเป็น null safety นั้น Dart จะมอง Null เป็น subtype ของทุก type คือสามารถให้ทุก type มีค่าเป็น null ได้ ซึ่งก็ทำให้เกิดปัญหา runtime exception ได้</p><p>ดั้งใน Dart 2.12 จึงมีการแยก Null type ออกจาก type ต่างๆ และทุก type จะมีค่า default เป็น non-nullable ดั้งจะไม่มี type ไหนที่จะมีค่า null ได้ยกเว้น type Nullอย่างเช่นเมื่อประกาศ String หมายความว่ามันจะต้องมีค่า string อยู่ ห้ามเป็น null</p><figure><img alt="Non-nullable and nullable type structure in Dart null safety" src="https://cdn-images-1.medium.com/max/1024/1*xagc2ZLJugCDzPlyN57img.png" /><figcaption>image from <a href="https://dart.dev/null-safety/understanding-null-safety#nullability-in-the-type-system">https://dart.dev/null-safety/understanding-null-safety#nullability-in-the-type-system</a></figcaption></figure><p>แต่ก็ไม่ใช่ว่า Null จะไม่มีประโยชน์ เพราะ Null สามารถเป็นการแสดงค่าแบบ optional ได้เป็นอย่างดี</p><pre>void makeCoffee(String coffee, [String? dairy]) {<br>  if (dairy != null) {<br>    print(&#39;$coffee with $dairy&#39;);<br>  } else {<br>    print(&#39;Black $coffee&#39;);<br>  }<br>}</pre><p>dairyคือค่า optional ที่สามารถจะรับค่า String หรือ null ได้ ซึ่งก็คือString | Nullการใส่ เครื่องหมาย ? หลัง type นั้นๆ เป็นการบอกว่า type สามารถรับได้ทั้งค่าของ type นั้น และค่า null เรียกว่า nullable type</p><p>ถ้าส่งค่า non-nullable type ให้ function ที่รับค่า nullable type เช่น void func(String? s) function นี้รับค่า String? (nullable String) หรือก็คือรับได้ทั้งค่า string และค่า nullดังนั้นการส่ง typeString (non-nullable String) เข้าไปก็ไม่ได้ก่อให้เกิดปัญหาใดใด</p><p>ดั้งนั้น Dart จึงออกแบบให้ nullable type เป็น supertype ของ type นั้นๆ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*OOdW5igQYVbxo6GG9MNXsA.png" /><figcaption>image from <a href="https://dart.dev/null-safety/understanding-null-safety#nullability-in-the-type-system">https://dart.dev/null-safety/understanding-null-safety#nullability-in-the-type-system</a></figcaption></figure><p>แต่ในทางกลับกัน ถ้าส่งค่า nullable type ให้ function ที่รับค่า non-nullable type นั้นอาจทำให้เกิดปัญหาได้ เนื่องจาก code ที่รับค่าเป็น non-nuallable ก็อาจมีการเรียกใช้ method ที่ไม่มีบน Null และก่อให้เกิด null exception ตอน runtime อีกเช่นเดิม</p><pre>// Hypothetical unsound null safety:<br>void requireStringNotNull(String definitelyString) {<br>  print(definitelyString.length);<br>}</pre><pre>void main() {<br>  String? maybeString = null; // Or not!<br>  requireStringNotNull(maybeString);<br>}</pre><p>การ run code ชุดนี้จะทำให้เกิด null exception เนื่องจาก Dart 1.x จะสามารถทำ implicit downcasts ได้ (implecit downcasts คือการ cast จาก supertype ไปเป็น subtype) ทำให้การ cast จาก nullable type ซึ่งเป็น supertype ของ non-nullable เป็นไปได้ การมี implicit downcasts จึงสามารถทำให้เกิดปัญหาใน null safety ได้ทำให้ขัดกับหลักการออกแบบ Null safety ดั้งนั้น Dart จึงได้ตัด implicit downcasts ทิ้งไปใน Dart 2.x</p><p>ถ้านำ code ตัวอย่างไปรันบน Dart 2.12 จะมี compile error แสดงว่าThe argument type &#39;String?&#39; can&#39;t be assigned to the parameter type &#39;String&#39;.</p><p>ซึ่ง implicit downcasts นั้น Dart คิดว่าดีกว่าใส่ไว้ เนื่องจากใน Dart 1.x การทำ implicit downcast ก็ได้ก่อให้เกิดปัญหา runtime exception ได้อยู่แล้ว ในบางกรณี</p><pre>// Without null safety:<br>List&lt;int&gt; filterEvens(List&lt;int&gt; ints) {<br>  return ints.where((n) =&gt; n.isEven);<br>}</pre><p>จาก code ข้างต้น .where() จะ return Iterable&lt;int&gt; ซึ่งไม่ใช่ List&lt;int&gt; ดังนั้นเมื่อ run code ชุดนี้จะเกิด runtime exception ขึ้น แต่ใน Dart 2.12 จากการตัด implicit downcasts ทิ้งไป จะทำให้ code ชุดนี้สามารถตรวจพบปัญหาในตอน compile แทน</p><p>สรุปได้ว่าใน Dart 2.x จะแบ่งออกเป็น 2 type หลัก ๆ คือ Non-nullable types และ Nullable types</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*idf7lkJJD9W8n7KB2goSwQ.png" /><figcaption>image from <a href="https://dart.dev/null-safety/understanding-null-safety#nullability-in-the-type-system">https://dart.dev/null-safety/understanding-null-safety#nullability-in-the-type-system</a></figcaption></figure><p>reference:</p><p><a href="https://dart.dev/null-safety/understanding-null-safety#nullability-in-the-type-system">Understanding null safety</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=665d49d1c9c1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ampos-mobile/%E0%B9%80%E0%B8%82%E0%B9%89%E0%B8%B2%E0%B9%83%E0%B8%88-null-safety-%E0%B9%83%E0%B8%99-dart-2-ep1-665d49d1c9c1">เข้าใจ Null Safety ใน Dart 2 (EP1)</a> was originally published in <a href="https://medium.com/ampos-mobile">AMPOS Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cheryl’s Birthday]]></title>
            <link>https://medium.com/ampos-mobile/cheryls-birthday-8c472c0264a1?source=rss----7d32d2560705---4</link>
            <guid isPermaLink="false">https://medium.com/p/8c472c0264a1</guid>
            <category><![CDATA[logic]]></category>
            <category><![CDATA[puzzle]]></category>
            <dc:creator><![CDATA[Pun Pakorn]]></dc:creator>
            <pubDate>Wed, 28 Jul 2021 12:07:13 GMT</pubDate>
            <atom:updated>2021-07-25T09:31:41.533Z</atom:updated>
            <content:encoded><![CDATA[<p>เป็นคำถามจากคณิตศาสตร์โอลิมปิคสำหรับเด็กสิงคโปร์รุ่นอายุ 14 ปี</p><blockquote>แปลเป็นภาษาไทย:<br>อัลเบิร์ตและเบอร์นาร์ดเพิ่งจะรู้จักกับเชอริล ทั้งสองคนอยากจะรู้วันเกิดของเธอ (จีบแน่ๆ) เชอริลก็เล่นตัวไม่ยอมบอกตรงๆ แต่เขียนวันและเดือนออกมาทั้งหมด 10 วัน คือ</blockquote><blockquote>May 15, 16, 19 <br>June 17, 18<br>July 14, 16<br>August 14, 15, 17</blockquote><blockquote>และกระซิบบอกเดือนเกิดที่ถูกต้องให้อัลเบิร์ต แถมไปกระซิบบอกวันที่ถูกต้องให้เบอร์นาร์ด (อ่อยสุด) บทสนทนาหลังจากนั้นเป็นดังนี้</blockquote><blockquote>อัลเบิร์ต: กูไม่รู้วันเกิดเชอริลว่ะ แต่กูมั่นใจว่ามึงก็ไม่รู้<br>เบอร์นาร์ด: ตอนแรกกูก็ไม่รู้หรอก แต่ตอนนี้กูรู้ละ (แหนะขิง)<br>อัลเบิร์ต: งั้นกูก็รู้เหมือนกัน (แนนน้ ไม่ยอม)</blockquote><blockquote>คำถามคือจริงๆ แล้วเฌอปราง เอ้ย เชอริล เกิดวันไหนกันแน่</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*oBfK65JfmnWINd8RowTKKg.png" /><figcaption>original question</figcaption></figure><p>พอดีว่าอัลเบิร์ตและเบอร์นาร์ดไม่ได้แค่ขิงใส่กันไปงั้น แต่สองคนนั้นรู้วันเกิดของเชอริลตามที่พูดจริงๆ เอาล่ะ มาคิดกันว่าความจริงเชอริลเกิดวันไหนกันแน่</p><p>ใครที่อยากลองคิดด้วยตัวเองหยุดตรงนี้ก่อนจะเลื่อนลงไปอ่านเฉลยด้านล่าง</p><p>.</p><p>.</p><p>.</p><p>.</p><p>เริ่มเฉลย</p><p>1. ก่อนอื่นเราก็เอาวันเกิดทั้ง 10 มาเรียงให้สวยงามก่อน ได้ตามนี้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/211/1*C6XHc1LYTS8K4A6lB21KqQ.png" /><figcaption>10 วันที่เชอริลให้มา</figcaption></figure><p>จุดสำคัญของเรื่องนี้คือ อัลเบิร์ตได้ข้อมูลเดือนและเบอร์นาร์ดได้ข้อมูลวัน และอัลเบิร์ตเป็นคนเปิดบทสนทนาก่อน</p><p>2. จากประโยคที่อัลเบิร์ตบอกว่าไม่รู้วันเกิดของเชอริล แต่ก็มั่นใจว่าเบอร์นาร์ดก็ไม่รู้ สามารถสรุปได้ว่าเชอริลบอกอัลเบิร์ตว่าเป็น July หรือ August เพราะว่าถ้าอัลเบิร์ตได้ข้อมูลมาว่า May หรือ June อัลเบิร์ตจะไม่สามารถมั่นใจได้ 100% ว่าเบอร์นาร์ดก็ไม่รู้</p><p>เช่น ถ้าอัลเบิร์ตได้ข้อมูลมาว่าเดือน May อัลเบิร์ตจะฟันธงไม่ได้ 100% ว่าเบอร์นาร์ดรู้วันเกิดแล้วรึเปล่า เพราะเป็นไปได้ว่าเบอร์นาร์ดอาจจะได้ข้อมูลว่าวันที่ 19 ถ้าเป็นเช่นนั้นเบอร์นาร์ดจะรู้วันเกิดแล้ว (และรู้ได้ทันทีว่าเชอริลเลือกใคร ถ้านางจะลำเอียงขนาดนี้) ทำนองเดียวกับเดือน June และวันที่ 18</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/211/1*i-WVtKH5vq9hDrq0F8TQgg.png" /><figcaption>ตัดเดือน May และ June ออกจากความเป็นไปได้</figcaption></figure><p>3. หลังจากที่เบอร์นาร์ดได้ยินประโยคนั้นและเบอร์นาร์ดฉลาดที่จะรู้ทันทีว่าการที่อัลเบิร์ตพูดประโยคนั้นได้แปลว่าอัลเบิร์ตได้เดือน July หรือ August แน่ เบอร์นาร์ดก็รีบขิงก่อนทันทีว่ารู้วันเกิดแล้ว ทำให้เราสามารถสรุปได้ว่าเบอร์นาร์ดต้องได้ข้อมูลว่าวันที่คือ 15 หรือ 16 หรือ 17 ไม่ใช่ 14 เพราะถ้าเป็น 14 เบอร์นาร์ดจะยังไม่สามารถสรุปได้ว่า 14 July หรือ 14 August</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/211/1*2vpRhrKxy15WQX_AsYtaNw.png" /><figcaption>ตัด 14 ทั้งสองเดือนทิ้งไป</figcaption></figure><p>4. หลังจากนั้นอัลเบิร์ตก็ไม่ยอมน้อยหน้า บอกว่ารู้วันเกิดแล้วเหมือนกัน ทำให้สรุปได้ว่าอัลเบิร์ตได้ข้อมูลว่าเดือน July เพราะถ้าเป็น August อัลเบิร์ตจะไม่รู้ว่า 15 หรือ 17</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/211/1*FF5NVQet44g4XOujKHnXHA.png" /></figure><p>สรุปได้ว่าเชอริลเกิดวันที่ 16 July นั่นเอง (ลีลาเยอะนักนะหล่อน)</p><p>มีเวอร์ชั่นอื่นๆ ของคำถามอัลเบิร์ต เบอร์นาร์ด และเชอริลอีก ไว้จะมาเขียนต่อในพาร์ทถัดไป</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c472c0264a1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ampos-mobile/cheryls-birthday-8c472c0264a1">Cheryl’s Birthday</a> was originally published in <a href="https://medium.com/ampos-mobile">AMPOS Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fun with Math]]></title>
            <link>https://medium.com/ampos-mobile/fun-with-math-b061d5df37a1?source=rss----7d32d2560705---4</link>
            <guid isPermaLink="false">https://medium.com/p/b061d5df37a1</guid>
            <dc:creator><![CDATA[Pun Pakorn]]></dc:creator>
            <pubDate>Sun, 25 Jul 2021 10:27:56 GMT</pubDate>
            <atom:updated>2021-07-25T10:27:56.140Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*EugK_-l7srBO0sFbd4RaVQ.png" /></figure><h4>from Mobile team March (many years ago) sharing</h4><h4>1. Is 0.999… = 1? Answer Yes</h4><p>1/9 = 0.111…..<br>multiply by 9<br>9 * 1/9 = 9 * 0.111…<br>1 = 0.999…</p><p>QED</p><h4>2. What’s wrong with this proof?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*uCkF6562RFhm5M75JhJNbg.png" /></figure><p>From the fourth line to the fifth, both sides are divided by (a-b), which is zero because a = b</p><h4>3. What’s wrong with this proof?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/171/1*lor8FAdH9wQK0ALsSC-vNQ.png" /></figure><p>From the fourth line to the fifth (again), in order to change from <em>sqrt(a / b)</em> to <em>sqrt(a) / sqrt(b)</em>, the condition it has to meet is <em>a, b &gt; 0</em></p><h4>4. Birthday Paradox</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hx4QTaJaa0Sc74wRT1BVNA.png" /></figure><p>Simply said, you and your friend are gonna bet whether there are people in the room that share the same birthday. How many people are in the room that will make you bet on `<strong>yes`</strong>?</p><p>Since there are 366 possibilities for birthdays, most people answer more than 100. Actually, if there are only 23 people, the chance to have shared-birthday people is more than 50%!!</p><h4><strong>Calculation:</strong></h4><p>First, you add a person into the room. The chance is 0%</p><p>Next, you add the second one. The chance of they <strong>don’t </strong>share a birthday is 365/366.</p><p>Then the third one. The chance of no one share birthday becomes (365 / 366) * (364 / 366)</p><p>So at the <em>nth</em> person, the chance that everyone has different birthday is (1/366)^n * (365 * 364 * 363 * … * (366-(n-1)), which is 0.492703 for n = 23. That’s less than 50%!</p><p>All the chances are in this table</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/1*ulj3zkghWsvGTBsDDgowwQ.png" /><figcaption>from Wikipedia</figcaption></figure><p>Only 40 people in the room, a chance to have the same birthday is almost 90%</p><p>Go bet with your bad-at-math friends!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b061d5df37a1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ampos-mobile/fun-with-math-b061d5df37a1">Fun with Math</a> was originally published in <a href="https://medium.com/ampos-mobile">AMPOS Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Switch to cross-platform]]></title>
            <link>https://medium.com/ampos-mobile/switch-to-cross-platform-bad9fc7afb5b?source=rss----7d32d2560705---4</link>
            <guid isPermaLink="false">https://medium.com/p/bad9fc7afb5b</guid>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Pimorn Senakat]]></dc:creator>
            <pubDate>Tue, 22 Jan 2019 06:39:07 GMT</pubDate>
            <atom:updated>2019-01-22T06:39:07.100Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why cross-platform?</h3><p>Due to a constraint of our organization situation, cross-platform can help reducing cost on mobile developer resource. It allows having the same code for Android and iOS and also speeds up the development process by having the ability to do hot reloading which saving build time compared to native. And it helps to solve iOS developers recruitment issue.</p><p>So we decided to go with cross-platform.</p><h3>How to choose?</h3><p>Last week, we did an experiment with 2 cross-platform technologies, React Native and Flutter. We separated into 2 groups, to do our new dashboard with the technologies and try to find out blockers for our app.</p><p>After the experiment, we found out that there are no blockers for our app, but Flutter is easy-to-learn for our mobile team.</p><p>So we chose to go with Flutter.</p><h3>Next Step</h3><p>Since we cannot rebuild our app from scratch with this new technology, therefore, we need to investigate how to integrate with native. And new to setup foundation for the new project.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bad9fc7afb5b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ampos-mobile/switch-to-cross-platform-bad9fc7afb5b">Switch to cross-platform</a> was originally published in <a href="https://medium.com/ampos-mobile">AMPOS Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Atlassian Smart Commits]]></title>
            <link>https://medium.com/ampos-mobile/atlassian-smart-commits-cc837b90b6e0?source=rss----7d32d2560705---4</link>
            <guid isPermaLink="false">https://medium.com/p/cc837b90b6e0</guid>
            <dc:creator><![CDATA[Pimorn Senakat]]></dc:creator>
            <pubDate>Wed, 16 May 2018 03:48:59 GMT</pubDate>
            <atom:updated>2018-05-16T03:48:59.095Z</atom:updated>
            <content:encoded><![CDATA[<p>ถ้าคุณอยู่ในโลกของ atlassian แล้วหล่ะก็ เราขอนำเสนอ Smart Commits ที่จะช่วยให้การ comment บน JIRA, การ update JIRA status หรือ การ log เวลาทำงานเป็นเรื่องที่ง่ายขึ้น</p><p>โดย syntax สำหรับ smart commits message มีรูปแบบดังนี้</p><pre>&lt;ignored text&gt; &lt;ISSUE_KEY&gt; &lt;ignored text&gt; #&lt;COMMAND&gt; &lt;optional COMMAND_ARGUMENTS&gt;</pre><p>#COMMAND ที่ใช้ได้มี 3 command ดังนี้</p><pre>comment</pre><pre>time</pre><pre>transition</pre><p><strong>comment</strong></p><p>เป็น command message สำหรับใส่ comment ใน JIRA</p><pre>&lt;ignored text&gt; ISSUE_KEY &lt;ignored text&gt; #comment &lt;comment_string&gt;</pre><p>ตัวอย่างเช่น</p><pre>JIRA-01 #comment corrected indent issue</pre><p>ซึ่งข้อความ corrected indent issue ก็จะกลายไปเป็น comment message ใน JIRA story JIRA-01 เช่นกัน</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc837b90b6e0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ampos-mobile/atlassian-smart-commits-cc837b90b6e0">Atlassian Smart Commits</a> was originally published in <a href="https://medium.com/ampos-mobile">AMPOS Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[8 ทักษะ ของพนักงานระดับท็อปใน Google]]></title>
            <link>https://medium.com/ampos-mobile/8-%E0%B8%97%E0%B8%B1%E0%B8%81%E0%B8%A9%E0%B8%B0-%E0%B8%82%E0%B8%AD%E0%B8%87%E0%B8%9E%E0%B8%99%E0%B8%B1%E0%B8%81%E0%B8%87%E0%B8%B2%E0%B8%99%E0%B8%A3%E0%B8%B0%E0%B8%94%E0%B8%B1%E0%B8%9A%E0%B8%97%E0%B9%87%E0%B8%AD%E0%B8%9B%E0%B9%83%E0%B8%99-google-d2a6659ce7a4?source=rss----7d32d2560705---4</link>
            <guid isPermaLink="false">https://medium.com/p/d2a6659ce7a4</guid>
            <category><![CDATA[google]]></category>
            <category><![CDATA[skills]]></category>
            <category><![CDATA[soft-skills]]></category>
            <category><![CDATA[employees]]></category>
            <dc:creator><![CDATA[Kittinan Pongpianskul]]></dc:creator>
            <pubDate>Sun, 18 Mar 2018 05:56:46 GMT</pubDate>
            <atom:updated>2018-03-18T06:09:46.419Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_ZjAGoHImkRKAMYgTRdKoQ.jpeg" /></figure><h3>ความเชื่อแต่เดิม</h3><p>เราถูกปลูกฝังมาโดยตลอดว่า โตขึ้นอยากมีงานดีๆทำ อยากจะประสบความสำเร็จก็ต้องเรียนเก่งๆ โดยเฉพาะวิชาจำพวก STEM — Science, Technology, Engineering, และ Mathematics แต่จากผลการศึกษาล่าสุด อาจจะไม่ใช่แค่ทักษะเหล่านี้ที่จะทำให้เราประสบความสำเร็จ</p><h3>ผลการวิจัยจาก Google</h3><p>Sergey Brin และ Larry Page — <em>2 ผู้ก่อตั้ง Google </em>— เขาเชื่อว่าคนที่จะเข้าใจเทคโนโลยีได้ ต้องเป็นคนที่จบด้านไอทีมาเท่านั้น โดย Google จึงคิดค้น Algorithm ในการคัดคนเข้าทำงาน เพื่อที่จะได้นักศึกษาที่จบ Computer science ด้วยอันดับต้นๆ ของมหาวิทยาลัยด้านวิทยาศาสตร์ดังๆ มาทำงานด้วย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QdeyQi6EvwJPwoOb." /><figcaption>Photo by <a href="https://unsplash.com/@grohsfabian?utm_source=medium&amp;utm_medium=referral">Fabian Grohs</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>ในปี 2013, Google ได้ตั้งโปรเจค Oxygen ขึ้นมาเพื่อทดสอบกระบวนการคัดเลือกคนเข้าทำงาน เลื่อนตำแหน่ง รวมไปถึงการให้ออก โดยรวบรวมข้อมูลตั้งแต่ปี 1998</p><p>ผลลัพธ์ที่ได้ สรุปทักษะที่พนักงานระดับท็อปมีนั้น มีด้วยกันอยู่ 8 ทักษะ<br>แต่ที่น่าตกใจคือ ทักษะที่เกี่ยวกับ STEM นั้นมาเป็นอย่างสุดท้าย</p><p>แล้วที่อะไรละที่สำคัญกว่า STEM?</p><h3>8 ทักษะที่นำไปสู่ความสำเร็จของพนักงาน Google</h3><h4>1. การเป็นโค้ชที่ดี</h4><p>ให้คำแนะนำกับคนในทีมทั้งในแง่บวกและแง่ลบ เปิดโอกาสให้พูดคุย ปรึกษา ขอคำแนะนำต่างๆ อย่างเป็นส่วนตัว เพื่อจะได้ช่วยให้พัฒนาและปรับปรุงแก้ไข</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OZtTTCb1ugj8PtoL." /><figcaption>Photo by <a href="https://unsplash.com/@rawpixel?utm_source=medium&amp;utm_medium=referral">rawpixel.com</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><em>1–1 meeting เป็นการประชุมแบบส่วนตัว โดยการเปลี่ยนบรรยากาศ​ออกมาจิบกาแฟแบบเป็นกันเอง พร้อมเปิดใจคุยถึงเรื่องปัญหา ปรึกษา เสนอไอเดียใหม่ๆ ที่สามารถปรับใช้กับทีมได้</em></p><h4>2. ให้อิสระทางความคิด</h4><p>Balance ระหว่างอิสระและการให้คำแนะนำ การให้งานที่ยืดหยุ่นจะสามารถทำให้ทีมมีการพัฒนาการคิดเชิงวิเคราะห์/วิพากษ์ และ การแก้ปัญหาที่ดีขึ้น</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XzdsPtc1DIh4LEtY." /><figcaption>Photo by <a href="https://unsplash.com/@headwayio?utm_source=medium&amp;utm_medium=referral">Headway</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>3. การเข้าใจผู้อื่น</h4><p>พยายามทำความรู้จัก เข้าใจในตัวพนักงาน สร้างความคุ้นเคย นอกเหนือจากการทำงาน เพราะแต่คนละล้วนมีการใช้ชีวิต ค่านิยม มุมมอง ไลฟ์สไตล์ที่แตกต่างกัน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hQM0CKOEJzj-mE7-." /><figcaption>“A row of t-shirts of different colors in Petersham” by <a href="https://unsplash.com/@parkerburchfield?utm_source=medium&amp;utm_medium=referral">Parker Burchfield</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>4. ความเห็นอกเห็นใจผู้อื่นและการช่วยเหลือเพื่อนร่วมงาน</h4><p>ดูว่าพนักงานอยากให้ทีมทำอะไรให้สำเร็จและคอยช่วยเหลือ ช่วยจัดลำดับความสำคัญและกำจัดอุปสรรคต่างๆออกไป</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*J8WVnYHdlSZJVeKk." /><figcaption>Photo by <a href="https://unsplash.com/@marcrafanell?utm_source=medium&amp;utm_medium=referral">Marc Rafanell López</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>5. เป็นผู้พูดและผู้ฟังที่ดี</h4><p>นอกจากเราจะพูดแล้ว เราต้องรับฟังความคิดเห็นของคนอื่นด้วย พยายามถามคำถามเป็นปลายเปิดเพื่อเปิดโอกาสในคนอื่นในทีมได้แสดงความคิดเห็น และพยายามทำให้ทีมโปร่งใส คือรู้ว่าเกิดอะไรขึ้น ตอนนี้กำลังทำอะไรกันอยู่ เป้าหมายคืออะไร</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZV7sD_2R4ra7re9x." /><figcaption>Photo by <a href="https://unsplash.com/@jessbroh?utm_source=medium&amp;utm_medium=referral">Jessica Sysengrath</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>6. ช่วยพนักงานในการพัฒนาเส้นทางในอาชีพให้โตขึ้น</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4T8k8uj5fGP4QlZT." /><figcaption>“A silhouette of a person walking on translucent glass steps seen from below” by <a href="https://unsplash.com/@christopher__burns?utm_source=medium&amp;utm_medium=referral">Christopher Burns</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>7. มีวิสัยทัศน์ และกลยุทธที่ชัดเจนให้ทีม</h4><p>แม้จะอยู่ในสภาวะที่วุ่นวาย ก็พยายามเน้นเป้าหมายและกลยุทธอยู่เสมอ โดยให้ทีมมีส่วนร่วมในการตัดสินใจ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VyRXDEJZUITkSSkw." /><figcaption>Photo by <a href="https://unsplash.com/@rawpixel?utm_source=medium&amp;utm_medium=referral">rawpixel.com</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>8. มี Technical skill ที่สามารถให้คำปรึกษาได้</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8xnRZihMBlHoRjDj." /><figcaption>“Two people in elegant shirts brainstorming over a sheet of paper near two laptops” by <a href="https://unsplash.com/@helloquence?utm_source=medium&amp;utm_medium=referral">Helloquence</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>จะเห็นว่าทักษะ 7 อย่างแรก ล้วนแล้วแต่เป็น Soft skill ทั้งสิ้น</p><blockquote><strong>Soft skill</strong> คือ ทักษะที่เกี่ยวกับความสัมพันธ์/ การจัดการทางอารมณ์ เช่น <br>การสื่อสารกับคนอื่น, การพูดจูงใจ, การพรีเซนต์, ความเป็นผู้นำ, การออกความคิดเห็นในทีม<br><strong>Hard skill</strong> คือ ทักษะความรู้ที่เราใช้ในการทำงาน</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TZW7bN3RRrXie9AI." /><figcaption>“A man getting ready to sprint on a running track” by <a href="https://unsplash.com/@willpower?utm_source=medium&amp;utm_medium=referral">William Stitt</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>การมี Soft skill ที่ดีนั้นเป็นข้อได้เปรียบเหนือคนอื่น เพราะทุกวันนี้เราไม่ได้ต้องการคนที่เก่งที่สุด แต่เราต้องการคนที่เก่งงานและเก่งคน</p><p><a href="https://www.washingtonpost.com/news/answer-sheet/wp/2017/12/20/the-surprising-thing-google-learned-about-its-employees-and-what-it-means-for-todays-students/?utm_term=.49564979d42a">https://www.washingtonpost.com/news/answer-sheet/wp/2017/12/20/the-surprising-thing-google-learned-about-its-employees-and-what-it-means-for-todays-students/?utm_term=.49564979d42a</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d2a6659ce7a4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ampos-mobile/8-%E0%B8%97%E0%B8%B1%E0%B8%81%E0%B8%A9%E0%B8%B0-%E0%B8%82%E0%B8%AD%E0%B8%87%E0%B8%9E%E0%B8%99%E0%B8%B1%E0%B8%81%E0%B8%87%E0%B8%B2%E0%B8%99%E0%B8%A3%E0%B8%B0%E0%B8%94%E0%B8%B1%E0%B8%9A%E0%B8%97%E0%B9%87%E0%B8%AD%E0%B8%9B%E0%B9%83%E0%B8%99-google-d2a6659ce7a4">8 ทักษะ ของพนักงานระดับท็อปใน Google</a> was originally published in <a href="https://medium.com/ampos-mobile">AMPOS Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unit test part I — Mocker]]></title>
            <link>https://medium.com/ampos-mobile/unit-test-part-i-mocker-9545b0fcab56?source=rss----7d32d2560705---4</link>
            <guid isPermaLink="false">https://medium.com/p/9545b0fcab56</guid>
            <category><![CDATA[unit-testing]]></category>
            <dc:creator><![CDATA[Pun Pakorn]]></dc:creator>
            <pubDate>Thu, 15 Mar 2018 10:35:25 GMT</pubDate>
            <atom:updated>2018-03-15T10:35:25.134Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*1Fq0bUVc0w42lY-KB-OEmg.png" /><figcaption>เผื่อคนไม่เก็ท <a href="https://www.youtube.com/watch?v=crR6pBGMZ90">https://www.youtube.com/watch?v=crR6pBGMZ90</a></figcaption></figure><p>เวลาเขียน test สิ่งหนึ่งที่หลีกเลี่ยงไม่ได้คือการสร้าง <strong>Test Doubles</strong></p><h4>Test Doubles คือ?</h4><p>คำว่า Double ในที่นี้มีความหมายเดียวกับ Stunt Double หรือตัวแสดงแทนในการถ่ายทำภาพยนตร์ ส่วนในการเขียน test ก็คือการสร้างของที่ไม่ได้ใช้ในโค้ดจริงๆ ขึ้นมาเพื่อให้การทำเทสง่ายขึ้น ที่เหล่า dev ชอบพูดติดปากกันว่า ทำ mock บ้าง ทำ stub บ้าง</p><p>เอาจริงๆ เราก็เป็นคนที่เคยสับสนเหมือนกันว่าศัพท์แต่ละอย่างมันต่างกันยังไง เด๋วก็ mock เด๋วก็ stub เด๋วก็ dummy (คิดว่าบางทีคนพูดก็ไม่รู้ว่ามันต่างกัน)</p><p>วันนี้เราจะมาว่ากันว่า ความจริงแล้วมันต่างกันยังไงนะ ละแต่ละอย่างควรจะใช้จังหวะไหน</p><h4>System ที่เราจะ test กัน</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7be61b4b2f4d890e96fd2d65ad5a7b9c/href">https://medium.com/media/7be61b4b2f4d890e96fd2d65ad5a7b9c/href</a></iframe><p>class System ของเราจะมี 2 properties คือ authorizer ซึ่งจะใช้ในการยืนยันตัวตน และ authorizedUser ซึ่งจะเก็บ User ที่ผ่านการยืนยันตัวตนเรียบร้อยแล้วไว้ เพื่อจะใช้ในการทำงานต่อๆ ไป</p><p>จะเห็นได้ว่าการทำงานของ System จะถูกผูกอยู่กับ Authorizer และโค้ดของ Authorizer ต้องต่อ API กับ backend เพื่อยืนยันตัวตนของผู้ใช้ แบบนี้จะทำให้เราเทส class System ได้ยาก</p><p>ถ้าเราใช้ Authorizer จริงๆ ต่อ API จริงๆ แบบนั้นก็จะเรียกว่าเป็น Integration Test แล้ว ไม่ใช่ Unit Test</p><h4><strong>ถ้างั้นเราควรทำไงล่ะ</strong></h4><p>เราก็จะเปลี่ยนให้ Authorizer เป็น Protocol (หรือ Interface ในภาษาอื่น) และสร้าง Test Double ของ Authorizer ให้ System ตอนที่จะเทส</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7b9335ef8fea4a99842350d5c927a065/href">https://medium.com/media/7b9335ef8fea4a99842350d5c927a065/href</a></iframe><p>มาดูกันดีกว่า ว่าสร้าง Test Double อะไรได้บ้าง และควรใช้จังหวะไหนบ้าง</p><h4>1. Dummy</h4><p>สมมติว่าสิ่งที่เราจะเทสคือ ตอนเริ่ม app จะต้องยังไม่มีผู้ใช้ที่ผ่านการยืนยันตัวตน นั่นคือ</p><p><em>ตอนที่ init System ขึ้นมา authorizedUser ต้องเป็น nil</em></p><p>โค้ดที่ใช้ในการเทสเคสนี้จะเป็นประมาณนี้</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e6b142719bd6d70cc70e8ad086b3ced2/href">https://medium.com/media/e6b142719bd6d70cc70e8ad086b3ced2/href</a></iframe><p>เราต้องสร้าง dummy ขึ้นมาก็เพราะว่า ตอน init System จำเป็นต้องใส่ Authorizer เข้าไปเป็น parameter แต่ถ้าดูดีๆ จะเห็นว่าเราไม่ได้ใช้ dummy ในการเทสเคสนี้เลย</p><p>ใช่แล้ว! นั่นแหละคือหน้าที่ของ dummy</p><p><strong>Dummy คือของที่เราจำเป็นต้องใช้ในการทำอะไรสักอย่าง แต่เราไม่สนใจเลยว่ามันจะถูกใช้อย่างไร</strong></p><blockquote><em>You pass it into something when you don’t care how it’s used. — Uncle Bob</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FkowJdTFe1lxcfl9qTgu5g.png" /></figure><h4>2. Stub</h4><p>สมมติว่า System ของเรามี method นึงที่ใช้ในการเชคว่า <em>authorizedUser ที่เรามี ยัง authorized อยู่จริงๆ รึเปล่า</em></p><p>โค้ดก็จะเป็นประมาณนี้</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ee6691028bea120256fdcc3195aa971/href">https://medium.com/media/6ee6691028bea120256fdcc3195aa971/href</a></iframe><p>การเทส method recheckAuthorizedUser อย่างหนึ่งที่ควรมีก็คือ ถ้าผู้ใช้ที่เราเก็บอยู่ ไม่ผ่านการยืนยันตัวตนแล้ว ก็ต้องเปลี่ยนหน้าไปหน้า login นะ นั่นคือ</p><p><em>ถ้ามี authorizedUser และ authorizer.authorize return false ต้องไปหน้า login</em></p><p>คราวนี้เราจะใช้ dummy ไม่ได้แล้วนะ เพราะเราอยากได้ค่า false ตอนเรียก authorize dummy มันรีเทินอะไรซี้ซั้วก็ได้ เพราะเราไม่แคร์อยู่แล้ว</p><p>ในเวลาแบบนี้เราต้องใช้ Stub!</p><p><strong>Stub คือ Test Double ที่สร้างขึ้นมาเพื่อทำหน้าที่เดียว </strong>เช่น ในกรณีนี้คือให้ authorize return false เท่านั้น</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/09aaa31e2e822dbec1be3e7596093a4f/href">https://medium.com/media/09aaa31e2e822dbec1be3e7596093a4f/href</a></iframe><p><strong>Note:</strong> อย่าเข้าใจผิดว่า เคสแรกให้ return true เลยเป็น dummy ส่วนเคสสอง return false เลยเป็น stub นะ เคสแรกเราไม่แคร์ผลลัพธ์จะ true หรือ false มันก็ยังเป็น dummy อยู่ดี ส่วนเคสสองพอดีเราอยากได้ผลลัพธ์เป็น false ถ้าอยากได้ผลลัพธ์เป็น true ก็สามารถสร้าง AuthorizerAlwaysTrueStub ได้</p><p>การจะเป็น Stub หรือ Dummy ไม่ได้อยู่ที่ว่า return อะไร แต่อยู่ที่ behavior</p><h4>3. Spy</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/272/1*FnkJIqDFl8VnhPE_XBpt5w.jpeg" /><figcaption>คนละ spy แล้วว้อยยย (หาวาร์ปกันเองนะ)</figcaption></figure><p>สมมติว่าเรามี method สักอย่างใน System ที่ต้องเรียก authorizer.authorize เทสเคสนึงที่เราควรเขียนก็คือ method นั้นเนี่ย มันไปเรียก authorizer.authorize จริงๆ นะ</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/96a9ce3f363cc62bdfd33a5616270127/href">https://medium.com/media/96a9ce3f363cc62bdfd33a5616270127/href</a></iframe><p>จังหวะนี้เราจะใช้ Spy เพื่อจะเชคว่า authorize ถูกเรียกจริงรึเปล่า แบบนี้</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/baa851728cd183d601140134cf53c939/href">https://medium.com/media/baa851728cd183d601140134cf53c939/href</a></iframe><p><strong>Spy คือ Test Double ที่สร้างขึ้นมาเพื่อตรวจสอบการทำงานบางอย่างของ Caller </strong>เช่น กรณีนี้คือตรวจสอบว่า authorize ถูกเรียกและ pass parameter มาถูกต้อง</p><p>การใช้ Spy มีข้อควรระวังคือ ควรจะ spy ให้น้อยที่สุดเท่าที่จะเทสได้ (ในกรณีนี้คือ spy parameter 2 ตัว) เพราะว่ายิ่ง spy มากก็จะยิ่งทำให้เกิด Coupling ระหว่าง Spy กับของที่จะเทสมาก และจะนำไปสู่ fragile test คือเทสที่พังง่าย เพียงแค่เราแก้โค้ดเล็กน้อย</p><h4>4. Mock</h4><p>คราวนี้เราจะมาพูดถึง Mock จริงๆ ตามนิยามละ ไม่ใช่คำพูดติดปากที่ใครต่อใครใช้กันไปทั่ว</p><p>โค้ดที่เราจะเทสด้วย Mock จะเหมือนกับ Spy เมื่อกี้นี้ คือเราจะเทสว่า doSomething เรียก authorize และส่ง parameter ถูกรึเปล่า</p><p>ถ้าเทสด้วย Mock จะเป็นแบบนี้</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fcebcc880863b697d23906885bcc8ed8/href">https://medium.com/media/fcebcc880863b697d23906885bcc8ed8/href</a></iframe><p>จะเห็นว่าการเทสด้วย Mock จะไม่สนใจค่าที่ Mock return กลับมาเลย แต่จะสนใจ behavior ของ System มากกว่า ว่าทำงานถูกอย่างที่ต้องการรึเปล่า และจะเชคใน method <strong><em>verify </em></strong>ซึ่ง return แค่ Bool เพื่อบอกว่า behavior ถูกมั้ย</p><p><strong>Note:</strong> verify ไม่จำเป็นต้องรับ parameter ก็ได้ เช่น ถ้าเราอยากจะเทสแค่ doSomething เรียก authorize จริงรึเปล่า ก็จะเขียนแค่นี้ก็ได้</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2e764c77a36a4189e479af9bd465a44a/href">https://medium.com/media/2e764c77a36a4189e479af9bd465a44a/href</a></iframe><p>Mock จะ coupling มากกว่า Spy มาก เพราะจะเทสใน Mock เลย ส่วน Spy จะแค่ return ค่าหรือมี property ให้ Test case มาตรวจสอบเอง</p><h4>5. Fake</h4><p>ตัวสุดท้ายที่เราจะพูดถึงกันคือ Fake</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/96c0cc738f78bbb673d4298ab8da83a4/href">https://medium.com/media/96c0cc738f78bbb673d4298ab8da83a4/href</a></iframe><p>อันนี้คือตัวอย่างของ Fake ที่จะ return true เมื่อ user เป็น admin อาจจะใช้ในการเทสว่า ค่าเริ่มต้นของระบบต้องมี admin user เสมอ</p><p>Fake แตกต่างกับ Stub ตรงที่ Fake จะรู้จัก business logic ด้วย!! เราอาจจะพูดได้ว่า Dummy &lt; Stub &lt; Spy &lt; Mock แต่ Fake คืออยู่อีกโลกนึงเลย ทำให้ตัว Fake จะซับซ้อนกว่าอีกสี่ตัวที่เหลือมากๆ มากจนอาจจะต้องมีเทสเคสเพื่อเทส Fake อีกที</p><h4>Conclusion</h4><p>จาก Dummy จนถึง Fake คือเรียงตามลำดับความซับซ้อนของ Test Double แล้ว ในการเขียนจริงๆ เราควรเลือกใช้ตัวที่ซับซ้อนน้อยที่สุดเท่าที่เป็นไปได้ที่ทำให้เราเขียนเทสที่ต้องการได้</p><p>จากประสบการณ์จริง ใน project ปัจจุบัน ส่วนใหญ่จะใช้แค่ Stub กับ Spy เท่านั้น</p><h3>จบแล้ว</h3><p>&lt;เขียนสามชั่วโมงได้ (3 min read) ฮือๆ&gt;</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9545b0fcab56" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ampos-mobile/unit-test-part-i-mocker-9545b0fcab56">Unit test part I — Mocker</a> was originally published in <a href="https://medium.com/ampos-mobile">AMPOS Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mobile Team Sharing on February]]></title>
            <link>https://medium.com/ampos-mobile/mobile-team-sharing-on-february-9c07e44bcdbc?source=rss----7d32d2560705---4</link>
            <guid isPermaLink="false">https://medium.com/p/9c07e44bcdbc</guid>
            <dc:creator><![CDATA[Pimorn Senakat]]></dc:creator>
            <pubDate>Wed, 14 Mar 2018 17:29:53 GMT</pubDate>
            <atom:updated>2024-07-12T09:59:15.401Z</atom:updated>
            <content:encoded><![CDATA[<p>At Au Bon Pain, Ekamai</p><p><a href="https://medium.com/u/3fda46439090">Pun Pakorn</a> — DI for Unit Testing</p><p><a href="https://medium.com/ampos-mobile/unit-test-part-i-mocker-9545b0fcab56">Unit test part I — Mocker</a></p><p><a href="https://medium.com/u/56973d90c7a1">Wanchuda Sukarrom (Tow)</a> — NLP</p><p><a href="https://medium.com/ampos-mobile/thoughts-on-nlp-271cd6567332">Thoughts on NLP 🤔</a></p><p><a href="https://medium.com/u/5706f9f220d3">Pimorn Senakat</a> — JIRA Smart Commit</p><p><a href="https://medium.com/ampos-mobile/atlassian-smart-commits-cc837b90b6e0">Atlassian Smart Commits</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c07e44bcdbc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ampos-mobile/mobile-team-sharing-on-february-9c07e44bcdbc">Mobile Team Sharing on February</a> was originally published in <a href="https://medium.com/ampos-mobile">AMPOS Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Thoughts on NLP ]]></title>
            <link>https://medium.com/ampos-mobile/thoughts-on-nlp-271cd6567332?source=rss----7d32d2560705---4</link>
            <guid isPermaLink="false">https://medium.com/p/271cd6567332</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[nlp]]></category>
            <dc:creator><![CDATA[Tow]]></dc:creator>
            <pubDate>Sat, 10 Mar 2018 18:53:24 GMT</pubDate>
            <atom:updated>2018-03-10T20:50:06.661Z</atom:updated>
            <content:encoded><![CDATA[<p>People try to find a way to communicate with machines in a more natural way because if computers understand languages, human life will be more convenient.</p><p>The field that tries to achieve this objective is <strong><em>Natural Language Processing (NLP)</em></strong>. It is one of the most active fields in computer science and it relates to other fields such as Data Science, A.I., and Linguistics. The most popular NLP approach is creating a language understanding model with the help of <strong><em>Machine Learning technique</em></strong>.</p><p>There are many challenges obstructing development of NLP. The most important problem that makes NLP hard is <strong><em>language ambiguity at every level</em></strong> and each language also has different syntax and structure.</p><p>For example,</p><p>1. Segmentation “Unionized”</p><pre>Union + ized</pre><pre>or</pre><pre>Un + ionized</pre><p>2. Homophone</p><blockquote>Same sound<br>Different spelling<br>Different meaning</blockquote><pre>I scream / Ice-cream</pre><pre>To / Two / Too</pre><pre>Bear / Bare</pre><pre>See / Sea</pre><pre>Right / Write</pre><p>3. Homograph</p><blockquote>Different sound<br>Same spelling<br>Different meaning</blockquote><pre>Minute<br>- Time (minit)<br>- Small (mīˈn(y)o͞ot)</pre><p>4. Homonym</p><blockquote>Same sound<br>Same spelling<br>Different meaning</blockquote><pre>Close<br>- The supermarket that <strong><em>close</em></strong> to my house will <strong><em>close</em></strong> at 5pm</pre><pre>Ring<br>- The phone which near the <strong><em>ring</em></strong> was <strong><em>ring</em></strong>ing for half an hour.</pre><p>5. Number</p><pre>12 (twelve or one-two)</pre><pre>Time 10.30<br>- Half past ten<br>- Ten thirty</pre><pre>Year<br>- 1999 : Nineteen ninety-nine<br>- 2000 : Two thousands</pre><pre>Some languages don’t have zero</pre><pre>Some languages don’t use base-10<br>- Nimbia, base-12<br>- French, mix of base-10 and base-20<br>- Traditional Welsh, base-20 with a pivot at 15</pre><p>6. Inflection</p><pre>Make | Makes | Made | Making</pre><pre>Some word in <strong><em>Sri Lanka</em></strong> has 216 word inflection</pre><pre><strong><em>Thai</em></strong> has no word inflection</pre><p>7. Tone</p><pre>Kai kai kai kai (Khır k̄hāy k̄hị̀ kị̀)<br>= ใครขายไข่ไก่</pre><pre>In Thai sentence means &quot;Who sell the chicken eggs&quot;</pre><p>8. Order</p><pre>What is your name?</pre><pre>In Thai is </pre><pre>&quot;ชื่อของคุณคืออะไร&quot; = Your name is what?</pre><p>9. RTL / LTR</p><pre>English read from left to right</pre><pre>Arabic read from right to left</pre><p>10. Grammar</p><pre><strong><em>&quot;Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo.&quot;</em></strong> is grammatically correct sentence in American English.</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1lz1jugHIVtuZW18gCtNnA.png" /></figure><p>More information :</p><p><a href="https://en.wikipedia.org/wiki/Buffalo_buffalo_Buffalo_buffalo_buffalo_buffalo_Buffalo_buffalo">Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo - Wikipedia</a></p><p>To teach machine to interact in a way similar to humans require a wide range of data. Good data can only be created by skillful humans, linguists in most cases. However, some dialects, tribe languages or languages which are spoken by small groups might not have any linguist or their linguists might not have enough expertise such as <strong><em>Sylbo</em></strong> (see the link below). For this reason, NLP development in some languages is lagging behind.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FC0CIRCjoICA%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DC0CIRCjoICA&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FC0CIRCjoICA%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/00a250195ee48afc51fd3a7ade6e545e/href">https://medium.com/media/00a250195ee48afc51fd3a7ade6e545e/href</a></iframe><p>Another point to consider is that because languages are evolving, linguists take critical roles in developing NLP. If linguists lack the knowledge of the history of languages, they could make mistake. Moreover, in some languages, there are no linguists at all. For those languages we couldn’t rely on linguists to develop NLP, so should we find other eligible native speakers to work in place of linguists or is it possible to train native speakers to help generate and check data?</p><blockquote><strong>Advantages</strong>: <br>More data can be generated in shorter time. For translation, choices of words selected by non-linguist translators can be easier to understand (commonly used) and can be less formal.</blockquote><blockquote><strong>Disadvantage</strong>: <br>More people working on a task means there is more management overhead cost. Data might be inconsistent since non-linguist translators might speak in different dialects or have different background. Drawing a conclusion from inconsistent data could be harder without linguists, so data quality could be expected to be lower than when only linguists are involved.</blockquote><h3>For a field like Machine Translation, if not enough data is given, translation between a language pair without data can be suffering from context losses.</h3><p>To be able to translate a sentence to another language, without availability of source-to-destination translation model, one first translate it to English and then translate English to the destination language. This approach might lead to the loss of contexts because some concepts do not exist in English. Accordingly, the translated result might be inaccurate or ambiguous.</p><p>Using English as the medium language for translation between two other languages is popular only because English is an international language with the most number of speakers. In fact, this could pose a problem since English might not be the best language to capture contexts and concepts of other languages. The best way to prevent context loss is to find a person that is native to both languages, for example, a person that is native to Javanese and Turkish to translate a sentence between Javanese and Turkish. Nevertheless, <strong><em>finding a speaker that is native to both languages is extremely hard</em></strong>. It also means that Javanese-and-Turkish translation data is rare, so creating a good model for this language pair is almost impossible.</p><p>When adopting a holistic view of a language, not all problems occur. As for syntax and structure, even though there are languages that share no features, like Xhosa and Japanese, there are languages that share many features like Thai and Lao. <strong><em>Grouping similar languages altogether could benefit the learning process.</em></strong> For example, grouping Japanese and Korea could result in better quality of translation than grouping Japanese and Portuguese.</p><h3>Collaboration between groups of similar languages</h3><p>helps result models could benefit from similarity between languages. They could be better than models created from group of not-so-similar languages and they could better than models created for single languages.</p><p>Beside this, linguists who are experts in different languages will have an opportunity to learn from each other and from other languages.</p><blockquote>In more technical terms, languages with similar structures can share data and multi languages model can be created using shared data. With this approach, less data are required per language.</blockquote><p>In addition, one model can be shared by many languages. As a consequence, programmer will have less work to generate models</p><p>However,<strong> grouping languages is not trivial</strong>. Sometimes, if languages are grouped wrongly, grouping might not help processes and models at all. Even worse, this could slow down the whole process. So there is a risk to bear.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*UrJ2ZLiNfBJKJVMecBXyow.jpeg" /></figure><h3><strong>Google translate</strong></h3><p>is probably the most powerful and most used translate tool at this moment.</p><p>But if we look back to 10 years ago, whether an article was translated by Google translate, we could know immediately once we read it.</p><p>Nowadays, Google improved Google translate by using an artificial neural network to learn by itself which call <strong><em>Google Neural Machine Translation (GNMT). </em></strong>This system increase the quality of translation by making it can translate more speed, accuracy and fluently.</p><p>To overcome an issue such as context loss, Google creates an approach called <strong><em>Google’s Multilingual Neural Machine Translation</em></strong>. This approach is extended from GNMT. It is interesting since they are able to blend abundant of data from multiple languages pairs to create a model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*ZmiMmdjLnhLVmBQZFNAOKg.gif" /></figure><p>The outcome is a model which capable of translating between many languages pairs, rather than one language pair per model. This <strong>enable zero-shot translation</strong> or translate from source-to-destination.</p><p>Since the model works, it proves that blended data from languages sharing commonality can help us overcome such a critical issue.</p><ul><li><a href="https://en.wikipedia.org/wiki/Google_Neural_Machine_Translation">Google Neural Machine Translation - Wikipedia</a></li><li><a href="https://research.googleblog.com/2016/11/zero-shot-translation-with-googles.html">Zero-Shot Translation with Google&#39;s Multilingual Neural Machine Translation System</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=271cd6567332" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ampos-mobile/thoughts-on-nlp-271cd6567332">Thoughts on NLP 🤔</a> was originally published in <a href="https://medium.com/ampos-mobile">AMPOS Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>