Mac: add ssh key to ssh-agent

```sh $ ssh-add -K ~/.ssh/id_rsa ``` https://help.github.com/en/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent

Wayne

Rails 直接取得欄位的值(before_type_cast)

How to get column value from ActiveRecord without being affect by overrided attributes? 有時候會想要直接取得 database 裡的值,以免被 model 裡覆蓋的 attribute...

Wayne

Function Composition in Ruby

Ruby 2.6 introduced `<<` and `>>` methods, this article explains function composition and history of Ruby new methods throughoutly, wort...

Wayne

How to test with Salesforce Heroku Connect

## What is Heroku Connect? This is a tool provided by Salesforce and Heroku, it will automatically sync all your salesforce tables int...

Wayne

Startup idea checklist

回答完後覺得值得再去做 https://www.defmacro.org/2019/03/26/startup-checklist.html

Wayne

What’s Object Marshalling?

## What’s Object Marshalling? Object Marshalling 將資料轉換,用在不同程式間傳輸,就稱為 Object Marshalling (序列化) 例如 Sidekiq 會把 Object 變成 JSON 存進 ...

DNS Challenge for HTTPs

簡而言之 你要在DNS加一筆record 每次更新他會要求你放不同的值 https://community.letsencrypt.org/t/i-am-confused-about-dns-challenge/18754

Wayne

sidekiq-scheduler and sidekiq-cron

There are 2 popular cron task gem for sidekiq, I find [sidekiq-scheduler](https://github.com/moove-it/sidekiq-scheduler) has more powerfu...

Wayne

在 middleware 裡塞 user 給 sidekiq 就不用每次傳

我個人是不喜歡啦,但可以參考一下有趣的作法 https://blog.bigbinary.com/2018/12/05/passing-current-user-by-default-in-sidekiq.html

Wayne

ignore and untrack committed file with git

``` git rm --cached config/database.yml ``` https://www.git-tower.com/learn/git/faq/ignore-tracked-files-in-git https://askjong.com/howt...

Wayne

Linux 防火牆: iptables

搜尋 linux 防火牆的話就會看到 `iptables` 和 `ufw`,常常會誤認為有兩個防火牆軟體,但其實不是,因為 `ufw` 只是 `iptables` 的 CLI 而已,參考: https://ubuntuforums.org/showthread.php?t=...

Wayne

Dump production database to local with Rails

```rb # lib/tasks/db/pull.rake # # Usage # # dump the development db # rake db:dump # # dump the production db # RAILS_ENV=production r...

Wayne

ActiveSupport::Inflector#parameterize

好用的 helper ```rb "123-this-is-標題-haha".parameterize #=> "123-this-is-haha" ``` 很適合拿來做 friendly url 的簡單解決方案 ```rb class Post < Applica...

Wayne

Rails disable some unwanted generators

Rails 常常會自動產生一些不需要的檔案,可以在 generator 裡面設定,放在 `config/application.rb` 裡面就行 記錄一下個人常用的設定 ```ruby # factory_bot config.generators do...

Wayne

Heoku pipeline stateless builds

Heroku pipeline 從 staging promot 到 production 的時候會把 compile 過的 file 一起 copy 過去,所以如果用到 Node + Webpack 讀取環境變數再 compile 成 js 的 file 就會吃到 st...

Wayne

在 Rails 使用 custom font

參考 https://coderwall.com/p/v5c8kq/web-fonts-and-rails-asset-pipeline 把檔案放到 `app/assets/fonts` 裡面 然後在 `application.scss` 裡加上 ```scss @...

Wayne

Ruby instance_eval & block

```rb class Test def initialize(&block) @name = "Hello World" instance_eval(&block) if block_given? end def name @n...

Wayne

Ansible + rails + letsencrypt

First, install nginx roles/nginx/tasks/main.yml ```yml - name: Install nginx apt: name: nginx state: latest - name: Disable ...

Wayne

Implement algolia autocomplete with rails

```js // app/javascripts/application.js const algoliasearch = require('algoliasearch/lite') const autocomplete = require('autocomplete....

Wayne

Integrate Uppy with Rails and ActiveStorage and use google drive direct upload

We're going to integrate Uppy with "upload from Google Drive" feature with rails backend and ActiveStorage, in this case we are going to ...

Wayne

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...

Wayne

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 <...

Wayne

Surfing tutorial video & tips

覺得講得不錯 https://surfsimply.com/surf-simply-tutorials/ ## Tips 初學: * Pop up 的速度來自於 gravity * 追浪的兩個重點:板的位置和速度 * 板的位置:追浪時盡量身體重心向前才有重力...

Wayne

常問的面試問題

目的是找出適合團隊的人,不是找牛人,所以我面試的時候會看溝通能力、合作能力大於技術能力,技術只需要達標就好,通常技術是否達標可以從討論 general tech concept 的時候就知道,最簡單的方法就是看對方對之前做的 project 的技術理解程度,我通常會問的問...

Wayne

My hiring strategy

很多 startup 都會說「我們只找最好的人」,我覺得這根本是屁話,哪有所謂最好的人,只有「在這個時間範圍內我能夠遇到的最適合團隊的人」而已,很繞口對吧?XD 讓我拆解並解釋一下這句話: 1. 首先是「在這個時間範圍內」,因為招人是有時間限制的,你只能遇到在這個時間...

Wayne