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
@echo off | |
openssl genrsa -out ca-key.pem 2048 | |
openssl req -new -out ca-req.csr -key ca-key.pem | |
openssl x509 -req -in ca-req.csr -out ca-cert.pem -signkey ca-key.pem -days 7300 | |
openssl pkcs12 -export -in ca-cert.pem -out ca-cert.p12 -inkey ca-key.pem |
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 text = 'Text'; | |
var split = [' ', ' ', ' ', ' ', '\n']; | |
var i = 0; | |
for (var c = 30; c <= 39; c++) { | |
for (var bg = 40; bg <= 49; bg++) { | |
[1,2,4,5,7,22,24,25,27].forEach(function (s) { | |
var v = [c, bg, s].join(';'); | |
var sp = split[i++]; | |
if (i >= split.length) i = 0; | |
process.stdout.write(v + ' \x1B[' + v + 'm' + text + '\x1B[39;49m' + sp); |
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 (global, fullName, sortName) { | |
function Selector(q) { | |
if (q instanceof Selector) return q; | |
if (!(this instanceof Selector)) return new Selector(q); | |
var list; | |
if (typeof q === 'string') { | |
list = document.querySelectorAll(q); | |
Selector.from(list, this); | |
} else if (q instanceof Element) { |
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
iptables -t nat -A PREROUTING -p tcp --dport 22 -j DNAT --to XX.XX.XX.XX:22 | |
iptables -A FORWARD -p tcp -d XX.XX.XX.XX --dport 22 -j ACCEPT | |
iptables -t nat -A POSTROUTING -j MASQUERADE |
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
/** | |
* 简单的HTTP代理服务器 | |
* | |
* @author 老雷<leizongmin@gmail.com> | |
*/ | |
var http = require('http'); | |
// 记录日志 | |
var log = function () { | |
var now = new Date().toISOString(); |
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 stream = process.stdout; | |
// 输出 | |
var write = function (str) { | |
stream.write(str); | |
}; | |
// 生成ANSI escape sequences代码:http://en.wikipedia.org/wiki/ANSI_escape_code | |
var CSI = exports.CSI = function (str, c) { |
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
// 一个特殊的国家忌讳7这个数字,所有包含7的数字他们都不用, | |
// 改用下一个数字,比如7他们用8代替,17用19代替。 | |
// 给定这个国家的数字,如何编程翻译成我们用的数字。 | |
function convert (n) { | |
// 先转成9进制,然后将大于6的数字都加1 | |
var x = n.toString(9); | |
var r = ''; | |
for (var i = 0; i < x.length; i++) { | |
if (x[i] > 6) { | |
r += parseInt(x[i]) + 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
/** | |
* 取子字符串的索引位置(不在引号内的) | |
* | |
* @param {String} text | |
* @param {String} subject | |
* @param {Integer} start | |
*/ | |
var textIndexOf = function (text, subject, start) { | |
if (start < 0) { | |
start = text.length + start; |
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
/** | |
* 克隆对象 | |
* | |
* @param {Object} obj | |
* @return {Object} | |
*/ | |
var clone = function (obj) { | |
var seen = []; | |
var cloneObj = function (obj) { | |
if (typeof(obj) === 'object') { |
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 path = require('path'); | |
var fs = require('fs'); | |
var _ = require('bright-flow'); | |
// 要列出的目录 | |
var dir = path.resolve(process.argv[2]); |