<?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 James Ho on Medium]]></title>
        <description><![CDATA[Stories by James Ho on Medium]]></description>
        <link>https://medium.com/@hoooching?source=rss-a7c0dfb1f89------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*2A-2P0IaYrIk5x6cyLUzrQ.jpeg</url>
            <title>Stories by James Ho on Medium</title>
            <link>https://medium.com/@hoooching?source=rss-a7c0dfb1f89------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 06:24:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hoooching/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[How does Snowflake Merge work?]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://blog.devgenius.io/how-does-snowflake-merge-work-e7af6805dc29?source=rss-a7c0dfb1f89------2"><img src="https://cdn-images-1.medium.com/max/2600/0*J57LOw5Jg9YqHOtK" width="4193"></a></p><p class="medium-feed-snippet">Detailed explanation with examples</p><p class="medium-feed-link"><a href="https://blog.devgenius.io/how-does-snowflake-merge-work-e7af6805dc29?source=rss-a7c0dfb1f89------2">Continue reading on Dev Genius »</a></p></div>]]></description>
            <link>https://blog.devgenius.io/how-does-snowflake-merge-work-e7af6805dc29?source=rss-a7c0dfb1f89------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7af6805dc29</guid>
            <category><![CDATA[dbt-incremental-model]]></category>
            <category><![CDATA[analytics-engineering]]></category>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[merge]]></category>
            <category><![CDATA[dbt]]></category>
            <dc:creator><![CDATA[James Ho]]></dc:creator>
            <pubDate>Sun, 26 Feb 2023 15:22:31 GMT</pubDate>
            <atom:updated>2023-03-03T13:05:20.278Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Powerful SQL queries that you might not know]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/data-science/powerful-sql-queries-that-you-might-not-know-c9953ea4bf20?source=rss-a7c0dfb1f89------2"><img src="https://cdn-images-1.medium.com/max/2600/0*mYc9Tdv_Vu_GFiO-" width="6000"></a></p><p class="medium-feed-snippet">Some queries and techniques that could bring your SQL to another level</p><p class="medium-feed-link"><a href="https://medium.com/data-science/powerful-sql-queries-that-you-might-not-know-c9953ea4bf20?source=rss-a7c0dfb1f89------2">Continue reading on TDS Archive »</a></p></div>]]></description>
            <link>https://medium.com/data-science/powerful-sql-queries-that-you-might-not-know-c9953ea4bf20?source=rss-a7c0dfb1f89------2</link>
            <guid isPermaLink="false">https://medium.com/p/c9953ea4bf20</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[analytics-engineering]]></category>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[James Ho]]></dc:creator>
            <pubDate>Sat, 03 Sep 2022 22:29:08 GMT</pubDate>
            <atom:updated>2022-09-06T14:09:57.776Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Data Scientist vs Data Analyst vs Data Engineer]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/data-science/data-scientist-vs-data-analyst-vs-data-engineer-1e2514a36d41?source=rss-a7c0dfb1f89------2"><img src="https://cdn-images-1.medium.com/max/2600/0*axU4vNov3I4IfbaC" width="3872"></a></p><p class="medium-feed-snippet">Find your true passion in the data field</p><p class="medium-feed-link"><a href="https://medium.com/data-science/data-scientist-vs-data-analyst-vs-data-engineer-1e2514a36d41?source=rss-a7c0dfb1f89------2">Continue reading on TDS Archive »</a></p></div>]]></description>
            <link>https://medium.com/data-science/data-scientist-vs-data-analyst-vs-data-engineer-1e2514a36d41?source=rss-a7c0dfb1f89------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e2514a36d41</guid>
            <category><![CDATA[careers]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[job-hunting]]></category>
            <category><![CDATA[data-analyst]]></category>
            <category><![CDATA[data-engineer]]></category>
            <dc:creator><![CDATA[James Ho]]></dc:creator>
            <pubDate>Wed, 05 Jan 2022 17:30:33 GMT</pubDate>
            <atom:updated>2022-01-15T20:44:10.222Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[百日封城下的自我省思與人生校正]]></title>
            <link>https://hoooching.medium.com/%E7%99%BE%E6%97%A5%E5%B0%81%E5%9F%8E%E4%B8%8B%E7%9A%84%E8%87%AA%E6%88%91%E7%9C%81%E6%80%9D%E8%88%87%E4%BA%BA%E7%94%9F%E6%A0%A1%E6%AD%A3-a2c8cda1a7bd?source=rss-a7c0dfb1f89------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2c8cda1a7bd</guid>
            <dc:creator><![CDATA[James Ho]]></dc:creator>
            <pubDate>Sun, 11 Apr 2021 21:21:38 GMT</pubDate>
            <atom:updated>2021-04-12T12:28:42.122Z</atom:updated>
            <content:encoded><![CDATA[<h3>百日封城下的自省與人生校正</h3><p>那些我希望自己二十出頭就開始做的事</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c5De-Cl2vI3avmKMsjkebg.jpeg" /><figcaption>第一次看到如此空曠的西敏橋</figcaption></figure><p>英國自從2020年末爆發第二波大流行後實施第二次封城，聖誕節期間短暫開放後感染及死亡人數又飆升，首相強森於年後又宣布從一月六號開始了第三次的封城，這一封就是將近百日。</p><p>疫情期間待在台灣的人，可能很難想像如末日電影般的情節，真真切切地在世界各大城市上演。除了餐廳（不含酒吧）、超市、及藥局，全數店家都拉下大門，餐廳僅提供外送外帶，所有形式的社交活動皆被禁止，出門唯一的目的就是去超市買菜。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l9wtD5txow0zdmR8hX7rgw.jpeg" /><figcaption>過去總是人滿為患的特拉法加廣場</figcaption></figure><p>試想一下，早上起床睜開眼睛，你今天所有的活動範圍就是這個家，若你跟我一樣家裡沒什麼公共空間，活動範圍就是只有這個房間。下了床就是辦公桌，除了吃飯上廁所洗澡，一整天就是在辦公座位跟床上輪流度過。這樣的一天，你還要重複過上百次，加上倫敦不見天日的冬天，對心靈的影響是無法言喻的。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f01Z5mAJIyKJQWQcfinPlQ.jpeg" /><figcaption>下了床就是辦公室，大多時候一整天的活動範圍就是這樣</figcaption></figure><p>這樣的生活最直接的感觸是：一天的時間變長了，與自己相處的時間也更長了，再加上去年看了The Social Dilemma之後我索性也把社群網站帳號都停掉了，這三個月等於是把所有的心思放在自己身上，不斷反思與正視現在的人生階段，並作出調整。</p><p>儘管憂鬱，我也把這段期間的封城當成老天給的一個禮物，讓我在原本汲汲營營的上班族生活中停頓片刻。</p><p>我們常常忙著賺錢，卻沒時間好好理財；</p><p>我們常常忙著工作，卻沒時間好好生活；</p><p>我們常常忙著倒數週末的來臨，卻沒時間好好想想這工作的意義是什麼；</p><p>我們常常忙著應付上級的要求，卻沒時間好好問問自己的熱情在哪裡。</p><p>而封城正給了我大把時間，捨棄所有工作之餘的雜事、休閒、社交，重新審視自己的生活模樣。</p><h3>理財</h3><p>打從大學上了第一堂金融相關課程起我就很不喜歡財金金融之類的東西，能不碰就不碰，就這樣一直拖到現在。但俗話說你不理財，財不理你，我總算是利用了這段時間開始好好研究辛苦工作賺來的錢究竟應該要如何配置。</p><p>理財我分兩個面向，一個是眾所皆知的投資理財，一個是創造被動收入。我們先複習一下巴菲特的名言：</p><blockquote>你如果沒辦法在睡覺時也能賺錢，你將會工作到死。</blockquote><blockquote>投資理財</blockquote><p>我不是專家，我也才剛開始接觸，本篇並不是要推薦什麼好的投資標的。但我想強調的是，不管你喜不喜歡，每個人都應該要學習理財，並且越小開始越好，我非常後悔到現在才開始重視理財。理財並不是我每個月存多少錢放進銀行就好，而是要讓那些錢繼續為你工作。窮人存錢，富人用錢滾錢。也不是一定要致富，但你總不希望辛苦賺來的錢一直減少，把錢存進銀行只會讓你的資產會因為通膨而不斷縮水這件事應該是顯學了。</p><p>我是屬於非常懶惰類型的投資者，不想花時間去研究每間公司的財報或是複雜的金融槓桿遊戲，所以選擇的都是無腦穩健的投資，例如ETF、股利成長股或是有口碑的投資機器人公司，標的都是英美的公司。只要能夠打贏通膨跟大盤我就心滿意足了，剩下的就交給時間跟複利去發揮它們的威力。</p><p>房地產可能會是下一個想要看的標的，繳了四年房租，錢都像是丟到水裡一樣。倫敦又是一個租金比房貸高的地方，繳房租不如繳房貸，將來回台灣也能繼續收租又是一筆被動收入。加上英國政府因為疫情暫時取消了印花稅，雖然房價好像沒有因此而降低許多，我個人還是認為這是一個不錯的置產時機。</p><blockquote>被動收入</blockquote><p>以前爸媽常說，最好的工作就是錢多事少離家近，也不斷勸說我們要認真讀書認真工作，躺在床上一整天錢並不會自己跑到你的口袋。這些「準則」都被現代科技一一打破，現在最好的工作就是躺在床上一整天，錢就會自己跑進我們口袋。比起以前人們追求的高薪，我認為創造被動收入才是更能實現財富自由的手段。除了投資理財，創造被動收入的另一個方式是「創造可持續為你帶來收益的資產」。我常常問自己，我今天工作做的這些事，能在未來讓我什麼都不做就創造收益嗎？</p><p>一個歌手出了一張唱片，將來他賣出去或是有人使用其中幾首歌的版權都能帶來收益，一個作家出一本書，未來這本書每賣出去一本就可以抽成一次。一個Youtuber上架一個影片，將來每個點閱都可以獲得廣告分潤，一個部落客發佈一篇文章，未來的流量也都能持續帶來收入。這種「努力一時，收錢一輩子」的資產，除了能在薪水之外創造第二筆收入，也比工作賺來的錢更有持續性，還可以降低單一收入帶來的風險。</p><p>於是我也開始在工作之餘嘗試建立多種收入來源。目前最流行的被動收入或是side hustle無非是Youtuber，部落客，網紅代言等等。我選擇了在Medium上寫一些技術文章，記錄工作的學習歷程與反芻學到的新知識，同時可以賺點小錢。不過這種side hustle的成長曲線非常緩，通常要幾年的時間才能帶來足以生活的收入。目前剛開始三個月也才賺了大概一百美金，不過好歹是踏出最難的第一步了。另外也開始嘗試接一些模特兒工作，用這種高時薪的工作來加速投資基數的增加，或是應付日常生活的開銷。</p><h3>自我提升與職涯探索</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/1*KMaEtOTqQmTvkniKGw7tyw.png" /></figure><p>雖然知道自己對資料科學有興趣，但資料科學領域非常之廣，工作上也未必能夠讓我接觸到所有的面向，工作了將近兩年還是有許多不了解的地方。因此我也在這段時間考了微軟的三張證照：資料分析師，資料工程師，以及資料科學家，透過學習證照課程以及實作練習去深入了解在這個領域中不同的分工裡實際的工作內容是什麼。由於都是微軟Azure的證照，對雲端運算也有更近一步的認識。</p><p>資料科學大概就是分成這三大種類，其他如機器學習工程師，人工智能工程之，商業分析師，商業分析工程師等都大概可以從這三個大分類去延伸出來，關於資料科學領域裡各個職位的工作內容與分工將來會再寫一篇文章介紹。其中資料科學家的定義最廣，是「用資料解決公司問題，為公司帶來正面影響」的人，在不同的公司規模下所負責的內容也不同，有興趣的朋友可以看看<a href="https://www.youtube.com/watch?v=xC-c7E5PK0Y">這部Joma的影片</a>，我覺得是目前看過講得最好的。</p><p>直到上個月前我的目標都還一直是進FAANG這種大科技公司，領個高薪享受爽到不行的員工福利，在經過一番思考與回憶剛出社會時的心情後改變了想法：在新創工作直接為公司帶來影響，並與公司一起成長，若有機會的話搭上IPO的順風車，那才是最有成就感的事吧。所以現在下一個目標是去一個高速成長的新創公司當Data Scientist，也從中觀察一個公司崛起的過程。哎，又要面臨找工作地獄了。</p><h3>活在當下</h3><p>前幾天又把印度神片三個傻瓜再看了一次。相較於學生時期，工作之後看了有更深的感觸。不知從什麼時候開始，工作時總是會想著：我做這個會讓我的年度評量好看嗎？會讓我升遷加薪嗎？能夠讓我找到更好的工作嗎？若不是的話做起來百般不情願。太過於注重結果反而讓我忘了去享受過程，去享受解決問題及能夠在資料科學領域中工作的喜悅。為了錢工作是很痛苦的一件事。</p><p>回想當年在新創公司愛上資料分析時，那時充滿了好奇，只想學習更多知識，縱使沒有加薪或是升遷，多學到一點都令當時的我雀躍。我帶著那樣的初衷來到英國，卻在真的實踐中將他遺忘。當我利用這段時間靜下來問自己為何會工作的這麼不開心時，我總會提醒自己去回想第一次用excel表拉出圖表時的心情，並告訴自己享受在正在做的事情上而不是薪水或是升遷。</p><blockquote>Pursue excellence, and success will follow. ~ 3 idiots</blockquote><h3>冥想</h3><p>大概從去年七八月開始練習冥想。一開始會想練習的原因是我深切的感受到自己的專注力與十年前相差甚遠，可能是因為年齡增長，可能是因為太多新的科技。看完比爾蓋茲唯一推薦的冥想書《The Headspace Guide to Meditation and Mindfulness》後按照書中的指示每天練習。雖然一天只要短短的十分鐘，但要每天做其實是非常難堅持的。我又都是安排在睡前練習，常常很累很想直接倒頭就睡，都要靠意志力堅持那十分鐘。</p><p>經過八九個月的練習，確實是有感受到專注力有所提升，而且比較不會想東想西。若發現到自己開始胡思亂想，很容易可以清空腦袋，沈澱一下心靈。再搭配番茄時鐘工作法，提升了許多做事的效率。</p><p>總的來說，封城帶來許多負面影響，但也不全是壞處，許多事情要不是因為封城，我可能不知道什麼時候才會去做。從中獲益最多的，是得已緩下生活步調，審視自己的生活。歸納以下幾點：</p><ol><li>開始將時間花在能在未來也創造價值的事情上，創造被動收入</li><li>開始尋找工作以外的收入來源</li><li>重新思考自己的熱情所在，找尋職涯方向</li><li>建立冥想、睡前閱讀、規律運動等習慣</li></ol><p>現在我的投資配置還沒什麼賺錢，Medium寫的文章還沒有什麼好成績，模特兒工作也只簽了Agency還沒接過案子，工作也還沒換成。不過至少開始把自己放進一個好的循環，讓時間成為自己最大的戰友，去讓這些小小的習慣慢慢發酵。我們不需要急著年輕時收割，而是該想著如何在十年二十年之後豐收。</p><p>封城也算是人生難得的經驗，這輩子應該就只會遇到這麼一次吧（拜託不要再有第四次了）。最後還是希望疫情早日結束，經濟復甦，人人有飯吃。</p><p>～04.11.2021英國解封前一日</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2c8cda1a7bd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 Git Practices I Found Most Useful]]></title>
            <link>https://javascript.plainenglish.io/5-git-practices-i-found-most-useful-af7410f390dd?source=rss-a7c0dfb1f89------2</link>
            <guid isPermaLink="false">https://medium.com/p/af7410f390dd</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[James Ho]]></dc:creator>
            <pubDate>Thu, 25 Feb 2021 00:43:28 GMT</pubDate>
            <atom:updated>2021-03-05T21:27:36.110Z</atom:updated>
            <content:encoded><![CDATA[<h4>Git initiation, rename, stash, reset, and rebase</h4><h3>6 Git Practices I Found Most Useful</h3><h4>Besides ordinary workflow, these are some of the Git practices that I found very useful at work</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Bxv2T_IzKl3_6L-v" /><figcaption>Photo by <a href="https://unsplash.com/@ffstop?utm_source=medium&amp;utm_medium=referral">Fotis Fotopoulos</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><blockquote>Prerequisite</blockquote><ol><li>You have to have Git installed on your local machine. You can follow the <a href="https://git-scm.com/book/en/v2/Getting-Started-Installing-Git">official documentation</a> to do so.</li><li>Have a <a href="https://github.com/">Github</a> account (a free version would suffice).</li></ol><h3>1. Initiate Git in your project and publish it to Github</h3><p>You might have been working on something on your own for a while. And one day you need to share it or cooperate with others. Maybe your supervisor wants to have a look at what you’ve been doing, maybe there are new recruits who are gonna share your workload, or you simply want to share your work! This practice consists of 2 parts, initiate Git and publish your project to Github.</p><p>First, you need to initiate Git in the root directory of your project.</p><pre>$cd root/path/to/project<br>$git init</pre><p>This will create a hidden folder.git in the directory, which contains metadata and version history that Git used to track your project. The next step is to tell Git what to be included in the commit. Here we use -A to include all files in this project directory.</p><pre>$git add -A</pre><p>Now you’re ready to make your first commit.</p><pre>$git commit -m &#39;This is the first commit. Add all files&#39;</pre><p>The local work is done. Let’s move to Github. What we need is very simple, a new repository. You can either make it public or private, have or not have README and .gitignore files in the creation stage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*3iQuA2Cd69WItH_wJubYzg.png" /><figcaption>Image from <a href="https://github.com/">Github</a></figcaption></figure><p>When the repository is created, you can add this repository as your remote via HTTPS or SSH:</p><pre>$git remote add origin https://github.com/{usrname}/{repo_name}.git</pre><p>Finally, set the upstream for your local repository to the remote you just added.</p><pre>$git push --set-upstream origin main</pre><h4>1.1 .gitignore</h4><p>It took me a while to really understand what this file is used for<em>. </em>.gitignore<em> </em>is a plain text file Git uses to identify those files that it shouldn’t track and include in a commit. In another word, as long as the name of your file is in .gitignore, it won’t appear in the tracked changes. It’s commonly used for virtual environments, sensitive data (like credentials), or cache files, etc. There are a lot of templates tailored to different environments available on Github when you create the repository.</p><h3>2. Rename the branch</h3><p>This is another common practice I found myself use a lot. Sometimes you realise there’s a certain policy of naming the branches, or sometimes you just feel like the original name is not representative enough, or there are typos, etc.</p><p>Renaming your branch is very simple with git branch -m.</p><pre>$git branch -m {old_branch_name} {new_branch_name}</pre><p>This only changes the branch name on local. If you have pushed the branch to remote, you’ll have to run the following to change the name at remote too.</p><pre>$git push origin -u {new_branch_name}</pre><pre># This resets the upstream branch, don&#39;t forget to delete the old branch</pre><pre>$git push origin -d {old_branch_name}</pre><h3>3. Undo the latest commit</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/885/0*GMeqIv4Rr3sEW7WG.png" /><figcaption>Image from <a href="https://www.atlassian.com/git/tutorials/undoing-changes">Altassian</a></figcaption></figure><p>It’s quite common that you have committed and changed the branch, however want to undo that commit afterward. Don’t worry, in Git, we can always take a step back and go back to the point where we desire.</p><p>We use git reset to undo a commit. If you want to also get rid of all of the changes made in that commit, use --hard. If you just want to do some adjustment to the commit and keep those changes, use --soft.</p><pre># This will keep the changes untouched<br>$git reset --soft HEAD~1</pre><pre># This will remove all the changes in this commit<br>$git reset --hard HEAD~1 </pre><h3>4. Stashing</h3><p>Often, in order to do other works, you have to check out your branch without getting to a place where you’re happy to commit your works. You definitely don’t want to start everything from scratch again. Stashing is what you’re looking for. Stashing will save all your changes and revert the working tree back to the latest HEAD commit. If you have untracked files to stash, -u, --untracked-files is needed. An optional note can be added at the end.</p><pre>$git stash save -u &#39;stash message&#39;</pre><p>You’ve worked on other things for a while and finally come back to pick up where you left. But you forget what you have done and what’s in the stashes. To see all existing stashes, run</p><pre>$git stash list</pre><p>Stashes are named as stash@{0}, stash@{1}, stash@{2}, etc. To inspect an individual stash, use</p><pre>$git stash show stash@{0}</pre><p>apply and pop are both used for bringing the changes in a stash back to the working tree, the difference is apply will keep the stash whereas pop won’t.</p><pre>$git stash apply stash@{0} <br>#stash@{0} is kept after bringing back changes</pre><pre>$git stash pop stash@{0}   <br>#stash@{0} is deleted after bringing back changes</pre><p>git stash pop equals to running git stash apply + git stash drop. To remove all stashes, run</p><pre>git stash clear </pre><h3>5. Interactive rebase</h3><p>Adding a -i , which stands for interactive, aftergit rebase command will open a text editor which allows you to modify your commit history. It looks something like this:</p><p>$git rebase -i {The_branch_you_rebase_on}</p><pre>pick dd113af This is the first commit<br>pick ca101aa This is the second commit<br>pick 4448c6c This is the third commit</pre><pre># Rebase dc50ea8..4448c6c onto 4448c6c (4 commands)<br>#<br># Commands:<br># p, pick &lt;commit&gt; = use commit<br># r, reword &lt;commit&gt; = use commit, but edit the commit message<br># e, edit &lt;commit&gt; = use commit, but stop for amending<br># s, squash &lt;commit&gt; = use commit, but meld into previous commit<br># f, fixup &lt;commit&gt; = like &quot;squash&quot;, but discard this commit&#39;s log message<br>.<br>.<br>.<br>.<br>.<br></pre><p>The latest commit is at the bottom and the earliest commit is at the top. Following you can see a lot of commands you can use to ‘<em>rewrite</em>’ the commit history. The descriptions after every command are quite self-explanatory already. You only need to change the ‘<em>pick</em>’ in front of the commits with the commands you’d like to apply. <a href="https://thoughtbot.com/blog/git-interactive-rebase-squash-amend-rewriting-history">Here’s a great article</a> that demonstrates some of them in practice.</p><p>Note that when you are editing the commits, you’re basically ditching old ones and creating new ones. You’re re-writing the history of the repository. It is not a big deal if you’re the only person working on this branch. But if someone else branched off from the commit you amended, they will be screwed since that commit is no longer exist. So be very certain of what you’re doing and cautious while rebasing.</p><h3>6. Inspecting other people’s branches</h3><p>This is quite common in the cooperations. Sometimes you have to review other people’s PR, or your colleague reaches out to you asking you to have a look at their code. For any reason, you need to get into other people’s branches. Firstly, that branch has to be pushed to Github. Then, you set up a local branch that ‘<em>tracks</em>’ the remote branch by addin — track after git checkout .</p><pre>$git checkout --track origin/{other people&#39;s branch on remote}</pre><p><strong><em>My Git series stories:</em></strong></p><p><a href="https://medium.com/swlh/an-intro-to-git-and-github-for-beginners-157c4374deff">An Intro to Git and GitHub for Beginners</a></p><p><a href="https://towardsdatascience.com/hands-on-git-workflow-with-code-example-a89ec2b3110b">Hands-On Git Workflow with Code Example</a></p><p><a href="https://towardsdatascience.com/the-differences-between-rebase-and-merge-30c91cd18f30">The Differences between Rebase and Merge</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af7410f390dd" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/5-git-practices-i-found-most-useful-af7410f390dd">5 Git Practices I Found Most Useful</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Differences between Rebase and Merge]]></title>
            <link>https://medium.com/data-science/the-differences-between-rebase-and-merge-30c91cd18f30?source=rss-a7c0dfb1f89------2</link>
            <guid isPermaLink="false">https://medium.com/p/30c91cd18f30</guid>
            <category><![CDATA[editors-pick]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[rebase]]></category>
            <category><![CDATA[merge]]></category>
            <dc:creator><![CDATA[James Ho]]></dc:creator>
            <pubDate>Sun, 21 Feb 2021 23:46:32 GMT</pubDate>
            <atom:updated>2021-02-25T00:46:20.943Z</atom:updated>
            <content:encoded><![CDATA[<h4>Git Question 101</h4><h4>This is probably the most-asked question of git users</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*M3MJEsr4TNpxR2b8" /><figcaption>Photo by <a href="https://unsplash.com/@marilezhava?utm_source=medium&amp;utm_medium=referral">mari lezhava</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>It’s been long debated in the community that whether merge or rebase should we use.</p><p>Some people would say merge is better cause it preserves the most complete working history. Others would argue rebase is neater, which makes the reviewer’s life easier and more efficient. This article will explain what are the differences between merge and rebase and what’s the benefits of using one of them.</p><p>Fundamentally, merge and rebase serve the same purpose, to integrate changes from one branch (sometimes multiples branches) into another. Most commonly used when you want to integrate the latest master or develop branch before opening a pull request. Although the purpose is the same, merge and rebase achieve it differently.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kZ6b-CeFvVuuhpnd1_02WA.png" /><figcaption>Image by Author</figcaption></figure><p>A quick reflection on the goal here. Imagine you have such a branch ‘feature’, which branched off from ‘develop’ at ‘base’. Since then, you’ve done your work of C, D, E and the develop has been added 2 changes, A, B. Now you’d like to open a pull request to integrate <em>‘your works’</em> into <em>‘the develop branch’</em>. Before doing that, you have to integrate the changes in <em>‘develop branch’ </em>into <em>‘your feature branch’</em> so there won’t be conflicts in your pull request.</p><h4>Merge</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VDMbHEO1l0uJ6UhhfY-UTw.png" /><figcaption>Image by Author</figcaption></figure><p>Merge will integrate the changes in develop into your feature branch and create a new commit F. F is the commit of merging develop branch and sort the conflicts if there’s any. This method will bring the changes in develp branch, which is A and B, to your feature branch. Now the commits on your feature branch are C, A, D, B, E, F. There are 3 more additional commits added to your feature branch.</p><h4>Rebase</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*51f5XVjrGdZlrov_LLO_sA.png" /><figcaption>Image by Author</figcaption></figure><p>On the other hand, rebase moves the whole feature branch, just as it was branched off from the latest commit on develop branch from the beginning. Rebase will first search for the base of the feature branch and change that base to the latest commit on develop branch, B in this case, and then <em>re-apply</em> all of the commits on feature branch based upon that base, B. Rebase actually creates new commits, C’, D’, E’. The original commits remain untouched. Finally, it changes which the feature branch points to from E to E’.</p><h4>Pros and Cons</h4><p>The biggest difference between these two approaches is that merge preserves the complete history of works, including the chronological order, whereas rebase makes the commits clean and only relevant to the works on the branch. When a reviewer is reviewing your PR, she will see A, B, C, D, E, F commits if you choose to merge and only C, D, E if you choose to rebase.</p><p>Merge has higher traceability. You can find the whole working history regardless of relevance to this PR. But it could be painful to the reviewer because the branch consists of a lot of irrelevant commits and often it’s difficult to identify them.</p><p>Rebase really makes the PR tidy and clean and relevant without noisy commits. The reviewer can easily pick up what this PR is about and what changes are made within this branch. However, it might not be so helpful if you’d like to track the exhaustive history of the repository.</p><blockquote><strong>Merge has higher traceability, whereas Rebase is tidier and reviewer-friendly.</strong></blockquote><h4>So which one should I use?</h4><p>It really depends on what kind of working strategy your organisaiton is using. You have to weigh the value of the simplicity of rebasing against the value of the traceability of merging. It’s likely to apply both of them too, use a certain method under certain circumstances.</p><p>From my personal experience, rebase is more favorable, because it provides a more effortless way to cooperate with team members. And most of the time, we really should avoid commits that are irrelevant to our work being included in the PR. It could easily lead to confusion.</p><h3>Conclusion</h3><p>I hope this article has cleared your doubts about merge and rebase, and therefore you can adopt the most suitable way to your workflow. If you’re looking for some more practical examples, <a href="https://github.com/edx/edx-platform/wiki/How-to-Rebase-a-Pull-Request">this</a> and <a href="https://www.freecodecamp.org/news/an-introduction-to-git-merge-and-rebase-what-they-are-and-how-to-use-them-131b863785f/">this</a> article are great to start with.</p><p>Next, I’ll be sharing some of the most useful Git tricks I found in my works. Stay tuned!</p><p><em>My Git series stories:</em></p><h4><a href="https://medium.com/swlh/an-intro-to-git-and-github-for-beginners-157c4374deff"><strong><em>An Intro to Git and GitHub for Beginners</em></strong></a></h4><h4><a href="https://towardsdatascience.com/hands-on-git-workflow-with-code-example-a89ec2b3110b"><strong><em>Hands-On Git Workflow with Code Example</em></strong></a></h4><h4><a href="https://hoooching.medium.com/5-git-practices-i-found-most-useful-af7410f390dd">5 Git Practices I Found Most Useful</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=30c91cd18f30" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/the-differences-between-rebase-and-merge-30c91cd18f30">The Differences between Rebase and Merge</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hands-On Git Workflow with Code Example]]></title>
            <link>https://medium.com/data-science/hands-on-git-workflow-with-code-example-a89ec2b3110b?source=rss-a7c0dfb1f89------2</link>
            <guid isPermaLink="false">https://medium.com/p/a89ec2b3110b</guid>
            <category><![CDATA[hands-on-tutorials]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[command-line]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[James Ho]]></dc:creator>
            <pubDate>Sun, 14 Feb 2021 23:53:49 GMT</pubDate>
            <atom:updated>2021-02-25T00:47:06.233Z</atom:updated>
            <content:encoded><![CDATA[<h4>Go through the Git workflow step by step with hands-on practice (code example)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*myaSOUQyPidpOti7" /><figcaption>Photo by <a href="https://unsplash.com/@jefflssantos?utm_source=medium&amp;utm_medium=referral">Jefferson Santos</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Following the previous <a href="https://medium.com/swlh/an-intro-to-git-and-github-for-beginners-157c4374deff"><strong>An Intro to Git and Github for Beginners</strong></a>, today we’re gonna get our hands dirty. This story is going to walk you through the Git workflow with practical code examples. Since Github is the most popular website to host Git repositories, we’ll be using it as examples. We’ll be working with Git’s Command-line interface, therefore, Github CLI is not considered.</p><h4>Prerequisite</h4><ol><li>You have to have Git installed on your local machine. You can follow the <a href="https://git-scm.com/book/en/v2/Getting-Started-Installing-Git">official documentation</a> to do so.</li><li>Have a <a href="https://github.com/">Github</a> account (a free version would suffice).</li></ol><h3>Clone the repository from Github</h3><p>There are 2 ways to get a repository, create your own or get it from Github or equivalent. We’ll focus on cloning one from Github here. If you’re interested in how to enable Git in your own project and publish it on Github, <a href="https://www.digitalocean.com/community/tutorials/how-to-push-an-existing-project-to-github">this is an excellent article</a> to help you do so.</p><p>You first need to go to the directory where you’d like to put the repository in the terminal. Let’s say we’d like to put it under Documents of home directory. When you go to a repository in Github, you can find a coloured “Code” bottom under “&lt;Code&gt;” tab. Under that, there are three options, HTTPS, SSH, and Github CLI. These are the three different ways that you can clone the repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dJ7K3xG0TxE0bMG_OU8_6A.png" /></figure><p>The syntaxes are the same, they are all git clone + the URL within that option.</p><pre>$cd ~/Documents/</pre><pre># HTTPS<br>$git clone https://github.com/&lt;USERNAME&gt;/&lt;REPO NAME&gt;</pre><pre># SSH<br>$git clone git@github.com:&lt;USERNAME&gt;/&lt;REPO NAME&gt;.git</pre><p>The difference is how your local machine access the remote repository. If you choose HTTPS, you will be prompted to type in your user credential whenever you interact with the remote (like pull, push, fetch, etc) if it is a private repository. On the other hand, accessing via SSH can save you a lot of trouble, especially when the repository is private. But you have to add your local machine’s SSH key to your Github account.</p><p>Once you have the repository cloned to your local machine, you need to create your own branch to work on.</p><h3>Create a new branch</h3><p>Let’s check the status first by running git status.</p><pre>$git status<br>&gt;&gt;On branch master<br>Your branch is up to date with &#39;origin/master&#39;.</pre><pre>nothing to commit, working tree clean</pre><p>Now we can branch off from this up to date master branch (mostly develop branch). To achieve, we need git branch command.</p><pre>$git checkout -b &quot;new_branch_name&quot;<br>&gt;&gt;Switched to a new branch &#39;new_branch_name&#39;</pre><p>Obviously, you can change the name of the branch to whatever you want.</p><p>Now, you have your branch set up, you can start working on whatever you’d like to change the files.</p><h3>Rebase and Commit</h3><p>Once you have everything done and ready to submit your work, always remember to rebase. To rebase to the latest master or develop branch, we need to pull the latest version first.</p><pre># Commit your changes first<br>$git add (this step is called staging, to add changes to the commit)<br>$git commit -a -m &quot;Your commit message&quot;</pre><pre># Switch to develop/master branch<br>$git checkout develop</pre><pre>&gt;&gt;Switched to branch &#39;master&#39;<br>Your branch is up to date with &#39;origin/master&#39;.</pre><pre># Use &#39;fetch&#39; to check (just check, we haven&#39;t pulled yet)if there are updates in remote<br>$git fetch</pre><pre># If nothing comes out, your develop is up to date. If there are updates, pull those updates to your local machine<br>$git pull</pre><p>Now the develop/master branch on our local machine is up to date. We can then rebase on this branch</p><pre>$git checkout new_branch_name<br>&gt;&gt;Switch to branch &#39;new_branch_name&#39;</pre><pre>$git rebase -i develop</pre><h3>Push to remote</h3><p>Recall that we only created the branch on our local machine so far, there’s no such a “new_branch_name” branch on the remote whatsoever. If you just run git push , you will get an error of the following message:</p><pre>fatal: The current branch test has no upstream branch.<br>To push the current branch and set the remote as upstream, use</pre><pre>     git push --set-upstream origin new_branch_name</pre><p>This error message is complaining that it can’t find a remote branch where it pushes your commits to. The solution is simple, do exactly what it suggests you to do:</p><pre>$git push --set-upstream origin new_branch_name</pre><p>This line will create a branch on remote and push your current branch, which includes all the commits, to remote.</p><h3>Create pull request</h3><p>The last thing to do is to create a pull request. General practice is creating a pull request on Github, where the interface is easier to create a PR than using CLI. You can designate a specific person in the team to review your PR, make it a draft PR so you can keep working on it, and review all the changes you’ve made within this PR.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RsPCGScehLWQjGKHtC6Sxg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*picAieDa9PDsxZ7czboG1A.png" /></figure><p><em>My Git series stories:</em></p><h4><a href="https://medium.com/swlh/an-intro-to-git-and-github-for-beginners-157c4374deff"><strong>An Intro to Git and Github for Beginners</strong></a></h4><h4><a href="https://hoooching.medium.com/the-differences-between-rebase-and-merge-30c91cd18f30">The Difference between Rebase and Merge</a></h4><h4><a href="https://hoooching.medium.com/5-git-practices-i-found-most-useful-af7410f390dd">5 Git Practices I Found Most Useful</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a89ec2b3110b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/hands-on-git-workflow-with-code-example-a89ec2b3110b">Hands-On Git Workflow with Code Example</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An Intro to Git and GitHub for Beginners]]></title>
            <link>https://medium.com/swlh/an-intro-to-git-and-github-for-beginners-157c4374deff?source=rss-a7c0dfb1f89------2</link>
            <guid isPermaLink="false">https://medium.com/p/157c4374deff</guid>
            <category><![CDATA[github]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[engineering]]></category>
            <dc:creator><![CDATA[James Ho]]></dc:creator>
            <pubDate>Tue, 09 Feb 2021 10:54:10 GMT</pubDate>
            <atom:updated>2021-02-25T00:46:43.030Z</atom:updated>
            <content:encoded><![CDATA[<h4>Lesson no.1 of Git and Github</h4><h4>To finally understand what the heck are those engineers are talking about!</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Uwt2wVIxLi5HnnXS" /><figcaption>Photo by <a href="https://unsplash.com/@lorenzoherrera?utm_source=medium&amp;utm_medium=referral">Lorenzo Herrera</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Engineer A: “Hey, have you merged your branch to develop yet?”</p><p>Engineer B: “No, I’m waiting for my previous PR to be merged so I can proceed. But I’ve already staged all my works and pushed.”</p><p>Engineer A: “Ok, I’ll review and merge it later. Don’t forget to rebase!”</p><p>Engineer B: “Thanks, I almost forget that. In the meantime, I’ll work on another branch.”</p><p>You: “Huh? Were you speaking English? So what’s the progress now??”</p><p>Does it sound familiar? This is exactly what happened to me when I first met these sounds-high-tech terminologies. I genuinely thought PR referred to public relations and it just made the whole conversation nonsense.</p><p>This story aims to help you to avoid those awkward moments, so you won’t look as dumb as I did. Let’s crack on!</p><h3>What is the problem Git is trying to solve?</h3><p>To understand something thoroughly, we first need to know why it exists, what drove people to develop this solution.</p><p>In every kind of project, be it web development, dashboard design, data analysis — you name it, it revolves around collaboration, i.e. there are multiple workers in the project. We want to monitor people’s work in hope of minimising the chance of messing up the system, or the work we’re developing. If someone is going to change something, we don’t want him to just change it. Ideally, he should make a copy of the whole system and work on it, so his work is isolated, and someone else should review his work before making the changes to the system permanently.</p><p>However meticulous the process is, people are still likely to make mistakes. People make mistakes! People forget things! That’s what makes us human! If something bad really happens and the whole system is messed up, we need a time machine that can bring us back to the good old time when everything was fine. This is where Version Control System comes in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EhbFmiyheuwCdpj6qS1Rjw.png" /></figure><h3>Version Control System</h3><p>Remember our old friend Super Mario? Whenever we finally successfully passed a level, the first thing to do was always ‘<strong>SAVE!</strong>”. So when we run out of lives, we don’t need to start from level 1.</p><p>Version control system is sort of doing the same thing. It <strong><em>keeps track of each stage(version) of the working progress</em></strong>, if something goes wrong, we can easily revert to a previous stage we want. For example, let’s say the initial stage of a project is version 1. Someone did some changes and made a version 2. One day you found that those changes are faulty and they’re crashing the system, you can instantly revert it back to version 1. Keep tracking each version of our project, from the beginning to the very end, makes it easier to fix some catastrophic disaster and synchronise everyone’s works smoothly.</p><p>Git is one of the many version control systems and it is the most ubiquitous one. Other popular version control systems for instances are Bitkeeper, CVS, Subversion, SVK, etc.</p><h3>What’s the difference between Git and Github?</h3><p>The first thing to know is that Git and Github are 2 <strong><em>completely different</em></strong> things. Git is a version control tool that enables us to track and maintain our working progress.</p><p>Github, on the other hand, is a<strong> cloud-based service that stores git repository</strong>. It provides a service that allows you to host your source codes, which have to be using Git, on the cloud. The purpose of this is to <strong>make sharing works with others more effortless</strong>. You don’t necessarily need a Github account to use Git, but you do need Git to use Github.</p><p>There are many other alternatives such as Gitlab, or BitBucket, but Github is the largest one in the world. When we are working in a repository, these cloud-based repository storage places are referred to as ‘<strong><em>remote</em></strong>’.</p><p>Before diving into Git, there are two more fundamental terminologies and concepts we better understand first. They are ‘repository’ and ‘branch’.</p><h4><strong>Repository/Repo</strong></h4><p>A repository is where we store all of the files that relate to the project. You can think of it as a folder that contains all of the codes, instructions, introductions, data, etc of the project.</p><h4>Branch</h4><p>Branch is one of the core concepts of Git. I’d like to think of it as parallel universes. The default name of Git’s branch is ‘<strong><em>master</em></strong>’, which is usually deployable and used as the production branch, although not always the case. In this master universe, the codes are ready to be shown to the world. This is where the public lives.</p><p>Next to the master universe, there is a ‘<strong><em>develop</em></strong>’ universe, where all the developers coordinate their works, either adding some new functionalities or fixing bugs. The develop universe will synchronise with the master universe once in a while, to make sure the latest and good-to-go developments are deployed to master. This is the universe where all workers live together.</p><p>All workers have the ability to create their own universe. If you wanted to build a skyscraper, you have to create your universe first and then build it there. Once you’re done, you need someone else’s approval to transition, or ‘merge’, your skyscraper to the develop universe.</p><p>The purpose of these parallel universes is obvious, to isolate each universe. If one universe is destroyed by Thanos, we still have others. Or we can always use the time stone to reverse back. If you don’t know who Thanos is, we’re probably in different universes.</p><h3>Git Workflow</h3><p>Now we can finally get to the juicy part, the Git workflow. A simplified version looks like below:</p><ol><li>Clone the repository from ‘remote’</li><li>Create your own branch</li><li>Work on your own branch, make changes</li><li>Rebase, or merge the latest develop branch</li><li>Commit your changes</li><li>Push your commit to remote</li><li>Create Pull Request</li><li>Merge to develop</li></ol><p>Clone is like making a copy of the project from the cloud to our local machine. Or you can think of it as downloading all the files we need. When we clone the repository to our local machine, it automatically creates a git repository in our machine as well. You can verify it by seeing a hidden file named ‘git’ in the folder you just cloned.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*7-851WFQlITFj5uMiyYBfw.png" /></figure><p>Now you have the develop branch on your local machine. Next, you need to create a branch to work on. Let’s call it ‘feature’. In this branch, no matter what changes we make, even if we delete all files, it won’t affect the main develop branch at all as long as this branch is not merged. Note that we are doing this on our own local machine, therefore, there won’t be a ‘feature’ branch appear on remote. The point where we branch off from the develop branch is called the ‘base’ of the branch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*MReIeb9-kiw665qvBhK-Eg.png" /></figure><p>Commit is the step that saves the changes we have made to the branch. Merely saving the files will only change the file, the ‘feature’ branch is not changed. In order to apply those changes to the branch, you need to commit.</p><p>Now everything seems fine and we’re ready to ask someone else to apply our changes to the develop. We normally don’t do it ourselves, otherwise there’s no point in branching and isolating our works. The other thing to consider is that during the time when we were working on our branch, the develop branch might have changed as well. We need to make sure our base is the latest develop, not the older version which we branched off to preserve consistency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*iYPe5OOWfeUxDBovdkTzlQ.png" /></figure><p>And because the develop branch is only updated in remote, it does not exist on your machine, we need to ‘<strong><em>pull</em></strong>’ the latest develop from remote to local. Think of this step as ‘updating’ your local develop branch to the latest version.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qEQ8whkDJ95csZqtpG2hVw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*47t-KJN6fcp5K4ToOVEufA.png" /></figure><p>Once you pull the latest develop, you can then use ‘rebase’ to move the base of your branch from the older version of develop to the latest version. Merge the develop to your branch can achieve the same goal, but here let’s just focus on rebase. The takeaway is to understand why we are doing this. If you’d like to know the difference between merge and rebase, check <a href="https://hoooching.medium.com/the-differences-between-rebase-and-merge-30c91cd18f30"><strong><em>The Difference between Rebase and Merge</em></strong></a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P569T5_TzOzAfb_7-EgJdg.png" /></figure><p>When everything is set, you have built your changes upon the latest develop, you’re ready to ‘<strong><em>push</em></strong>’ your branch to remote. When you created your branch on your local machine and work on it, they only exist in your machine. We need to ‘push’ your branch from local to remote so others can see and review your branch.</p><p>Finally, create a pull request (PR), requesting someone else to ‘pull out the changes in your branch and merge them to the develop’. It’s like submitting your assignment and someone in the team will review it. Once it is approved, it can be ‘<strong>merged</strong>’ to the develop branch, i.e, your skyscraper can be built in the develop universe.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GVGe0X0L_OkNRFlofP3FzA.png" /></figure><p>If you’d like to dive deeper into the Git workflow, <a href="http://datasift.github.io/gitflow/IntroducingGitFlow.html">this is a fantastic article</a>. Now you understand most of the git terminologies as well as the workflow. If you just don’t want to look dumb in front of those nerdy engineers, these should be enough to impress them. Next, we’ll be looking at some hands-on practices of using Git. Stay tuned!</p><p><em>My Git series stories:</em></p><h4><a href="https://hoooching.medium.com/hands-on-git-workflow-with-code-example-a89ec2b3110b">Hands-On Git Workflow with Code Example</a></h4><h4><a href="https://hoooching.medium.com/the-differences-between-rebase-and-merge-30c91cd18f30">The Difference between Rebase and Merge</a></h4><h4><a href="https://hoooching.medium.com/5-git-practices-i-found-most-useful-af7410f390dd">5 Git Practices I Found Most Useful</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=157c4374deff" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/an-intro-to-git-and-github-for-beginners-157c4374deff">An Intro to Git and GitHub for Beginners</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Precision and Recall Affect the Anti-COVID Measures]]></title>
            <link>https://medium.com/data-science/how-precision-and-recall-affect-the-anti-covid-measures-38d625de61d9?source=rss-a7c0dfb1f89------2</link>
            <guid isPermaLink="false">https://medium.com/p/38d625de61d9</guid>
            <category><![CDATA[specificity]]></category>
            <category><![CDATA[precision]]></category>
            <category><![CDATA[sensitivity]]></category>
            <category><![CDATA[recall]]></category>
            <category><![CDATA[editors-pick]]></category>
            <dc:creator><![CDATA[James Ho]]></dc:creator>
            <pubDate>Wed, 20 Jan 2021 18:48:13 GMT</pubDate>
            <atom:updated>2021-02-05T19:09:48.101Z</atom:updated>
            <content:encoded><![CDATA[<h4>See how we combat the pandemic from a statistical perspective</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BPXY_ChOUtjakQsc" /><figcaption>Photo by <a href="https://unsplash.com/@edwinhooper?utm_source=medium&amp;utm_medium=referral">Edwin Hooper</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><blockquote>To test or not to test, this is a statistical question.</blockquote><p>In this global battle with the pandemic, Taiwan has done a marvelous job keeping its citizens safe and healthy, with only 850 confirmed cases and 7 deaths in total to date (17/01/2021). As a small island only a strait from China, where the virus originated, the number is nothing but incredible. Apart from recognising the pandemic much sooner than the rest of the world, Taiwan has never imposed compulsory COVID-19 testing on international arrivals. As a matter of fact, there aren’t many countries that have this policy imposed.</p><p>Why don’t we test all arrivals? Doesn’t the universal testing enable us to recognise the patients before they get into the country and, therefore, to prevent local transmission and community spread? Why do I still have to do self-quarantine if I’m tested negative? You may ask.</p><p>This article is aiming to answer your questions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UvkG4cYdpa_jiptHr0VOEQ.png" /><figcaption>Image by <a href="https://pixabay.com/users/openclipart-vectors-30363/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=152217">OpenClipart-Vectors</a> from <a href="https://pixabay.com/vectors/unimaginative-uninspired-pencil-152217/">Pixabay</a></figcaption></figure><p>To understand the rationale behind this decision, we need to understand 2 statistical metrics, precision and recall, first. They are two widely-used metrics for accuracy. And they have been playing a significant role in a lot of decision makings.</p><h3><strong>Confusion Matrix</strong></h3><p>Before diving into what these 2 metrics are and how they affect the implementation of universal testing, I have to introduce you <strong>‘Confusion matrix</strong>’ first.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*tUH4S1jqBJw7g0yDOfvMSw.png" /><figcaption>Confusion Matrix</figcaption></figure><p>For every kind of binary testing, either positive or negative, the results will only fall into one of the four grids. If the result is correct, which means the testing result matches the true situation, it will either fall into the upper left grid (you have COVID and you are tested positive) or the bottom right grid (you don’t have COVID and you are tested negative). Otherwise, it will fall into the upper right or bottom left grid.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wIFeexHYrco7RXJ7lD9xdw.png" /></figure><p>But only calling the results correct or wrong is not precise enough. How correct? How wrong? So we have to give each grid a name to better understand the results. The naming is <strong><em>‘the right(true) or wrong(false) of the result’ + ‘the testing result(positive or negative)’</em></strong>.</p><ol><li>True Positive: You have COVID-19 and you are tested positive.</li><li>True Negative: You don’t have COVID-19 and you are tested negative.</li><li>False Positive: You don’t have COVID-19 but you are tested positive.</li><li>False Negative: You have COVID-19 but you are tested negative.</li></ol><p>Put them in the grid, you’ll get one of the most prominent tables in the statistics world:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s7q31NU1rfQDiwGJ_fsNag.png" /><figcaption>Confusion Matrix</figcaption></figure><p>All kinds of testing or screening are aiming for minimising FN and FP. The optimal testing tool will have 0 FN and 0 FP. Unfortunately, this perfect, 100% accurate, 0 error testing tool just doesn’t exist (yet?).</p><h3>Accuracy</h3><p>Now we understand the confusion matrix, we can then get into how we evaluate the results of the testing. For the sake of illustration, I’ll use the following scenario as an example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*-Gxxo-dPaqM__5C3cyxN6w.png" /></figure><p>Instinctively, people would think the accuracy is the <strong>right results/the total results</strong>. So we have an accuracy of (90+1)/(90+1+1+8)=91%. Wow, that is impressive! A 95% accuracy testing tool! Well, it’s technically nothing wrong with this statement, but you might have found it a bit odd by looking at the confusion matrix.</p><p>From the matrix, we know in fact that there are 9 people who are positive and 91 people who are negative. The majority of the people are negative. Now imagine there is a testing tool, which will give every single testee a result of negative regardless. Therefore, this testing tool will still get an accuracy of 91%. <em>Is it high?</em> <strong>It’s high as hell!</strong> <em>Do you want to use this testing tool in the hospital? </em><strong>Definitely not!</strong></p><h3>So how should we validate the testing tool?</h3><p>From the example, we know merely accuracy is not enough to evaluate the results. New metrics have to be introduced. This is where <strong>precision</strong> and <strong>recall</strong> come in. Mathematically, these 2 metrics are defined as:</p><p><strong>Precision = TP / (TP+FP) = 1/ (1+1) = 0.5</strong></p><p><strong>Recall = TP / (TP+FN) = 1/ (1+8) = 0.11</strong></p><p>The performance drops drastically if we look at these 2 metrics, especially in recall. Why is this happening? What’s wrong with the testing tool?</p><p>Look at the formula and pause here for 10 seconds. You probably already have an idea of what precision and recall stand for.</p><h4>Precision</h4><p>If you look close enough, you can find that the precision is actually calculated as <strong><em>True Positive/Total Classified Positive</em></strong>. That’s right! Precision measures the accuracy under the circumstance that when the testing result is positive. In other words, how accurate it is if you are tested positive.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*F516U2qzAVxwnYlOc0uJiQ.png" /></figure><blockquote><strong>Precision</strong> reflects what proportion of positive classification is actually correct.</blockquote><p>If you are tested positive by this testing tool, there’s a 50% chance that you actually didn’t contract the virus. That is pretty high! You probably don’t want to use a swab with this accuracy.</p><p>Precision is useful when the cost of FP is high. For example, if we have low precision in our COVID-19 testing, it means there are a lot of healthy people diagnosed as positive. These people will be falsely sent to the hospital and treated for a disease they don’t have. This is not only a total waste of our health-care resources but also exposing healthy people to a dangerous environment, and therefore potentially create more patients. This vicious cycle could crash the health-care system in a very short period of time. This, to some extent, explains why most of the countries don’t send people who are tested positive to hospitals.</p><h4>Recall</h4><p>On the other hand, recall is calculated as <strong><em>True Positive/Total Actual Positive</em></strong>. It measures how many positive cases we actually identified out of the total positive cases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*UPvUx0q23l1qO8QT3Q3MGg.png" /></figure><blockquote>Recall represents what proportion of actual positive cases are identified correctly.</blockquote><p>In this scenario, there are 9 positive cases in total, however, this testing tool only identifies 1 of them, which is 11%. This is dangerous! You definitely don’t want to see lots of people with COVID-19 hanging on the street just because their testing results are negative!</p><p>Recall is more important when the cost of FN is high. For example, cancer detection, or credit card fraud detection. If someone has cancer but is tested negative, the patient will miss the best timing for treatment. The consequence could be serious. Similarly, if a credit card issuer’s fraud detection algorithm has a low recall rate, it may frequently falsely identify the transaction as fraud negative (not fraud) and let it go through, which could cost its customer a lot of money.</p><p>A good way to remember when to use recall is when the goal of your classifier is to identify a ‘<em>bad thing’</em>, like cancer or identity theft. Missing identifying those ‘<em>bad things’</em> is very likely to lead to serious consequences. We want the recall rate as high as possible in these kinds of detection.</p><h4>Sensitivity and Specificity</h4><p>In medicine, recall is also referred to as <strong><em>sensitivity</em></strong>. There is another metric, <strong><em>specificity</em></strong>, that is opposite to sensitivity. It measures the proportion of actual negative cases that are identified correctly. It is calculated as <strong><em>TN/(TN+FP) = 90/ (90+1)=0.9</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*B5V0jMUzj25pu11OTk6EEw.png" /></figure><blockquote>Sensitivity is equal to recall. Specificity represents what proportion of actual negative cases are identified correctly.</blockquote><p>You may see these two terms more often in the news when the reporters asking professional opinions from a scholar or a governor.</p><h3>What do all these have to do with universal testing?</h3><p>Now we can finally get to the topic, how do all these metrics affect the decision of whether to impose universal testing on international arrivals?</p><p>Imagine we have a testing tool that achieves <strong>85% sensitivity</strong> and <strong>95% specificity</strong>. And the current prevalence rate in, I’m taking London for example, is around 0.7%. Knowing what those metrics mean, we can therefore get the following matrix out of every 100,000 testings:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*zWsABF_vtyM0wfg-GgTMuw.png" /></figure><h4>The False Positive People</h4><p>The numbers we need to pay attention to are the False Positive and the False negative. There are 4,965 false positives, who is healthy but is tested positive. From the aforementioned example, we’ve already known that these people will be wasting our health-care resources and are very likely to crash the whole system.</p><h4>The False Negative People</h4><p>On the other hand, there are 105 false negatives, who have contracted COVID-19 but is tested negative. These people have no idea they’re actually contagious. They are sent back home as normal and will easily loosen their prevention measures because they thought they were healthy. Not wearing a face mask or hanging out with others. Eventually, they will be spreading the virus without even knowing it. This is usually how community spread started.</p><p>Even if the sensitivity and specificity are higher, the big number of testing will still lead to big numbers of FP and FN. The bigger number of testing the more FP and FN people.</p><h3>Conclusion</h3><p>We have seen some countries that imposed compulsory testing on international arrivals have either nearly crashed their health-care system, like Germany, or had explosive community spread, such as Iceland. Imposing compulsory testing on all international arrivals seems not to be the best way to beat the virus.</p><p>Of course, it is far more complicated when the government is drafting and implementing the policy. I’m not an epidemic expert and this is only one perspective of the whole picture. But when it comes to the debate of whether should we implement universal screening, instead of telling the government off of not doing anything, there are some simple notions that can enable us to have a more rational argument.</p><p>I hope this story helps you understand a few statistical concepts and how we can apply them to a real-world issue.</p><h4>Reference:</h4><p><a href="https://towardsdatascience.com/accuracy-precision-recall-or-f1-331fb37c5cb9">Accuracy, Precision, Recall or F1?</a></p><p><a href="https://uberpython.wordpress.com/2012/01/01/precision-recall-sensitivity-and-specificity/">Precision, recall, sensitivity, and specificity.</a></p><p><a href="https://developers.google.com/machine-learning/crash-course/classification/precision-and-recall">Classification: Precision and Recall</a>.</p><p><a href="https://data.london.gov.uk/dataset/coronavirus--covid-19--cases">London Coronavirus Data</a></p><p><a href="https://en.wikipedia.org/wiki/Sensitivity_and_specificity">Sensitivity and Specificity</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38d625de61d9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/how-precision-and-recall-affect-the-anti-covid-measures-38d625de61d9">How Precision and Recall Affect the Anti-COVID Measures</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enhance Your Pandas Skills with SQLite]]></title>
            <link>https://medium.com/data-science/enhance-your-pandas-skills-with-sqlite-c542ad266da1?source=rss-a7c0dfb1f89------2</link>
            <guid isPermaLink="false">https://medium.com/p/c542ad266da1</guid>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[data-manipulation]]></category>
            <category><![CDATA[editors-pick]]></category>
            <category><![CDATA[sqlite]]></category>
            <category><![CDATA[pandas]]></category>
            <dc:creator><![CDATA[James Ho]]></dc:creator>
            <pubDate>Sat, 16 Jan 2021 16:20:50 GMT</pubDate>
            <atom:updated>2021-01-16T19:22:16.794Z</atom:updated>
            <content:encoded><![CDATA[<h4>An easy trick of python’s built-in database, SQLite, to make your data manipulation more flexible and effortless.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cKI3aB5PiwG11I-8" /><figcaption>Photo by <a href="https://unsplash.com/@firmbee?utm_source=medium&amp;utm_medium=referral">William Iven</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Pandas is a powerful Python package to wrangle your data. However, have you ever encountered some tasks that just make you think ‘if only I could use SQL query here!’? I personally found it particularly annoying when it comes to joining multiple tables and extracting only those columns you want in pandas. For example, you’d like to join 5 tables. You absolutely can do this with only one query in SQL. But in pandas, you have to do 4 times merge, a+b, (a+b)+c, ((a+b)+c)+d,….What’s worse, every time you merge, pandas will keep all columns, despite you probably only need one or two columns from the other table. If you have the same or similar issue as mine, you come to the right place.</p><p>This issue brought me to SQLite, a built-in, lightweight database for Python. Built-in means it comes with Python, you don’t have to run any more pip/conda install to install this package. How amazing is it?! Let’s see how this magic works. There are 2 ways to implement this, either use the built-in sqlite3 package, or you can also use sqlalchemy. I will illustrate them both in the following.</p><p>Simply import the package without any other installations (you might need to install sqlalchemy):</p><pre>import sqlite3 as sl<br>import sqlalchemy as sa<br>from sqlalchemy import create_engine</pre><p>Don’t worry about drivers or connection strings etc. You can create a connection as easy as:</p><pre># SQLite<br>sl_conn = sl.connect(‘{your db name}.db’)</pre><pre># SQLAlchemy<br>engine = create_engine(&#39;sqlite:///PATH/TO/DB/{your db name}.db&#39;,echo=True)<br>sa_conn = engine.connect()</pre><p>If the database does not exist, this will create the database automatically and then connect to it. Otherwise, it will connect to the database directly. How convenient is that?</p><p>Note that this will create a db file. In sqlalchemy’s create_engine, setting the echo attribute to True will print out the log. Set to False if you don’t want to see the whole log printed out.</p><p>Once you have created the connection, it’s even easier to interact with the database via pandas’s to_sql and read_sql function.</p><p>Say you’ve already had some pandas dataframe that you want to use SQL query on. The first step is to import that dataframe to the database we just created.</p><pre># sa_conn and sl_conn can be used interchangeably<br>df_1.to_sql(‘table_1’, sa_conn, if_exists=&#39;replace&#39;)<br>df_2.to_sql(‘table_2’, sl_conn, if_exists=&#39;replace&#39;)<br>df_3.to_sql(‘table_3’, sa_conn, if_exists=&#39;replace&#39;)</pre><p>You can specify the table name in the database, it doesn’t have to be the same as the dataframe’s name. Use if_exists to specify what would you like to do if that table has already existed in the database. Options are ‘fail’, ‘replace’, ‘append’.</p><ul><li>‘fail’: Raise a ValueError. (Default)</li><li>‘replace’: Drop the table before inserting new values.</li><li>‘append’: Insert new values to the existing table.</li></ul><p>Once having the tables in the database, you can start using SQL to query them.</p><pre>query = ```<br>        SELECT <br>            *<br>        FROM table_1<br>        INNER JOIN table_2 ON table_1_key=table_2_key<br>        INNER JOIN table_3 ON table_1_key=table_3_key<br>        ```<br>joined_table = pd.read_sql(query, sa_conn)</pre><p>Define your query as a string first, use ``` if the query is lengthy and has multiple lines, and then use pandas’s functionread_sql to pull the data from the database and convert it into a pandas dataframe.</p><p>Interacting with the database with SQL client tools is a complete no-brainer too. You can use tools like DBeaver or DB Browser for SQLite (DB4S).</p><p><strong>DBeaver</strong></p><p>Open your DBeaver and choose SQLite as the database driver.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/0*MoYN8fFBojDEg1FS.png" /></figure><p>Browse to your DB file generated before and click finish.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/0*IGk60g7jzClfer1e.png" /></figure><h3>DB4S</h3><p>DB Browser for SQLite is no different. Click on the ‘Open Database’ then navigate to the DB file and open it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*by_6USDfSeDMlt2I.png" /></figure><p>Congratulations!! Now you know how to utilise Python’s built-in database tool, SQLite, to bring your pandas skills to another level! By integrating pandas and SQL queries, you’ve made your data processing skills more flexible and powerful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c542ad266da1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/enhance-your-pandas-skills-with-sqlite-c542ad266da1">Enhance Your Pandas Skills with SQLite</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>