2018年8月19日 星期日
setup ubuntu with ansible for rails deployment
https://semaphoreci.com/community/tutorials/how-to-deploy-rails-applications-with-ansible-capistrano-and-semaphore
標籤:
Deployment,
Developer Tools,
ROR,
Server
2018年8月13日 星期一
JSON API 什麼時候用 included 什麼時候用 relationships
resource 有可能在兩邊都出現,relationships 出現的原因是給 API user 知道有哪些相關連資料,但不一定要給 data details。而 included 則是把關聯資料的 details 也一次回傳。
https://stackoverflow.com/questions/35991897/json-api-questions-included-vs-relationships
2018年8月2日 星期四
虛擬價值與證券化
Ex:
公司送禮
月餅廠商印 100 元的月餅卷賣 65 給經銷商
經銷商賣 80 給公司讓公司送員工
員工用 40 把月餅卷賣給票販子
月餅廠商用 50 再跟票販子收購月餅券
對員工而言的情感(虛擬)價值: 60
員工的實體價值:40
月餅廠商賺 15
票販子賺 10
單純情感(虛擬)價值利用證券化的方式來交換,不需要生產任何月餅。
retrospective meeting
Some good handy tips
https://www.atlassian.com/team-playbook/plays/retrospective
https://www.atlassian.com/team-playbook/plays/retrospective
2018年7月22日 星期日
不要在 rake task 裡定義 method
因為 rake task 的 scope 是 global 的,如果在裡面定義 method 等於是為 Object class 定義 private method,污染全部的 code
可行的做法之一是把要跑的 task 寫成 service 執行
另外推薦的做法是使用 `Rake::DSL`
```ruby
# lib/tasks/bicycle.rake
class BicycleTasks
include Rake::DSL
def initialize
namespace :bicycle do
task :assemble do
bicycle = Bicycle.new
# Assemble the bicycle:
attach_wheels(bicycle)
attach_handlebars(bicycle)
attach_brakes(bicycle)
end
end
end
private
def attach_wheels(bicycle)
# ...
end
def attach_handlebars(bicycle)
# ...
end
def attach_brakes(bicycle)
# ...
end
end
# Instantiate the class to define the tasks:
BicycleTasks.new
```
https://supergood.software/dont-step-on-a-rake/
2018年7月8日 星期日
Xcode Storyboard and NSCoder (Codable in swift)
.plist file 是一個 xml 格式的文件,意思是 Property List
Swift 可以用 Codable protocol 來處理這類文件
而 Xcode 的 Storyboard 也是類似的方式處理 View,只是用的是 OC 的 NSCoder
每當我們在 Storyboard 上更改什麼東西時,就會透過 NSCoder 轉換(encoding)成 Property 存在某個 .plist 文件裡,而當 App 啟動時則再用 NSCoder 讀取這些 Property 再轉化(decoding)為 UI 元件。
其實角色就像是 serializer
2018年7月7日 星期六
Swift weak keyword
weak keyword 是為了避免 ownership cycle,所謂 ownership cycle 就是當 Object A reference Object B 而 Object B 又 reference Object A 時,兩個 Objects 就會都無法釋放(Object 只有在沒有 strong reference 時才會被回收)
如果 Object 只有weak references ,也是會被回收。
所以此例 A 跟 B 其中一個用 strong reference 另一個用weak 就可以了
通常要用weak的地方就是 delegate
當然 UI 的東西也常常用 weak,但那是為了強調「ViewController」並不是 View Outlet 的 owner。
另外還有一個 keyword 叫做 unowned,下次再介紹
訂閱:
文章 (Atom)