讀書筆記 - 股市心裡操縱術 - G.C. Selden
只要有更好的投資標的,就不該管現在投資的損益,那些都是沈沒成本,而應該直接把現在的投資換到更好的投資標的上 大眾堅信不移的說法大多是錯的 自己過度貪心可以從幾點看出來: 1. 不斷提高自己的投資報酬率 2. 原先覺得風險高的投資,現在看起來能穩操勝卷 3. 不再分散投...
2018 Ruby Kaigi 網路上看到的懶人整理
* Matz considering alias yied_self with then * Rib, an alternative for irb * Stripe team building Ruby type checker https://blog....
Understanding your Circle of Competence
之前在 Twitter 看到一個段落是說成功的關鍵在於 focus 但什麼是 focus,這個 Circle of Competence 也許是一個更好的解釋  new(param...
http.rb replace net::http
作者認為 Net::Http 雖然是 standard lib 之一,但 API 設計很不好,底層實作也有很多覺得不滿的地方,包含 Net::Http 的 Error 封裝方式,讓人不知道怎麼 rescue 有機會可以試用看看 https://github.com/h...
skip document installation when gem install
https://stackoverflow.com/questions/1381725/how-to-make-no-ri-no-rdoc-the-default-for-gem-install 1. 加 ~/.gemrc ``` gem: --no-document...
ruby proc 可以傳default 值since ruby 1.9
所以 scope :latest, ->(size=5) { recent.limit(size) } 這樣是可以的 好廢的一篇文 呵呵
github issue 和 pr 帶不同 params 就有不同功能
潮潮的,可以指定 title, labels, template 和 assignees 之類的 https://help.github.com/articles/about-automation-for-issues-and-pull-requests-with-qu...
Vue computed v.s. methods
computed 會 cached methods 不會 computed 回傳一個值,methods 不一定 https://cn.vuejs.org/v2/guide/computed.html
Devise 每次都會同時下 ORDER BY 和 LIMIT 的 sql 去找 users
同事提出的建議: ``` SELECT "users".* FROM "users" WHERE "users"."id" = $? ORDER BY "users"."id" ASC LIMIT $? id 是 primary key, 理論上不會有重複的資料. ...
bcrypt, devise, and rails secret_key_base
devise 用 secret_key_base 當作產生 token 的依據 devise 用 bcrypt hashify password 然後儲存 rails 的 has_secure_password 也是用 bcrypt 實現 bcrypt() is a h...
How to Create Postgres Indexes Concurrently in ActiveRecord Migrations
之前的文章提到要避免 deployment downtime 其中一個方式是 create index concurrently http://everyday1percent.blogspot.com/2018/05/rails-deployment-downtime....
explain https again
CA 憑證方發憑證,所謂的憑證就是包含 1. 公鑰 2. 用 CA 方的私鑰加密過的 Hash ## 具體步驟是: 1. client端發起Https request 2. Server端返回CA發的憑證 3. Client端收到憑證,並驗證憑證是否可信,如果可...
墮天使路西法 Lucifer
剛好在研究七原罪的時候看到傲慢的代表惡魔是 Lucifer,於是想知道是怎樣傲慢。 教會的解釋是 Lucifer 忘了自己天使的身份,把自己看的跟神一樣等級(所以才叛變?) 正常來說 Lucifer 的履歷如下: * 率兵叛變的天使首腦 * 化身伊甸園的蛇 * Som...
deploy vue to github page
兩個不錯的方式: 1. 用 push-dir + webpack 做 https://medium.com/@codetheorist/vue-up-your-github-pages-the-right-way-955486220418 2. 用直接寫好的 plug...
一篇講 OO cohesion 和 coupling 簡單易懂的文章
一直想找個好方式跟同事解釋怎麼 decoupling 和 design better code,這篇文章涵蓋了最重要的兩個概念而且用很簡單易懂的 code 解釋了,很不錯。 cohesion: class 裡的 methods 是不是 share 一樣的 contex...
使用 Vagrant 練習 chef-solo deployment
每次都自己調 server 太煩了,用 chef-solo 調一次以後一直套用比較方便,可以用 Vagrant 練習會快一點 先安裝 VirtualBox 和 Vagrant https://www.virtualbox.org/wiki/Downloads https...
新的做 soft delete 的 gem - discard
https://github.com/jhawthorn/discard 沒有 default 加上 default scope 我覺得是很棒的決定,這個 gem 留給開發者更多的彈性實作 soft delete,我覺得在大多數的 case 下都是很夠用...
檢查 gem verison 的方法
在devise 裡看到的 ```rb def self.rails51? # :nodoc: Rails.gem_version >= Gem::Version.new("5.1.x") end def self.activerecord51? #...
Profiling Rails Boot Time
Infos: https://mildlyinternet.com/code/profiling-rails-boot-time.html https://tenderlovemaking.com/2011/12/05/profiling-rails-startup-w...
Rails deployment 如何避免 downtime?
有哪些造成 downtime 的可能性? 1. Code 有問題 2. Migration 跑完後 Web Server 還沒 restart 3. Deploy 完後需要重啟 Server 4. Request 沒有被 queue 起來 可能的解決方式: ...
cc 系列 license,看到一個還不錯的,以後文章可以用
https://creativecommons.org/licenses/by-nc/2.5/ 可以允許分享也可以改動 分享要 credit 原作者,如果有改動也要指出改動哪裡。
rspec test protocal (interface) - part 1 - define what's interface and find it
通常我們會希望繼承於 Base class 底下的 class 會有相同的 interface,for example, 每個 service 都要有一個 #call 的 instance method,應該要有個很簡單的方法來對這些 services 測試是否有 imp...