This file contains hidden or 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) { |
This file contains hidden or 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 chart = highchart(this.el, opts).highcharts(); | |
var svg = chart.getSVG(); | |
request | |
.post('/image') | |
.send({ | |
xml: svg | |
}) | |
.set('Accept', 'application/json') | |
.end(function(err, res) { | |
if(err) throw err; |
This file contains hidden or 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
require('longjohn') | |
var prettyjson = require('prettyjson') | |
function formatJson(object) { | |
// adds 4 spaces in front of each line | |
var json = prettyjson.render(object) | |
json = json.split('\n').join('\n ') | |
return ' ' + json | |
} | |
function playNiceError(error) { | |
// remove longjohn properties that break prettyjson |
This file contains hidden or 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>webview ad for testing</title> | |
</head> | |
<body> | |
<div id="info">info</div> | |
<div id="download">download</div> |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
// drop this into <tern folder>/plugin | |
// run `npm i enhanced-resolve` in you tern folder | |
// add config "plugins": { "webpack": {}} to your .tern_project | |
// done | |
(function(mod) { | |
if (typeof exports == "object" && typeof module == "object") // CommonJS | |
return mod(require("../lib/infer"), require("../lib/tern"), require("./commonjs"), require) | |
if (typeof define == "function" && define.amd) // AMD | |
return define(["../lib/infer", "../lib/tern", "./commonjs"], mod) | |
mod(tern, tern) |
OlderNewer