比較 websocket 和其他技術,以及解釋action cable 的好文

大意 http stateless - polling - long polling - server send event websocket stateful - 2 ways - simultaneous communication - hard to loa...

Wayne

reddit 上的 rails performance 總結

The Complete Guide to Rails Performance 這本書 https://www.railsspeed.com/ 的總結: * Measure. If you have a serious project a cost of NewRelic...

Wayne

管理 dotfile 的方法

https://developer.atlassian.com/blog/2016/02/best-way-to-store-dotfiles-git-bare-repo/ 和 dotfile manager https://github.com/TheLocehili...

Wayne

實做 graphql api 的各種眉角

這篇文章提到了很多實做 graphql api 的各種眉角,都是很 practical 的,值得參考 https://blog.codeship.com/graphql-and-performance-in-rails/

Wayne

k8s + docker + google cloud

### Docker ``` docker build -t wayne5540/poloniex-toy . docker run -p 49160:3000 -d wayne5540/poloniex-toy ``` Go to `http://localhost...

Wayne

docker

* 看 images ``` docker images ``` * remove images ``` docker rmi <IMAGE_ID> ``` * 建立 image ``` docker build -t <your username>/node...

Wayne

炒幣須知金融術語

- limit - 一般的買賣,自己設定買價賣假,match 到就成交 - market - 以現在市場價買入賣出 - stop - 市場價格到了某一個點之後,以市場價賣出一定數量的幣 - stop limit - 市場價格到了某一個點之後,以自己設定的買賣價開始買賣幣...

Wayne

用 screen 在 server 執行程序

screen 可以讓程序在背景跑,不會因為斷線而結束 https://blog.gtwang.org/linux/screen-command-examples-to-manage-linux-terminals/

Wayne

bitcoin address validation

第一時間會想到用正規表示來驗證 正式 chain 的 regex ``` \A[13][a-km-zA-HJ-NP-Z1-9]{25,34}\z ``` Test net 的 regex ``` \A[2mn][1-9A-HJ-NP-Za-km-z]{26,35}\...

Wayne

在 Geth js console send ether

http://faucet.ropsten.be:3001/ ``` miner.setEtherbase("0xe7c2be3d07217101aeced9d68400cd142acb3d2f") personal.unlockAccount(eth.coinbas...

Wayne

SSO single sign on

About SSO single sign on https://auth0.com/docs/sso/current TL;DR: 在 A 登入後自動登入 B,反之亦然

Wayne

learn truffle and solidity - pet shop - note

* Public variables have automatic getter methods * array getters return only a single value from a given key * this, a contract-wide vari...

Wayne

什麼是 ERC20 token

先說明 ERC-20 Token erc20 是公認的 token interface, 定義了一個 token 應該要有哪些 functionalities,原始提案在這:https://github.com/ethereum/EIPs/issues/20 基本上有...

Wayne

rails 5 better redirect_to :back -> redirect_back(fallback_location: root_path)

redirect_back(fallback_location: root_path) http://blog.bigbinary.com/2016/02/29/rails-5-improves-redirect_to_back-with-redirect-back.h...

Wayne

Deploy contract from truffle to testnet

Truffle 設定新的 network Geth 開啟 test net Deploy! In geth console ``` personal.unlockAccount(eth.accounts[0]) ``` ```sh truffle migrate -...

Wayne

Rails query tips

Exist 滿酷的用法之前沒想過 ```ruby # Post scope :famous, ->{ where("view_count > ?", 1_000) } # User scope :without_famous_post, ->{ where(_no...

Wayne

DATETIME 和 TIMESTAMP 的差別

這邊說的是 database type 幾個結論 1. datetime 存了 date 和 time,可能用到 8 bit 2. datetime 可以支援的 range 比較廣,從 1000~9999 years 都可以 3. timestamp 則是存從 epoc...

Wayne

怎麼在 rake task 裡面跑 task

最簡單: ```ruby task build: [ "migration:t15349:create_init_version_for_all_accounts", "migration:t15349:migrate_account_version", "migrati...

Wayne

Rails 5 support CURRENT_TIMESTAMP

rails5 現在 support CURRENT_TIMESTAMP 成為 default value 的寫法,但 annotate_model 的 gem 好像不會自動偵測到 ```ruby class CreatePosts < ActiveRecord::Migr...

Wayne

rails 可以自己定義 model callback

滿實用的,但應該少用,正常的 lifecycle 能夠滿足就不應該增加新的東西 想到最有可能會用的的地方就是搭配 sub/pub design pattern 的時候,例如 publish 後要 broadcast `published` event http://vi...

Wayne

Metaprograming 做 after method callback

Magic ```ruby class Example def self.after(*names) names.each do |name| m = instance_method(name.to_s) # override ol...

Wayne

postgresql explain

可以看 sql 的複雜度和 cost,很方便的 sql command https://www.postgresql.org/docs/9.4/static/using-explain.html

Wayne

devise and warden - 登入失敗寄信

使用 lockable 或是不使用 lockable 都行 `DeviseController#require_no_authentication` 時會 call `warden.authenticate?`,這時會引發 `Lockable#valid_for_aut...

Wayne

gem open gem_name -e editor

好方便的功能,不用再自己 clone 了 https://github.com/adamsanderson/open_gem

Wayne

CSS Grid

推薦連結: https://www.youtube.com/watch?v=txZq7Laz7_4&feature=share TL;DR: CSS grid 先把畫面切隔成不同的區塊後再把 content 丟到區塊裡,符合設計直覺 只套用第一層子元素 做 RWD ...

Wayne