Specify Rails Version When Init Aug 30, 2021 It’s common to installed multiple versions of the same gem. For example, rails with 5.2.7 and 6.1.1, etc. By default, it uses the latest release. To specify the old one, just use command like below, which specifies the expected version with underscode _. ...
Typescript Array.map 後的型別推論技巧 - type predicate Mar 27, 2021 在集合或陣列類型的資料處理中,偶爾會遇到需要使用 Array.map 把所需要的資料從物件中轉化成另一個陣列物件。 例如 class Foo { bar?: number constructor(bar?: number) { this.bar = bar; } } let foos: Foo[]; fooArray = [ new Foo(123), new Foo() ]; let bars = foos. ...
TypeScript 上手二三事 Feb 5, 2021 經歷過 Java, Ruby, JavaScript(咦?),最近因為職涯的轉換開始上手 TypeScript。 簡單說 TypeScript 就是 JavaScript 的超集,最大的好處是加強了型別系統。 上手的過程使用了 91 (Joey Chen) 極速開發帶領的 Tennis Kata 練習。 明確的主題可以練習,不會漫無目的的從頭開始學。 新的語言有新的工具鍊,必須要有基本使用的能力。 承 2,我希望可以最快速的達到我在 Ruby 環境的純 coding 戰力。 目前的感受 用了一個主題上手真的比較精準和快速,簡單說就是作中學。 多了編譯的過程貌似會慢一點點( TypeScript -> JavaScript -> run Test)。 內建型別推論(Type Inference)在多數情形下可以不去註記型別。 承 3,但是對於某些特別用途,例如 dictionary,就必須要記得註記他。 因為 3 跟 4,反而在寫程式的時候需要特別去思考要不要作型別註記,覺得會有一點額外耗腦。
Have Custom Attribute for a Rails ActiveRecord Model Aug 3, 2020 Framework is pretty opinionated in its area, but that also means it handles many repetitive and tedious tasks. When using ORM like ActiveRecord, it saved us so much time defining which model has what attributes. ...
Generate RSA key pairs with encryption May 20, 2020 I’ve spent some time investigating how to create RSA key pairs for a feature. Put a note here just in case I need it again. Generate RSA private key with 2048 bits $ openssl genrsa -out private. ...