Skip to content

Instantly share code, notes, and snippets.

View ywwwtseng's full-sized avatar

William ywwwtseng

  • LangLive
  • Taipei, Taiwan
View GitHub Profile
@ywwwtseng
ywwwtseng / color-terminal.md
Last active January 23, 2019 02:27
color terminal
@ywwwtseng
ywwwtseng / design-pattern-for-javascript.md
Last active January 23, 2019 02:36
design pattern for javascript

Javascript 設計模型

許多 Javascript 開發者努力編寫可讀性高、維護性高且復用性高的 Javascript 代碼,因為要寫出糟糕的 Javascript 代碼非常簡單。設計模型幫助我們結構與組織我們的 Javascript 代碼。每個設計模型都包含許多特性,了解各個設計模型能幫助我們寫出優雅的程式代碼。

設計模型是被驗證過的,它已經事先幫解決一些我們可能會遇到的問題。

Constructor Pattern

Gang of Four(有關於設計模型的書) 一書中沒有提及 Constructor Pattern,但我們在 Javascript 中建立一個新的物件時,Constructor Pattern 是很重要的概念。

git rm -r --cached .
git add .
git commit -m "fixing .gitignore"
@ywwwtseng
ywwwtseng / css-naming-conventions.md
Created December 20, 2017 07:14
css naming conventions

CSS Naming Conventions

Components

A page module that has a certain purpose and is a wrapper for its children.

Naming components

.component {…}
@ywwwtseng
ywwwtseng / mongodb-practice.md
Created December 12, 2017 08:05
Mongodb practice

Mongodb practice

Array Query Operators > $elemMatch (query)

Given the following documents in the scores collection:

{ _id: 1, results: [ 82, 85, 88 ] }
{ _id: 2, results: [ 75, 88, 89 ] }
@ywwwtseng
ywwwtseng / redirect-practice.js
Created December 12, 2017 07:56
Redirect practice
function redirect() {
res.writeHead({ location: 'https://www.example.org/' });
res.end();
}
@ywwwtseng
ywwwtseng / host-react-app-on-apache-server.md
Last active May 3, 2024 15:52
Host react application on Apache server

Host react application on Apache server

Step 1 : Create your app

$ npm install -g create-react-app 
$ create-react-app my-app

Step 2 : Build it for production

@ywwwtseng
ywwwtseng / redux.js
Last active January 7, 2019 01:58
Simple redux tutorial
// 以下用簡單的程式碼說明 Redux
/*
* 核心概念
*
* 1. 只使用一個 store 將整個應用程式的狀態 (state) 用物件樹 (object tree) 的方式儲存起來。
*
* 2. 唯一可以改變這個 state 的方法就是發送 action,這個 action 其實就只是一個物件告訴 state 該怎麼改變而已。
*
* 3. 實際因應 action 裡的內容對 state 做變化的函式叫做 reducer。
@ywwwtseng
ywwwtseng / mongodb-security.md
Last active August 22, 2017 02:51
Mongodb Security
@ywwwtseng
ywwwtseng / create-a-self-certified-certificate.md
Created August 21, 2017 08:47
Create a self-certified certificate

Create a self-certified certificate

For development purposes you can create a self-certified certificate.Here's how to do it on a linux-based system.

generate a private key

> openssl genrsa 1024 > key.pem