This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 適用場景:偵測 input 做搜尋或自動完成 | |
// inputEl.addEventListener('keyup', debounce(func, 500)); | |
function debounce(func, delay = 200) { | |
let timer = null; | |
return (...args) => { | |
if (timer) clearTimeout(timer); | |
timer = setTimeout(() => { | |
func.apply(this, args); | |
}, delay); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function inherit(Child, Parent) { | |
// 繼承原型上的屬性 | |
Child.prototype = Object.create(Parent.prototype); | |
// 修復 constructor | |
Child.prototype.constructor = Child; | |
// 儲存超類別 | |
Child.super = Parent; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MyPromise.prototype.catch = function(catchFunc) { | |
return this.then(null, catchFunc) | |
} | |
MyPromise.resolve = function(value) { | |
return new MyPromise((resolve, reject) => { | |
resolve(value); | |
}) | |
} | |
MyPromise.reject = function(value) { | |
return new MyPromise((resolve, reject) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require('http'); | |
exports.handler = function(event, context, callback) { | |
const option = { | |
"hostname": "api.ipify.org", | |
"path": "/?format=JSON", | |
"method": "GET" | |
}; | |
callback(null, Request(option). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lambda: | |
npm install . | |
@echo "Factory package files..." | |
. . . . . . . | |
@echo "Create package archive..." | |
@cd build && zip -rq aws-lambda-image.zip . | |
@mv build/aws-lambda-image.zip ./ | |
uploadlambda: lambda | |
@if [ -z "${LAMBDA_FUNCTION_NAME}" ]; then (echo "Please export LAMBDA_FUNCTION_NAME" && exit 1); fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// [START initialize_firebase_in_sw] | |
// Import and configure the Firebase SDK | |
// These scripts are made available when the app is served or deployed on Firebase Hosting | |
// If you do not serve/host your project using Firebase Hosting see https://firebase.google.com/docs/web/setup | |
importScripts('https://www.gstatic.com/firebasejs/5.0.0/firebase-app.js'); | |
importScripts('https://www.gstatic.com/firebasejs/5.0.0/firebase-messaging.js'); | |
firebase.initializeApp({ | |
messagingSenderId: '<YOUR_SENDER_ID>' | |
}); | |
const messaging = firebase.messaging(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div> | |
... | |
<button @click="registeFCM">Register</button> | |
... | |
</div> | |
</template> | |
<script> | |
import 'firebase/messaging' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const FCMconfig = { | |
apiKey: 'YOUR_API_KEY', | |
authDomain: 'YOUR_DOMAIN', | |
databaseURL: 'https://<YOUR_PROJECT_ID>.firebaseio.com', | |
projectId: 'YOUR_PROJECT_ID', | |
storageBucket: '<YOUR_PROJECT_ID>.appspot.com', | |
messagingSenderId: 'YOUR_SENDER_ID' | |
} | |
firebase.initializeApp(FCMconfig) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.cssLoaders = function (options) { | |
options = options || {} | |
const cssLoader = {...} | |
const postcssLoader = {...} | |
function generateLoaders (loader, loaderOptions) {...} | |
// ========= | |
// SASS 配置 | |
// ========= | |
function resolveResouce(name) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { shallow, createLocalVue } from '@vue/test-utils' | |
import Vuex from 'vuex' | |
import VueI18n from 'vue-i18n' | |
import i18n from '@/i18n' | |
import router from '@/router' | |
// Component | |
import Login from '@/pages/Login' |
NewerOlder