Skip to content

Instantly share code, notes, and snippets.

@shepherdwind
shepherdwind / path.js
Created March 20, 2012 22:05
a way to count which point it is availabed
"use strict";
/**
* 11 12 13 14 15
* 21 22 23 24 25
* 31 32 33 34 56
* 41 42 43 44 45
* 51 52 53 54 55
*/
//var maps = [];
var log = console && console.log;
@shepherdwind
shepherdwind / proxy.js
Created April 11, 2012 04:36
proxy for node
#!/usr/bin/env node
/**
* Created by [email protected]
*
* 使用方式,依赖于node
* 1. 下载node.js, http://nodejs.org/#download
* 2. 在命令行下执行:
* node proxy.js
*
* 静态文件代理工具,基于node实现,实现原理,把a.tbcdn.cn通过host设置,转到本地
@shepherdwind
shepherdwind / combine.js
Created April 16, 2012 11:38
kissy ui auto combine
(function(S){
var _use = S.use;
var _add = S.add;
var getMappedPath = S.__getMappedPath;
//url映射
var maps = {};
//依赖关系
var requires = {};
/**
* Created by [email protected].
* Date: 2012-06-04
* Time: 13:40
* Desc: 自动跟随
*/
KISSY.add('market/scrollFollow', function(S){
var D = S.DOM;
var E = S.Event;
@shepherdwind
shepherdwind / function.coffee
Created June 19, 2012 16:21 — forked from sankage/function.coffee
CoffeeScript: self executing anonymous functions
# Is there a coffeescript way of doing this?
(function($, exports){
# doing random stuff here
})(jQuery, window);
# Other than this:
( ($, exports) ->
# doing random stuff here
@shepherdwind
shepherdwind / getNum.js
Created July 9, 2012 06:22
fast way to find path
/* 后端数据 */
var data = {
"10;20;30": {
price: 5,
count: 1
},
"10;20;31": {
price: 10,
count: 2
},
@shepherdwind
shepherdwind / error
Last active December 14, 2015 21:09
jear api
{
"status": false,
"message": "错误提示"
}
velocity.js joycss plum peersay kissy-gallery
#!/usr/bin/env node --harmony
var fs = require('fs')
var path = require('path')
var co = require('co')
var thunkify = require('thunkify')
var cwd = process.cwd()
var file = path.join(cwd, 'templates')
var dir = thunkify(fs.readdir)
@shepherdwind
shepherdwind / conver.sh
Created April 10, 2014 04:00
convert all file to utf8
#!/bin/bash
FROM=gbk
TO=UTF-8
ICONV="iconv -f $FROM -t $TO"
# Convert
find . -type f -name "*" | while read fn; do
cp ${fn} ${fn}.bak
$ICONV < ${fn}.bak > ${fn}
rm ${fn}.bak
done