Using marked.js with hightlight.js in rails to provide github flavored markdown to github style html
In this example, I'll use webpacker to import highlight js and marked js and css file, you can use cdn as well. `app/javascripts/appli...
Import css from npm module in rails with webpacker
I use highlight.js In `app/javascripts/styles.js` ```js import 'highlight.js/styles/github.css'; ``` And then add to layout ```erb <...
Surfing tutorial video & tips
覺得講得不錯 https://surfsimply.com/surf-simply-tutorials/ ## Tips 初學: * Pop up 的速度來自於 gravity * 追浪的兩個重點:板的位置和速度 * 板的位置:追浪時盡量身體重心向前才有重力...
常問的面試問題
目的是找出適合團隊的人,不是找牛人,所以我面試的時候會看溝通能力、合作能力大於技術能力,技術只需要達標就好,通常技術是否達標可以從討論 general tech concept 的時候就知道,最簡單的方法就是看對方對之前做的 project 的技術理解程度,我通常會問的問...
How to do a 1on1
## General Tips: - 提早約時間,盡量按照 schedule ,給對方準備時間 - 1 on 1 前先問券問重點問題 - 多問問題, 不要過早下定論 (judge) - 結束時要有結論(如果可以有可量化的 task 最好) ## SOP: 0. 提...
My hiring strategy
很多 startup 都會說「我們只找最好的人」,我覺得這根本是屁話,哪有所謂最好的人,只有「在這個時間範圍內我能夠遇到的最適合團隊的人」而已,很繞口對吧?XD 讓我拆解並解釋一下這句話: 1. 首先是「在這個時間範圍內」,因為招人是有時間限制的,你只能遇到在這個時間...
Rails schema 到底怎麼保持乾淨
在不能 access production database 的情況下: 1. 怎麼保持 local database schema 是乾淨的 2. 如果髒了,怎麼恢復成乾淨的而且不影響現在 local 有的資料(乾淨的資料恢復,不乾淨的就丟掉) ## Idea 1...
How to keep forked git repo up to dated?
### 1. Clone your fork: git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git ### 2. Add remote from original repository in...
JSON API 什麼時候用 included 什麼時候用 relationships
resource 有可能在兩邊都出現,relationships 出現的原因是給 API user 知道有哪些相關連資料,但不一定要給 data details。而 included 則是把關聯資料的 details 也一次回傳。 https://stacko...
retrospective meeting
Some good handy tips https://www.atlassian.com/team-playbook/plays/retrospective
虛擬價值與證券化
Ex: 公司送禮 月餅廠商印 100 元的月餅卷賣 65 給經銷商 經銷商賣 80 給公司讓公司送員工 員工用 40 把月餅卷賣給票販子 月餅廠商用 50 再跟票販子收購月餅券 對員工而言的情感(虛擬)價值: 60 員工的實體價值:40 月餅廠商賺 15 票販子賺 ...
不要在 rake task 裡定義 method
因為 rake task 的 scope 是 global 的,如果在裡面定義 method 等於是為 Object class 定義 private method,污染全部的 code 可行的做法之一是把要跑的 task 寫成 service 執行 另外推薦的做法是...
Xcode Storyboard and NSCoder (Codable in swift)
.plist file 是一個 xml 格式的文件,意思是 Property List Swift 可以用 Codable protocol 來處理這類文件 而 Xcode 的 Storyboard 也是類似的方式處理 View,只是用的是 OC 的 NSCoder ...
Swift weak keyword
weak keyword 是為了避免 ownership cycle,所謂 ownership cycle 就是當 Object A reference Object B 而 Object B 又 reference Object A 時,兩個 Objects 就會都無法...
reset password token leaking
reset password 的網址常常是 https://yourdomain/password/reset?token=xxxx 但這樣就會被第三方網站從 `HTTP Referer` 內找到並紀錄起來 reset password 的 token,例如 googl...
Swift 回收 memory 的機制 - ARC
Automatic Reference Counting 字面意思就是看 object 被 reference 多少次,沒被 reference 就回收 https://tommy60703.gitbooks.io/swift-language-tradit...
NSRange vs. Range and NSString vs. String
NSRange 是 Objective-C 的 Range, Range 則是 Swift 的 Range,是不同的結構。 但是 iOS API 內因為歷史因素都是給 NSRange ,所以通常要 cast 一下,例如: ```swift func textFiel...
iOS 在 screens 之間傳資料
所謂 screens 之間就是 ViewControllers 之間,這裡討論的是 A screen 叫出了 B screen,但 B screen 想要送資料回 A screen 時該怎麼做。 通常如果是 A controller contains B contro...
讀書筆記 - 鉤癮效應 Hooked - Nir Eyal
習慣指的是想都不用想就能進行的行為,且習慣是可以刻意製造的,方式是 習慣不是創造出來的,而是累積出來的 觸發(內在與外在)-> 行動 -> 變動獎賞 -> 投入 ## 觸發 一開始都是外在觸發,例如文章、廣告、通知等等 然後藉由刻意製造的習慣讓使用者開始有內在觸發...
rails model conditional validation 的神奇用法 extend
lol, 沒想過可以這樣 ```ruby user = User.find(id) user.extend(User::RegistrationContext) ``` ```ruby # app/models/user/registration_context.rb ...
Sam Altman co-found 的公司 Open AI 在強化學習 (Reinforcement Learning)上有了進展
http://blog.samaltman.com/reinforcement-learning-progress Sam Altman co-found 的公司 Open AI 在強化學習上有了進展,證明專精於特定領域的強化學習演算法可以有效的解決問題,在這篇文章中 D...
growth engineering at Netflix
用 API 控制前端 signup 時要顯示的 fields,算是 API 控制 UI 的一種方法,有趣 https://medium.com/netflix-techblog/growth-engineering-at-netflix-accelerating-inn...
Suspender 用 1.46.0 可以使用 rails 5.1.6
ThoughtBot 的 rails bootstraper,現在最新版 default 使用了 rails 5.2 很煩,因為我不喜歡 5.2 的 credential 要使用 5.1.x 版本的話要用 v1.46.0 版本的 Suspender,但 1.46.0 是用...
Rails where.not 的寫法會略過欄位是 Null 的值
`where.not` 的寫法會略過欄位是 Null 的值,所要對有可能是 Null 值的字串欄位使用 `where.not` 有兩個做法: 1. default 空字串 2. 使用 `or` 另外如果是 boolean 欄位但有可能是 null (雖然一開始就不應該這...
Conway's Game of Life
今年 Ruby Kaigi 看到 Matz 參加 live pair 做 Conway's Game of Life,才發現我常常聽到這個詞但從來沒去研究這到底是啥、為何這麼多人都知道 所以去查了一下,原來是一個模擬細胞生存的遊戲,吸引人的點在於這個遊戲可以有很多變體...