Skip to content

Home

Does Hack Reactor Make You Smarter?

The Daily Routine

Every morning, I wake up at 12 a.m. My alarm clock helps me start my day with the goal of becoming a software engineer. As a remote student in Hong Kong, I'm 16 hours ahead of San Francisco time. Adapting to this time difference hasn't been easy. The course material only adds to the complexity, covering topics like recursion, hash tables, pseudo-classical inheritance, Backbone, and Express, among others. So, what am I gaining from this experience?

Learning to Think Critically

Professional software engineers create exceptional products not just because they are skilled coders, but also because they have the right mindset. How proficient they are with a particular framework is just one factor. They are also fast and consistent learners, effective and empathetic communicators, and motivated, inquisitive problem solvers. These skills can't be learned from books or online videos alone; they come from hands-on practice, observing how instructors approach problems, and learning from mentors.

Learning from More Knowledgeable Peers

The coding bootcamp attracts many intelligent individuals, setting it apart from other learning platforms. I often ask myself, "Am I smart enough for this prestigious institution?" The feeling of imposter syndrome is real. Interacting with smarter people can sometimes be intimidating and make me feel inadequate. However, it also pushes me to be more comfortable with making mistakes, failing, and thereby learning at a faster rate.

Does Coding Make Me Smarter?

I believe it does, and what we believe often becomes a self-fulfilling prophecy. Working with intelligent people enhances the way I approach and think about challenges. There is always a better, more effective, and simpler way to do things. The smarter the people you surround yourself with, the more you are likely to learn from them, consequently becoming more intelligent yourself.

Hack Reactor能否讓你變得更聰明?

日常流程

每天早上,我在午夜12點醒來。我的鬧鐘幫我以成為軟體工程師的目標開始我的一天。作為香港的遠程學生,我比舊金山時間快16個小時。適應這種時差並不容易。課程材料只是增加了複雜性,涵蓋了遞迴、哈希表、偽經典繼承、骨幹和快速等主題。那麼,我從這個經驗中得到了什麼?

學習批判性思考

專業軟體工程師能創造出優秀的產品,不僅僅是因為他們具有出色的編碼技巧,更因為他們具備正確的思維方式。他們對特定框架有多熟練只是其中一個因素。他們也是快速而持久的學習者,有效且富有同理心的溝通者,並且是主動好奇的問題解決者。這些技能不能僅從書本或網上視頻中學習到;他們來自於實踐操作,觀察導師如何解決問題,並從導師身上學習。

從更有知識的同伴身上學習

這個編碼訓練營吸引了許多聰明的人,將它與其他學習平台區分開來。我經常問自己:"我是否足夠聰明以應對這個優秀的機構?"騙子症候群的感覺是真實的。與更聰明的人接觸有時會讓我感到害怕,讓我覺得自己不夠好。然而,它也促使我更樂意去犯錯、失敗,從而以更快的速度學習。

編碼能否讓我變得更聰明?

我認為確實能,而我們相信的往往會成為自我應驗的預言。與聰明的人共事提升了我的迎接挑戰和思考問題的方式。總有一種更好、更有效、更簡單的方法來做事。你周圍的人愈聰明,你就越有可能從他們身上學到,從而讓自己變得更聰明。

Testing with Mocha: Array Comparison

The Problem

While writing a Mocha test suite for array comparison, I encountered an issue. Here is the test suite:

describe("Array comparison", function () {
  "use strict"
  it("should return true if two arrays have the same values", function () {
    var myArray = ["a", "b", "c"]
    expect(myArray).to.equal(["a", "b", "c"])
  })
})

Contrary to my expectations, this test fails, producing the following error:

AssertionError: expected ['a', 'b', 'c'] to equal ['a', 'b', 'c']

My Explanation

Why don't arrays compare like other values? It's because the typeof array is an object. In Mocha, to.equal doesn't indicate that the operands are semantically equal; rather, it checks if they refer to the exact same object. In other words, the test fails because myArray is not the exact same object as ['a', 'b', 'c'].

Possible Solutions

  1. Use .eql for "loose equality" to deeply compare values.
  2. Use .deep.equal, which tests whether the operands are equivalent but not necessarily the same object.
  3. Check .members in the array instead.
  4. Convert the array to a string and then compare.

References


I hope this revised version better communicates your insights and solutions.

使用Mocha進行測試:陣列比較

問題

在為陣列比較寫一個Mocha測試套件時,我遇到了一個問題。這是測試套件:

describe("Array comparison", function () {
  "use strict"
  it("should return true if two arrays have the same values", function () {
    var myArray = ["a", "b", "c"]
    expect(myArray).to.equal(["a", "b", "c"])
  })
})

與我的期望相反,這個測試失敗了,產生以下的錯誤:

AssertionError: expected ['a', 'b', 'c'] to equal ['a', 'b', 'c']

我的解釋

為什麼陣列不像其他值那樣進行比較呢?這是因為陣列的typeof是物件。在Mocha中,to.equal並不表示操作數在語義上是相等的;相反,它檢查他們是否參考了相同的物件。換句話說,這個測試失敗是因為myArray並不是與['a', 'b', 'c']完全相同的物件。

可能的解決方案

  1. 使用.eql進行"寬鬆相等"以深度比較值。
  2. 使用.deep.equal,這檢查操作數是否在語義上相等,但不一定是相同的物件。
  3. 在陣列中檢查.members
  4. 將陣列轉換為字符串然後進行比較。

參考


我希望這個修改的版本更好地傳達了您的見解和解決方案。

How to Customize Sublime Text's Default Auto-Complete

I use Sublime Text 3 every day, and I particularly appreciate its JavaScript auto-complete feature.

However, there's an issue with the default completion for if statements; it includes an unnecessary semicolon at the end:

if (true) {
}

When using JSHint, this semicolon generates an error for most of the code I write. Having to manually delete it each time is counterproductive.

Solution for the Problem

  1. Navigate to Preferences → Browse Packages to open the Sublime Text folder.
  2. Locate the folder named JavaScript (create one if it doesn’t exist).
  3. Inside this folder, open if.sublime-snippet (create one if it doesn’t exist).
  4. Remove the semi-colon so that your snippet now looks like this:
    <snippet>
        <content><![CDATA[if (${1:true}) {${0:$TM_SELECTED_TEXT}}]]></content>
        <tabTrigger>if</tabTrigger>
        <scope>source.js</scope>
        <description>if</description>
    </snippet>

By following these steps, you can eliminate the unnecessary semicolon and make your coding process more efficient.

如何自設Sublime Text的預設自動完成功能

我每天都使用Sublime Text 3,我特別欣賞它的JavaScript自動完成功能。

然而,預設完成if語句的方式存在一個問題;它在結尾處包含了一個不必要的分號:

if (true) {
}

使用JSHint時,這個分號會在我寫的大部分代碼中產生錯誤。每次都要手動刪除它是逆生產的。

解決問題的方法

  1. 導航到 首選項 → 瀏覽套件以開啟Sublime Text文件夾。
  2. 找到名為 JavaScript的文件夾(如果不存在,則創建一個)。
  3. 在此文件夾中,打開 if.sublime-snippet(如果不存在,則創建一個)。
  4. 刪除分號,以便您的片段現在看起來像這樣:
    <snippet>
        <content><![CDATA[if (${1:true}) {${0:$TM_SELECTED_TEXT}}]]></content>
        <tabTrigger>if</tabTrigger>
        <scope>source.js</scope>
        <description>if</description>
    </snippet>

按照這些步驟,您可以消除不必要的分號,使您的編碼過程更有效率。

Build an Awesome Chat App in 5 Minutes with Meteor

In this tutorial, I'm going to show you how to write a simple chat application using MeteorJS.

Here is a live demo as our goal: http://hrr2demo.meteor.com/

And the source code on GitHub: https://github.com/victorleungtw/hrr2demo

Feel free to try the demo and fork the repo before we get started.

What is Meteor?

Meteor is an awesome web framework for building real-time applications using JavaScript. It is based on NodeJS and MongoDB.

Step 1: Install Meteor

For macOS and Linux users, run the following command in your terminal:

> curl [https://install.meteor.com/](https://install.meteor.com/) | sh

Step 2: Create a New App

> meteor create awesomeChatApp

Then change the directory to your app:

> cd awesomeChatApp

Try to run it:

> meteor

And open your browser at the address: http://localhost:3000

Step 3: Create Folders and File Structure

Remove the default files with the command:

> rm awesomeChatApp.*

Create three folders:

> mkdir client server both

By convention, we'll put anything that runs on the client side (i.e., the user's browser) in the 'client' folder, anything that runs on the server side in the 'server' folder, and anything accessed by both client and server in the 'both' folder.

Step 4a: Create a Collection to Store Messages

Inside the 'both' folder, we'll place our model here.

> touch collection.js

To create a new 'messages' collection:

Messages = new Meteor.Collection("messages")

Step 4b: Create the Index Page

Inside the 'client' folder, we'll place our homepage view.

> touch index.html

With the following HTML:

<head>
  <title>chatterbox</title>
</head>
<body>
  {{> loginButtons align="right"}} # chatterbox {{> input}} {{> messages}}
</body>

Step 4c: Create HTML Template with Helpers

To better organize our files, we can create a new folder:

> mkdir messages > cd messages > touch messages.html

Now, we create a template with the name 'messages'.

<template name="messages">
  {{#each messages}} {{name}}: {{message}} {{/each}}
</template>

And we'll create helpers to loop through each message in the 'Messages' collection.

Template.messages.helpers({
  messages: function () {
    return Messages.find({}, { sort: { time: -1 } })
  },
})

Step 4d: Create HTML Template with Event Handlers

Similarly, we'll create a template for the input box and submit button.

> mkdir input > cd input > touch input.html
<template name="input">
  <form id="send">
    <input id="message" type="text" />
    <input type="submit" value="Submit" />
  </form>
</template>

Also, we'll create a JavaScript file to handle the click event of the submit button.

Template.input.events({
  "submit form": function (event) {
    event.preventDefault()
    var name = Meteor.user() ? Meteor.user().profile.name : "Anonymous"
    var message = document.getElementById("message")
    if (message.value !== "") {
      Messages.insert({
        name: name,
        message: message.value,
        time: Date.now(),
      })
      message.value = ""
    }
  },
})

Step 4e: Add Accounts Package for Login Using GitHub Account

Meteor is very easy to use. Because it has a rich package ecosystem, we're going to add accounts-ui and accounts-github for a simple user login system.

meteor add accounts-ui
meteor add accounts-github

Step 4f: Add Stylesheets (Optional)

Copy and paste the following stylesheets inside your 'client' folder.

> mkdir style > cd style > touch style.css

Step 5: Deploy Your Website to Meteor's Free Server

meteor deploy awesomeChatApp.meteor.com

Done! You may need to deploy to a different address if the given address is already in use. Open your browser with your address: http://awesomeChatApp.meteor.com

You will also need to configure the login system

使用Meteor在五分鐘內建立一個超棒的聊天應用程式

在這個教程中,我將向你展示如何使用MeteorJS編寫一個簡單的聊天應用程式。

這裡有一個我們目標的實際演示:http://hrr2demo.meteor.com/

和GitHub上的原始碼:https://github.com/victorleungtw/hrr2demo

在我們開始之前,隨意嘗試演示並分叉存儲庫。

什麼是Meteor?

Meteor是一個用於使用JavaScript構建實時應用程式的出色網絡框架。它基於NodeJS和MongoDB。

步驟1:安裝Meteor

對於macOS和Linux用戶,在終端機中運行以下命令:

> curl [https://install.meteor.com/](https://install.meteor.com/) | sh

步驟2:創建新應用程式

> meteor create awesomeChatApp

然後更改為你應用程式的目錄:

> cd awesomeChatApp

嘗試運行它:

> meteor

並在瀏覽器中打開此地址:http://localhost:3000

步驟3:創建資料夾和檔案結構

使用命令刪除默認檔案:

> rm awesomeChatApp.*

創建三個資料夾:

> mkdir client server both

按慣例,我們將把在客戶端(即,用戶的瀏覽器)運行的任何內容放在“client”資料夾中,將在服務器端運行的任何內容放在“server”資料夾中,將由客戶端和服務器共同訪問的任何內容放在“both”資料夾中。

步驟4a:創建收集來儲存訊息

在'both'文件夾內,我們將在這裡放置我們的模型。

> touch collection.js

創建一個新的'messages'集合:

Messages = new Meteor.Collection("messages")

步驟4b:創建索引頁

在'client'文件夾內,我們將在此處放置我們的首頁視圖。

> touch index.html

使用以下HTML:

<head>
  <title>chatterbox</title>
</head>
<body>
  {{> loginButtons align="right"}} # chatterbox {{> input}} {{> messages}}
</body>

步驟4c:創建帶有助手的HTML模板

為了更好地組織我們的檔案,我們可以創建一個新的文件夾:

> mkdir messages > cd messages > touch messages.html

現在,我們創建一個名為'messages'的模板。

<template name="messages">
  {{#each messages}} {{name}}: {{message}} {{/each}}
</template>

並且我們將創建助手以通過在'Messages'集合中的每個消息。

Template.messages.helpers({
  messages: function () {
    return Messages.find({}, { sort: { time: -1 } })
  },
})

步驟4d:創建帶有事件處理程序的HTML模板

同樣,我們將為輸入框和提交按鈕創建一個模板。

> mkdir input > cd input > touch input.html
<template name="input">
  <form id="send">
    <input id="message" type="text" />
    <input type="submit" value="Submit" />
  </form>
</template>

另外,我們將創建一個JavaScript文件來處理提交按鈕的點擊事件。

Template.input.events({
  "submit form": function (event) {
    event.preventDefault()
    var name = Meteor.user() ? Meteor.user().profile.name : "Anonymous"
    var message = document.getElementById("message")
    if (message.value !== "") {
      Messages.insert({
        name: name,
        message: message.value,
        time: Date.now(),
      })
      message.value = ""
    }
  },
})

步驟4e:添加帳戶包以便使用GitHub帳戶登錄

Meteor非常容易使用。因為它具有豐富的包生態系統,所以我們要添加accounts-uiaccounts-github以便一個簡單的用戶登錄系統。

meteor add accounts-ui
meteor add accounts-github

步驟4f:添加樣式表(可選)

將以下樣式表複製並粘貼到您的'client'文件夾內。

> mkdir style > cd style > touch style.css

步驟5:將您的網站部署到Meteor的免費服務器

meteor deploy awesomeChatApp.meteor.com

完成!如果給出的地址已經在使用,您可能需要部署到其他地址。在瀏覽器中打開您的地址:http://awesomeChatApp.meteor.com

您還將需要配置登錄系統

Fun Facts I Discovered in Melbourne

Which is better, Sydney or Melbourne? The choice is yours. There's a traditional, petty rivalry between the two cities.

In my opinion, comparing them is like comparing apples to oranges. Melbourne won my heart when I finally visited. Sorry, Sydney.

My story begins in July. Despite a rainy and windy weekend, nothing could deter me from visiting my best friend in Melbourne. Like most of my trips, I had no plans; I simply showed up and did what I felt like doing. The nicknames a city earns can often reveal much about its character — for example, "the world's most livable city." One visit is not enough to see everything Melbourne has to offer, and I don't recommend trying. So here's a selection of highlights, in no particular order. If you're unfamiliar with the city, these are some interesting facts I discovered:

Winter is Extremely Cold - This may seem obvious, but Melbourne's winter is a unique kind of cold. Two hours earlier, I was enjoying the weather in Brisbane; two hours later, I was shivering non-stop in Melbourne. Though my time in the city was pleasant, don't be misled into thinking it's always warm and sunny here. The worst experience was being awakened multiple times during the night by the cold. Thankfully, my friend's room had a heater, which was a lifesaver. Interestingly, the best part of the trip was enjoying ice cream at night, as it didn't melt while I walked down the street.

You Might Get Disoriented - It's not embarrassing for newcomers to get lost, especially when most streets have the ubiquitous "Pie Face." Fortunately, Melbourne's architecture sets it apart. One of the city's most iconic landmarks is Flinders Street Station. Most tourist attractions are in the city center, making it easy to explore and visit places like the Queen Victoria Market and Victoria's State Library. These attractions are all within walking distance, or you can take the free city circle tram.

Art Galleries Are Not Always Free - They say the best things in life are free, and many city attractions are accessible at no cost. We didn't realize we needed tickets until we reached the exit—or was it the entrance? Regardless, we got to see some contemporary art for free. Culture enthusiasts will find plenty to keep them occupied at Federation Square.

The Aquarium - This might be the city's least-visited tourist attraction. After all, it's pretty similar to other aquariums worldwide. However, I enjoy watching animals, and this place offers an exploratory journey—penguins spit everywhere. Bile causes the greenish hue. Using satellites, you can estimate the number of emperor penguins based on the spots of their excrement—unless they all have gastroenteritis, of course.

Chinatown is Everywhere - You don't have to look hard for Chinatown; it's all over Melbourne. The CBD is densely populated, and you're likely to encounter Chinese people. Thanks to this international blend, there's no longer such a thing as a "typical Australian resident." With such diversity, it's not surprising that one can find international cuisine within a few kilometers of each other. One Chinese restaurant sign translates to "Hot and Lust"—and no, it's not a brothel.

The (Twelve) Apostles - The name is misleading; there are neither twelve stacks nor any biblical connection. The site used to be called "The Sow and Piglets," but was renamed "The Apostles" for tourism purposes. Our driver, Fujiwara Takumi, whom you might recognize from the manga "Initial D," navigated the winding Great Ocean Road beautifully. The views were breathtaking. If you're planning a day trip to Victoria's most popular tourist site, hope for good weather!

So what are you waiting for? Book a plane ticket and fly there right away. There are countless exciting sights to see and memories to make. If you've already visited, go back and see what's new. Remember, different seasons offer varied perspectives on what makes the city enjoyable. In my opinion, Melbourne is a fantastic place to both live and visit.

我在墨爾本發現的有趣事實

雪梨和墨爾本,哪一個更好?選擇在你。兩座城市之間有著傳統且小氣的對立。

在我看來,比較它們就像是比較蘋果與橙子。當我終於訪問墨爾本時,它贏得了我的心。對不起,雪梨。

我的故事始於七月。儘管那是一個風雨交加的週末,但沒有任何事情能阻止我去墨爾本探望我最好的朋友。像我大部分的旅行一樣,我沒有計劃;我只是到達後,做我想做的事情。一個城市贏得的綽號往往可以揭示出很多關於它的特性 - 例如"世界上最宜居的城市"。一次造訪無法看盡墨爾本所有的一切,我並不建議大家嘗試。所以,這裡有一些精選的亮點,並無特定的順序。如果你對這個城市並不熟悉,以下是我發現的一些有趣的事實:

冬季極其寒冷 - 這可能看起來很明顯,但墨爾本的冬天有一種獨特的冷。兩個小時前,我正享受著布里斯班的天氣;兩個小時後,我在墨爾本不停地顫抖。雖然我在該市的時間很愉快,但不要被誤導認為這裡總是溫暖和陽光明媚的。最糟糕的經歷是冷到在夜間多次被喚醒。謝天謝地,我朋友的房間有一個暖氣機,真是救星。有趣的是,這次旅行最好的部分是在晚上享用冰淇淋,因為它不會在我走在街上的時候融化。

你可能會迷失方向 - 對於新來的人來說,迷路並不尷尬,尤其是當大多數街道都有普遍存在的"派臉"。幸好,墨爾本的建築使它與眾不同。該市最具標誌性的地標之一是弗林德斯街車站。大多數的旅遊景點都位於城市中心,方便探索和參觀像皇后維多利亞市場和維多利亞州立圖書館這樣的地方。這些景點都在步行距離之內,或者你可以乘坐免費的城市環線電車。

藝術館並非總是免費 - 他們說生活中最好的事情是免費的,許多城市景點可以免費進入。我們直到到達出口 - 還是入口? - 才意識到我們需要門票。無論如何,我們還是免費看了一些當代藝術。文化愛好者在聯邦廣場將發現有很多能讓他們忙碌的事情。

水族館 - 這可能是該市最少被遊客參觀的旅遊景點。畢竟,它與全世界的其他水族館相差無幾。然而,我喜歡觀察動物,這個地方提供了一次探索之旅 - 企鵝到處吐口水。膽汁導致了綠色的色調。使用衛星,你可以根據他們排泄物的斑點来估算皇帝企鵝的數量 - 除非他們全都有腸胃炎,當然。

唐人街無處不在 - 你不必努力尋找唐人街,它遍布墨爾本。中央商業區人口密集,你很可能會遇到華人。多虧了這種國際融合,不再有所謂的"典型澳洲居民"。有了如此的多元性,可以在幾公里範圍內找到各種國際美食並不令人驚奇。一家中華料理餐館的招牌翻譯成"熱情如火" - 不,它不是一家妓院。

(十二)使徒 - 這個名字有些誤導人 ;那裡既沒有十二個石柱,也沒有任何與聖經相關的東西。該地點原本被稱為"母豬和小豬",但為了適應旅遊的需要被重新命名為"使徒群"。我們的司機藤原拓海,你可能會認出他是來自漫畫"頭文字D",他操控在崎嶇曲折的大洋路上行駛得非常漂亮。風景令人驚艷。如果你計劃嘗試一日遊去維多利亞州最熱門的旅遊地點,希望有個好天氣!

那麼,你還在等什麼呢?立即預訂飛機票,直飛那裡。有無數的令人興奮的景點等你去看,還有許多記憶等你去創造。如果你已經去過,那就回去看看有什麼新的。請記住,不同的季節提供了不同的角度來讓你了解這個城市有趣的地方。在我看來,墨爾本是一個無論是生活還是旅遊都極好的地方。