Skip to content

Instantly share code, notes, and snippets.

function orderedFlow ( order ) {
this.order = order;
this.listnerId = uuid('orderedFlow.');
this.dataStack = [];
this.index = 0;
this.interval = 0;
this.maxListen= 500;
this.nextTime = 0;
this.timeout = undefined;
@ssddi456
ssddi456 / gist:5018461
Created February 23, 2013 04:40
a wrapper for typeperf zh-cn windows
var child_process = require('child_process');
var iconvLite = require('iconv-lite');
var csv = require('csv');
var util = require('util');
var events = require('events');
var _ = require('underscore');
var tracecpu = child_process.spawn('typeperf', ["\\Memory\\Available bytes","\\processor(_total)\\% processor time"]);
var lastRecord,
@ssddi456
ssddi456 / autocomplete.less
Last active December 15, 2015 10:09
autoComplete for ace usage: autocomplete( aceediter )
.ace-autocomplete-dialog{
position:absolute;
top:0;left:0;
min-width:200px;
max-height:196px;
overflow:hidden;
font-size:12px;
display:none;
box-shadow:0 0 5px 1px rgba(0, 0, 0, 0.3);
background:#E8E8E8;
@ssddi456
ssddi456 / gist:5566866
Last active December 17, 2015 06:39
for browser gbkescape
define([],function() {
var iframe=document.createElement("iframe");
iframe.src="about:blank";
iframe.setAttribute("style","display:none;visibility:hidden;");
document.body.appendChild(iframe);
var d=iframe.contentWindow.document;
d.charset=d.characterSet="GBK";
function getGBKEscape(s) {
d.write("<body><a href='?"+s+"'>X</a></body>");
d.close();
@ssddi456
ssddi456 / gist:6138590
Last active December 20, 2015 13:28
int to chiness
function intToChinese (str) {
str = str + '';
var len = str.length - 1;
var idxs = ['', '十', '百', '千', '万', '十', '百', '千', '亿', '十', '百', '千', '万', '十', '百', '千', '亿'];
var num = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'];
return str.replace(/([1-9]|0+)/g, function($, $1, idx, full) {
var pos = 0;
if ($1[0] != '0') {
pos = len - idx;
@ssddi456
ssddi456 / gist:6162378
Created August 6, 2013 05:59
check used linux port in range [x,y)
var child_process = require('child_process');
module.exports = function check_linux_port ( port_range, done ) {
var check = child_process.exec('netstat -tln');
var res = '';
check.stdout.on('data',function(chuck) {
res+= chuck;
});
check.on('exit',function(code) {
@ssddi456
ssddi456 / gist:6181902
Created August 8, 2013 06:13
check sublime custom install packages
var fs = require('fs');
var _temp = [fs.readdirSync('Packages'),
fs.readdirSync('Pristine Packages')]
_temp[1] = _temp[1].map(function( line ) {
return line.replace(/\.sublime-package$/,'');
});
var _ = require('underscore');
var ret = _.without.apply(null, ( _temp[1].splice(0,0,_temp[0]), _temp[1] ) );
@ssddi456
ssddi456 / harvest.js
Last active December 21, 2015 22:38
get google doodle list
var _ = require('underscore');
var request = require('request');
var async = require('async');
console.log('/*');
var checkApi = _.template('http://www.google.com/doodles/json/<%=year%>/<%=month%>');
async.reduce(_.range(1998,2013+1),[],function( cache ,year, yeardone) {
console.log( 'year', year );
var fullyear = [];
async.eachLimit(_.range(1,12+1), 5, function( month, monthdone ) {
console.log( 'month', month );
@ssddi456
ssddi456 / reciever.php
Created September 12, 2013 02:53
upload folder demo
<?php
$deploy_root=dirname(__FILE__);
function mkdirs($path, $mod = 0777) {
if (is_dir($path)) {
return chmod($path, $mod);
} else {
$old = umask(0);
if(mkdir($path, $mod, true) && is_dir($path)){
@ssddi456
ssddi456 / fis_package.js
Created March 3, 2014 05:30
requirejs preload with fis's namespaced package
define("common:lib/base.js",function(
require, exports, module
){
exports.sayhi = function( some_one) {
console.log( 'hello, ' + some_one );
}
});
define('widget:tip',function(
require, exports, module