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
// Check for the various File API support. | |
if (window.File && window.FileReader && window.FileList && window.Blob) { | |
// Great success! All the File APIs are supported. | |
} else { | |
alert('The File APIs are not fully supported in this browser.'); | |
} |
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 net = require ('net'); | |
var fs = require ('fs'); | |
var client = net.connect(3000, '127.0.0.1'); | |
var log = fs.createWriteStream('out.log'); | |
log.on('error', function(err) { | |
console.log(err); | |
}) |
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 co = require('co'); | |
var r = require('co-rethinkdb'); | |
var conn; | |
r.getConnection = function* () { | |
return conn || (conn = yield r.connect({ | |
host: 'chemzqm.me', | |
port: 28015, | |
db: 'blog', |
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 co = require('co'); | |
var assert = require('assert') | |
var redisClient = require('redis').createClient(); | |
var wrapper = require('co-redis'); | |
var rc = wrapper(redisClient); | |
co(function* () { | |
yield rc.set('test', 33); | |
var test = yield rc.get('test'); // logs 33 | |
assert(test === '33'); |
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/env node | |
// 使用方式: redirect [url] | |
// 手机上每次都访问 http://[你机器的ip]:3000就成了 | |
var http = require('http'); | |
var url = process.argv[2]; | |
http.createServer(function (req, res) { | |
res.setHeader('Location', url); |
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
function doc | |
set folder (moduledir $argv[1]) | |
if test $status != 0 | |
return $status | |
end | |
if test -f $folder/Readme.md | |
open $folder/Readme.md | |
else if test -f $folder/readme.md | |
open $folder/readme.md | |
else if test -f $folder/README.md |
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
function! PreviewModule(name, ...) | |
if empty(a:name) | echo "need module name" | return | endif | |
if empty(a:000) | |
let res = system("findmodule ".a:name) | |
let file = res | |
else | |
let type = a:000[0] | |
let res = system("moduledir ".a:name) | |
if type ==? 'doc' | |
let file = res . "/readme.md" |
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/env node | |
var fs = require('fs') | |
var path = require('path') | |
var moduleName = process.argv[2] | |
var dir = process.cwd() | |
function exit(msg, code) { | |
console.error(msg) | |
process.exit(1) |
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
" ============================================================================ | |
" Description: An easy comment plugin | |
" Author: Qiming Zhao <chemzqm@gmail.com> | |
" Licence: Vim licence | |
" Version: 0.1 | |
" ============================================================================ | |
"let g:comment_debug = 1 | |
if exists("g:comment_loaded") && !exists("g:comment_debug") | |
finish | |
endif |
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
/* | |
* service for simple validate | |
*/ | |
var express = require ('express'); | |
var app = module.exports = express(); | |
var Canvas = require('canvas'); | |
var moment = require('moment'); | |
function vertify_img(req, res) { |
OlderNewer