<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>แนท (/næt/)</title>
	<atom:link href="http://llun.in.th/feed" rel="self" type="application/rss+xml" />
	<link>http://llun.in.th</link>
	<description>/īm/ /ə/ /prōgræmər/</description>
	<lastBuildDate>Sat, 06 Mar 2010 16:11:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Function declaration style and variable scope problem</title>
		<link>http://llun.in.th/archives/1413</link>
		<comments>http://llun.in.th/archives/1413#comments</comments>
		<pubDate>Sat, 06 Mar 2010 11:27:35 +0000</pubDate>
		<dc:creator>llun</dc:creator>
				<category><![CDATA[ภาษา]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[scope]]></category>

		<guid isPermaLink="false">http://llun.in.th/?p=1413</guid>
		<description><![CDATA[เป็นปัญหาที่ยังไม่สามารถทำให้เกิดขึ้นอีกในโค้ดแบบอื่นได้ แต่เอามาเขียนไว้ก่อนเพราะมันสร้างความปวดหัวให้กับคนเขียน Javascript มาก่อนมากมาย และไม่รู้จะเจอมันอีกทีเหมื่อไหร่ แต่ไม่สามารถเอาโค้ดต้นฉบับทั้งก้อนมาใส่ในนี้ได้ เลยขอแค่เล่าแล้วเอา stacktrace มาแปะใส่ไว้ละกัน

เหตุการณ์เริ่มต้นเกิดจาก @pitiphong_p เจอบั๊กหนึ่งที่ไม่รู็จะแก้อย่างไรเข้าเพราะใน Flash Builder Debugger บอกว่าตัวแปรต่างๆ มีค่าครบสมบุรณ์หมด แต่ error บอกไม่สามารถหาตัวแปรนั้นได้


&#91;Fault&#93; exception, information=TypeError: Error #1010: A term is undefined and has no properties.
Fault, CheckboxListRenderer.as:21
 21            data.selected = checkbox.selected
&#40;fdb&#41; bt
#0   this = &#91;Object 32588233, class='global'&#93;.&#60;anonymous&#62;&#40;event=&#91;Object [...]]]></description>
			<content:encoded><![CDATA[<p>เป็นปัญหาที่ยังไม่สามารถทำให้เกิดขึ้นอีกในโค้ดแบบอื่นได้ แต่เอามาเขียนไว้ก่อนเพราะมันสร้างความปวดหัวให้กับคนเขียน Javascript มาก่อนมากมาย และไม่รู้จะเจอมันอีกทีเหมื่อไหร่ แต่ไม่สามารถเอาโค้ดต้นฉบับทั้งก้อนมาใส่ในนี้ได้ เลยขอแค่เล่าแล้วเอา stacktrace มาแปะใส่ไว้ละกัน</p>
<p>
เหตุการณ์เริ่มต้นเกิดจาก @<a href="http://www.twitter.com/pitiphong_p">pitiphong_p</a> เจอบั๊กหนึ่งที่ไม่รู็จะแก้อย่างไรเข้าเพราะใน Flash Builder Debugger บอกว่าตัวแปรต่างๆ มีค่าครบสมบุรณ์หมด แต่ error บอกไม่สามารถหาตัวแปรนั้นได้
</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #000000;">&#91;</span>Fault<span style="color: #000000;">&#93;</span> exception, information=<span style="color: #004993;">TypeError</span><span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Error</span> #<span style="color: #000000; font-weight:bold;">1010</span><span style="color: #000000; font-weight: bold;">:</span> A term <span style="color: #0033ff; font-weight: bold;">is</span> <span style="color: #0033ff; font-weight: bold;">undefined</span> and has no properties.
Fault, CheckboxListRenderer.<span style="color: #0033ff; font-weight: bold;">as</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">21</span>
 <span style="color: #000000; font-weight:bold;">21</span>            <span style="color: #004993;">data</span>.selected = checkbox.selected
<span style="color: #000000;">&#40;</span>fdb<span style="color: #000000;">&#41;</span> bt
#<span style="color: #000000; font-weight:bold;">0</span>   <span style="color: #0033ff; font-weight: bold;">this</span> = <span style="color: #000000;">&#91;</span><span style="color: #004993;">Object</span> <span style="color: #000000; font-weight:bold;">32588233</span>, <span style="color: #9900cc; font-weight: bold;">class</span>=<span style="color: #990000;">'global'</span><span style="color: #000000;">&#93;</span>.<span style="color: #000000; font-weight: bold;">&lt;</span>anonymous<span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000;">&#40;</span>event=<span style="color: #000000;">&#91;</span><span style="color: #004993;">Object</span> <span style="color: #000000; font-weight:bold;">659079665</span>, <span style="color: #9900cc; font-weight: bold;">class</span>=<span style="color: #990000;">'flash.events::Event'</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span> at CheckboxListRenderer.<span style="color: #0033ff; font-weight: bold;">as</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">21</span>
#<span style="color: #000000; font-weight:bold;">1</span>   <span style="color: #004993;">EventDispatcher</span><span style="color: #000000; font-weight: bold;">/</span>dispatchEventFunction<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> at <span style="color: #000000; font-weight: bold;">&lt;</span>null<span style="color: #000000; font-weight: bold;">&gt;:</span><span style="color: #000000; font-weight:bold;">0</span>
#<span style="color: #000000; font-weight:bold;">2</span>   <span style="color: #0033ff; font-weight: bold;">this</span> = <span style="color: #000000;">&#91;</span><span style="color: #004993;">Object</span> <span style="color: #000000; font-weight:bold;">655130785</span>, <span style="color: #9900cc; font-weight: bold;">class</span>=<span style="color: #990000;">'mx.controls::CheckBox'</span><span style="color: #000000;">&#93;</span>.<span style="color: #004993;">EventDispatcher</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #004993;">dispatchEvent</span><span style="color: #000000;">&#40;</span>_arg1=<span style="color: #000000;">&#91;</span><span style="color: #004993;">Object</span> <span style="color: #000000; font-weight:bold;">659079665</span>, <span style="color: #9900cc; font-weight: bold;">class</span>=<span style="color: #990000;">'flash.events::Event'</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span> at <span style="color: #000000; font-weight: bold;">&lt;</span>null<span style="color: #000000; font-weight: bold;">&gt;:</span><span style="color: #000000; font-weight:bold;">0</span>
#<span style="color: #000000; font-weight:bold;">3</span>   <span style="color: #0033ff; font-weight: bold;">this</span> = <span style="color: #000000;">&#91;</span><span style="color: #004993;">Object</span> <span style="color: #000000; font-weight:bold;">655130785</span>, <span style="color: #9900cc; font-weight: bold;">class</span>=<span style="color: #990000;">'mx.controls::CheckBox'</span><span style="color: #000000;">&#93;</span>.UIComponent<span style="color: #000000; font-weight: bold;">/</span><span style="color: #004993;">dispatchEvent</span><span style="color: #000000;">&#40;</span>event=<span style="color: #000000;">&#91;</span><span style="color: #004993;">Object</span> <span style="color: #000000; font-weight:bold;">659079665</span>, <span style="color: #9900cc; font-weight: bold;">class</span>=<span style="color: #990000;">'flash.events::Event'</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span> at UIComponent.<span style="color: #0033ff; font-weight: bold;">as</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">9440</span>
#<span style="color: #000000; font-weight:bold;">4</span>   <span style="color: #0033ff; font-weight: bold;">this</span> = <span style="color: #000000;">&#91;</span><span style="color: #004993;">Object</span> <span style="color: #000000; font-weight:bold;">655130785</span>, <span style="color: #9900cc; font-weight: bold;">class</span>=<span style="color: #990000;">'mx.controls::CheckBox'</span><span style="color: #000000;">&#93;</span>.Button<span style="color: #000000; font-weight: bold;">/</span>http<span style="color: #000000; font-weight: bold;">:</span><span style="color: #009900;">//www.adobe.com/2006/flex/mx/internal::setSelected(value=true, isProgrammatic=false) at Button.as:1204</span>
#<span style="color: #000000; font-weight:bold;">5</span>   <span style="color: #0033ff; font-weight: bold;">this</span> = <span style="color: #000000;">&#91;</span><span style="color: #004993;">Object</span> <span style="color: #000000; font-weight:bold;">655130785</span>, <span style="color: #9900cc; font-weight: bold;">class</span>=<span style="color: #990000;">'mx.controls::CheckBox'</span><span style="color: #000000;">&#93;</span>.Button<span style="color: #000000; font-weight: bold;">/</span>clickHandler<span style="color: #000000;">&#40;</span>event=<span style="color: #000000;">&#91;</span><span style="color: #004993;">Object</span> <span style="color: #000000; font-weight:bold;">591642521</span>, <span style="color: #9900cc; font-weight: bold;">class</span>=<span style="color: #990000;">'flash.events::MouseEvent'</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span> at Button.<span style="color: #0033ff; font-weight: bold;">as</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">2798</span></pre></div></div>

<p>ตอนแรกก็พยายามคาดเดาปัญหาไปต่าง ๆ อาจเกิดจากการ bind ตัวแปรผิดที่ หรือตอนกำหนดค่าผิด แต่ถ้าอย่างนั้น ทำไมตอน debug ถึงสามารถเอาค่าออกมาดูได้หละ ลองดูโค้ดเจ้าปัญหาซักนิดก่อนละกัน</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> sample
<span style="color: #000000;">&#123;</span>
  <span style="color: #0033ff; font-weight: bold;">import</span> mx.binding.utils.BindingUtils
  <span style="color: #0033ff; font-weight: bold;">import</span> mx.containers.HBox
  <span style="color: #0033ff; font-weight: bold;">import</span> mx.controls.Alert
  <span style="color: #0033ff; font-weight: bold;">import</span> mx.controls.CheckBox
  <span style="color: #0033ff; font-weight: bold;">import</span> mx.core.IFactory
&nbsp;
  <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">Event</span>
&nbsp;
  <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> CheckboxListRenderer extends HBox <span style="color: #000000;">&#123;</span>
&nbsp;
    <span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span>
    <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> listRenderer<span style="color: #000000; font-weight: bold;">:</span>IFactory
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> checkbox<span style="color: #000000; font-weight: bold;">:</span>CheckBox = <span style="color: #0033ff; font-weight: bold;">new</span> CheckBox<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> instance<span style="color: #000000; font-weight: bold;">:*</span>
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> checkboxChange = <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
      <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">data</span>.<span style="color: #004993;">hasOwnProperty</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">'selected'</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
        <span style="color: #004993;">data</span>.selected = checkbox.selected
      <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">public</span> override <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> <span style="color: #004993;">data</span><span style="color: #000000;">&#40;</span>item<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
      <span style="color: #0033ff; font-weight: bold;">super</span>.<span style="color: #004993;">data</span> = item
      <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>item <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> item.<span style="color: #004993;">hasOwnProperty</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">'selected'</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
        checkbox.selected = item.selected
      <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">protected</span> override <span style="color: #339966; font-weight: bold;">function</span> createChildren<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
      <span style="color: #0033ff; font-weight: bold;">super</span>.createChildren<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
      <span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>checkbox<span style="color: #000000;">&#41;</span>
&nbsp;
      <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>listRenderer <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
        instance = listRenderer.newInstance<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>instance<span style="color: #000000;">&#41;</span>
      <span style="color: #000000;">&#125;</span>
      <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Checkbox list renderer created children&quot;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">protected</span> override <span style="color: #339966; font-weight: bold;">function</span> commitProperties<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
      <span style="color: #0033ff; font-weight: bold;">super</span>.commitProperties<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
      horizontalScrollPolicy = <span style="color: #990000;">&quot;off&quot;</span>
      verticalScrollPolicy = <span style="color: #990000;">&quot;off&quot;</span>
&nbsp;
      <span style="color: #009900;">// Handle change in targeting phase for changing data selected flag.</span>
      checkbox.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">CHANGE</span>, checkboxChange<span style="color: #000000;">&#41;</span>
&nbsp;
      BindingUtils.bindProperty<span style="color: #000000;">&#40;</span>instance, <span style="color: #990000;">&quot;data&quot;</span>, <span style="color: #0033ff; font-weight: bold;">this</span>, <span style="color: #990000;">&quot;data&quot;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
  <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>
รับรองได้เลยว่าถ้าใครเอาโค้ดด้านบนไปลองเล่นดูเองจะไม่เจอปัญหาแน่นอน ซึ่งถึงวันนี้ยังไม่เข้าใจเหมือนกันว่าทำยังไงถึงจะเกิดปัญหาได้ แต่วิธีแก้นั้นง่ายมากคือ เปลี่ยนวิธีประกาศฟังก์ชั่นจาก
</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>20
21
22
23
24
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;">    <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> checkboxChange = <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
      <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">data</span>.<span style="color: #004993;">hasOwnProperty</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">'selected'</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
        <span style="color: #004993;">data</span>.selected = checkbox.selected
      <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>
เป็น
</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>20
21
22
23
24
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;">    <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> checkboxChange<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
      <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">data</span>.<span style="color: #004993;">hasOwnProperty</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">'selected'</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
        <span style="color: #004993;">data</span>.selected = checkbox.selected
      <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>
ปัญหาทุกอย่างก็หายไปอย่างปริศนา ทิ้งไว้แต่เครื่องหมายคำถามว่าทำไมขอบเขตของฟังก์ชั่นถึงต่างกันเพียงแค่เปลี่ยนรูปแบบการประกาศฟังก์ชั่นเท่านั้น และไม่สามารถทดลองซ้ำกับการเขียนโค้ดแบบง่าย ๆ ได้ แต่หลังจากนี้รู้แล้วว่า จะไม่ประกาศฟังก์ชั่นในรูปแบบตัวแปรอีก เพราะไม่อยากเจอปัญหาแปลกๆ แบบนี้ให้นั่งปวดหัวหาวิธีแก้อีกแล้ว</p>
]]></content:encoded>
			<wfw:commentRss>http://llun.in.th/archives/1413/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Vietnam Trip</title>
		<link>http://llun.in.th/archives/1400</link>
		<comments>http://llun.in.th/archives/1400#comments</comments>
		<pubDate>Wed, 17 Feb 2010 14:29:18 +0000</pubDate>
		<dc:creator>llun</dc:creator>
				<category><![CDATA[มั่ว]]></category>
		<category><![CDATA[trip]]></category>

		<guid isPermaLink="false">http://llun.in.th/?p=1400</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p><a href="http://picasaweb.google.com/llunspace/VietnamTrip?feat=directlink"><img class="aligncenter size-full wp-image-1401" style="border: 1px solid black;" title="Vietnam Trip" src="http://llun.in.th/wp-content/uploads/2010/02/Screen-shot-2010-02-17-at-9.22.52-PM.png" alt="" width="453" height="325" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://llun.in.th/archives/1400/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>เข้าใจตรงกัน?</title>
		<link>http://llun.in.th/archives/1384</link>
		<comments>http://llun.in.th/archives/1384#comments</comments>
		<pubDate>Tue, 26 Jan 2010 13:39:20 +0000</pubDate>
		<dc:creator>llun</dc:creator>
				<category><![CDATA[มั่ว]]></category>

		<guid isPermaLink="false">http://llun.in.th/?p=1384</guid>
		<description><![CDATA[ทำงานมาเกือบสามปี ประชุมมาก็หลายครั้ง จนวันนี้ถึงได้คิดอย่างจริงจังว่า ที่คุยๆ กันเนี๊ยะ มันเข้าใจตรงกันหรือป่าว มันเป็นสิ่งที่กวนใจจนทำให้ไปสมัครเรียน ป.โท เพื่อหวังจะได้คำตอบนี้ และหาวิธีที่จะทำให้มันตรงกัน(ซึ่งก็ไม่รู้จะได้คำตอบหรือป่าว)
วันนี้ก็มีประชุมอีก ประชุมกันประมาณ ห้า &#8211; หก คน พูดมาถึงจุดหนึ่งทุกคนรู้แล้วว่าจะแก้ปัญหาอะไร (ซึ่งกว่าจะทำให้รู้ว่าจะแก้ปัญหาอะไรก็เหนื่อยอีก ผลลัพธ์ในหัวแต่ละคนก็ไม่รู้เหมือนกันป่าว) อยู่ดีๆ ก็มีคนนึงพูดถึงการแก้ปัญหาขึ้นมา ก็ไม่ตรงกับที่คิดไว้ แถมจินตนาการที่คนอื่นพูดไม่เข้าใจอีก (เพราะหัวคิดติดกับสิ่งที่ตัวเองกำลังแก้) สุดท้ายเลยไปเขียนในกระดานวาดภาพที่อยู่ในหัวออกมาให้เห็น ถึงได้รู้ว่า คนที่อธิบายมานั้น คิดเลยไปอีกขั้นแล้ว และคนอื่นๆ ก็คิดถึงตรงนั้นแล้วเหมือนกัน(หรือป่าว คือ ทุกคนเห็นเป็นภาพเหมือนกันหรือป่าว) ลองดูภาพด้านล่างดู ไม่รู็จะเข้าใจที่กำลังอธิบายอยู่ดีขึ้นหรือป่าว


จากรูป ปัญหาที่พูดจบตอนแรกจนทุกคนเข้าใจแล้วคือ A และกำลังหาวิธีแก้ปัญหากัน แล้วก็มีคนพูดถึงวิธีแก้ปัญหาโดยใช้วิธี C ซึ่งในหัวก็อาจจะมี B มาก่อนแล้วถึงได้เสนอ C ขึ้นมา ส่วนคนที่สองก็อาจจะมีความรู้ที่คล้ายกัน แต่อาจจะไม่เหมือนกับ คนแรกซะทีเดียว แต่สุดท้ายคือได้ C เหมือนกัน แต่คนสุดท้ายนี่สิ ยังคิดอยู่ที่ A เพื่อให้ได้ B&#8217; ออกมาอยู่เลย [...]]]></description>
			<content:encoded><![CDATA[<p>ทำงานมาเกือบสามปี ประชุมมาก็หลายครั้ง จนวันนี้ถึงได้คิดอย่างจริงจังว่า ที่คุยๆ กันเนี๊ยะ มันเข้าใจตรงกันหรือป่าว มันเป็นสิ่งที่กวนใจจนทำให้ไปสมัครเรียน ป.โท เพื่อหวังจะได้คำตอบนี้ และหาวิธีที่จะทำให้มันตรงกัน(ซึ่งก็ไม่รู้จะได้คำตอบหรือป่าว)</p>
<p style="text-align: left;">วันนี้ก็มีประชุมอีก ประชุมกันประมาณ ห้า &#8211; หก คน พูดมาถึงจุดหนึ่งทุกคนรู้แล้วว่าจะแก้ปัญหาอะไร (ซึ่งกว่าจะทำให้รู้ว่าจะแก้ปัญหาอะไรก็เหนื่อยอีก ผลลัพธ์ในหัวแต่ละคนก็ไม่รู้เหมือนกันป่าว) อยู่ดีๆ ก็มีคนนึงพูดถึงการแก้ปัญหาขึ้นมา ก็ไม่ตรงกับที่คิดไว้ แถมจินตนาการที่คนอื่นพูดไม่เข้าใจอีก (เพราะหัวคิดติดกับสิ่งที่ตัวเองกำลังแก้) สุดท้ายเลยไปเขียนในกระดานวาดภาพที่อยู่ในหัวออกมาให้เห็น ถึงได้รู้ว่า คนที่อธิบายมานั้น คิดเลยไปอีกขั้นแล้ว และคนอื่นๆ ก็คิดถึงตรงนั้นแล้วเหมือนกัน(หรือป่าว คือ ทุกคนเห็นเป็นภาพเหมือนกันหรือป่าว) ลองดูภาพด้านล่างดู ไม่รู็จะเข้าใจที่กำลังอธิบายอยู่ดีขึ้นหรือป่าว</p>
<p style="text-align: center;">
<a href="http://llun.in.th/wp-content/uploads/2010/01/Man-talk.png"><img class="aligncenter size-full wp-image-1385" style="border: 1px solid black;" title="Man talk" src="http://llun.in.th/wp-content/uploads/2010/01/Man-talk.png" alt="" width="490" height="235" /></a></p>
<p style="text-align: left;">จากรูป ปัญหาที่พูดจบตอนแรกจนทุกคนเข้าใจแล้วคือ A และกำลังหาวิธีแก้ปัญหากัน แล้วก็มีคนพูดถึงวิธีแก้ปัญหาโดยใช้วิธี C ซึ่งในหัวก็อาจจะมี B มาก่อนแล้วถึงได้เสนอ C ขึ้นมา ส่วนคนที่สองก็อาจจะมีความรู้ที่คล้ายกัน แต่อาจจะไม่เหมือนกับ คนแรกซะทีเดียว แต่สุดท้ายคือได้ C เหมือนกัน แต่คนสุดท้ายนี่สิ ยังคิดอยู่ที่ A เพื่อให้ได้ B&#8217; ออกมาอยู่เลย เพราะยังมองไม่ออกว่ามาเป็น C ได้ยังไง (ซึ่งก็คือคนที่เขียนบล๊อกนี้นี่เอง ^^!) คำถามคือ จะให้คนที่เสนอวิธี C มาแล้วทำให้คนสุดท้ายรู้ได้ไง และเห็นภาพเหมือนกันหมด</p>
<p>จริงๆ ก็ไม่ใช่แค่เรื่องแก้ปัญหานี้ แต่ก็เป็นมาก่อนหน้านั้นหลายอย่างแล้วเหมือนกัน ทั้งที่อธิบายให้คนอื่น และคนอื่นอธิบายให้ฟัง เพราะแต่ละคนก็จะมีประสบการณ์ก่อนหน้ามาไม่เหมือนกัน แต่ก็ยังหาวิธีอธิบายให้เข้าใจตรงกันด้วยวิธีง่ายๆ ไม่ได้ซักที และบางที พูดกันจบแล้วภาพในหัวได้กันคนละภาพอีกต่างหาก แต่คิดว่าได้เหมือนกัน</p>
<p>ตอนนี้คิดวิธีแก้ตอนประชุมออก แต่ไม่รู้จะใช้ได้ผลจริงหรือป่าว คือ พูดแล้วก็วาดภาพในหัวออกมาเลย โดยอาจจะวาดเป็น Mind map หรืออะไรก็แล้วแต่ แต่ต้องทำให้คนอื่นเข้าใจด้วยว่าภาพในหัวเป็นยังไง ข้อเสียคือ มันคงจะเสียเวลาพอสมควร แต่ก็ยังนึกวิธีที่ดีกว่านี้ไม่ออก เอ ตอนนี้เริ่มสงสัยแล้วสิ ว่าตัวเองเรียนถูกสาขาที่ต้องการคำตอบหรือป่าว</p>
]]></content:encoded>
			<wfw:commentRss>http://llun.in.th/archives/1384/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Flex Event Propagation</title>
		<link>http://llun.in.th/archives/1359</link>
		<comments>http://llun.in.th/archives/1359#comments</comments>
		<pubDate>Mon, 25 Jan 2010 14:52:48 +0000</pubDate>
		<dc:creator>llun</dc:creator>
				<category><![CDATA[ภาษา]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://llun.in.th/?p=1359</guid>
		<description><![CDATA[ปล่อยเรื่องนี้ค้างคาใจมานานเหลือเกิน เพราะไม่ได้ใช้ Event ครบทุก Phase อย่างจริงจัง วันนี้ต้องทำให้ Checkbox List ทำงานเร็วขึ้นแต่ไม่อยากแก้ List ของ Adobe ตรงๆ หรือทำไรเพิ่มเติมก็ต้องเล่นกับ Event แทนนี่แหละ อ่านคร่าวๆ ขั้นตอนการส่งต่อ Event ของ Flex มีแค่สามขั้นคือ Capturing Phase, Targeting Phase, Bubbling Phase ลองดูภาพด้านล่างเผื่อเข้าใจง่ายขึ้น

ภาพด้านบนแสดงการซ้อนกันของ Component ต่างๆ ที่สร้างขึ้น มี Application เป็น Component ที่อยู่นอกสุด ตามด้วย HBox และ Button ถ้าเขียนเป็น mxml ก็จะได้อย่างด้านล่าง

&#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62;
&#60;mx:Application xmlns:mx=&#34;http://www.adobe.com/2006/mxml&#34;&#62;
&#60;mx:Box&#62;
&#60;mx:Button /&#62;
&#60;/mx:Box&#62;
&#60;/mx:Application&#62;

เมื่อมีคนกดปุ่มสิ่งที่เกิดขึ้นคือ component ที่อยู่นอกสุดซึ่งก็คือ Application จะดักจับ event ได้ก่อน [...]]]></description>
			<content:encoded><![CDATA[<p>ปล่อยเรื่องนี้ค้างคาใจมานานเหลือเกิน เพราะไม่ได้ใช้ Event ครบทุก Phase อย่างจริงจัง วันนี้ต้องทำให้ <a href="http://llun.in.th/archives/395">Checkbox List</a> ทำงานเร็วขึ้นแต่ไม่อยากแก้ List ของ Adobe ตรงๆ หรือทำไรเพิ่มเติมก็ต้องเล่นกับ Event แทนนี่แหละ อ่านคร่าวๆ ขั้นตอนการส่งต่อ Event ของ Flex มีแค่สามขั้นคือ Capturing Phase, Targeting Phase, Bubbling Phase ลองดูภาพด้านล่างเผื่อเข้าใจง่ายขึ้น<br />
<center><a href="http://llun.in.th/wp-content/uploads/2010/01/Event.png"><img src="http://llun.in.th/wp-content/uploads/2010/01/Event.png" alt="" title="Event" width="580" class="aligncenter size-full wp-image-1360" /></a></center><br />
ภาพด้านบนแสดงการซ้อนกันของ Component ต่างๆ ที่สร้างขึ้น มี Application เป็น Component ที่อยู่นอกสุด ตามด้วย HBox และ Button ถ้าเขียนเป็น mxml ก็จะได้อย่างด้านล่าง</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>Application xmlns<span style="color: #000000; font-weight: bold;">:</span>mx=<span style="color: #990000;">&quot;http://www.adobe.com/2006/mxml&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>Box<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>Button <span style="color: #000000; font-weight: bold;">/&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;/</span>mx<span style="color: #000000; font-weight: bold;">:</span>Box<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;/</span>mx<span style="color: #000000; font-weight: bold;">:</span>Application<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>เมื่อมีคนกดปุ่มสิ่งที่เกิดขึ้นคือ component ที่อยู่นอกสุดซึ่งก็คือ Application จะดักจับ event ได้ก่อน จากนั้นจะส่งต่อไปที่ Box และ Box จะส่งต่อให้ Button อีกที การส่งต่อ Event ในช่วงนี้เรียกว่า <strong>Capturing Phase</strong> เมื่อถึง Button ซึ่งเป็นปุ่มที่เรากดแล้ว ช่วงที่อยู่ตรงปุ่มเรียกว่า <strong>Targeting Phase</strong> จากนั้น Button จะส่ง Event กลับไปยัง Box และ Box ส่งต่อให้ Application อีกที เรียกว่า <strong>Bubbling Phase</strong><br />
เอาหละ มาดูผลลัพธ์กันดีกว่าว่าใช้พวกนี้ช่วยแล้วเป็นยังไง หรือจะ <a href="http://llun.in.th/wp-content/uploads/2010/01/Checkbox.zip">ดาวโหลด</a> ไปดูเต็มๆ ก็ได้<br />
<center><br />
<object width="150" height="250"><param name="movie" value="http://llun.in.th/wp-content/uploads/2010/01/Sample.swf"><embed src="http://llun.in.th/wp-content/uploads/2010/01/Sample.swf" width="150" height="250"></embed></object><br />
</center><br />
<a href="http://llun.in.th/wp-content/uploads/2010/01/Propagation.zip">ของแถม</a> อันนี้ทำเพื่อทดสอบว่า Event มันส่งต่อยังไงบ้าง<br />
<center><br />
<object width="300" height="350"><param name="movie" value="http://llun.in.th/wp-content/uploads/2010/01/Propagation.swf"><embed src="http://llun.in.th/wp-content/uploads/2010/01/Propagation.swf" width="300" height="350"></embed></object><br />
</center></p>
<p>เกี่ยวข้อง:</p>
<ol>
<li><a href="http://livedocs.adobe.com/flex/3/html/help.html?content=events_08.html">Event Propagation in Adobe help</a></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://llun.in.th/archives/1359/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Dropzone + Simplenote</title>
		<link>http://llun.in.th/archives/1355</link>
		<comments>http://llun.in.th/archives/1355#comments</comments>
		<pubDate>Mon, 18 Jan 2010 15:55:34 +0000</pubDate>
		<dc:creator>llun</dc:creator>
				<category><![CDATA[ของเล่น]]></category>
		<category><![CDATA[dropzone]]></category>
		<category><![CDATA[OSX]]></category>
		<category><![CDATA[simplenote]]></category>

		<guid isPermaLink="false">http://llun.in.th/?p=1355</guid>
		<description><![CDATA[ช่วงนี้เบื่อๆ เลยหาอะไรที่ทำเสร็จได้ไม่เกินหนึ่งวันเล่น ก็เลยเผลอหลวมตัวจิ้มเอา Dropzone มาจนได้ วันนี้ก็เลยหาทางเขียนตัวเสริมให้มันเชื่อมกับ Simplenote ที่ใช้อยู่ด้วยซะเลย ผลก็ตามด้านล่าง



แต่ก่อนใช้งานต้องติดตัวช่วยให้ ruby ในเครื่องก่อนด้วยคำสั่งด้านล่าง

llun$sudo gem i rest-client

จากนั้นดาวโหลด simplenote.dropzone กดติดตั้ง ใส่ username(email) และ password ก็เรียบร้อย 
ตอนเย็นมีคำแนะนำเพิ่มเติมว่า น่าจะลากไฟล์ประเภทอื่นได้ด้วย เช่น PDF ลองหาๆ ดูว่ามี Library ไหนอยู่แล้วบ้างปรากฏว่าหาไม่เจอ เลยช่างมันก่อนละกัน ไว้เบื่ออีกรอบ จะกลับมาทำเพิ่มเติม
English step for install Dropzone and Simplenote extension:

Download Dropzone. Open it dmg and drag Dropzone icon to Application folder.
Install rest-client ruby library. I use [...]]]></description>
			<content:encoded><![CDATA[<p>ช่วงนี้เบื่อๆ เลยหาอะไรที่ทำเสร็จได้ไม่เกินหนึ่งวันเล่น ก็เลยเผลอหลวมตัวจิ้มเอา Dropzone มาจนได้ วันนี้ก็เลยหาทางเขียนตัวเสริมให้มันเชื่อมกับ Simplenote ที่ใช้อยู่ด้วยซะเลย ผลก็ตามด้านล่าง<br />
<center><br />
<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/RZAig8lZ5bg&#038;hl=en&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/RZAig8lZ5bg&#038;hl=en&#038;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object><br />
</center><br />
แต่ก่อนใช้งานต้องติดตัวช่วยให้ ruby ในเครื่องก่อนด้วยคำสั่งด้านล่าง</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">llun$sudo gem i rest-client</pre></div></div>

<p>จากนั้นดาวโหลด <a href="http://mirror.nytes.net:81/dropzone/simplenote.dropzone">simplenote.dropzone</a> กดติดตั้ง ใส่ username(email) และ password ก็เรียบร้อย </p>
<p>ตอนเย็นมีคำแนะนำเพิ่มเติมว่า น่าจะลากไฟล์ประเภทอื่นได้ด้วย เช่น PDF ลองหาๆ ดูว่ามี Library ไหนอยู่แล้วบ้างปรากฏว่าหาไม่เจอ เลยช่างมันก่อนละกัน ไว้เบื่ออีกรอบ จะกลับมาทำเพิ่มเติม</p>
<p>English step for install Dropzone and Simplenote extension:</p>
<ol>
<li>Download <a href="http://aptonic.com/releases/Dropzone-0.3.0.zip">Dropzone</a>. Open it dmg and drag Dropzone icon to Application folder.</li>
<li>Install rest-client ruby library. I use this library instead of NET::HTTP because I&#8217;m lazy to find the way to use it. I try standard library but it always error with HTTP 500. So, I switch to rest-client but it needs a few more step to use, install rest-client library on Shell(Terminal)

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">llun$sudo gem install rest-client</pre></div></div>

</li>
<li>Download <a href="http://mirror.nytes.net:81/dropzone/simplenote.dropzone">Simplenote extension</a> and install by double click on download file.</li>
<li>Set username(email) and password then add.</li>
<li>Simplenote icon should lives in Dropzone now. Drag text file to it or click Simplenote icon and paste text for create note.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://llun.in.th/archives/1355/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Functional Programming Camp</title>
		<link>http://llun.in.th/archives/1339</link>
		<comments>http://llun.in.th/archives/1339#comments</comments>
		<pubDate>Mon, 11 Jan 2010 04:03:53 +0000</pubDate>
		<dc:creator>llun</dc:creator>
				<category><![CDATA[ภาษา]]></category>
		<category><![CDATA[functional programming]]></category>

		<guid isPermaLink="false">http://llun.in.th/?p=1339</guid>
		<description><![CDATA[วันเสาร์เพื่อนเลื่อนนัด เลยตัดสินใจไป Functional Programming Camp แทน(จริงๆ มีสอบอังกฤษ แต่โดดไป ^^!) ไปถึงประมาณสิบโมง หลงทาง(ในหมู่บ้าน) อีกครึ่งชั่วโมง กว่าจะไปถึงจริงๆ ก็ประมาณสิบโมงครึ่งนั่งเล่น นั่งคุย แล้วเริ่มกันจริงๆ ก็สิบเอ็ดโมงกว่า แต่จากนั้น เนื้อหาที่ตามมาเรียกว่าหนักหัวมาก กว่าจะย่อยได้หมดเรียกว่าเมาสัญลักษณ์ไปเลย
เริ่มจาก Functional Programming คืออะไร คำตอบจากพี่ @pphetra บอกว่ามันคือรูปแบบในการเขียนโปรแกรม โดยรูปแบบที่ว่ามีลักษณะคือ

Immutable ข้อมูลต่างๆ เมื่อประกาศมาแล้วจะไม่มีการเปลี่ยนแปลง หรือเทียบเท่ากับ function ที่ไม่รับตัวแปรอะไรเลยแล้วให้ผลลัพธ์กลับมา เช่น var a = 5 ก็จะเหมือนกับประกาศว่า function a() = 5
Recursion การทำซ้ำต่างๆ ในรูปแบบการเขียนโปรแกรมอื่น จะใช้รูปแบบการวนซ้ำเช่น for, while แต่เนื่องจาก ตัวแปรไม่สามารถเปลี่ยนแปลงได้ การวนซ้ำแบบนั้นจึงทำไม่ได้ การทำซ้ำต่างๆ ใน functional programming จึงอยู่ในรูปแบบเรียกตัวเองซ้ำ (นอกจากนี้ในงานมีการพูดถึงเทคนิคต่างๆ [...]]]></description>
			<content:encoded><![CDATA[<p>วันเสาร์เพื่อนเลื่อนนัด เลยตัดสินใจไป Functional Programming Camp แทน(จริงๆ มีสอบอังกฤษ แต่โดดไป ^^!) ไปถึงประมาณสิบโมง หลงทาง(ในหมู่บ้าน) อีกครึ่งชั่วโมง กว่าจะไปถึงจริงๆ ก็ประมาณสิบโมงครึ่งนั่งเล่น นั่งคุย แล้วเริ่มกันจริงๆ ก็สิบเอ็ดโมงกว่า แต่จากนั้น เนื้อหาที่ตามมาเรียกว่าหนักหัวมาก กว่าจะย่อยได้หมดเรียกว่าเมาสัญลักษณ์ไปเลย</p>
<p>เริ่มจาก Functional Programming คืออะไร คำตอบจากพี่ @<a href="http://www.twitter.com/pphetra">pphetra</a> บอกว่ามันคือรูปแบบในการเขียนโปรแกรม โดยรูปแบบที่ว่ามีลักษณะคือ</p>
<ol>
<li>Immutable ข้อมูลต่างๆ เมื่อประกาศมาแล้วจะไม่มีการเปลี่ยนแปลง หรือเทียบเท่ากับ function ที่ไม่รับตัวแปรอะไรเลยแล้วให้ผลลัพธ์กลับมา เช่น var a = 5 ก็จะเหมือนกับประกาศว่า function a() = 5</li>
<li>Recursion การทำซ้ำต่างๆ ในรูปแบบการเขียนโปรแกรมอื่น จะใช้รูปแบบการวนซ้ำเช่น for, while แต่เนื่องจาก ตัวแปรไม่สามารถเปลี่ยนแปลงได้ การวนซ้ำแบบนั้นจึงทำไม่ได้ การทำซ้ำต่างๆ ใน functional programming จึงอยู่ในรูปแบบเรียกตัวเองซ้ำ (นอกจากนี้ในงานมีการพูดถึงเทคนิคต่างๆ เช่น continuos passing style, tail recursion, &#8230; อีกพอสมควร เรียกว่าช่วงเช้าหนักหัวเพราะคำศัพท์นี่แหละ =_=)</li>
<li>First class function คือ function ที่มีลักษณะเหมือนตัวแปรในภาษาอื่น คือสามารถเปลี่ยนแปลงการทำงานของ function ได้ โดยใช้ชื่อเดิม เช่น

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> a <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>x<span style="color: #339933;">,</span>y<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>x<span style="color: #339933;">+</span>y<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#125;</span>
a <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>x<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>x<span style="color: #339933;">*</span>x<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#125;</span></pre></div></div>

</li>
<li>Higher order function เนื่องจาก function นั้นมีความสามารถเหมือนตัวแปรแล้ว มันจึงส่งเข้าไปใน function อื่น หรือ return จาก function อื่นได้ โดยถ้า มันรับจาก function อื่นซ้อนๆ กันหรือคืนค่าจาก function อื่นซ้อนๆกัน ลำดับของมันก็สูงขึ้นตามจำนวนที่ซ้อนเรียกลงไป เช่น
<pre lang="javascript>
var plus = function(x,y) { alert(x+y) }
var minus = function(x,y) { alert(x-y) }
var calculate = function(x,y,operation) { operation(x,y) }
calculate(1,2,plus)
calculate(1,2,minus)

var greet = function(name) {
  return function(date, name) {
    if (date is monday) return 'Good Monday' + name
    else return 'Good Morning' + name
  }
}
</pre>
</li>
<li>Pattern matching มาถึงหัวข้อนี้ยอมรับเลยว่า หนักหัวมาก เพราะย่อย เนื้อหาก่อนหน้าแทบไม่ทันแล้ว เอาเป็นว่า มันสามารถเอาค่ามาใส่ตัวแปรจากรูปแบบที่กำหนดได้ เช่น
<pre lang="javascript>
(A,_,B) = (1,2,3)
A=1
B=3
</pre>
</li>
<li>non-strict evaluation คือการทำงานกับข้อมูลที่ต้องใช้เท่านั้นเช่นๆ ถ้าหากมี List ขนาด 10 ฃ่อง แล้วเราต้องการหาว่า ในช่องแรกเก็บค่าอะไร เราก็แค่ดูที่ช่องแรก โดยไม่ต้องดูสิบช่องที่เหลือว่าถูกหรือผิด</li>
<li>lambda function &#8230; อื่ม ยังเป็นสิ่งที่คาใจผมอยู่ว่ามันคืออะไร เพราะเข้ามาดูอีกทีก็ตัวอย่างแล้ว</li>
</ol>
<p>เอาหละหมดช่วงเช้าด้วยนิยามหนักๆ แล้ว ตอนบ่ายพักกินข้าว ต่อด้วยลองเขียนเล่นจริงโดย @<a href="http://www.twitter.com/iporsut">iporsut</a> ปิดท้ายด้วย เหตุผลต่างๆ ว่าทำไม Functional Programming จึงพูดถึงกันตอนนี้ (ทั้งๆ ที่มันก็มานานพอสมควรแล้ว) สรุปเป็นข้อๆ คือ</p>
<ol>
<li>เนื่องจาก CPU มันไม่เพิ่มประสิทธิภาพเท่าไหร่แล้ว แบ่งเหัวแยกออกมาแทน การที่จะใช้พื้นที่ร่วมกัน ก็จะใช้ประสิทธิภาพได้ไม่เต็มที่ จึงเอา Functional Programming มาช่วยเพื่อลดผลข้างเคียงจากการเปลี่ยนแปลงข้อมูลของตัวแปรต่างๆ (เพราะกันไม่ให้มันเปลี่ยนเลย -*-)</li>
<li>จะหัดเขียน อยากเข้าใจง่ายๆ ก็จงเริ่มจาก Haskell ซะ แต่ถ้ามันลำบากไป ก็จะเริ่มจากลูกครึ่งอย่าง Scala ก็ได้แต่อาจจะเข้าใจช้ากว่า เพราะอาจเผลอไปเขียนรูปแบบเดิมๆ ได้</li>
<li>ปัจจุบันยังไม่มีใครใช้เอามาเขียนเป็นโปรแกรมในระบบใหญ่ๆ ทั่วไป จะเห็นส่วนมากก็ใน AI หรือข่ายวิชาเฉพาะทางต่างๆ ซะมากกว่า</li>
</ol>
<p>คราวถัดไป นัดกันอีกประมาณเดือนหรือสองเดือน เรื่องที่จะคุยกันคือ <a href="http://en.wikipedia.org/wiki/NoSQL">NoSQL</a> แต่ก่อนเจอทุกวัน​(Berkley DB) ปัจจุบันเจอแต่ Flex เลยโม้ไม่ได้ ให้ @<a href="http://www.twitter.com/visibletrap">visibletrap</a> ที่กำลังหมกมุ่นอยู่ไปโม้แทนแน่นอน แต่จะได้ไปหรือป่าวนั้นอีกเรื่องนึงแฮะ</p>
]]></content:encoded>
			<wfw:commentRss>http://llun.in.th/archives/1339/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>AR.Drone</title>
		<link>http://llun.in.th/archives/1335</link>
		<comments>http://llun.in.th/archives/1335#comments</comments>
		<pubDate>Thu, 07 Jan 2010 02:49:32 +0000</pubDate>
		<dc:creator>llun</dc:creator>
				<category><![CDATA[ของเล่น]]></category>
		<category><![CDATA[cool]]></category>

		<guid isPermaLink="false">http://llun.in.th/?p=1335</guid>
		<description><![CDATA[เมื่อคืนอ่านข่าวดูวิดีโอ Tweet แล้วก็พบว่า จดมันเก็บไว้ในบล๊อกเลยดีกว่า เพราะว่าเป็นของเล่นในฝันที่อยากได้โคตรๆ ขุดทั้งเว็บคนทำ แล้วก็อ่านข่าวเพิ่มเติมเช้านี้ทำให้รู้ว่ามันจะเปิดตัวในงาน CES2010 เอาเป็นว่าถ้ามันขายเมื่อไหร่+มีตัง จะเป็นคนนึงที่ไปต่อคิวซื้อเลยหละ

]]></description>
			<content:encoded><![CDATA[<p>เมื่อคืนอ่านข่าวดูวิดีโอ Tweet แล้วก็พบว่า จดมันเก็บไว้ในบล๊อกเลยดีกว่า เพราะว่าเป็นของเล่นในฝันที่อยากได้โคตรๆ ขุดทั้ง<a href="http://ardrone.parrot.com/parrot-ar-drone/en">เว็บคนทำ</a> แล้วก็<a href="http://mashable.com/2010/01/06/parrot-ar-drone-video/?">อ่านข่าวเพิ่มเติมเช้านี้</a>ทำให้รู้ว่ามันจะเปิดตัวในงาน CES2010 เอาเป็นว่าถ้ามันขายเมื่อไหร่+มีตัง จะเป็นคนนึงที่ไปต่อคิวซื้อเลยหละ<br />
<object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/V3KrFV0-WFw&#038;hl=en_US&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/V3KrFV0-WFw&#038;hl=en_US&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://llun.in.th/archives/1335/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rebase คืออะไร</title>
		<link>http://llun.in.th/archives/1323</link>
		<comments>http://llun.in.th/archives/1323#comments</comments>
		<pubDate>Wed, 06 Jan 2010 18:48:11 +0000</pubDate>
		<dc:creator>llun</dc:creator>
				<category><![CDATA[ของเล่น]]></category>
		<category><![CDATA[mercurial]]></category>
		<category><![CDATA[merge]]></category>
		<category><![CDATA[rebase]]></category>

		<guid isPermaLink="false">http://llun.in.th/?p=1323</guid>
		<description><![CDATA[วันนี้และเมื่อวานค้นพบว่าเพื่อนยังงงกับ rebase อยู่ และยังคงสงสัยว่าทำไปทำไม ก็เลยเขียนในบล๊อกรวดเดียวเก็บไว้อธิบายทีหลังเลยละกัน เพราะจริงๆ แล้วก็พึ่งรู้ว่ามีความจำเป็นยังไงไม่นานมานี้เอง แต่ก่อนจะไปถึง rebase ขอย้อนมาดูขั้นตอนการรวม branch ของ svn หรือระบบที่มีศูนย์กลางกันก่อน โดยคร่าวๆ คือ

แก้ไขเอกสารต่างๆ แล้ว commit ลง server
สั่ง merge จาก branch หลักมาที่ branch ที่แก้ไขอยู่
แก้ไข conflict ที่เกิดขึ้น
commit การแก้ไขที่เกิดจาก conflict
switch ไป branch หลัก
สั่ง merge จาก branch ที่แก้ไขกลับมาที่ branch หลัก
commit สิ่งที่ merge มา

จากขั้นตอนด้านบนจะเห็นว่ามีการเอาสิ่งที่เปลี่ยนแปลงในกิ่งหลักมารวมกับ กิ่งที่แก้ไขอยู่ก่อน เพื่อปรับปรุงเอกสารในกิ่งปัจจุบันให้ทันกับกิ่งหลักและรู้ว่าเอกสารเมื่อรวมแล้วถูกต้อง โดยไม่ทำให้กิ่งหลักเสียหาย(คือ อาจจะยังมีข้อผิดพลาดจากการแก้อยู่ได้ แต่ไม่ใช่ข้อผิดพลาดที่เกิดจากการรวม) ถ้ายังนึกภาพไม่ออกลองดูรูปด้านล่าง

A คือกิ่งหลัก ส่่วน B คือกิ่งที่แตกออกมาเพื่อเพิ่มหรือแก้ไข
กลับมาเรื่อง rebase การ rebase [...]]]></description>
			<content:encoded><![CDATA[<p>วันนี้และเมื่อวานค้นพบว่าเพื่อนยังงงกับ rebase อยู่ และยังคงสงสัยว่าทำไปทำไม ก็เลยเขียนในบล๊อกรวดเดียวเก็บไว้อธิบายทีหลังเลยละกัน เพราะจริงๆ แล้วก็พึ่งรู้ว่ามีความจำเป็นยังไงไม่นานมานี้เอง แต่ก่อนจะไปถึง rebase ขอย้อนมาดูขั้นตอนการรวม branch ของ svn หรือระบบที่มีศูนย์กลางกันก่อน โดยคร่าวๆ คือ</p>
<ol>
<li>แก้ไขเอกสารต่างๆ แล้ว commit ลง server</li>
<li>สั่ง merge จาก branch หลักมาที่ branch ที่แก้ไขอยู่</li>
<li>แก้ไข conflict ที่เกิดขึ้น</li>
<li>commit การแก้ไขที่เกิดจาก conflict</li>
<li>switch ไป branch หลัก</li>
<li>สั่ง merge จาก branch ที่แก้ไขกลับมาที่ branch หลัก</li>
<li>commit สิ่งที่ merge มา</li>
</ol>
<p>จากขั้นตอนด้านบนจะเห็นว่ามีการเอาสิ่งที่เปลี่ยนแปลงในกิ่งหลักมารวมกับ กิ่งที่แก้ไขอยู่ก่อน เพื่อปรับปรุงเอกสารในกิ่งปัจจุบันให้ทันกับกิ่งหลักและรู้ว่าเอกสารเมื่อรวมแล้วถูกต้อง โดยไม่ทำให้กิ่งหลักเสียหาย(คือ อาจจะยังมีข้อผิดพลาดจากการแก้อยู่ได้ แต่ไม่ใช่ข้อผิดพลาดที่เกิดจากการรวม) ถ้ายังนึกภาพไม่ออกลองดูรูปด้านล่าง<br />
<center><a href="http://llun.in.th/wp-content/uploads/2010/01/merge-graph.png"><img class="size-full wp-image-1324  aligncenter" title="merge graph" src="http://llun.in.th/wp-content/uploads/2010/01/merge-graph.png" alt="" width="438" height="177" /></a></center></p>
<p style="text-align: center;">A คือกิ่งหลัก ส่่วน B คือกิ่งที่แตกออกมาเพื่อเพิ่มหรือแก้ไข</p>
<p style="text-align: left;">กลับมาเรื่อง rebase การ rebase เหมือนการตัดต่อกิ่ง โดยย้ายจากจุดเชื่อมต่อเดิมไปยังจุดเชื่อมใหม่ เพื่อให้เอกสารในกิ่งมีการปรับปรุงเท่าการเปลี่ยนแปลงในกิ่งหลักตามจุดที่ย้ายไป</p>
<p><center><a href="http://llun.in.th/wp-content/uploads/2010/01/merge-graph1.png"><img class="size-full wp-image-1325 aligncenter" title="rebase graph" src="http://llun.in.th/wp-content/uploads/2010/01/merge-graph1.png" alt="" width="378" height="291" /></a></center></p>
<p style="text-align: center;">ภาพบนคือก่อน rebase ภาพล่างคือหลังจาก rebase แล้ว โดย rebase branch B ไปยังปลาย branch A</p>
<p style="text-align: left;">โดยปกติแล้ว ถ้าเป็นกิ่งธรรมดาทั่วไปก็ไม่จำเป็นต้อง rebase แต่อย่างใด สามารถ merge การแก้ไขจากกิ่งหลักมารวมกับกิ่งที่แก้ไขอยู่ได้ เพื่อเก็บสิ่งที่แก้ไขในอดีต และใน svn หรือระบบที่มีศูนย์กลางก็ไม่ค่อยมีคำสั่งนี้ให้ใช้แต่อย่างใด แต่คำสั่งนี้จะเจอในระบบแบบกระจายศูนย์เช่น hg หรือ git เนื่องจาก เมื่อแต่ละคน clone เอาเอกสารไปแล้วแก้ไขเอกสารนั้นในเครื่อง แต่ละคนก็เหมือนมีกิ่งของตนเอง เมื่อแต่ละคนต้องเอาสิ่งที่แก้ไปมารวมกัน ก็ต้องมีการรวมการแก้ไข ซึ่งหากใช้วิธี merge สิ่งที่ได้ก็อาจจะกลายเป็นแบบภาพด้านล่าง หรือภาพที่หนึ่ง</p>
<p><center><a href="http://llun.in.th/wp-content/uploads/2010/01/merge-graph2.png"><img class="aligncenter size-full wp-image-1328" title="1-way merge" src="http://llun.in.th/wp-content/uploads/2010/01/merge-graph2.png" alt="Merge directly to trunk" width="376" height="185" /></a></center><br />
แต่ที่ต้องการจริงๆ แล้วอาจจะเป็นเส้นตรง เพราะการแก้ไขไม่ได้เกิดจากการเพิ่มเติม หรือแก้ไขข้อผิดพลาดในรุ่นก่อนๆ  คราวนี้มาดูวิธีทำใน hg แบบ command line กันดีกว่า(สำหรับ Windows จะเขียนถึงอีกทีพรุ่งนี้)</p>
<ol>
<li>แก้ไขไฟล์ .hg/hgrc โดยเพิ่ม rebase option เพื่อให้มี option นี้ตอน pull

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: black;">&#91;</span>extensions<span style="color: black;">&#93;</span>
rebase =</pre></div></div>

</li>
<li>จากนั้นทุกครั้งที่ pull ก็สั่ง hg pull &#8211;rebase</li>
</ol>
<p style="text-align: left;">ขั้นตอนนั้นง่ายสำหรับคนถนัด command line/shell script แต่คิดว่าถ้าคนใช้ tortoise hg อาจจะไม่ชอบเท่าไหร่ แต่อันนั้นไว้เขียนอธิบายอีกทีพรุ่งนี้อีกทีหลังจากมี Windows อยู่ใกล้ตัว</p>
<p style="text-align: left;">เพิ่มเติม:</p>
<ul>
<li><a href="http://mercurial.selenic.com/wiki/RebaseProject" target="_blank">Mercurial Rebase Project</a></li>
<li><a href="http://mercurial.selenic.com/wiki/RebaseExtension">Mercurial Rebase extension</a></li>
<li><a href="http://book.git-scm.com/4_rebasing.html" target="_blank">Rebasing in git</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://llun.in.th/archives/1323/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>My Shell History</title>
		<link>http://llun.in.th/archives/1321</link>
		<comments>http://llun.in.th/archives/1321#comments</comments>
		<pubDate>Wed, 06 Jan 2010 07:44:01 +0000</pubDate>
		<dc:creator>llun</dc:creator>
				<category><![CDATA[ของเล่น]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://llun.in.th/?p=1321</guid>
		<description><![CDATA[เห็นในเว็บ @iake ผ่าน feed แต่ตอนแรกเฉยๆ ไ่ม่ได้สนใจ หลังปีใหม่สนใจอยากทำมั่ง แต่ลืม url เข้าตรงๆ ขี้เกียจค้นผ่าน feed ด้วยเลยลองหาผ่าน Google เจอ ikea แทนซะงั้น วันนี้ลองใช้คำแนะนำจาก @iake วันนั้น เข้าตรงๆ เลยได้เล่นมั่งซะที

llun$ history &#124; awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] &#34; &#34; CMD[a]/count*100 &#34;% &#34; a;}' &#124; grep -v &#34;./&#34; &#124; column -c3 -s &#34; &#34; -t &#124; sort -nr &#124; nl &#124; [...]]]></description>
			<content:encoded><![CDATA[<p>เห็นในเว็บ @<a href="http://iake.blogspot.com/2010/01/126-my-shell-history.html">iake</a> ผ่าน feed แต่ตอนแรกเฉยๆ ไ่ม่ได้สนใจ หลังปีใหม่สนใจอยากทำมั่ง แต่ลืม url เข้าตรงๆ ขี้เกียจค้นผ่าน feed ด้วยเลยลองหาผ่าน Google เจอ ikea แทนซะงั้น วันนี้ลองใช้คำแนะนำจาก @iake วันนั้น เข้าตรงๆ เลยได้เล่นมั่งซะที</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">llun$ history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] &quot; &quot; CMD[a]/count*100 &quot;% &quot; a;}' | grep -v &quot;./&quot; | column -c3 -s &quot; &quot; -t | sort -nr | nl |  head -n10
     1	111  22.2%  ant
     2	70   14%    ls
     3	64   12.8%  sudo
     4	53   10.6%  cd
     5	52   10.4%  scp
     6	20   4%     ping
     7	18   3.6%   svn
     8	16   3.2%   play
     9	15   3%     hg
    10	10   2%     vi</pre></div></div>

<p>ใช้ ant compile เยอะมาก เพราะว่าไม่ได้ใช้ Flex Builder เลยใช้ Ant แทน</p>
]]></content:encoded>
			<wfw:commentRss>http://llun.in.th/archives/1321/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Adium กับ groups.im(P4-Context)</title>
		<link>http://llun.in.th/archives/1315</link>
		<comments>http://llun.in.th/archives/1315#comments</comments>
		<pubDate>Mon, 28 Dec 2009 17:48:09 +0000</pubDate>
		<dc:creator>llun</dc:creator>
				<category><![CDATA[ของเล่น]]></category>
		<category><![CDATA[adium]]></category>
		<category><![CDATA[groups.im]]></category>
		<category><![CDATA[P4-Context]]></category>
		<category><![CDATA[patch]]></category>

		<guid isPermaLink="false">http://llun.in.th/?p=1315</guid>
		<description><![CDATA[หลังจากทนใช้ groups.im แบบไม่เห็นชื่อว่าใครพิมพ์มาอยู่นาน (เคยพยายามแก้ครั้งนึง แล้วงานเข้า เลยขี้เกียจขุดต่อ) วันนี้ @teerapapc หาทางแก้อีกครั้ง แล้วก็ได้ถึง stack trace ของ libpurple มา สุดท้ายเลยเอามาทำต่อเอง  แต่กว่าจะขุด Libpurple ออกมาได้เล่นซะเหนื่อย ตอนนี้ build binary ยัดไว้ที่ mirror เรียบร้อย ด้านล่างเป็นขั้นตอนการ build libpurple สำหรับ Adium ไม่สนใจก็ข้ามไปได้เลย เพราะจดเก็บไว้เผื่อต้อง build ใหม่ในอนาคต
เริ่มจากเอา Pidgin ออกมาตอนแรกคิดว่าง่ายเพราะหน้าดาวโหลดของ Pidgin มีให้ดาวโหลด source อยู่แล้ว ปรากฏว่าดาวโหลดมาเสร็จขาด autogen.sh ไป สุดท้ายต้อง checkout มาเอง(คือขี้เกียจหาวิธีเอา autogen.sh ออกมา)

ติด monotone ก่อนเพื่อเอา source ของ Pidgin จาก repository
ดาวโหลด [...]]]></description>
			<content:encoded><![CDATA[<p>หลังจากทนใช้ groups.im แบบไม่เห็นชื่อว่าใครพิมพ์มาอยู่นาน (เคยพยายามแก้ครั้งนึง แล้วงานเข้า เลยขี้เกียจขุดต่อ) วันนี้ @<a href="http://twitter.com/teerapapc">teerapapc</a> หาทางแก้อีกครั้ง แล้วก็ได้ถึง stack trace ของ libpurple มา สุดท้ายเลยเอามาทำต่อเอง  แต่กว่าจะขุด Libpurple ออกมาได้เล่นซะเหนื่อย ตอนนี้ build binary ยัดไว้ที่ <a href="http://mirror.nytes.net:81/adium/Adium.zip">mirror</a> เรียบร้อย ด้านล่างเป็นขั้นตอนการ build libpurple สำหรับ Adium ไม่สนใจก็ข้ามไปได้เลย เพราะจดเก็บไว้เผื่อต้อง build ใหม่ในอนาคต</p>
<p>เริ่มจากเอา Pidgin ออกมาตอนแรกคิดว่าง่ายเพราะหน้าดาวโหลดของ Pidgin มีให้ดาวโหลด source อยู่แล้ว ปรากฏว่าดาวโหลดมาเสร็จขาด autogen.sh ไป สุดท้ายต้อง checkout มาเอง(คือขี้เกียจหาวิธีเอา autogen.sh ออกมา)</p>
<ol>
<li>ติด <a href="http://www.monotone.ca/" target="_blank">monotone</a> ก่อนเพื่อเอา source ของ Pidgin จาก repository</li>
<li>ดาวโหลด monotone database ของ Pidgin มาจะเอาจาก<a href="http://developer.pidgin.im/static/pidgin.mtn.bz2" target="_blank">เว็บ Pidgin</a> โดยตรง หรือจาก <a href="http://mirror.nytes.net:81/pidgin/pidgin.mtn.bz2" target="_blank">Mirror</a> ก็ได้ดาวโหลดมาไว้แล้ว</li>
<li>bzip2 -d pidgin.mtn.bz2 เพื่อขยายเอา database มันออกมา</li>
<li>เอา source code ออกมาด้วยคำสั่งด้านล่าง

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">mtn db -d pidgin.mtn migrate &amp;amp;&amp;amp; mtn -d pidgin.mtn pull --set-default \
mtn.pidgin.im &quot;im.pidgin.*&quot; &amp;amp;&amp;amp; mtn -d pidgin.mtn co -b im.pidgin.adium.1-4 .;</pre></div></div>

</li>
</ol>
<p>ได้ code Pidgin มาแล้วต่อไปก็เตรียมของ Adium บ้าง</p>
<ol>
<li>เริ่มจาก clone source ของ Adium repository ก่อน

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">hg clone http://hg.adium.im/adium</pre></div></div>

</li>
<li>
โหลด dependency ทั้งหมดของ LibPurple</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">$cd $ADIUM_SOURCE/Utilities/dep-build-scripts/common.sh -d</pre></div></div>

<p>จากนั้นก็รอยาว จนได้มาครบ
</li>
<li>
แก้ไฟล์ common.sh โดยเพิ่ม PIDGIN_SOURCE ไปที่ pidgin.mtn ที่โหลดมาเมื่อครั้งแรกสุด</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">PIDGIN_SOURCE=$SOURCE_DIRECTORY/Pidgin.mtn</pre></div></div>

<p>(หรือจะ export เป็น environment variable ก็ได้คิดว่าได้ผลเหมือนกัน)
</li>
<li>
สั่ง make dependencies ทั้งหมดอีกรอบ</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">$ ./general_dependencies_make.sh
$ ./purple_dependencies_make.sh</pre></div></div>

</li>
<li>
make libpurple แล้ว copy ให้ Adium</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">$ ./purple_make.sh --i386
$ ./universalize.sh
$ ./copy_frameworks.sh</pre></div></div>

</li>
</ol>
<p>สั่ง build อีกรอบ ก็ได้ Adium + Libpurple ตัวล่าสุดโคตรๆ จาก Source Repository แล้ว</p>
<p>สำหรับปัญหาที่เกิดขึ้นคือ ใน MSN Groups แต่ละคนสามารถมีชื่อปลอมได้ โดย MSN Protocol จะกำหนดมาใน Attribute P4-Context แต่ว่า interface ที่ติดต่อระหว่าง Libpurple และ Adium ได้ตัด Attribute ออกทั้งหมด ตอนนี้เลยแก้ชั่วคราว​ โดยการเติมชื่อปลอมหน้าข้อความที่พิมพ์มาซะ</p>

<div class="wp_syntax"><div class="code"><pre class="diff" style="font-family:monospace;">#
# old_revision <span style="">&#91;</span>83e01106830ff<span style="color: #440088;">1a309406</span>ff<span style="color: #440088;">0304c8</span>dcec08aa725<span style="">&#93;</span>
#
# patch &quot;libpurple/protocols/msn/msg.c&quot;
#  from <span style="">&#91;</span>795b<span style="color: #440088;">1a623</span>db46112fd<span style="color: #440088;">23481325996a6714691973</span><span style="">&#93;</span>
#    to <span style="">&#91;</span>7b43dd8ef3caf<span style="color: #440088;">344d0862</span>d<span style="color: #440088;">3a3</span>ab<span style="color: #440088;">89d5</span>e<span style="color: #440088;">1a496758</span><span style="">&#93;</span>
#
============================================================
<span style="color: #888822;">--- libpurple/protocols/msn/msg.c	795b<span style="color: #440088;">1a623</span>db46112fd<span style="color: #440088;">23481325996a6714691973</span></span>
<span style="color: #888822;">+++ libpurple/protocols/msn/msg.c	7b43dd8ef3caf<span style="color: #440088;">344d0862</span>d<span style="color: #440088;">3a3</span>ab<span style="color: #440088;">89d5</span>e<span style="color: #440088;">1a496758</span></span>
<span style="color: #440088;">@@ -<span style="">864</span>,<span style="">6</span> +<span style="">864</span>,<span style="">10</span> @@ msn_plain_msg<span style="">&#40;</span>MsnCmdProc *cmdproc, MsnMe</span>
 		body_final = body_enc;
 	<span style="">&#125;</span>
&nbsp;
<span style="color: #00b000;">+  if <span style="">&#40;</span><span style="">&#40;</span>value = msn_message_get_attr<span style="">&#40;</span>msg, &quot;P4-Context&quot;<span style="">&#41;</span><span style="">&#41;</span> != NULL<span style="">&#41;</span> <span style="">&#123;</span></span>
<span style="color: #00b000;">+    body_final = g_strdup_printf<span style="">&#40;</span>&quot;&lt;b&gt;%s&lt;/b&gt;: %s&quot;, value, body_final<span style="">&#41;</span>;</span>
<span style="color: #00b000;">+  <span style="">&#125;</span></span>
<span style="color: #00b000;">+</span>
 	if <span style="">&#40;</span>cmdproc-&gt;servconn-&gt;type == MSN_SERVCONN_SB<span style="">&#41;</span> <span style="">&#123;</span>
 		MsnSwitchBoard *swboard = cmdproc-&gt;data;</pre></div></div>

<p>จริงๆ ปัญหานี้อยู่ใน Trac ของ Pidgin แล้ว(<a href="http://developer.pidgin.im/ticket/3319">เมื่อสองปีที่แล้ว</a>) แต่ดูจากการแก้ไขแล้วตอบโต้ไปมาก็ไม่รู้จะแก้ไขเมื่อไหร่ เลยต้องทำแก้ขัดไปก่อน จะแก้ไปใน Pidgin ชั่วคราวด้วยก็ยังได้ (เพียงแต่ว่าขี้เกียจหา dependencies อีกเลยทำแต่ของ Adium) ก็หวังว่า Pidgin จะปิด Ticket นี้ได้เร็ววัน เพราะจากที่แก้ดูไปแล้วก็ไม่ค่อยสวยงามเท่าไหร่ </p>
<p>Link ที่เกี่ยวข้อง</p>
<ol>
<li><a href="http://developer.pidgin.im/ticket/3319">Pidgin Trac: MSN group name display support</a></li>
<li><a href="http://github.com/felipec/msn-pecan/commit/3ca18140149aede5ae9b55dc590b4335ff9402b5">MSN-Pecan patch</a></li>
<li><a href="http://developer.pidgin.im/wiki/UsingPidginMonotone"> Using Monotone for Pidgin</a></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://llun.in.th/archives/1315/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
