可使用这个快速上传文件
注意:公司外部是无法使用
确保已经配置好 node 环境 http://aralejs.org/docs/installation.html
| var stat = fs.statSync(dir); | |
| (stat.mode & 07777).toString(8); // => e.g. 755 |
| var https = require('https'); | |
| var Base64 = require('js-base64').Base64; // can use other base64 implement | |
| var twitterConsumerKey = 'your consumer key'; | |
| var twitterConsumerSecret = 'your consumer secret'; | |
| var encodedBearerToken = Base64.encode(twitterConsumerKey + ':' + twitterConsumerSecret); | |
| var options = { | |
| hostname: 'api.twitter.com', | |
| path: '/oauth2/token', |
| var fs = require('fs'); | |
| var path = require('path'); | |
| var spawn = require('child_process').spawn; | |
| function run(cmd) { | |
| var output, out, index = cmd.indexOf('>'); | |
| if (index > -1) { | |
| output = cmd.substring(index + 1).replace(/(^\s+|\s+$)/g, ''); | |
| cmd = cmd.substring(0, index).split(/\s+/); | |
| } else { |
| function format(fmt, args) { | |
| if (!fmt) return ''; | |
| var toString = Object.prototype.toString; | |
| if (toString.call(args) === '[object Object]') { | |
| return fmt.replace(/%{?([a-z]*)}?/g, function(all, m1){ | |
| return args[m1] ? args[m1] : all; | |
| }); | |
| } else { | |
| if (toString.call(args) !== '[object Array]') { |
| module.exports = function(grunt) { | |
| grunt.initConfig({ | |
| // https://github.com/gruntjs/grunt-contrib-watch | |
| // grunt.loadNpmTasks('grunt-contrib-watch'); | |
| // 页面上插入 <script src="http://localhost:35729/livereload.js"></script> | |
| watch: { | |
| scripts: { | |
| files: ['**/*'], | |
| task: [], |
| var fs = require('fs'); | |
| var path = require('path'); | |
| var url = require('url'); | |
| var protocol = { | |
| https: require('https'), | |
| http: require('http') | |
| }; | |
| function download(src, dest, cb) { | |
| var options = url.parse(src); |
| function readDirs(dir) { | |
| var result = []; | |
| fs.readdirSync(dir) | |
| .forEach(function(file) { | |
| var sub = path.join(dir, file); | |
| if (fs.statSync(sub).isDirectory()) { | |
| result = result.concat(readDirs(sub).map(function(subFile) { | |
| return path.join(file, subFile); | |
| })); | |
| } else { |
| Array.prototype.uniq = function() { | |
| return this.filter(function(item, index, arr) { | |
| return index === arr.indexOf(item); | |
| }); | |
| }; | |
| // test | |
| [1,2,3,2,1,2,4,6,8,3,2].uniq(); |
可使用这个快速上传文件
注意:公司外部是无法使用
确保已经配置好 node 环境 http://aralejs.org/docs/installation.html
| # install gist by `brew install gist` | |
| # | |
| # create gist on first time | |
| # update gist when .gistid exists | |
| function gist() { | |
| local gistid | |
| args=$@ | |
| if [ -f .gistid ]; then | |
| gistid=$(cat .gistid) |