Skip to content

Instantly share code, notes, and snippets.

View pjchender's full-sized avatar

Aaron Chen pjchender

View GitHub Profile
@pjchender
pjchender / validate_object.js
Last active July 13, 2017 14:04
Snippet - Validation Object with Required
/**
* 利用 validate function 可以驗證 object 中的必填欄位有無填寫
**/
// object validation rules
const schema = {
firstName: {
required:true
},
lastName: {
@pjchender
pjchender / README.md
Created July 31, 2017 02:31
Gulp BrowserSync
tags: gulp, browsersync, browser reload, autoreload

This is a simple web server for auto browsersync.

@pjchender
pjchender / computer_science_terms.md
Last active October 25, 2022 04:59
[CS] Computer Science 專有名詞(繁簡對照)

[CS] Computer Science 專有名詞(繁簡對照)

英文 台灣(繁體) 中國(簡體)
Array 陣列 數組
Object 物件 對象
variable 變數 變量
literal 字面量
expression 表達式 表達式
statement 陳述式 陳述式/語句
@pjchender
pjchender / getLocations.js
Last active February 9, 2018 07:24
取得全國藝文活動展演場地
/* eslint-disable */
const request = require('request')
const cheerio = require('cheerio')
const async = require('async')
const path = require('path')
const fse = require('fs-extra')
let getLocationURL = 'https://event.moc.gov.tw/'
let pageSize = '100'
@pjchender
pjchender / README.md
Created February 25, 2018 04:34
好文收藏 by PJCHENder
@pjchender
pjchender / package.js
Created May 18, 2018 02:24
Webpack 4 常用設定
// package.json
{
"name": "webpack-sandbox",
"sideEffects": false,
"version": "1.0.0",
"description": "",
"private": true,
"scripts": {
"build": "webpack -p",
"watch": "webpack --watch", // 當檔案有變更時會重 build
@pjchender
pjchender / _form.html.erb
Created July 23, 2018 09:36
Quill + Rails + Stimulus
<!-- ./app/views/posts/_form.html.erb -->
<div class="form-group mb-3">
<%= content_fields.label :body, class: 'col-form-label' %>
<div data-controller="quill-editor">
<div data-target="quill-editor.container" style="min-height: 250px;"></div>
<%= content_fields.text_area :body, class: 'form-control d-none', placeholder: 'Content' %>
</div>
</div>
@pjchender
pjchender / Async Await 基本使用.js
Last active November 28, 2023 12:38
Promise and Async/Await Example
// async function 本身會回傳 Promise,
// 因此 async function 之後也可以用 `.then()` 串起來
main().then(value => {
console.log(value);
});
async function main () {
console.log('start fn') // STEP 1-1
let val = await get() // STEP 1-2
@pjchender
pjchender / MDN 上的範例.js
Last active August 10, 2018 09:02
[AC] constructor function and prototypal inheritance
function Person(name, interests) {
this.name = name;
this.interests = interests;
};
Person.prototype.greeting = function() {
console.log(`Hi! I'm ${this.name}.`);
};
function Teacher(name, interests, subject) {
@pjchender
pjchender / create object.js
Last active August 8, 2018 15:34
[AC] Object creating and constructor function
let alphaPhoneX = {
name: 'AlphaPhoneX', // String
price: 14999, // Number
features: ['long battery life', 'AI camera'], // Array
showSpec: function() { // Function
console.log('show the spec of the phone')
},
hardware: { // Object
ram: '8GB',
storage: '64GB'