This file contains hidden or 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
| server{ | |
| listen 80; | |
| server_name example.com; | |
| location / { | |
| proxy_pass http://0.0.0.0:8002; | |
| proxy_set_header Host $host; | |
| proxy_set_header X-Real-IP $remote_addr; | |
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
| } |
This file contains hidden or 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
| var mongoose = require('mongoose'); | |
| var Sequence = require('./sequence'); | |
| var pieceSchema = mongoose.Schema({ | |
| id: { type : Number, index: { unique: true } }, | |
| content: String, | |
| link: String, | |
| pics:[String] , |
This file contains hidden or 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 MyError(code, message) { | |
| this.code = code; | |
| this.message = message; | |
| } | |
| MyError.prototype = new Error(); |
This file contains hidden or 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
| // 好的写法 | |
| if ('count' in object) | |
| //判断DOM对象 IE8之前 DOM对象不从Object对象继承 需要判断 | |
| //判断实例需要使用hasOwnProperty | |
| if (object.hasOwnProperty("related")) { | |
| //非dom对象 | |
| } |
This file contains hidden or 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 getType(foo, type) { | |
| return Object.prototype.toString.call(foo) == "[Object " + type + "]" | |
| } | |
| //ES5 Array 有isArray方法 | |
| function isArray(value) { | |
| if (typeof Array.isArray === "function") { | |
| return Arrary.isArray(value); | |
| } else { |
This file contains hidden or 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 loadDialog(name, oncomplete) { | |
| var xhr = new XMLHttpRequest(); | |
| xhr.open("get", "/js/dialog/" + name, true); | |
| xhr.onreadystatechange = function(){ | |
| if (xhr.readyState == 4 && xhr.status == 200){ | |
| var div = document.getElementById("dlg-holder"); | |
| div.innerHTML = xhr.responseText; | |
| oncomplete(); |
This file contains hidden or 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 addListener(target, type, handler) { | |
| if (target.addEventListener) { | |
| target.addEventListener(type, handler, false) | |
| } else if (target.attachEvent) { | |
| target.attachEvent("on" + type , handler); | |
| } else { | |
| target["on" + type] = handler; | |
| } | |
| } |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>Show Hide Dropdown Using CSS</title> | |
| <style type="text/css"> | |
| ul{ | |
| padding: 0; | |
| list-style: none; | |
| } |
This file contains hidden or 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
| var mod = require('module'); | |
| module.exports = function module_exist(name){ | |
| /** | |
| * This is UGLY but since we're not allowed to require 'native_module' | |
| * this is the only way to test if a native module (or non-native module) exist. | |
| */ | |
| try{ | |
| require(name); | |
| } catch(err){ |
This file contains hidden or 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
| // 解决隐私模式下 localStorage 不正常问题 | |
| ;(function() { | |
| var KEY = '_localStorage_' | |
| , VALUE = 'test'; | |
| // 检测是否正常 | |
| try { | |
| localStorage.setItem(KEY, VALUE); | |
| } catch(e) { | |
| var noop = function() {}; |