Skip to content

Instantly share code, notes, and snippets.

View pjchender's full-sized avatar

Aaron Chen pjchender

View GitHub Profile
@pjchender
pjchender / transition-mobile-menu.html
Last active May 1, 2017 14:06
[Flycan][CSS] lightbox, mobile-menu by transition
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<title>Document</title>
<style type="text/css">
*{
margin: 0;
@pjchender
pjchender / render-error-1.html
Last active April 30, 2017 14:55
[Vue] 生命週期與 AJAX 使用說明
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Demo Vue</title>
<script src="https://unpkg.com/vue@2.3.0/dist/vue.js"></script>
<script src="https://unpkg.com/axios@0.16.1/dist/axios.js"></script>
</head>
<body>
@pjchender
pjchender / app.html
Created May 17, 2017 02:19
[Vue] Vue + Webpack 起手式
<!-- app.vue -->
<template lang="html">
<div class="message">
{{ message }}
{{ ok }}
</div>
</template>
<script>
@pjchender
pjchender / module_pattern.js
Last active May 22, 2017 14:13
[Node][Unit26] Module Pattern
/* eslint-disable */
/**
* PATTERN 1
**/
module.exports = function() {
console.log('Hello world');
};
@pjchender
pjchender / app.js
Last active May 22, 2017 14:13
[Node][Unit33] 模擬 Event Emitter
const Emitter = require('./emitter')
let emtr = new Emitter()
emtr.on('greet', function () {
console.log('Somewhere, someone said hello')
})
emtr.on('greet', function () {
console.log('A greeting occurred')
@pjchender
pjchender / app.js
Last active May 22, 2017 14:12
[Node][Unit34] Putting string variable in configuration.js
const Emitter = require('events')
const eventsConfig = require('./config').events
let emtr = new Emitter()
emtr.on(eventsConfig.GREET, function () {
console.log('Somewhere, someone said hello')
})
@pjchender
pjchender / app.js
Last active May 22, 2017 15:10
[Node][Unit36] 使用 util.inherits 來繼承 EventEmitter 的方法
// 使用 util.inherits 來繼承 EventEmitter 的方法
const EventEmitter = require('events')
const util = require('util')
function Greetr () {
// 如果我們想要完整繼承 EventEmitter 中的屬性
EventEmitter.call(this)
this.greeting = 'someone greet'
}
@pjchender
pjchender / app.js
Created May 22, 2017 14:22
[Node][Unit 38] Call and Apply
let obj = {
name: 'Aaron Chen',
greet: function () {
console.log(`Hello ${this.name}`)
}
}
obj.greet()
obj.greet.call({name: 'Andy Chang'})
@pjchender
pjchender / authenticate.js
Last active June 21, 2017 07:25
Dive into Passport JS
// ./node_modules/passport/lib/middleware/authenticate.js
/**
* Module dependencies.
*/
var http = require('http'),
IncomingMessageExt = require('../http/request'),
AuthenticationError = require('../errors/authenticationerror')
/**
@pjchender
pjchender / post-vm.js
Last active June 22, 2017 10:24
Vue Reactivity Demo
const request = window.superagent;
const root = "https://jsonplaceholder.typicode.com";
const postVm = new Vue({
el: "#post",
data: {
post: {
userId: "",
id: "",
title: ""