Skip to content

Instantly share code, notes, and snippets.

View tpai's full-sized avatar
🌴
On vacation in Spain

Tony Pai tpai

🌴
On vacation in Spain
View GitHub Profile
@tpai
tpai / eslint.md
Last active December 19, 2024 12:27
ESLint Cheatsheet

Install Dependencies

yarn add babel-eslint \
eslint \
eslint-config-airbnb \
eslint-loader \
eslint-plugin-import \
eslint-plugin-jsx-a11y \
eslint-plugin-react
@tpai
tpai / redux-saga.md
Last active July 21, 2016 15:26
Saga 的概念有點像 Event Loop,使用 take helpers 觀測 Trigger Action(load) 是否被 Dispatch,進而透過 Generator Function 使用 Call Effect 執行 Async Requests,再用 Put Effect 去 Dispatch 不同階段的 Action(loading, loaded, failed...) 以讓 UI 物件呈現出不同變化。

Learning Redux Saga With Simple Example

The concept of saga is like event loop, take effect/helpers for watching action, call effect for handling async request and put effect for dispatching different stage of actions(loading, loaded, failed...). Unlike thunk get invoked on every actions, saga only run once at the start and process watching in the background. About saga and thunk, two of the most common differences are async task could be cancelled at any moment, and the structure of saga is easy for developer to test different stage of actions.

###Flow

Update specific article title of list:

  1. Keep watching
  2. Component dispatch UPDATE_TITLE action
@tpai
tpai / config.md
Last active June 24, 2016 04:04
the webpack settings you should know when developing isomorphic app

Isomorphic App 開發要注意的 Webpack 設定

前情提要

鍵盤發電機是當初與 @steveice@vansteki 參加百度黑客松 2013 時的作品,後端技術有 Node.js & Express & Socket.io,前端技術則是 jQuery,現在要對這個專案進行重構。

前端後端設定大不同

@tpai
tpai / requirements.md
Last active October 13, 2016 06:29
My work requirements

開發相關

專案

  • devops
  • Scrum: Jira
  • Kanban: Trello

溝通

@tpai
tpai / note.md
Created May 18, 2016 07:54
general frontend attack

前端常見的網站攻擊

  • ClickJacking: 利用視覺誤判誘導使用者點擊按鈕或連結引導至其它頁面。
  • XSS: 將語法注入網站(儲存型),或透過網站發出(反射型),在使用者不自覺的情況下致使瀏覽器執行該語法。
  • CSRF: 利用受信任的使用者在夾帶驗證資訊的情況下發出非法請求。

Ref:

Recently, I'm writing React.js unit test, it confused me for a while when need to stub React component method with expect spy.

Without Class Properties

export default class Sample extends React.Component {
    sampleMethod() {
        console.log("SAMPLE");
    }
 render() {
@tpai
tpai / nextvod.md
Last active May 3, 2016 15:44
improve no use nextvod box

Improve NextVOD

I don't know how to deal with NextVOD box since NextTV abandoned this service, and there's a group of people make this box live again but with difference uses.

Basic

  1. sh4twbox
@tpai
tpai / Vagrantfile
Last active April 17, 2018 09:57
Docker and Vagrant
Vagrant.configure(2) do |config|
config.vm.box = 'ubuntu/xenial64'
config.vm.network 'forwarded_port', guest: 3000, host: 3000
config.vm.network 'private_network', ip: '10.10.10.10'
config.vm.provider 'virtualbox' do |vb|
vb.name = 'repo_name'
vb.auto_nat_dns_proxy = false
vb.customize ["modifyvm", :id, "--natdnsproxy1", "off" ]
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "off" ]
vb.memory = '4096'
@tpai
tpai / extend.md
Last active April 12, 2016 09:10
Design Pattern Learning Note

Classical / Modern Extend Pattern

Classical 在此並不是指傳統或者是經典,而是書中作者用來代表與 Class 相關的意思。而 Modern 則沒其他用意,就是指現在常用的意思。

Recommend Book: Learning Javascript Design Patterns

推薦書籍:Javascript 設計模式

The prototype pattern focuses on creating an object that can be used as a blueprint for other objects through prototypal inheritance. This pattern is inherently easy to work with in JavaScript because of the native support for prototypal inheritance in JS.