Here are some interesting tips when you are using Kotlin. Let’s take a look at something about object,
invoke operator,
and destructuring.
Cron Job on TypeScript
What is Cron?
Cron is a classic utility found on Linux and UNIX systems for running tasks at pre-determined times or intervals. These tasks are referred to as Cron tasks or Cron jobs. Use Cron to schedule automated updates, report generation, or check for available disk space every day and send you an email if it falls below a certain amount.
Composition over the inheritance
The Story
I recently encountered a question about why it’s better to using interface than inheritance. I have this because we defined lots of interfaces (behaviors) in a recent project. And, I am not saying this is bad, but just because this is not my familiar pattern when trying to design a system and also wanted to think of it deeper why we are doing that. I am confused if some classes share the same behaviors, my first thought from Java world is to create a parent class to define those common behaviors and then derivative classes would get the benefits without implementing the same behaviors again. But someone told me: Using an interface is better. So, I want to figure out why an interface is better than inheritance. According to the wiki description:
Composition over inheritance - Wikipedia
Composition over inheritance (or composite reuse principle) in object-oriented programming (OOP) is the principle that classes should achieve polymorphic behavior and code reuse by their Composition (by containing instances of other classes that implement the desired functionality) rather than inheritance from a base or parent class
System loading test by using Artillery
There are so many choices for doing a system loading test on backend side. Let’s see the list below:
You can read this post to get more detail information. Choosing Artillery is because it can provide the test scenario for developers to design a test context. After doing some researches and adapting to this tool, I found some advantages for using it to do the web benchmark.
The difference between import from and import require in TypeScript
You might sometimes see import * from library
in the third-party library or some project, and in the meantime, you can also see this code import something = require('library').
Would you wonder what the difference between these two sentences is? Here is the explanation about what difference between import from
and import require
is.
Let’s see an example first, and you can find these two usages:
1 | import uuid = require('uuid'); |
And, another way like this:
1 | import uuid from 'uuid'; |
Import path in TypeScript
Problem
In the recent project, we’ve mentioned about one question:
why do we do our imports as relative paths rather than absolute paths? It’s not easy to figure out what’s the correct path.
We then start discussing what the pros and cons are for using an absolute path or relative path. To my best knowledge, I always voted for the relative path, cause that won’t cause a problem when we try to deploy the service into different file paths. But the con is that we need first to figure out what’s the correct import path. But using an absolute import path is the contrary.
Use ESLint and Prettier to format your code in TypeScript
Use ESLint and Prettier to format your code in TypeScript
I think ESLint
[1] is an essential thing when you try to create a project using JavaScript/TypeScript. That would be an excellent tool to parse the potential issues in your code.
Let’s check the philosophy of ESLint:
- Everything is pluggable:
- Rule API is used both by bundled and custom rules
- Formatter API is used both by bundled and custom formatters
- Additional rules and formatters can apply at runtime
- Rules and formatters don’t have to be bundled to combine
- Every rule:
- Is standalone
- Can be turned off or on (nothing can be deemed “too important to turn off”)
- Can be set to a warning or error individually
- Additionally:
- Rules are “agenda-free” - ESLint does not promote any particular coding style
- Any bundled rules are generalizable
- The project:
- Values documentation and clear communication
- Is as transparent as possible
- Believes in the importance of testing
Moving in the U.S - the check list
這篇主要是用來提醒自己, 在美國搬家要注意的相關事項. 畢竟還尚未成為美國公民之前, 在美國國內的搬家相關係法律還是需要遵守, 像是 告知義務
Change of Address Information
We strongly encourage you to update your address with USCIS to ensure you receive all correspondence and benefits from us in a timely manner and avoid possible delays related to your case.
Changing your address with the U.S. Postal Service will not change your address with USCIS. Please update your information with both USCIS and USPS.
EQUIFAX Data Breach
剛來美國信用記錄非常重要, 我還記得剛過來的時候, 因為沒有任何信用紀錄, 所以在申請信用卡的時候基本上都是被打槍, 只有極少數幾家不需要 SSN 不需要考慮你的信用紀錄的發卡行有提供申請的服務, 但會不會過還是不知道.
目前美國有三大信用局分別是 EQUIFAX, Experian, 跟 TransUnion. 我目前有開 Experian 的帳號, 其他兩家沒什麼接觸, 所以也不太知道他們的狀況. 而會對 EQUIFAX 關注的最主要原因就是因為日前沸沸揚揚的賠償事件 [1][2]. 2017 EQUIFAX 由於被 Hack [3][4], 造成將近 1.47 億筆個資洩漏. 紛紛擾擾兩年之後, 最後結果終於出來了.
Introduction of Spinnaker
Why Spinnaker?
在開始使用 Spinnaker 之前, 先來了解一下它是什麼東西, 為什麼要使用它, 以及它能為我們整合開發上帶來什麼好處.
Netflix 推出這個開源的 project 用來做為 Continuous Integration (CI) 之後的發佈動作 (Continuous Delivery, CD) 最後一哩路. 而 Spinnaker 在 Github 上面對自己的定位:
Spinnaker is an open source, multi-cloud continuous delivery platform for releasing software changes with high velocity and confidence.