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
Rx.Observable.throw(new Error('splut')) | |
.retryWhen(attempts => | |
Rx.Observable.range(1, 3) | |
.zip(attempts, i => i) | |
.mergeMap(i => { | |
console.log('delay retry by ' + i + ' second(s)'); | |
return Rx.Observable.timer(i * 1000); | |
}), | |
) | |
.subscribe(); |
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 Disqueue = require('disqueue-node'); | |
const Bluebird = require('bluebird'); | |
class Disq { | |
constructor(qname, options) { | |
this.q = new Disqueue(options || { | |
'port': 7711, | |
'retryMax': 5, |
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
// JS帮你计算属相 | |
// 背景:一个人出生在2014年的正月初一,他的生肖到底是属蛇还是属马呢?这就要确定那一天才是一年的开始。是春节还是立春?每年的春节是正月初一,但是生肖必须是从立春日开始计算。春节是1912年孙中山先生废除旧历,采用公元纪年之后的1914年,时任民国大总统的袁世凯颁布法令,每年的正月初一是春节,在此之前传统上都是以二十四节气的立春作为岁首。综上所属,2014年正月初一出生的应该是属蛇。 | |
// 既然知道了每年的立春日才是真正的生肖判断标准,那么怎么才能获取每年的立春日是多少呢? | |
// 网上有这么一个计算立春日的公式:[Y*D+C]-L | |
// 公式解读:Y:年数的后2位 D:常量0.2422 C:世纪值,21世纪是3.87 取整数减 L:闰年数。 | |
// 举例说明:2058年立春日期的计算步骤[58×.0.2422+3.87]-[(58-1)/4]=17-14=3,则2月3日立春 | |
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
// -------------------------------------------------- | |
// Flexbox LESS mixins | |
// The spec: http://www.w3.org/TR/css3-flexbox | |
// -------------------------------------------------- | |
// Flexbox display | |
// flex or inline-flex | |
.flex-display(@display: flex) { | |
display: ~"-webkit-@{display}"; | |
display: ~"-moz-@{display}"; |
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
/* 单行文字溢出时出现省略号,需设定宽度 */ | |
.fn-text-overflow { | |
overflow: hidden; | |
text-overflow: ellipsis; | |
white-space: nowrap; | |
} | |
/* clear fix hack */ | |
.clearfix() { | |
*zoom: 1; |
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
<?php | |
// 新建时间戳 | |
echo (new \DateTime)->format('Y-m-d H:i:s'); | |
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
// inline-block | |
.inline-block-compatible() { | |
display: inline-block; | |
*display: inline; | |
*zoom: 1; | |
} | |
// 最小高度 min-height | |
.min-height-compatible(@height) { | |
min-height: ~'@{height}px'; |
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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Document</title> | |
<link media="all" href="https://a.alipayobjects.com/??alice/base/1.0.0/base.css" rel="stylesheet"> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/backbone.js/1.0.0/backbone-min.js"></script> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.1/underscore-min.js"></script> | |
</head> |