<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by littlebookboy on Medium]]></title>
        <description><![CDATA[Stories by littlebookboy on Medium]]></description>
        <link>https://medium.com/@kevin2pig?source=rss-c6c7cb471a17------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*UB0dNAbYk65aJWZzW2R3mw.jpeg</url>
            <title>Stories by littlebookboy on Medium</title>
            <link>https://medium.com/@kevin2pig?source=rss-c6c7cb471a17------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 07:55:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kevin2pig/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Joel On Software 閱讀筆記]]></title>
            <link>https://kevin2pig.medium.com/joel-on-software-%E9%96%B1%E8%AE%80%E7%AD%86%E8%A8%98-e944be5f1edf?source=rss-c6c7cb471a17------2</link>
            <guid isPermaLink="false">https://medium.com/p/e944be5f1edf</guid>
            <dc:creator><![CDATA[littlebookboy]]></dc:creator>
            <pubDate>Sat, 16 Mar 2019 04:41:21 GMT</pubDate>
            <atom:updated>2019-12-19T23:17:00.964Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>寫下讀完「約耳趣談軟體」此書的一些重點節錄與閱讀筆記</strong></p><pre><a href="https://gist.github.com/littlebookboy/0c69ab8ce1c401268f157c561d42c711">https://gist.github.com/littlebookboy/0c69ab8ce1c401268f157c561d42c711</a></pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e944be5f1edf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[More Joel On Software 閱讀筆記]]></title>
            <link>https://kevin2pig.medium.com/more-joel-on-software-%E9%96%B1%E8%AE%80%E7%AD%86%E8%A8%98-7dc1c6b345d2?source=rss-c6c7cb471a17------2</link>
            <guid isPermaLink="false">https://medium.com/p/7dc1c6b345d2</guid>
            <dc:creator><![CDATA[littlebookboy]]></dc:creator>
            <pubDate>Sun, 17 Feb 2019 14:50:30 GMT</pubDate>
            <atom:updated>2019-12-19T23:17:53.482Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>寫下讀完「約耳續談軟體」此書的一些重點節錄與閱讀筆記</strong></p><pre><a href="https://gist.github.com/littlebookboy/79f41c449f06de794ae071d7a006517a">https://gist.github.com/littlebookboy/79f41c449f06de794ae071d7a006517a</a></pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7dc1c6b345d2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Git worktree 筆記]]></title>
            <link>https://kevin2pig.medium.com/git-worktree-%E7%AD%86%E8%A8%98-5bd8939fe53b?source=rss-c6c7cb471a17------2</link>
            <guid isPermaLink="false">https://medium.com/p/5bd8939fe53b</guid>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[littlebookboy]]></dc:creator>
            <pubDate>Mon, 08 Oct 2018 05:31:54 GMT</pubDate>
            <atom:updated>2018-12-14T00:29:17.368Z</atom:updated>
            <content:encoded><![CDATA[<p>簡單紀錄下 ihower 分享的這篇文章內容實際操作過程</p><h4>參考文章</h4><p>貼在最前面：</p><p><a href="https://ihower.tw/blog/archives/8740">Git worktree: 同時開多個工作目錄</a></p><p>根據原文描述，使用 git worktree 可以建立專案分身（為原始專案目錄複製出一個一樣的專案，並建立 git worktree link 連結）進行獨立作業。</p><p>不用指令來說就是「複製原始專案 → 貼上 → 到複製目錄底下建立分支」然後少了「連結」，也就是你在複製目錄底下的異動，還要手動同步到原始專案中，但當你使用 worktree 就沒有這個問題。</p><p>先講指令有哪些，再來講我想像出來的使用場景（根據原文延伸）：</p><h4>從原始專案建立 worktree</h4><pre>git worktree add -b add-feature ../my-work-for-new-feature master</pre><pre># output<br>Preparing ../my-work-for-new-feature (identifier my-work-for-new-feature)<br>HEAD is now at a776d5f my-work-for-new-feature</pre><p>最後面的 master 為指定原始專案以哪個分支為基礎，若以平常來說，這動作與在原始專案建立分支一樣，只是差異在這裡為：複製出作為一個新專案，同時建立新分支，兩個目錄的版控是連在一起的。</p><pre>cd ../my-work-for-new-feature # 跳到複製專案底下<br>git branch -a # 查看目前所有分支</pre><pre># output the `git branch -a` result</pre><pre>  master<br>* my-work-for-new-feature</pre><p>接下來就可以在新目錄底下做新工作了。</p><h4>列出目前的 worktree</h4><pre>git worktree list</pre><h4>清除 worktree 連結</h4><pre>git worktree prune</pre><h4>使用情境說明</h4><p>需要別人的 code 做參考時，不需要做 stash, pull, merge,… 等動作後才能繼續工作；想像一下，你需要參考同事Ａ正在寫的某些邏輯寫法，但專案只有一個，你的工作也進行到一半，要先把他的 code git pull 下來合併一次，假設分支結構如下</p><pre>git branch -a # and then the output is</pre><pre>* your-work<br>  your-company-work<br>  master</pre><p>你要看他的 code 還要切換到 `your-company-work` 參考完再切回 `your-work`，反覆進行，直到你參考完..覺得累是不是？這時使用 worktree 建立一個分身，你就可以同時開啟不同目錄，切到個別不同分支進行開發。</p><pre>pwd # output is /path/original-project<br>git pull # new branch is your-company-work<br>git worktree add -b your-work../your-work master<br>cd ../your-work &amp;&amp; git branch -a # and then the output is</pre><pre>* your-work<br>  your-company-work<br>  master</pre><p>此時你會擁有 original-project 與 your-work 兩個資料夾，你就可以分別在專案底下切到不同分支，顯示不同份的 code，而且你在 your-work 的變更提交 (commit) 都會被連結到 original-project 底下。</p><h4>結論</h4><p>稍微操作並筆記過後，會比較清楚想像與實際指令執行結果，是否有出入。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5bd8939fe53b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PHPStorm 跑測試 Class Not Found 解法]]></title>
            <link>https://kevin2pig.medium.com/phpstorm-%E8%B7%91%E6%B8%AC%E8%A9%A6-class-not-found-%E8%A7%A3%E6%B3%95-89d5fe930675?source=rss-c6c7cb471a17------2</link>
            <guid isPermaLink="false">https://medium.com/p/89d5fe930675</guid>
            <category><![CDATA[phpstorm]]></category>
            <dc:creator><![CDATA[littlebookboy]]></dc:creator>
            <pubDate>Wed, 21 Mar 2018 02:24:49 GMT</pubDate>
            <atom:updated>2018-12-14T00:33:17.281Z</atom:updated>
            <content:encoded><![CDATA[<p>測試中 Class Not Found 的解決方法記錄</p><p>提要：在刻套件的時候，先寫了一個簡單的單元測試，斷言直接 true 為 true。</p><p>先大概講一下專案配置</p><ol><li>Preferences &gt; Directories &gt; 設置 /src 為 Sources，變藍色</li><li>Preferences &gt; Directories &gt; 設置 /tests 為 Tests，變綠色</li><li>Preferences &gt; Languages &amp; Frameworks &gt; PHP &gt; Test Frameworks &gt; Path to script 設定對應 /vendor/autoload.php，這邊你的 composer.json 要有 required-dev 包含 phpunit/phpunit 套件，對應檔案才會偵測到 PHPUnit 6.5.x</li></ol><p>設置完成，直接測試有斷言的那個 function 應該會得到一個綠燈。</p><p>以上情況都 ok 了，自己新增一個 Class 作為服務器，並在剛剛的測試中直接呼叫</p><pre>public function testGetFooName()<br>{<br>    $fooName = MyClass::getFooName();</pre><pre>    $this-&gt;assertTrue(true);<br>}</pre><p>並在頂端 use MyClass 進來</p><pre>use App\Service\MyClass;</pre><p>再執行測試，得到</p><pre>Error : Class &#39;MyClass&#39; not found</pre><p>用 command + click 去追蹤，可以追到 class MyClass 上，這時候可以檢查：</p><ol><li>確定命名空間沒問題，測試依然找不到 class 時，確認以下項目。</li><li>執行 composer dump-autoload 更新 autoload_classmap，測試依然找不到 class 時，確認以下項目。</li><li>關閉 IDE (確認已不在背景)，移除 .idea ，這是用來儲存 IDE 幫你建置的索引，以及個人在此專案的配置。</li><li>經過第 3 點動作後，打開專案，重做文章一開始所說的 3 點專案配置，再次執行測試，通常就會找到 class。</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89d5fe930675" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lodash 去抖功能沒有 Promise 怎麼辦？]]></title>
            <link>https://kevin2pig.medium.com/lodash-%E5%8E%BB%E6%8A%96%E5%8A%9F%E8%83%BD%E6%B2%92%E6%9C%89-promise-%E6%80%8E%E9%BA%BC%E8%BE%A6-55eecb0dcf09?source=rss-c6c7cb471a17------2</link>
            <guid isPermaLink="false">https://medium.com/p/55eecb0dcf09</guid>
            <category><![CDATA[lodash]]></category>
            <category><![CDATA[vue]]></category>
            <category><![CDATA[promises]]></category>
            <dc:creator><![CDATA[littlebookboy]]></dc:creator>
            <pubDate>Sun, 25 Jun 2017 13:07:06 GMT</pubDate>
            <atom:updated>2017-06-25T13:08:33.156Z</atom:updated>
            <content:encoded><![CDATA[<p>遇到需要去抖功能被執行之後進行 Promise then 的需求</p><p>前幾天在 Vue 中用了 Lodash 的去抖功能，來避免（連點）觸發 API 次數超過，而遭到系統限制，但後來需要在頁面中新增使用者，完成後需要進到最後一頁這個動作，遇到問題：</p><ol><li>頁面中分頁器需要 setPage 去觸發換頁 click</li><li>頁面中的 data table 資料是觸發 API 回來的，所以包了去抖</li><li>在第二點的 then 需要 return 最後一頁頁碼，並把 axios 自己 return</li><li>讓新增使用者的動作完成時，執行 goToLastPage 方法，其中執行頁面資料重讀，以及 setPage 事件</li><li>由於分頁器需要重新渲染才會更新頁碼（當使用者新增後剛好會產生新一頁時），我們需要先執行去抖那個方法</li><li>第五點後，在 then 執行 setPage，因為這樣保證新頁已被產生</li></ol><p>問題點就在包了去抖之後，第五點雖然被執行，但是並沒有 Promise 回傳，所以一直失敗，解法是不要用 Lodash 的去抖，改用<a href="https://www.npmjs.com/package/es6-promise-debounce">這包</a>：</p><pre>var debounce = require(&#39;es6-promise-debounce&#39;);</pre><pre>var debouncedFunction = debounce(function() {<br>    return new Promise(function(resolve) {<br>        resolve();<br>    });<br>}, 200);</pre><pre>debouncedFunction().then(function() { console.log(&#39;this one should be ignored&#39;); });<br>debouncedFunction().then(function() { console.log(&#39;this one should be executed&#39;); });</pre><p>在我們的 Vue 中 import 進來</p><pre>import promiseDebounce from &quot;es6-promise-debounce&quot;</pre><p>就可以取代原本的 debounce 方法。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=55eecb0dcf09" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Vue 2.x 中使用 lodash 去抖功能]]></title>
            <link>https://kevin2pig.medium.com/vue-2-x-%E4%B8%AD%E4%BD%BF%E7%94%A8-lodash-%E5%8E%BB%E6%8A%96%E5%8A%9F%E8%83%BD-a125368eb9aa?source=rss-c6c7cb471a17------2</link>
            <guid isPermaLink="false">https://medium.com/p/a125368eb9aa</guid>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[vue]]></category>
            <category><![CDATA[laravel54]]></category>
            <category><![CDATA[lodash]]></category>
            <dc:creator><![CDATA[littlebookboy]]></dc:creator>
            <pubDate>Tue, 20 Jun 2017 14:35:16 GMT</pubDate>
            <atom:updated>2018-12-14T00:35:11.738Z</atom:updated>
            <content:encoded><![CDATA[<p>透過去抖功能，降低觸發 API 次數超過限制的情形</p><p>最近在寫前端部分，有一些功能，是透過呼叫後端的 API，進行資料修改，這部份遇到了存取限制的問題，所以在此篇稍微記錄一下。</p><p>在 Laravel 中，API 路由預設會經過一個 <a href="https://github.com/laravel/framework/blob/5.4/src/Illuminate/Routing/Middleware/ThrottleRequests.php">ThrottleRequests</a> 中介層，他會限制你在單位時間內，呼叫系統提供的任何 API 的次數，在 Laravel 中預設是每分鐘 60 次（也就是約 1 秒 1 次）；</p><p>假設今天我有一個功能是按了按鈕，發送一個修改請求給系統端，在正常情況下，會在 1 秒內就完成整個動作；問題在於如果使用者「一直點」這個按鈕，1 秒內送了 1.5 次，那 40 秒之後的請求，就會被系統暫時性的限制存取，在滿 1 分鐘以前，都會收到 429「Too Many Attempts.」的回應。</p><p>這邊可以簡單的使用 lodash 這個強大的輔助套件，來解決這個問題；他提供了一個方法叫 <a href="https://lodash.com/docs/#debounce">debounce</a>，中文叫去抖，<a href="https://css-tricks.com/debouncing-throttling-explained-examples/">有一篇文章</a>已經實現了一些簡單的例子，以下這組是我們需要的功能：</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2Fdcorb%2Fembed%2Fpreview%2FKVxGqN%3Fheight%3D600%26slug-hash%3DKVxGqN%26default-tabs%3Dcss%2Cresult%26host%3Dhttps%3A%2F%2Fcodepen.io%26embed-version%3D2&amp;url=https%3A%2F%2Fcodepen.io%2Fdcorb%2Fpen%2FKVxGqN&amp;image=https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fi.cdpn.io%2F143454.KVxGqN.small.31e02f93-933a-486b-bddb-c037fa03097d.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/8849cb3dd8314d550934451cc2cae828/href">https://medium.com/media/8849cb3dd8314d550934451cc2cae828/href</a></iframe><p>你可以看到你連按 Trigger area 後，經過一段延遲，才會真正被觸發 1 次，而不是每次點每次都觸發。</p><p>在 Vue 中（無論是 Laravel 整合的，還是 Vue-cli 都適用），你只要輕輕的 import lodash 這個套件，再把整個 method 包起來，就可以實現，以下是一個簡單的例子，當你連續點按鈕，經過 1 秒延遲，文字才會被真的更新：</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjsfiddle.net%2Flittlebookboy%2Frak3cxmj%2Fembedded%2F&amp;url=https%3A%2F%2Fjsfiddle.net%2Flittlebookboy%2Frak3cxmj%2F&amp;image=https%3A%2F%2Fwww.gravatar.com%2Favatar%2Fb68e4b495e5a2d65246378fb4f68e378%2F%3Fdefault%3D%26s%3D80&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=jsfiddle" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/86469d374fd1ea5d60c5cc0fb522f585/href">https://medium.com/media/86469d374fd1ea5d60c5cc0fb522f585/href</a></iframe><p>感謝強者同事介紹這麼方便的功能。</p><p>延伸參考：</p><p><a href="https://medium.com/@kevin2pig/lodash-%E5%8E%BB%E6%8A%96%E5%8A%9F%E8%83%BD%E6%B2%92%E6%9C%89-promise-%E6%80%8E%E9%BA%BC%E8%BE%A6-55eecb0dcf09">Lodash 去抖功能沒有 Promise 怎麼辦？</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a125368eb9aa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Vue 2.x 簡易的全選功能實現]]></title>
            <link>https://kevin2pig.medium.com/vue-2-x-%E7%B0%A1%E6%98%93%E7%9A%84%E5%85%A8%E9%81%B8%E5%8A%9F%E8%83%BD%E5%AF%A6%E7%8F%BE-9ae3cbfa3482?source=rss-c6c7cb471a17------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ae3cbfa3482</guid>
            <category><![CDATA[vue]]></category>
            <dc:creator><![CDATA[littlebookboy]]></dc:creator>
            <pubDate>Mon, 19 Jun 2017 15:14:11 GMT</pubDate>
            <atom:updated>2017-06-20T14:36:37.390Z</atom:updated>
            <content:encoded><![CDATA[<p>在 Vue 組件中，實作相對簡單、無狀態的 checkbox 全選功能</p><p>今天在處理前端套版時，遇到要做 checkbox 全選的功能，想說 Vue 在這方面實現起來應該是蠻容易的，一開始自己刻了一下，綁定了 v-model 與 v-on:bind，以為這樣就足以應付，但發現用起來不如預期，不好懂，也不夠簡潔，於是問了一下 Google，有興趣的人可以先直接參考<a href="https://stackoverflow.com/questions/33571382/check-all-checkboxes-vuejs">這篇</a>，本篇文章僅是自己實現該篇解答之後所做的整理。</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjsfiddle.net%2Flittlebookboy%2Fq5gLww88%2Fembedded%2F&amp;url=https%3A%2F%2Fjsfiddle.net%2Flittlebookboy%2Fq5gLww88%2F&amp;image=https%3A%2F%2Fwww.gravatar.com%2Favatar%2Fb68e4b495e5a2d65246378fb4f68e378%2F%3Fdefault%3D%26s%3D80&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=jsfiddle" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/1eacd98667f97eb738a0bf7c8e218345/href">https://medium.com/media/1eacd98667f97eb738a0bf7c8e218345/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ae3cbfa3482" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>