一鍵安裝 shadowsocksR

https://github.com/teddysun/shadowsocks_install

Wayne

eth syncmode

還不是很確定,先翻譯貼過來 Full - 拿到所有資料 Fast - 差不多的意思,但不執行transaction Light - 只拿到現在的狀態,但不能驗證 https://ethereum.stackexchange.com/questions/11297/w...

Wayne

Mac OS 用 Geth 跑 ETH ethereum node 全節點

https://github.com/ethereum/go-ethereum/wiki/Installation-Instructions-for-Mac brew tap ethereum/ethereum brew install ethereum 然後跑 ...

Wayne

PG::ConnectionBad: FATAL: Peer authentication failed for user XXX

sudo vim /etc/postgresql/9.5/main/pg_hba.conf 加一行: ``` local all your_user_name trust `...

Wayne

kickstarter 的 event sourcing approach

也解釋了一些 event sourcing 相關的東西,還不錯的深入淺出好文,而且還有 gif 圖加分XD 這張就很棒的解釋了他們所謂的 Aggregation (綠色, state), Reactor (黃色), Calculator (藍色箭頭), Event (藍色...

Wayne

How rails store your migration history

有時候手動操作 database 刪掉了 table,於是乎 rails migration 跟 database 就對不起來了,要怎麼樣騙 rails 說上一個 create table 的 migration file 沒跑過呢?how does rails trac...

Wayne

little funny learn from ruby private

I usually make my private methods like this: ``` class Foo private def private_method end end ``` However, there is inline-style...

Wayne

Rails 不常用但可以變得很實用的 callback

## after_initialize && after_find ```ruby class User < ApplicationRecord after_initialize do |user| puts "You have initialized ...

Wayne

同時定義 class method 和 instance method 的潮潮寫法

You can delegate method to your `class` since your class is also a object in Ruby, interesting ```ruby class Foo def self.bar ret...

Wayne

slug 是啥意思?

https://stackoverflow.com/questions/4230846/what-is-the-etymology-of-slug 簡單說就是代稱的意思

Wayne

Rspec aggregate_failures syntax

意思就是在 aggregate_failures block 底下任一個的 expectation 有 error 時會針對每個 expectation 顯示 error 的 message example ```ruby it "returns false ...

Wayne

Git don't blame, we are asking for context bot blaming people

Nice little trick to avoid blaming mindset ``` ➜ ~ cat .gitconfig [alias] context = blame ```

Wayne

git bisect

debugging 的時候可以使用,原理就是 1. 先找到確定沒有問題的 commit 2. git bisect 會用二分法切換到中間的 commit,然後就可以 test 是否存在相同的 bug,持續使用二分法直到找到有問題的 commit

Wayne

PaperTrail whodunnit find object (ex: find User object)

PaperTrail::Verison object 的 methods 可以去 PaperTrail::VersionConcern 裡面查 查了一下沒有可以找到 whodunnit object 的方法,只好自己加一個: ```rb #initializers/p...

Wayne

釐清 DatabaseCleaner strategy 跟 clean_with

```rb config.before(:suite) do DatabaseCleaner.strategy = :transaction DatabaseCleaner.clean_with(:truncation) end ``` ### 釐清...

Wayne

rails table_name_prefix

```rb module Snapshot def self.table_name_prefix 'snapshot_' end end ``` ```rb class Snapshot::Schedule < ActiveRecord::Base e...

Wayne

想在 server 上持續性地跑個簡單的 script - screen

screen 進到 screen ```sh screen ``` Detach (離開 screen, 但是讓 screen 裡面的東西繼續執行) ``` ctrl+a d ``` Re-attach (重回 screen) ```sh screen ...

Wayne

RSpec best practice

https://github.com/thoughtbot/guides/tree/dee16052f49cb4b41fb8d090ffdb75942512ddb1/best-practices#testing https://robots.thoughtbot.c...

Wayne

Mutation in Ruby, it tells why more and more people like pure functional (immutable function)

Some mind blown examples: ```rb [1] pry(main)> list = Array.new(5, "foo") # => ["foo", "foo", "foo", "foo", "foo"] [2] pry(main)> list[...

Wayne

看到一個不錯的 mock example (RSpec)

之前一篇文章提到 RSpec 盡量不用 let, 那要用啥?可以用 method。 另外看到一個不錯的 mock example, 用 tap 來 return double 但是 yield Authentictor ```rb def stub_authentica...

Wayne

great feature spec example

```rb feature 'User views all books' do scenario 'list all books' do create(:book, title: 'Practical Vim') create(:book, titl...

Wayne

用 foreign_key 確保資料相依正確性 (referential integrity)

Rails 4.2 以後開始支援 database 的 foreign key,很好的文章: https://robots.thoughtbot.com/referential-integrity-with-foreign-keys 我們會用 ```rb class...

Wayne

避免在 migration 裡面用其他 class,最常誤用 model class

為什麼呢?因為 migration 是永久留在那裡的,但是某些 class 是在未來可能被刪掉的,所以一個好的 migration file 要能夠讓 scope 維持在 migration file 裡 > While migrations contain the fu...

Wayne

Test 4 phases

Setup -> Exercise -> Verify -> Teardown Setup: 準備資料 Exercise: 做事情 Verify: 確認事情正確執行 Teardown: 還原成 setup 前的狀態 好的 test 是依序執行這四個步驟 An...

Wayne

chmod 改變檔案權限

Linux檔案的基本權限就有九個,分別是owner/group/others三種身份各有自己的read/write/execute權限, 先複習一下剛剛上面提到的資料:檔案的權限字元為:『-rwxrwxrwx』, 這九個權限是三個三個一組的!其中,我們可以使用數字來代表各...

Wayne