<?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 Erik Ho on Medium]]></title>
        <description><![CDATA[Stories by Erik Ho on Medium]]></description>
        <link>https://medium.com/@erikho_51835?source=rss-5ca17b15cef9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*589jaIgRU4UiA6P4ifZdOA.jpeg</url>
            <title>Stories by Erik Ho on Medium</title>
            <link>https://medium.com/@erikho_51835?source=rss-5ca17b15cef9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 10:22:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@erikho_51835/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[在蔚藍海岸寫下七天的日記：尼斯慢旅手記]]></title>
            <link>https://medium.com/@erikho_51835/%E5%9C%A8%E8%94%9A%E8%97%8D%E6%B5%B7%E5%B2%B8%E5%AF%AB%E4%B8%8B%E4%B8%83%E5%A4%A9%E7%9A%84%E6%97%A5%E8%A8%98-%E5%B0%BC%E6%96%AF%E6%85%A2%E6%97%85%E6%89%8B%E8%A8%98-e56814226ee5?source=rss-5ca17b15cef9------2</link>
            <guid isPermaLink="false">https://medium.com/p/e56814226ee5</guid>
            <dc:creator><![CDATA[Erik Ho]]></dc:creator>
            <pubDate>Sat, 14 Jun 2025 14:18:44 GMT</pubDate>
            <atom:updated>2025-08-05T07:27:47.952Z</atom:updated>
            <content:encoded><![CDATA[<h3>前言｜蔚藍海岸的召喚：我們為什麼選擇尼斯？</h3><p>這趟旅行的起點，其實只是某天和朋友們閒聊時，隨口問了一句：「放假要不要去哪裡玩？」沒想到一聊成真，最後我們決定來一趟南法自駕之旅，而尼斯成了我們毫不猶豫的首選。</p><p>決定要去尼斯之後，有朋友推薦我去看 Netflix 上的日本戀愛實境節目《離線找真愛》。節目中多次出現尼斯的街景與海岸，那片蔚藍的海、悠閒的氛圍，和我們即將踏上的旅程不謀而合，也讓我對這座城市的期待更深了一層。</p><p>尼斯，是法國南部的一座海濱小城，節奏悠閒、氣氛輕柔，是個非常適合放鬆心情、親近海岸的地方。這裡被稱作「蔚藍海岸」（Côte d’Azur），一踏上這片土地你就會明白，這個名字一點都不誇張。</p><p>走過這一趟，我真心覺得：尼斯是一座會讓人愛上的城市。她有氣質，也有魅力，靜靜地等待著你來發現她的美好。</p><h3>行程總覽｜7 天尼斯與蔚藍海岸探索路線全覽</h3><blockquote><strong><em>Day 1｜抵達尼斯：取車後前往市區，展開旅程</em></strong><em><br> 從尼斯機場抵達後順利取車，沿著海岸駛入市區，入住民宿，為接下來幾天的探索做好準備。</em></blockquote><blockquote><strong><em>Day 2｜邊境雙城：Menton 的彩色街景與 Monaco 的奢華海港</em></strong><em><br> 一路東行，造訪義法邊境的陽光小鎮 Menton，午後前往摩納哥，感受王宮與賭場的華麗氣息。</em></blockquote><blockquote><strong><em>Day 3｜電影與香氣：坎城沙灘與 Grasse</em></strong> <strong><em>香水工廠</em></strong><em><br> 上午漫步坎城影展宮，午後轉往山上的 Grasse，深入香水工藝的發源地，感受南法另一種優雅。</em></blockquote><blockquote><strong><em>Day 4｜藝術與海港：山城 Saint-Paul-de-Vence 與 Antibes 老港</em></strong><em><br> 探索靜謐的藝術小鎮 Saint-Paul-de-Vence，午後移動至 Antibes，享受港邊老城的閒適午後。</em></blockquote><blockquote><strong><em>Day 5｜天空之城 Èze 與尼斯海岸線漫步</em></strong><em><br> 走訪鷲巢小鎮 Èze，俯瞰地中海壯闊景色，下午回到尼斯，沿著英國人散步道悠閒走一回。</em></blockquote><blockquote><strong><em>Day 6｜深入尼斯：城堡山、公園、市集與當代藝術</em></strong><em><br> 不再奔波，留在尼斯探索城市本身，從城堡山俯瞰海灣，到舊城巷弄與藝術館，感受城市靈魂。</em></blockquote><blockquote><strong><em>Day 7｜旅程的尾聲：明信片、紀念品與說再見的方式</em></strong><em><br> 整理行李、還車，帶著蔚藍海岸的記憶前往機場，為這趟南法之旅畫下句點。</em></blockquote><h3>旅行日誌｜尼斯與蔚藍海岸的七日漫遊記錄</h3><p><strong>Day 1：從陽光灑落的機場開始，故事就這樣啟程了</strong></p><p>一抵達尼斯機場，我們便前往租車地點。從第二航廈步行大約五分鐘，就能看見一棟集合了多家租車公司的大樓。辦理好租車手續後，接著進行基本的車況檢查，確認無誤後正式上路，也開始適應法國的道路環境。</p><p>法國和台灣一樣是左駕，駕駛邏輯相近，因此整體開起來不算困難，高速公路的收費站也可使用信用卡通行。不過比較讓人不習慣的，是部分停車場的通道以及市區某些街道相當狹窄，車輛的警示聲一路響個不停，開車時需要特別注意轉彎與會車。</p><p>放好行李後，我們在尼斯市區的一間餐廳會合，享用了此行第一餐正宗的法式料理。晚餐後，我們在夜色中漫步尼斯街頭，來到那個《離線找真愛》中經常出現的集合地點──太陽噴泉。這裡晚上人潮不多，夜景安靜而迷人。</p><p>走著走著，我們還發現了影集中常常作為轉場畫面的老城鐘樓。這座鐘樓在夜間燈光照映下格外有氛圍，和節目裡白天的樣子截然不同，也讓我們多了一份屬於「離線粉」的朝聖感。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QZVzUcEg_sEM3nR4NYEjJw.png" /><figcaption><strong>鐘樓</strong></figcaption></figure><p><strong>Day 2：在 Menton 沉醉陽光，在 Monaco 觸碰奢華</strong></p><p>Menton 是一座以檸檬聞名的陽光小鎮，映入眼簾的是一棟棟溫暖的橘黃色建築，讓人一踏進就忍不住放慢腳步。鎮上最經典的拍照景點非 <strong>Escaliers </strong>莫屬，從下往上拍，一層層橘黃相間的階梯與建築交織成一幅溫柔的地中海畫作，許多旅人都會在這裡停下來欣賞。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MTas1MjmXQVIwmTP_fo7qg.png" /><figcaption><strong>Escaliers</strong></figcaption></figure><p>另一側則是蔚藍海岸與醒目的 <strong>MENTON 地標大字</strong>，從海邊往上望去，地標與後方的色彩建築構成了另一種視覺美感。小鎮裡四處可見檸檬主題的商品，我們也試喝了當地特產檸檬酒。酒體偏甜，單喝略膩，但若搭配氣泡水或冰塊，會變得清爽許多。這裡的檸檬特別大顆、果香濃郁，大概是因為南法陽光實在太充足了吧。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s-tZUUsyZENRwfLCJdHizA.png" /><figcaption><strong>MENTON 地標</strong></figcaption></figure><p>Menton 靠近義大利邊界，我們順道開車到邊境拍照，短短一天之內便踏足法國、義大利與摩納哥三個國家，別具紀念意義。</p><p>午後我們前往摩納哥。那時正逢當地準備舉辦 F1 一級方程式賽車，街道上已經開始架設賽道設施，看得我們熱血沸騰。我駕車體驗了傳說中的 <strong>髮夾彎</strong>，雖然不能超速，但那幾個連續轉彎的路段，依然讓人印象深刻。</p><p>接著我們來到知名的 <strong>Casino Square</strong>，由於進入賭場需要額外門票，因此我們並未進入。不過在廣場外就已經夠精彩，停滿了紅色法拉利、銀色勞斯萊斯與藍寶堅尼，成為大家的打卡聖地。</p><p>回到民宿後，我們迎來這天的豐富大餐 <strong>BBQ 烤肉</strong>。因為民宿設有烤肉爐，我們準備了牛排、羊排和當地新鮮蔬果，一邊料理一邊聊天，再配上一點白天在 Menton 買的檸檬酒，這頓晚餐不只美味，更是旅行中最快樂的片段之一。</p><p><strong>Day 3｜從紅毯到花田：坎城的海風與 Grasse 的香氣</strong></p><p>這天的天氣變化劇烈，就像給我們的行程設下一點小考驗。我們開車前往坎城，途中卻下起傾盆大雨，雨勢猛烈到一度看不清前方的車輛，開車視線模糊，讓人感到不安。</p><p>抵達坎城後，天氣逐漸放晴，我們找了一家餐廳坐下來享用午餐。這一餐再次讓我對法國料理留下好印象，尤其是松露義大利麵，濃郁的香氣與滑順的口感實在太迷人，非常值得推薦。</p><p>剛好這天碰上坎城影展，街道上比平常熱鬧許多。我們先逛了幾家紀念品店，也想碰碰運氣，看能不能在紅毯附近見到明星。聽說當天 Scarlett Johansson 有出席，但紅毯區被柵欄圍住，加上人潮擁擠，視線難以穿透，大多數人只能隔著距離感受現場氛圍。我們待了一會兒後便提早離開，準備前往 Grasse。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7i5qrfaMcqPhqUl423WXWQ.png" /><figcaption><strong>坎城影展</strong></figcaption></figure><p>Grasse 是以香水聞名的山城，也是《離線找真愛》中曾出現的場景之一。這次的行程中，我特別期待參加香水工坊的調香體驗。每位參加者的座位前擺滿了各種原料，種類將近一百種，從前調、中調到基調依序試聞與挑選，最後由專業的調香師協助配比，完成一瓶專屬香氛。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*03Kq5ccOvGuDzXpqSKhqbw.png" /><figcaption><strong>香水體驗</strong></figcaption></figure><p>調香過程非常有趣，但聞到後來嗅覺會有些疲乏。調香師建議我們可以先聞聞自己的手腕，讓鼻子稍微「重置」後再繼續挑選。原料種類繁多，選擇過程對有選擇障礙的人來說可能會有點困難，不過對我而言，這反而讓整個體驗更有記憶點。</p><p>體驗的最後一步，是幫自己調製出的香水命名。看著眼前這瓶專屬於我的香氣，我又陷入選擇障礙，糾結了好一會兒。不知道該取一個浪漫的名字、帶點法文氣息的名字，還是乾脆取一個只有我懂的小暗號。這個簡單的步驟，卻讓我覺得特別有意義。畢竟，這瓶香水不只是味道的組合，更是這段旅程的記憶濃縮。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0kjKqDqlCFu-YtVoEnEf_g.png" /><figcaption><strong>Brise Calme 寧靜的微風</strong></figcaption></figure><p>這個行程很適合親子或情侶一起參加，一邊試香一邊交換彼此的感想，也能更認識對方的喜好。在體驗的同時，我們還意外碰上日本電視節目來拍攝調香過程，原以為是在錄製《離線找真愛》第二季，後來才知道是採訪這項體驗活動，看來這部節目確實帶動了不少人對製作香水的興趣。</p><p><strong>Day 4｜從藝術小鎮到濱海古港，一日感受南法的靜與動</strong></p><p>走進 Saint-Paul-de-Vence 彷彿穿越時光，這座中世紀山城保留著古老石牆與蜿蜒小徑，小鎮的每間小屋裡藏著畫廊、雕塑、裝置藝術，就像一座靜靜展開的迷你藝術博物館。雖然這裡被譽為南法最具藝術氣息的小鎮，但對我來說，氛圍是文靜的、內斂的，也許是太過平靜，以致我沒有留下太深刻的記憶點。不過如果喜歡靜靜看畫、走巷弄、欣賞石造建築的人，應該會很喜歡這裡。</p><p>午後，我們開車前往 Antibes，氣氛立刻轉換。一抵達海邊，眼前展開的是一片悠閒風景，沙灘上許多人正享受著南法特有的日光浴，有人攤在毛巾上睡午覺，有人拿著書，還有人跳入海中乘涼，整個城市都在呼吸。</p><p>我們沿著海邊走到 Antibes 的著名地標 — — <strong>白色巨人</strong>。這座雕塑是一位坐著的白色空心人，面朝大海而坐，遠看像在思考，又像守護著這座港口。這個場景讓我聯想到《進擊的巨人》中艾倫第一次見到大海時的情節，那一幕突然在腦海中閃過，莫名產生了一種現實與虛構交錯的趣味感。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kTRsPefmM25p1yLqoxWV2Q.png" /><figcaption><strong>白色巨人</strong></figcaption></figure><p>在 Antibes，我們沒有安排太多行程，只是靜靜地走、坐下、吹風，看海。比起山城的靜謐，這裡的放鬆是真正能讓人放空的。旅行不是每一刻都需要景點，有時候，什麼都不做反而是最美好的安排。</p><p><strong>Day 5｜從雲端眺望到浪花邊走路，走過南法最動人的一線天</strong></p><p>Èze 是一座坐落在山中的小鎮，那天我們買票進入鎮上的植物園。說是植物園，但我想不少旅客和我一樣，重點其實不是植物，而是為了登上高處欣賞整座山城與地中海交織而成的壯麗景色。站在最高處往外望，紅瓦屋頂延伸到山崖邊，再向外就是一片深藍，視野開闊得讓人屏息。</p><p>午後我們回到尼斯，天氣好得幾乎像幅畫。這一帶白天拍照特別出色，尤其推薦馬塞納廣場一帶的街景。紅磚與黃綠交錯的建築在蔚藍天光下顯得鮮明耀眼，完美呈現出尼斯獨有的地中海色彩美學。隨手一拍都是風景明信片，走在這樣的街道上，腳步也不自覺慢了下來。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rdvj_Efd_swojKfHYUgCaQ.png" /><figcaption><strong>馬塞納廣場</strong></figcaption></figure><p>途中經過《離線找真愛》中劇中成員交換書信的地點──<strong>Maison Margaux</strong>。親眼看到熟悉的場景，讓我莫名地興奮，好像自己也成了節目的一份子，穿梭在他們曾走過的街角巷弄裡。</p><p>有點好笑的是，我模仿 Netflix 劇組的運鏡方式，拍下自己經過 Maison Margaux 的畫面，彷彿真的是節目的新一集成員。那一刻雖然只是短暫經過，卻有種說不出的雀躍與沉浸感 !</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NcUrhYhkzJqNILdbBjNcKA.png" /><figcaption><strong>MAISON MARGAUX</strong></figcaption></figure><p>接著我們前往蔚藍海岸。頭頂的天空時不時有飛機劃過，而眼前的海洋藍得令人難以置信，像水晶般澄澈透亮，陽光灑在海面上，閃爍出一片片銀白的光點。</p><p>我們隨意找了個角落坐下，躺在沙灘上曬太陽，吹著海風，踏著浪，還玩起丟石頭的小遊戲，像孩子一樣無憂無慮。那一刻，好像回到了某個純真、簡單的時光，只需要陽光、海浪和笑聲就能感到滿足。</p><p>在這裡可以慵懶待上一整個下午，什麼都不做，只是靜靜感受海的藍、海的聲音，和心裡那份終於放鬆下來的自由。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CvraqoSv-vcP3z2M7vpXGA.png" /><figcaption><strong>蔚藍海岸</strong></figcaption></figure><p><strong>Day 6｜從山頂風景到街頭市集，感受尼斯的慢生活</strong></p><p>這一天，我繼續在尼斯的巷弄間尋找那些熟悉的場景。走著走著，來到了影集中成員曾相遇的那座教堂。教堂靜靜地佇立在街角，我停下腳步，享受這座歐洲教堂特有的莊嚴與寧靜，也感受到當時節目中情緒的延伸。</p><p>接著我前往城堡山公園，這裡也是影集中成員常集合的場景。第一站是 <strong>Bellanda Tower</strong>，站在高台上，可以將整個尼斯海岸線盡收眼底。若還有體力，不妨再往上走一段，抵達城堡山公園的至高處，從這裡能更清楚地眺望整座城市：舊城與新區交錯相連，一旁則是無盡的蔚藍海岸，景色壯麗。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ifWNWHsYgIeAu_k9dQ5YVA.png" /><figcaption><strong>從城堡山公園拍攝</strong></figcaption></figure><p>山上還藏有一座小瀑布，若是天氣炎熱，不妨靠近感受一下水氣帶來的涼意，是個既意外又剛好的小驚喜。當然，也不能錯過山下的 <strong>NICE 彩色地標</strong>。不過有趣的是，這次看到的顏色跟影集裡的版本不太一樣，看來這個地標會定期重新設計上色，讓每次造訪的旅人都能拍出獨一無二的回憶。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WKIrhXRTMa9HmV8g2_t2lQ.png" /><figcaption><strong>I LOVE NICE</strong></figcaption></figure><p>這條散步路線最終會連接到著名的 <strong>英國人散步大道</strong>，沿著海岸慢慢走，看著碧藍海景與路旁盛開的花朵，真的會讓人忘記時間。走累了也別忘了找間餐廳坐下，來杯葡萄酒、配上一道法式佳餚，在這樣的風景與節奏中，任何一餐都顯得特別美味。</p><p><strong>Day 7｜風景留在眼裡，故事留在心裡</strong></p><p>旅行的最後一天，我和朋友們一同前往影集中出現過的那間香料店。牆上的電視正播放著節目的片段，讓人瞬間進入熟悉的場景。店內的香料種類豐富，氣味各具特色，老闆非常熱情，細心地向我們介紹每一款的用途與搭配方式。我挑了兩種自己特別喜歡的味道，其中一種是印象深刻的是松露香料，光是聞起來就讓人食指大動，回家後可以灑在料理上增添風味。我們也開心地告訴店員，自己是因為影集才特地來朝聖的，他們聽了也非常開心。</p><p>在這幾天的旅行裡，和朋友們一起下廚成了每天最期待的小事。法國的食材新鮮又美味，超大的法國超市讓我們總是逛得不亦樂乎。我們煮了許多好吃的料理，包括香煎鴨胸、橄欖油蒜炒小捲、義大利餃和鮭魚生菜沙拉還有搭配 1664 啤酒，每一餐都像在開小型晚宴。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cHZa7osUcBN0wsYCT915qA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BOjYOIQRGG2oiyfjgcc4Cg.png" /><figcaption><strong>法式鴨胸、鮪魚沙拉、義大利餃、烘蛋</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*owVXYjuDgTarmBjnbXlryQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*atjv2CvoDHx5919k0oS7pA.png" /><figcaption><strong>鮪魚沙拉、蒜頭雞湯、烤雞、蒜頭炒小捲、甜點、啤酒</strong></figcaption></figure><p>到機場之前，我們為自己挑了幾張明信片，寫下這幾天的回憶與祝福，投進郵筒，寄給未來的自己，也寄給還沒來過這裡的朋友。或許有一天，他們也會跟我們一樣，在尼斯的海風裡寫下屬於自己的故事。</p><h3>後記｜旅行結束，風景還在心裡繼續蔓延</h3><p>其實在看完《離線找真愛》之後，心裡對尼斯便多了一層濾鏡。那張椅子，是某位成員曾哭泣過的地方；太陽噴泉，是大家經常集合的場景；而馬格之家，則承載著他們寫下心聲與等待回覆的每一次心跳。</p><p>走進那些畫面裡，對這些景點早已不陌生，反而多了一種悸動感。有時候像是在追星，當親眼發現那個轉角、那面牆、那個門口真的存在於現實中，心中總會浮現一種安靜卻難以言喻的感動。</p><p>當然，除了節目的濾鏡之外，尼斯本身就已經足夠動人。蔚藍海岸的美，遠遠超出想像。海面在陽光下閃爍著銀色波光，空氣裡是自在、緩慢的節奏，走在岸邊，真的會讓人不自覺愛上海洋。</p><p>這趟旅程也吃了好多美食，從法式料理到朋友親手下廚的每一道菜，都是屬於我們的味覺回憶。而最讓我感動的，是同行的每一位朋友，互相幫忙、一起計畫、一起笑、一起迷路，也一起說「這裡真美」。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AqzIovcputfgvV97wRjing.png" /><figcaption><strong>太陽噴泉</strong></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e56814226ee5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Leetcode 714. Best Time to Buy and Sell Stock with Transaction Fee]]></title>
            <link>https://medium.com/@erikho_51835/leetcode-714-best-time-to-buy-and-sell-stock-with-transaction-fee-a87723824e4d?source=rss-5ca17b15cef9------2</link>
            <guid isPermaLink="false">https://medium.com/p/a87723824e4d</guid>
            <dc:creator><![CDATA[Erik Ho]]></dc:creator>
            <pubDate>Sun, 23 Feb 2025 16:16:15 GMT</pubDate>
            <atom:updated>2025-02-23T16:17:36.327Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ecJuozGIXU-xxMLaiFJlGA.jpeg" /><figcaption>Stock</figcaption></figure><p><a href="https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/">Leetcode Link</a></p><h3>Concept</h3><p>Every day, we have two choices: either <strong>hold a stock</strong> or <strong>sell a stock</strong>.</p><ul><li><strong>Holding a stock</strong> means we either bought it on a previous day or purchased it today.</li><li><strong>Selling a stock</strong> means we either still have cash from previous transactions or we sold a stock today.</li></ul><p>To solve this problem efficiently, we can use <strong>dynamic programming</strong>.</p><h3>Understanding the Problem</h3><p>Given an array prices where prices[i] represents the stock price on the ith day, and an integer fee representing the transaction fee, our goal is to determine the maximum profit achievable through multiple transactions while ensuring that we pay the fee each time we sell a stock.</p><pre>prices = [1,3,2,8,4,9], fee = 2</pre><h3>Initial Approach</h3><p>At first, we might attempt to define dp[i] as follows:</p><ul><li><strong>Buying a stock:</strong> dp[i] = dp[i-1] - prices[i]</li><li><strong>Selling a stock:</strong> dp[i] = dp[i-1] + prices[i] - fee</li><li><strong>Doing nothing:</strong> dp[i] = dp[i-1]</li></ul><p>However, this approach is incorrect because in order to sell a stock, we must have previously purchased and held it. This means we need to track two separate states:</p><ol><li><strong>hold[i]</strong> – The maximum profit when <strong>holding a stock</strong> on day i</li><li><strong>cash[i]</strong> – The maximum profit when <strong>not holding any stock</strong> (i.e., holding cash) on day i</li></ol><h3>State Transition Equations</h3><p>Since we can either <strong>continue holding</strong> or <strong>buy a new stock</strong>, the state transitions are as follows:</p><ul><li><strong>Buying a stock:</strong><br>hold[i] = max(hold[i-1], cash[i-1] - prices[i])<br>(Either we continue holding from the previous day, or we buy a new stock using available cash.)</li><li><strong>Selling a stock:</strong><br>cash[i] = max(cash[i-1], hold[i-1] + prices[i] - fee)<br>(Either we keep the cash from yesterday, or we sell the stock we were holding and gain profit minus the transaction fee.)</li><li><strong>Doing nothing:</strong></li></ul><blockquote>hold[i] = hold[i-1] (If we don&#39;t buy today, our hold value remains the same.)</blockquote><blockquote>cash[i] = cash[i-1] (If we don&#39;t sell today, our cash remains the same.)</blockquote><h3>Implementation</h3><p>We create two arrays, hold and cash, to store the values for each state over n days:</p><pre>class Solution {<br>    public int maxProfit(int[] prices, int fee) {<br>        int n = prices.length;<br>        int [] hold = new int[n];<br>        int [] cash = new int[n];<br><br>        hold[0] = -prices[0];<br>        cash[0] = 0;<br><br>        for (int i = 1; i &lt; n; i++) {<br>            hold[i] = Math.max(hold[i-1], cash[i-1] - prices[i]);<br>            cash[i] = Math.max(cash[i-1], hold[i-1] + prices[i] - fee);<br>        }<br>        return cash[n-1];<br>        <br>    }<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a87723824e4d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Leetcode 216. Combination Sum III]]></title>
            <link>https://medium.com/@erikho_51835/leetcode-216-combination-sum-iii-d4837e6c4c64?source=rss-5ca17b15cef9------2</link>
            <guid isPermaLink="false">https://medium.com/p/d4837e6c4c64</guid>
            <dc:creator><![CDATA[Erik Ho]]></dc:creator>
            <pubDate>Wed, 05 Feb 2025 23:58:49 GMT</pubDate>
            <atom:updated>2025-02-06T00:00:46.667Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BxmbKZzS-r_uf2bzLu0xqw.jpeg" /></figure><p><a href="https://leetcode.com/problems/combination-sum-iii"><strong>Leetcode Link</strong></a></p><h3><strong>Analysis</strong></h3><p>If we start with k=3 and n=9, we need to find all possible combinations of three distinct numbers from 1 to 9 that sum up to 9.</p><p>For example, the valid combinations are:</p><p>- [1, 2, 6] → sum = 9 ✅</p><p>- [1, 3, 5] → sum = 9 ✅</p><p>- [2, 3, 4] → sum = 9 ✅</p><p>This problem is similar to the <a href="https://leetcode.com/problems/subsets/description/"><strong>subsets problem</strong></a>, where we explore different combinations by picking each number one at a time. The key difference is that we need to ensure the selected numbers add up to a specific target sum.</p><h3><strong>How do we solve it?</strong></h3><p>We use <strong>backtracking</strong>!</p><h3><strong>Pseudocode</strong></h3><pre>let combinations = List&lt;List&lt;Integer&gt;&gt;;<br><br>backtracking(int num, List&lt;Integer&gt; current, int k, int n, int sum) {<br>    if sum &gt; n return;<br>    if current.size &gt; k return;<br>    if sum == n and current.size == k {<br>        combinations.add(current);<br>        return;<br>    }<br>    for (i = num; i &lt;= 9; i++) {<br>        current.add(i);<br>        backtracking(i + 1, current, k, n, sum + i);<br>        current.pop();<br>    }<br>    }<br>call backtracking(1, [], k, n, 0);</pre><h3><strong>Explanation</strong></h3><p>- We recursively explore all possible combinations starting from `num = 1`.</p><p>- If the sum exceeds `n` or the size exceeds `k`, we stop early (pruning).</p><p>- If we find a valid combination where the sum equals `n` and the size equals `k`, we add it to our results.</p><p>- We use a loop to try all numbers from `num` to `9`, ensuring that each number appears only once in a combination.</p><p>- After each recursive call, we <strong>**backtrack**</strong> by removing the last added number to explore other possibilities.</p><p>This approach efficiently finds all valid combinations while avoiding unnecessary calculations.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d4837e6c4c64" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Leetcode 735. Asteroid Collision]]></title>
            <link>https://medium.com/@erikho_51835/leetcode-735-asteroid-collision-d8eaaf11a2fd?source=rss-5ca17b15cef9------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8eaaf11a2fd</guid>
            <dc:creator><![CDATA[Erik Ho]]></dc:creator>
            <pubDate>Tue, 21 Jan 2025 10:40:40 GMT</pubDate>
            <atom:updated>2025-01-21T10:41:37.472Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W24X_mzLuzemCp8Kvmoh0w.jpeg" /></figure><p><a href="https://leetcode.com/problems/asteroid-collision">Leetcode Link</a></p><p>We can use a <strong>stack</strong> to solve this problem.</p><p>From the problem description, the planets move at the same speed, so we only need to consider their direction and size.</p><p>Whether two planets will collide and the result of the collision can be divided into three cases:</p><p>1. asteroids = [5, 10] or asteroids = [-5, -10]</p><p>- Both planets move in the same direction, so no collision occurs.</p><p>2. asteroids = [-5, 10]</p><p>- The two planets move in different directions but will not collide.</p><p>3. asteroids = [5, -10]</p><p>- The two planets move in opposite directions and will collide.</p><p>Collisions can be further divided into two outcomes:</p><p>1. <strong>Different sizes: </strong>The larger planet will remain.</p><p>Example: asteroids = [5, -10] → asteroids = [-10]</p><p>2. <strong>Same size:</strong> Both planets will disappear.</p><p>Example: asteroids = [8, -8] → asteroids = []</p><p>Thus, we only need to focus on cases where “two planets move in opposite directions and collide.”</p><p>We iterate through each planet, add it to the stack, and use the stack to determine whether the planet should remain or be removed based on the conditions above.</p><p>Here’s the solution in Python:</p><pre>class Solution(object):<br>    def asteroidCollision(self, asteroids):<br>        &quot;&quot;&quot;<br>        :type asteroids: List[int]<br>        :rtype: List[int]<br>        &quot;&quot;&quot;<br>        stack = []<br>        for star in asteroids:<br>            while stack and star &lt; 0 and stack[-1] &gt; 0:<br>                if abs(star) &gt; abs(stack[-1]):<br>                    stack.pop()<br>                    continue<br>                elif abs(star) == abs(stack[-1]):<br>                    stack.pop()<br>                break<br>            else:<br>                stack.append(star)<br>        return stack</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8eaaf11a2fd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bitbucket Pipelines 持續部署]]></title>
            <link>https://medium.com/@erikho_51835/bitbucket-pipelines-%E6%8C%81%E7%BA%8C%E9%83%A8%E7%BD%B2-4186b0518b2a?source=rss-5ca17b15cef9------2</link>
            <guid isPermaLink="false">https://medium.com/p/4186b0518b2a</guid>
            <category><![CDATA[bitbucket-pipelines]]></category>
            <category><![CDATA[continuous-deployment]]></category>
            <dc:creator><![CDATA[Erik Ho]]></dc:creator>
            <pubDate>Sun, 15 Sep 2024 22:02:51 GMT</pubDate>
            <atom:updated>2024-10-27T10:39:43.335Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9RxZZj3Eut_r2ISPG6f34w.jpeg" /></figure><h3>引言</h3><p>由於公司內部使用 Bitbucket 進行程式碼管理，過去的版本更新流程需要每個帳號手動到伺服器進行操作，這導致了資料夾權限的混亂，有時甚至會出現權限不足（permission denied）的問題。本文將分享如何透過 Bitbucket Pipelines CICD 方案，實現自動化部署腳本，以簡化 DevOps 流程並解決這些權限相關的問題。</p><h3>建立專屬的部署帳號</h3><ol><li>Server User 帳號設置：設定一個專屬帳號：專門給部署使用，這邊帳號名稱為 <em>bitbucket</em>。</li><li>調整 repo 的權限：讓該帳號有權限可以修改專案的檔案，大部分都需要調整成 <em>bitbucket</em>。 以需要進入 git 管理為原則，建議一個檔案一個指令調整，避免有錯。<br>不需要進 git 的檔案或資料夾，像是 log 或是 image 可留原本權限。(log 資料夾必須為 nginx 因為我們使用的 php 是用 nginx 權限執行，才能寫入 log 檔案)</li></ol><pre># 此為 root 帳號下 <br>## 設定帳密 <br>sudo useradd bitbucket <br>sudo passwd<br><br># 把要自動部署的專案資料夾下的 檔案/資料夾 指定權限給 bitbucket:bitbucket <br>## group 就一樣用 bitbucket <br>sudo chown bitbucket:bitbucket [檔案] <br>## -R 代表旗下的都會一起改，要注意 <br>sudo chown -R bitbucket:bitbucket [資料夾] <br><br># 注意： 要用 ls -al 看隱藏檔案(.git/ 跟 .gitignore 也需要設定) <br># .git 是資料夾，整個資料夾也需要遞迴指定權限所有人</pre><p>3. Pulling 權限：由於需要 git pull 權限，因此還必須在這台機器加上 ssh key 並丟到 bitbucket 設置。</p><pre>#在bitbucket 的帳號執行 (在哪個路徑位置下都可以)<br>ssh-keygen</pre><p>並將 id_rsa.pub 公鑰複製貼到 <em>Repository Settings</em> <em>→ Access Keys</em> <em>→ Add Key</em></p><p>可以進行以下指令測試</p><pre>ssh -T git@bitbucket.org</pre><p>接著應該會看到類似的回覆</p><blockquote>authenticated via a deploy key.<br>You can use git to connect to Bitbucket. Shell access is disabled.<br>This deploy key has read access to the following repositories:<br>accountName/repositoryName</blockquote><h3>Bitbucket Pipeline 連線設定</h3><h4><strong>防火牆</strong></h4><p>由於 Bitbucket Pipeline 是使用 Bitbucket 的雲平台進行連線到我們的 Server，因此我們要開放權限給雲平台連線。以下說明我比較熟悉在 Linux 設定防火牆的兩種方法：</p><ol><li>vi /etc/ssh/sshd_config 調整設定，加上白名單，讓 bitbucket 帳號可以從這些 IP 連進機器</li></ol><pre>AllowUsers bitbucket@34.199.54.113 bitbucket@34.232.25.90 bitbucket@34.232.119.183 bitbucket@34.236.25.177 bitbucket@35.171.175.212 bitbucket@52.54.90.98 bitbucket@52.202.195.162 bitbucket@52.203.14.55 bitbucket@52.204.96.37 bitbucket@34.218.156.209 bitbucket@34.218.168.212 bitbucket@52.41.219.63 bitbucket@35.155.178.254 bitbucket@35.160.177.10 bitbucket@34.216.18.129 bitbucket@3.216.235.48 bitbucket@34.231.96.243 bitbucket@44.199.3.254 bitbucket@174.129.205.191 bitbucket@44.199.127.226 bitbucket@44.199.45.64 bitbucket@3.221.151.112 bitbucket@52.205.184.192</pre><p>2. iptables 或是 ufw，可以參考我之前寫的<a href="https://medium.com/@erikho_51835/linux-%E5%BB%BA%E7%AB%8B%E9%98%B2%E7%81%AB%E7%89%86%E7%9A%84%E5%85%A9%E7%A8%AE%E6%96%B9%E5%BC%8F-bc1b98338aac">文章</a></p><pre>sudo iptables -A INPUT -p tcp -s 34.199.54.113/32 --dport 22 -j ACCEPT<br>sudo iptables -A INPUT -p tcp -s 34.232.25.90/32 --dport 22 -j ACCEPT<br>sudo iptables -A INPUT -p tcp -s 34.232.119.183/32 --dport 22 -j ACCEPT<br>sudo iptables -A INPUT -p tcp -s 34.236.25.177/32 --dport 22 -j ACCEPT<br>sudo iptables -A INPUT -p tcp -s 35.171.175.212/32 --dport 22 -j ACCEPT<br>sudo iptables -A INPUT -p tcp -s 52.54.90.98/32 --dport 22 -j ACCEPT<br>sudo iptables -A INPUT -p tcp -s 52.202.195.162/32 --dport 22 -j ACCEPT<br>sudo iptables -A INPUT -p tcp -s 52.203.14.55/32 --dport 22 -j ACCEPT<br>sudo iptables -A INPUT -p tcp -s 52.204.96.37/32 --dport 22 -j ACCEPT<br>sudo iptables -A INPUT -p tcp -s 34.218.156.209/32 --dport 22 -j ACCEPT<br>sudo iptables -A INPUT -p tcp -s 34.218.168.212/32 --dport 22 -j ACCEPT<br>sudo iptables -A INPUT -p tcp -s 52.41.219.63/32 --dport 22 -j ACCEPT<br>sudo iptables -A INPUT -p tcp -s 35.155.178.254/32 --dport 22 -j ACCEPT<br>sudo iptables -A INPUT -p tcp -s 35.160.177.10/32 --dport 22 -j ACCEPT<br>sudo iptables -A INPUT -p tcp -s 34.216.18.129/32 --dport 22 -j ACCEPT<br>sudo iptables -A INPUT -p tcp -s 3.216.235.48/32 --dport 22 -j ACCEPT<br>sudo iptables -A INPUT -p tcp -s 34.231.96.243/32 --dport 22 -j ACCEPT<br>sudo iptables -A INPUT -p tcp -s 44.199.3.254/32 --dport 22 -j ACCEPT<br>sudo iptables -A INPUT -p tcp -s 174.129.205.191/32 --dport 22 -j ACCEPT<br>sudo iptables -A INPUT -p tcp -s 44.199.127.226/32 --dport 22 -j ACCEPT<br>sudo iptables -A INPUT -p tcp -s 44.199.45.64/32 --dport 22 -j ACCEPT<br>sudo iptables -A INPUT -p tcp -s 3.221.151.112/32 --dport 22 -j ACCEPT<br>sudo iptables -A INPUT -p tcp -s 52.205.184.192/32 --dport 22 -j ACCEPT<br>sudo iptables -A INPUT -p tcp -s 52.72.137.240/32 --dport 22 -j ACCEPT</pre><p>Bitbucket Pipeline IP 請參考這篇 <a href="https://support.atlassian.com/bitbucket-cloud/docs/what-are-the-bitbucket-cloud-ip-addresses-i-should-use-to-configure-my-corporate-firewall/#Atlassian-IP-ranges">Valid IP addresses for Bitbucket Pipelines build environments</a></p><h4>部署權限</h4><p><em>持續部署(英語：Continuous deployment，縮寫為 CD)</em>，Bitbucket 雲平台登入我們的 Server 的時候需要驗證，這時候可以設定 SSH keys。<br>請點選到 <em>Repository Settings &gt;&gt; SSH keys</em></p><ol><li>依照指示將 public key 複製到 ~/.ssh/authorized_keys</li><li>接著設定 Known Hosts</li><li>調整權限：若有遇到以下錯誤，可以嘗試將權限做調整</li></ol><pre>ssh_askpass: exec(/usr/bin/ssh-askpass): No such file or directory<br>Permission denied, please try again.<br>ssh_askpass: exec(/usr/bin/ssh-askpass): No such file or directory<br>Permission denied, please try again.<br>ssh_askpass: exec(/usr/bin/ssh-askpass): No such file or directory<br>Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).</pre><pre>chmod 700 ~/.ssh<br>chmod 600 ~/.ssh/authorized_keys</pre><h3>Bitbucket Pipeline 環境參數</h3><p>設定環境參數可以避免機密資料露出在 pipeline.yaml。</p><ol><li>確認是否有開啟 pipeline 功能：（其實預設應該會打開）<br><em>專案資料夾 → Repository settings → Settings (左側選單)</em></li><li>設定環境參數：<br><em>專案資料夾 → Repository settings → Depolyments -&gt; </em>點右上角的設置 <em>→ </em>設定 USER, SERVER, SSH_KEY。請搭配下方的 pipeline.yaml<br>(1) USER：bitbucket<br>(2) SERVER：專案主機IP</li><li>pipeline.yaml</li></ol><pre>definitions:<br>  steps:<br>    - step: &amp;hello-world<br>       name: hello world<br>       script:<br>        - echo &quot;Hello World&quot;<br><br>    - step: &amp;build<br>        name: Build Testing<br>        caches:<br>          - composer<br>        script:<br>          - cd ./public_html<br>          - composer update --no-progress --with-all-dependencies<br>        artifacts:<br>          - public_html/vendor/**<br><br>    - step: &amp;unit-test<br>        name: Unit Testing<br>        caches:<br>          - composer<br>        script:<br>          - cd ./public_html<br>          - ./vendor/bin/phpunit --configuration ./phpunit.xml<br>        artifacts:<br>          - public_html/vendor/**<br><br>    - step: &amp;lint-check<br>        name: Lint Check<br>        caches:<br>          - composer<br>        script:<br>          - ./public_html/vendor/bin/phplint --exclude=vendor<br>        artifacts:<br>          - public_html/vendor/**<br><br>    - step: &amp;deploy-to-test<br>        name: Deploy to Dev<br>        deployment: test<br>        script:<br>          - echo &quot;Deploying to test environment...&quot;<br>          - ssh $USER@$SERVER &#39;cd YOUR_PATH &amp;&amp; git pull&#39;<br><br>    - step: &amp;deploy-to-prod<br>        name: Deploy to Prod<br>        deployment: production<br>        script:<br>          - echo &quot;Deploying to production environment...&quot;<br>          - ssh $USER@$SERVER &#39;cd YOUR_PATH &amp;&amp; git pull&#39;<br><br>pipelines:<br>  branches:<br>    develop:<br>      - step: *hello-world<br>      - step:<br>          &lt;&lt;: *deploy-to-test<br>          deployment: test<br>          trigger: manual<br><br>    master:<br>      - step: *hello-world<br>      - step:<br>          &lt;&lt;: *deploy-to-prod<br>          deployment: production<br>          trigger: manual</pre><p>接著設定完畢就可以嘗試在 Bitbucket 做持續部署，就不用每次都登入機器更新版本。我認為有諸多好處，可以利用機器做部署減少人為登入機器(減少大量登入的時間)，並且前面可以加上<em>持續整合(英語：Continuous integration，縮寫CI)</em>，先進行單元測試等等檢查讓程式碼品質更穩健。</p><h3>參考資料</h3><ol><li><a href="https://dev.to/manuelbosi/bitbucket-pipelines-configure-ssh-keys-1l56">https://dev.to/manuelbosi/bitbucket-pipelines-configure-ssh-keys-1l56</a></li><li><a href="https://support.atlassian.com/bitbucket-cloud/docs/what-are-the-bitbucket-cloud-ip-addresses-i-should-use-to-configure-my-corporate-firewall/#Atlassian-IP-ranges">https://support.atlassian.com/bitbucket-cloud/docs/what-are-the-bitbucket-cloud-ip-addresses-i-should-use-to-configure-my-corporate-firewall/#Atlassian-IP-ranges</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4186b0518b2a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cloud Summit 2024 參展心得]]></title>
            <link>https://medium.com/@erikho_51835/cloud-summit-2024-%E5%8F%83%E5%B1%95%E5%BF%83%E5%BE%97-9152a93c285a?source=rss-5ca17b15cef9------2</link>
            <guid isPermaLink="false">https://medium.com/p/9152a93c285a</guid>
            <dc:creator><![CDATA[Erik Ho]]></dc:creator>
            <pubDate>Sat, 06 Jul 2024 04:38:50 GMT</pubDate>
            <atom:updated>2024-07-06T06:19:54.574Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pz_2DrGKv4cEr27BV4DVKg.jpeg" /><figcaption>Cloud Summit 2024 臺灣雲端大會</figcaption></figure><h3>綜觀</h3><p>第一次參與 Cloud Summit ，對於我來說，可以了解更多有關雲端的知識。我相當開心這個產業有許多新鮮的工具或技術，可以化簡為繁，持續地推通臺灣軟體業的實力。</p><p>當然，這場也有講者提到 Cloud 的雙面刃，有好有壞。在這個 AI 的時代，技術迭代如此迅速，但不變的原則依舊是我們要保持學習的動能並擁抱新科技的產生。</p><h3>各式各樣的攤商</h3><p>這次的攤位數量，對比我前幾個月參加的 SRE Conference，真的是小巫見大巫，數量應該有 40 + 以上。我認為是好事，一來可以讓大家更認識雲端有哪些新技術、開拓自己的視野，二來或許可以將技術導入在未來的工作環境並了解最新的技術。最後對大家來說更重要的是，這次攤商給的戰利品有夠多，我認為最好的是拿到萬國轉接頭 (需要擲兩顆骰子擲到兩面紅色，機率大概是 1/9 )。</p><p>還有一個攤商直接給我手機支架和刷卡，連填資料都不用 (廠商：趕快發回趕快回家?)</p><p>當時一進去就是先跑 40 個攤位刷卡，為了下午拿一件粉紅 t-shirt (笑)。廠商也都很主動地伸出刷卡機直接刷，不過有些廠商要你賣個資一下換取刷卡XD。</p><h3>演講心得</h3><h4><a href="https://cloudsummit.ithome.com.tw/2024/session-page/2611">淺談 Cloud Native 生態系下工程師逐漸喪失的那些技能</a></h4><p>本次演講最推薦的主題是<strong>「淺談 Cloud Native 生態系下工程師逐漸喪失的那些技能」</strong>，詳細可參考講者的投影片<a href="https://speakerdeck.com/hwchiu/exploring-the-gradually-lost-technical-skills-in-the-cloud-native-era">連結</a>，這邊我想分享個人的反思。</p><p>聽完講者的分享，不經意反思，技術的迭代是科技文明進步的必然結果，但是我們是否在當中會失去一位開發者必要的技能呢？</p><p>目前是 Cloud 蓬勃發展、K8S 太方便，很容易部署一個複雜的服務，這是好處，但也是壞事，如講者所說是一個雙面刃。往往是沒問題很好，但發生問題往往是我們沒辦法解決 (yaml 往往會把一些細節隱藏起來)，講者 diss 大家是不是都是 yaml 工程師。我認為在現在 Cloud 這麼便利的情況下，也可以說是 Click 工程師，點點介面就可以部署相當複雜的服務，但一樣的情況，若是不去深究基礎的知識，很可能 debug 時間不但很長、甚至方向可能也是錯誤的。</p><p>以往需要數個月開發的服務架構，現在可能只要數週內、甚至一天內就可以完成。於是這類的情況可能讓你的主管會有很大的錯覺，他會認為你發生問題的時候，應該也是幾天內可以解決的事情。但如上面所描述，由於部署太方便，我們不夠了解底層邏輯運作，而導致問題發生的時候，可能超出我們預料。</p><p>這個問題亦可以延伸到 AI 層面，我們在使用 chatGPT 的同時，通常會越來越懶惰。例如不去先看看開發者文件，反而直接問 AI，當然我覺得這樣的方法沒有不好，我們可以用自然語言，讓節省我們大量的時間去搜尋程式碼語法，快速取得知識。以前看 Stack Overflow、Google 對的關鍵字的時代漸漸式微，現在的工程師可以更快取得「可以應用」的程式碼，但可能往往會是不知道為什麼可以用就先應用了。</p><p>講者最後提到基礎知識學習、唸書仍然是一件重要的事情。例如組讀書會去定期汲取新知識，我非常認同且認為這還是相當重要且必要的事情，在這個大 AI 時代，基礎知識可以在問題發生的當下，用不同角度去切入問題或是有不同的思路，並且透過它去更透明地了解目前看到簡化作業流程的雲端平台(一個按鈕可能執行了好幾個 scripts)。</p><h4><a href="https://cloudsummit.ithome.com.tw/2024/lab-page/2982">體驗企業級 DevSecOps 平台 — 全面提升程式碼品質與資安弱點修復</a></h4><p>以前曾經聽過 DevOps 概念也實際應用在工作流程上，但隨著近年來越注重資訊安全，DevSecOps 也被工程師們逐漸重視 (Sec 是 Security 安全)。</p><p>在工作上可以應用實際使用這平台的話，我覺得會很方便。由於這套產品導入 CICD 的流程並加弱點掃描等等，並可以註冊它的產號取代多個平台的帳號(因為它會串第三方服務，例如 gitlab、sonarqube 等等)。最後的賣點甚至可以透過 AI 進行修復 sonarqube 掃出來有問題的程式碼，也可以在 yaml 檔客製化設定修復的程度。當然 AI 改的程式碼可能還是有很大的問題，這時候就不得不提到「單元測試」的重要性，讓 AI 修復完成的程式碼必定要通過這些測試。</p><p>當然這個方便的平台，與剛剛上一個推薦的演講有點矛盾。倘若公司要導入這個類似這種方便平台，我認為開發者還是要有基礎相關的 domain knowhow 去駕馭，才能避免出錯時一問三不知。</p><h3>結語</h3><p>由於近期公司內部也是想要導入 CICD 流程，因此這次參展可以學到平常沒有看到的新知識概念，也聽聽業界人士的想法和意見交流。因此整體下來我覺得參展還是挺不錯，除了早上搶不到便當券 XDD (大會公告 8:30 前來可以拿到便當券，而我是 8:15 到，但是排隊的人龍超乎我預期地長)。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9152a93c285a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linux 建立防火牆的兩種方式]]></title>
            <link>https://medium.com/@erikho_51835/linux-%E5%BB%BA%E7%AB%8B%E9%98%B2%E7%81%AB%E7%89%86%E7%9A%84%E5%85%A9%E7%A8%AE%E6%96%B9%E5%BC%8F-bc1b98338aac?source=rss-5ca17b15cef9------2</link>
            <guid isPermaLink="false">https://medium.com/p/bc1b98338aac</guid>
            <dc:creator><![CDATA[Erik Ho]]></dc:creator>
            <pubDate>Sun, 16 Jun 2024 08:35:09 GMT</pubDate>
            <atom:updated>2024-08-12T07:12:33.126Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d0MAcpOKsbyDrqlMPD74DQ.jpeg" /></figure><h3><strong>防火牆設定</strong></h3><p>在 Ubuntu，linux 可以用 ufw 或是 iptables 來進行設定。這兩個方法都可以對防火牆進行設定，ufw 是高層級的套件去控制 iptables。</p><p>這裡記錄指令和分享一下我遇到的雷坑🤣</p><h4><strong>UFW</strong></h4><ul><li>查看防火牆設定</li></ul><pre>sudo ufw status</pre><ul><li>新增防火牆</li></ul><pre># allow ssh<br>sudo ufw allow ssh<br># allow specific ip to specific port<br>sudo ufw allow from 123.123.123.123 to any port 22/tcp</pre><ul><li>列出防火牆規則的編號</li></ul><pre>sudo ufw status numbered</pre><p>例如</p><pre>root@localhost:~# sudo ufw status numbered<br>Status: active<br>To Action From<br>- - - - - -<br>[ 1] 80/tcp ALLOW IN Anywhere<br>[ 2] 443/tcp ALLOW IN Anywhere<br>[ 3] 22/tcp ALLOW IN 123.123.123.123<br>[ 4] 22/tcp ALLOW IN 123.123.123.124<br>[ 5] 443/tcp (v6) ALLOW IN Anywhere (v6)<br>[ 6] 80/tcp (v6) ALLOW IN Anywhere (v6)</pre><ul><li>刪除特定規則</li></ul><pre>sudo ufw delete [編號]</pre><ul><li>重載規則</li></ul><pre>sudo ufw reload</pre><ul><li>啟用/停用規則</li></ul><pre>sudo ufw enable<br>sudo ufw disable</pre><h4><strong>IPTABLES</strong></h4><p>如果你用 ufw 加上 22 port 規則，可以查看以下指令，但最終還是要看 sudo iptables -L INPUT -n — line-number 有沒有這條規則</p><ul><li>查看 22 port：</li></ul><p>如果你用 ufw 加上 22 port 規則，可以查看以下指令</p><pre>sudo iptables -L -n | grep :22<br>ACCEPT tcp - 123.123.123.123 0.0.0.0/0 tcp dpt:22<br>ACCEPT tcp - 123.123.123.124 0.0.0.0/0 tcp dpt:22</pre><ul><li>查看 input 規則</li></ul><pre>sudo iptables -L INPUT -n - line-number</pre><ol><li>機器一</li></ol><pre>root@localhost:~# sudo iptables -L INPUT -n --line-number<br>Chain INPUT (policy DROP)<br>num target prot opt source destination<br>1 ufw-before-logging-input all - 0.0.0.0/0 0.0.0.0/0<br>2 ufw-before-input all - 0.0.0.0/0 0.0.0.0/0<br>3 ufw-after-input all - 0.0.0.0/0 0.0.0.0/0<br>4 ufw-after-logging-input all - 0.0.0.0/0 0.0.0.0/0<br>5 ufw-reject-input all - 0.0.0.0/0 0.0.0.0/0<br>6 ufw-track-input all - 0.0.0.0/0 0.0.0.0/0<br>7 ACCEPT tcp - 123.123.123.123 0.0.0.0/0 tcp dpt:22<br>8 DROP tcp - 0.0.0.0/0 0.0.0.0/0 tcp dpt:22</pre><p>2. 機器二</p><pre>root@localhost:~# sudo iptables -L INPUT -n --line-number<br>Chain INPUT (policy DROP)<br>num target prot opt source destination<br>1 ACCEPT tcp - 123.123.123.123 0.0.0.0/0 tcp dpt:22<br>2 ACCEPT tcp - 123.123.123.124 0.0.0.0/0 tcp dpt:22<br>3 f2b-sshd tcp - 0.0.0.0/0 0.0.0.0/0 multiport dports 22<br>4 ACCEPT tcp - 0.0.0.0/0 0.0.0.0/0 tcp dpt:80<br>5 ACCEPT tcp - 0.0.0.0/0 0.0.0.0/0 tcp dpt:443</pre><ul><li>寫入 input 規則</li></ul><pre>sudo iptables -A INPUT -p tcp -s 123.123.123.123 --dport 22 -j ACCEPT</pre><ul><li>刪除 input 規則</li></ul><pre>sudo iptables -D INPUT &lt;line-number&gt;</pre><h3><strong>實際處理心得</strong></h3><p>這篇的緣由是公司的其他團隊遇到駭客，主要是沒有設定防火牆和密碼複雜度低導致被駭。因此我想說來增加一下資訊安全，限制 22 port 的連線白名單，但不料不熟悉指令遇到的小雷坑。</p><p>基本上加上防火牆的白名單應該滿夠使用，如果不是內部人員，應該就沒辦法取得特定 IP。(如果有其他更好的方法歡迎交流😆)</p><p>由於我在機器一設定好 ufw，</p><p>使用下列指令加入白名單，</p><pre>sudo ufw allow from [IP] to any port 22/tcp</pre><p>亦確認以下指令有顯示我的 IP 地址，</p><pre>sudo iptables -L -n | grep :22</pre><p>因此在機器一可以用特定 IP 登入機器來增加機器安全。我在機器二如法炮製卻遇到問題，屢次發現無法登入自己的 IP (駭客還沒登入，自己先登入不了XD)。</p><p>主要的原因其實就是機器二根本沒有將 ufw 規則丟到 iptables，因此 ufw 怎麼設定都沒有辦法成功啟用(或是你可能要重新安裝一次 ufw)。</p><p>我最後的解法是直接用 iptables 加入白名單方式，確認有寫入 iptables，這下確保真正有進防火牆。</p><pre>sudo iptables -A INPUT -p tcp -s 123.123.123.123 - dport 22 -j ACCEPT</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bc1b98338aac" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A lot of places in the world rely on tourism as a main source of income.]]></title>
            <link>https://medium.com/@erikho_51835/a-lot-of-places-in-the-world-rely-on-tourism-as-a-main-source-of-income-0b45631d4bf5?source=rss-5ca17b15cef9------2</link>
            <guid isPermaLink="false">https://medium.com/p/0b45631d4bf5</guid>
            <dc:creator><![CDATA[Erik Ho]]></dc:creator>
            <pubDate>Sun, 22 Oct 2023 02:35:19 GMT</pubDate>
            <atom:updated>2023-10-22T02:35:19.869Z</atom:updated>
            <content:encoded><![CDATA[<h3>A lot of places in the world rely on tourism as a main source of income. Unfortunately, tourism can also be a source of problems if it is not managed correctly.</h3><p>Describe the advantages and disadvantages of tourism in the modern world. Do you think that benefits of tourism outweigh its drawbacks?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oxWEZjCcPkFM6eOf" /></figure><p>Traveling has recovered and become more popular after three years of severe pandemic or coronavirus. Some people assert tourism can have adverse impact on the environment. However, I do not agree with this and I will illustrate several compelling reasons for supporting the benefits of tourism outweigh its drawbacks.</p><p>Tourism boosts the economy. In many countries, it is evident that tourism indeed brings tens of thousands of visitors annually and the governments make profits from it. Human resources are essential key factors for the tourism, such as the waiters in the restaurants, the cleaners in the hotels and the employees in the airports. With such substantial demands, local companies can offer more higher salary for their employees. Moreover, tourists from wealthy countries can purchase more products which can help local people earn extra money.</p><p>Furthermore, traveling abroad not only opens our horizon but gives us more concerns on historical sites. First, experiencing local culture or customs is an amazing and unforgettable memory when flying to another country. For example, drinking beers with fired chicken is a popular trend in Korea when hanging out with friends. Second, lots of historical tourist attraction are preserved well because of money flow from tourists.</p><p>However, it is undeniable that more and more tourists cause earth-shattering consequences. Some people throw away plastic waste or trash to the mountains. Recently, a lot of visitors came to Mountain Fuji and left bunch of junks, which had negative impact on the environment. Simultaneously, excessive visitors make the area crowded and noisy and affect local transportation. Governments should take measures to address the issues and regulate laws to protect the environment. In my opinion, these difficulties can be overcome with appropriate policy or laws, so they are not huge problems.</p><p>In conclusion, tourism can boost a country’s economy with job opportunities, product-selling. It also provides several benefits like opening one’s horizon and putting more emphasis on historical sites. Nevertheless, authorities should take actions to prevent the environment from vicious tourists’ destruction. It can benefit people and reduce the effect of its drawbacks by appropriate measures and I believe that the pros outweigh the cons.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0b45631d4bf5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The diagram show the recycling process of aluminum cans.]]></title>
            <link>https://medium.com/@erikho_51835/the-diagram-show-the-recycling-process-of-aluminum-cans-2195a8af2650?source=rss-5ca17b15cef9------2</link>
            <guid isPermaLink="false">https://medium.com/p/2195a8af2650</guid>
            <dc:creator><![CDATA[Erik Ho]]></dc:creator>
            <pubDate>Sun, 22 Oct 2023 02:05:57 GMT</pubDate>
            <atom:updated>2023-10-22T02:05:57.124Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*sWWeLJKRgw_rPoxUguJ0eQ.png" /></figure><p>The diagram below illustrates the several stages of how to recycle aluminum cans.</p><p>Overall, it is evident that the process commences with disposing of the used cans and ends with manufacturing containers with reusing material.</p><p>Initially, used cans are thrown away into the trash bins then collected and sent to the special center which is particularly dealing with these containers for recycling. The aluminum cans are cleaned and sorted first, because they may be filthy and inappropriate for reusing. Subsequently, they are shredded and compressed by a sophisticated recycling machine. After completing the stage, the aluminum cans are heated and melted into the form of liquid, which is the raw material for reusing.</p><p>The liquid is rolled out to the thickness of between 2.5mm to 6.mm, and it is ready to apply the ingredients into producing the containers. The recycling products are used into various containers, such as drinks cans or foods jars, which are quite often seen in the supermarkets or convenience stores. In the UK, Coke Cola cans are made up of 74 percent recycled material.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2195a8af2650" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Summarise the information by selecting and reporting the main features, and make comparisons where…]]></title>
            <link>https://medium.com/@erikho_51835/summarise-the-information-by-selecting-and-reporting-the-main-features-and-make-comparisons-where-88d6421bcee0?source=rss-5ca17b15cef9------2</link>
            <guid isPermaLink="false">https://medium.com/p/88d6421bcee0</guid>
            <dc:creator><![CDATA[Erik Ho]]></dc:creator>
            <pubDate>Thu, 19 Oct 2023 16:41:25 GMT</pubDate>
            <atom:updated>2023-10-20T07:02:16.345Z</atom:updated>
            <content:encoded><![CDATA[<h3>Summarise the information by selecting and reporting the main features, and make comparisons where relevant.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-lySwedub-rWOy-5QZ7VoA.png" /></figure><p>The initial chart depicts the export earnings between 2015 and 2016 across different types, while the second table illustrates the variation rate in 2016 compared with 2015 in various categories.</p><p>Overall, it is evident that both petroleum products and engineered goods consistently outperformed the other three categories in terms of total export earnings during 2015 and 2016. Notably, the category of textiles accounted for the largest percentage in this table.</p><p>Looking at first chart more closely, export earnings for both of petroleum products and engineered goods stood out throughout this period, reaching at approximately 60 billion in each year. The textiles category reached its lowest figure (around 25 billion) in 2015, whereas it had an upward trend in the following, surpassing 30 billion. Moreover, the earnings of textiles were nearly same as those of agricultural products in 2016. Gems and jewellery earned around 43 billion and 41 billion in each year, respectively.</p><p>In the second table, a significant upward trend was seen in the category of textiles, which had the highest growth rate (15.24 %). On the other hand, the gems and jewellery category was the only one to experience a decline, with a rate of -5.18%.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fbutton.like.co%2Fin%2Fembed%2Foceanuheart%2Fbutton&amp;display_name=LikeCoin&amp;url=https%3A%2F%2Fbutton.like.co%2Fin%2Flike%2Foceanuheart&amp;image=https%3A%2F%2Fstorage.googleapis.com%2Flikecoin-foundation.appspot.com%2Flikecoin_store_user_oceanuheart_main%3FGoogleAccessId%3Dlikecoin-api-public%2540likecoin-foundation.iam.gserviceaccount.com%26Expires%3D2430432000%26Signature%3DMHEAGnTdETv69F6swIi5OOWkQYs6NLmLiBjxaPYEGwA8zvMy8iMfEA6MDfF459Zc%252BgwHXSp8gpkBirWGnGhO7Hx4d9B3XIXUOqlrEOeGTY7ZBYQ%252Fk4LQyt0bwk0dwmJlT5sKaI1athca1Snos8%252Bmj0Og0eVR%252BP95UYpMLn4ApNSmm2eNI%252ByA9I%252F8LZgrstaykAE2ubKBLTiba%252Bvvm3gq6PvSDo1y0MLIlsBhLQyC95tp7oHNEKwej1W1K4PwFcw5Kk4m3TDQ26AVTEvtWqdR8YXYjsHoIXHmSrvdOMQOLkYrtcAqxTYY1rLJkSIMSShIkGG7ePwxPmHhVDngyp8QwA%253D%253D%26d313108&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=like" width="360" height="212" frameborder="0" scrolling="no"><a href="https://medium.com/media/582a40f7628fae64386dbab9005726cf/href">https://medium.com/media/582a40f7628fae64386dbab9005726cf/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=88d6421bcee0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>