Skip to content

Instantly share code, notes, and snippets.

View e7h4n's full-sized avatar
🎯
Focusing

Ethan Zhang e7h4n

🎯
Focusing
View GitHub Profile
<div>
<div>
<a href="" ng-click="expanded = true" ng-if="!expanded">展开</a>
<a href="" ng-click="expanded = false" ng-if="expanded">收起</a>
{{user.name}}
</div>
<div ng-if="expanded">
{{user.info}}
</div>
</div>

Node 出现 uncaughtException 之后的优雅退出方案

Node 的异步特性是它最大的魅力,但是在带来便利的同时也带来了不少麻烦和坑,错误捕获就是一个。由于 Node 的异步特性,导致我们无法使用 try/catch 来捕获回调函数中的异常,例如:

try {
    console.log('进入 try/catch');
    require('fs').stat('SOME_FILE_DOES_NOT_EXIST', function readCallback(err, content) {
        if (err) {
            throw err; // 抛出异常
// ProcessContainer.js
// Child wrapper. Redirect output to files, assign pid & co.
// by Strzelewicz Alexandre
var fs = require('fs');
var p = require('path');
var cst = require('../constants');
var worker = require('cluster').worker;
require('coffee-script');
<!DOCTYPE HTML>
<html lang="zh-CN" class="default-layout">
<head>
<link rel="icon" type="image/vnd.microsoft.icon" href="http://ytk.fbcontent.cn/s/c34fd141-favicon.ico">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<title>不支持的浏览器 - 猿题库 - 手机电脑做题就用猿题库</title>
<style type="text/css">
.wrap { text-align: center; margin-top: 170px; }
a { text-decoration: none; color: #A4BFDD; }
exports.orderList = function (req, res, next) {
var orderLogical = req.logical.bookOrder;
orderLogical.query(function (err, orders) {
if (err) {
return next(err);
}
res.locals.orders = orders;
res.render('book/page/OrderList');
});
'use strict';
var exception = require('../lib/exception');
var logger = require('../lib/logger');
var config = require('../lib/config');
/*jshint maxparams: false, unused: false */
module.exports = function (err, req, res, next) {
if (req.path.indexOf('/' + config.get('view').staticUrl) === 0) {
res.send(500, err);
/**
* DistributionChart.js, Jul 11, 2013
*
* Copyright 2013 fenbi.com. All rights reserved.
* FENBI.COM PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/**
* @author zhangyc <[email protected]>
*/
/**
* TrendChart.js, May 31, 2013
*
* Copyright 2013 fenbi.com. All rights reserved.
* FENBI.COM PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/**
* @author zhangyc <[email protected]>
*/
server {
listen 80;
server_name tarzan-dev.zhenguanyu.com;
location / {
root /Users/pw/workspace/tarzan-web;
autoindex on;
}
location /uni {
var filter = function (mustLogin) {
return function (req, res, next) {
req.command.execute('currentUser', function (err, response) {
if (err) {
next(err);
return;
}
if (mustLogin && response.statusCode >= 400) {
res.redirect('/login?redirect=' + encodeURIComponent(req.url));