Skip to content

Instantly share code, notes, and snippets.

@ppxu
ppxu / quickSort.js
Last active January 11, 2017 14:45
function quickSort(arr) {
var lt = [],
gt = [],
pivot;
if (arr.length < 2) return arr;
pivot = arr.pop();
for (var i = 0, len = arr.length; i < len; i++) {
function sizeOf ( object ) {
var objects = [ object ];
var processed = [];
var size = 0;
for ( var index = 0; index < objects.length; ++index ) {
var _object = objects[ index ];
switch ( typeof _object ) {
case 'boolean':
size += 4;
function smartDate(originDate) {
let nowDate = new Date(),
isToday = false,
isYesterday = false,
isPastYear = false,
isPreviousYear = false,
originYear, originMonth, originDay, diffMinute, formatedDate;
originDate = new Date(originDate * 1000);
diffMinute = Math.round((nowDate.getTime() - originDate.getTime()) / (1000 * 60));
function formatDate(date, format) {
const o = {
'M+': date.getMonth() + 1, // 月份
'd+': date.getDate(), // 日
'H+': date.getHours(), // 小时
'm+': date.getMinutes(), // 分
's+': date.getSeconds(), // 秒
'q+': Math.floor((date.getMonth() + 3) / 3), // 季度
'f+': date.getMilliseconds() // 毫秒
}
@ppxu
ppxu / umd.js
Last active February 24, 2017 07:06
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define([DEPENDENCE], factory);
} else if (typeof module === 'object' && module.exports) {
module.exports = factory(require(DEPENDENCE));
} else {
root.YOURMOD = factory(root.DEPENDENCE);
}(this, function(DEPENDENCE) {
return {};
}));
@ppxu
ppxu / demo
Created September 27, 2012 06:17
custom html
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<link rel="stylesheet" href="css_example_url" />
<style></style>
<script src="http://a.tbcdn.cn/s/kissy/1.2.0/kissy.js"></script>
</head>
<body>