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
var MongoClient = require('mongodb').MongoClient; | |
var mg = require('../config').mongodb; | |
var DB = function(){ | |
this.url = "mongodb://" + mg['host'] + ":" + mg['port'] + "/" + mg['database']; | |
}; | |
module.exports = new DB; | |
DB.prototype.connect = function(cb){ |
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
/** | |
* @author 靖鸣君 | |
* @email barret.china@163.com | |
* @description 滚动 | |
* @class Marquee | |
* @param {Object} | |
*/ | |
var Marquee = function(){ | |
this.direction = "top"; | |
this.speed = 30; |
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 db = require('double-bits'); | |
const pad = require('pad'); | |
// [lo, hi] where lo is a 32 bit integer and hi is a 20 bit integer. | |
const base2Str = (n) => { | |
const f = db.fraction(n); | |
const s = db.sign(n) ? '-' : ''; | |
const e = `2^${db.exponent(n) + 1}`; | |
const t = `0.${pad(f[1].toString(2), 20, '0')}${pad(f[0].toString(2), 32, '0')}`; | |
return `${s}${e} * ${t}`; |
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
<script src="http://cdn.staticfile.org/socket.io/1.3.7/socket.io.js"></script> | |
<script src="http://cdn.staticfile.org/jquery/2.2.1/jquery.min.js"></script> | |
<script> | |
function htmlspecialchars(str){ | |
str = str || ''; | |
str = str.replace(/&/g, '&'); | |
str = str.replace(/</g, '<'); | |
str = str.replace(/>/g, '>'); | |
str = str.replace(/"/g, '"'); |
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
#! /usr/bin/python | |
# -*- coding: utf-8 -*- | |
# @author weishu @2015/12/7 | |
import subprocess | |
import os | |
import re | |
import json |
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
# atom-sync |
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 fs = require('fs'); | |
const request = require('request'); | |
const BASE = 'https://api.xiaomiquan.com/v1.2/groups/4512888248/topics'; | |
const ORIGIN = 'https://wx.xiaomiquan.com'; | |
const REFERER = 'https://wx.xiaomiquan.com/dweb/'; | |
const UA = 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36'; | |
const AUTHORIZATION = 'xxx'; | |
const pageSize = '?count=20'; | |
const end_time = (t) => t ? `&end_time=${encodeURIComponent(t)}` : t; |
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
// from https://github.com/suxiaogang/WeiboPicBed | |
// under its license | |
function uploadToWeibo( url , callback ) | |
{ | |
var xhr = new XMLHttpRequest(); | |
xhr.onload = function() { | |
var reader = new FileReader(); | |
reader.onloadend = function( e ) | |
{ |
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
<title>百万数据前端快速流畅显示</title> | |
<style type="text/css"> | |
#box {position: relative; height: 300px; width: 200px; border:1px solid #CCC; overflow: auto} | |
#box div { position: absolute; height: 20px; width: 100%; left: 0; overflow: hidden; font: 16px/20px Courier;} | |
</style> | |
<div id="box"></div> | |
<script type="text/javascript"> | |
var total = 1e5 |
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
var readyStart = timing.fetchStart - timing.navigationStart; | |
var redirectTime = timing.redirectEnd - timing.redirectStart; | |
var appcacheTime = timing.domainLookupStart - timing.fetchStart; | |
var unloadEventTime = timing.unloadEventEnd - timing.unloadEventStart; | |
var lookupDomainTime = timing.domainLookupEnd - timing.domainLookupStart; | |
var connectTime = timing.connectEnd - timing.connectStart; | |
var requestTime = timing.responseEnd - timing.requestStart; | |
var initDomTreeTime = timing.domInteractive - timing.responseEnd; | |
var domReadyTime = timing.domComplete - timing.domInteractive; | |
var loadEventTime = timing.loadEventEnd - timing.loadEventStart; |