Skip to content

Instantly share code, notes, and snippets.

View leizongmin's full-sized avatar
😴
I may be slow to respond

LEI Zongmin leizongmin

😴
I may be slow to respond
View GitHub Profile
@leizongmin
leizongmin / timer1.js
Created February 6, 2018 03:39
Node.js定时器测试代码
// 高精度定时器,interval为毫秒
function myTimer(callback, interval) {
function getTime() {
return process.uptime() * 1000;
}
let previous = getTime();
setInterval(function() {
const now = getTime();
if (now - previous >= interval) {
previous = now;
@leizongmin
leizongmin / package.json
Created January 3, 2018 08:15
跨域共享Cookie示例
{
"name": "cookie example",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"connect-redis": "^3.3.3",
"cookie-parser": "^1.4.3",
"express": "^4.16.2",
"express-session": "^1.15.6"
@leizongmin
leizongmin / createPromiseCallback.js
Last active December 20, 2017 03:40
兼容Promise的callback函数
function createPromiseCallback() {
const callback = (err, ret) => {
if (err) {
callback.reject(err);
} else {
callback.resolve(ret);
}
};
callback.promise = new Promise((resolve, reject) => {
callback.resolve = resolve;
@leizongmin
leizongmin / lei.css
Last active December 13, 2017 02:01
Typora Theme - Lei
html, body {
font-family: "Biaodian Pro Sans CNS","Helvetica Neue",Helvetica,Arial,"Zhuyin Heiti","Han Heiti",sans-serif;
-webkit-font-smoothing: subpixel-antialiased;
line-height: 1.7;
word-break: break-word;
color: #333;
background-color: #f3f2ee;
}
@leizongmin
leizongmin / npm-proxy.js
Last active December 11, 2017 05:09
私有NPM代理程序
const httpRequest = require("http").request;
const httpsRequest = require("https").request;
const parseUrl = require("url").parse;
const connect = require("connect");
const colors = require("colors");
const PORT = Number(process.env.PORT || 6666);
const REGISTRY_CDN =
process.env.REGISTRY_CDN || "https://registry.npm.taobao.org";
const REGISTRY_PRIVATE =
@leizongmin
leizongmin / http-reverse-proxy.go
Last active December 11, 2017 05:07
Go语言写的简单HTTP反向代理
package main
import (
"fmt"
"io"
"log"
"net/http"
"net/url"
"time"
)
@leizongmin
leizongmin / msf-gui-armitage.sh
Created November 16, 2017 12:40
Armitage启动命令
#!/bin/sh
echo "start msfrpcd..."
pkill msf
msfrpcd -U msf -P msf -f -S -a 127.0.0.1 &
echo "wait..."
sleep 20
echo "start armitage..."
export MSF_DATABASE_CONFIG=~/.msf4/database.yml
armitage &
@leizongmin
leizongmin / check_password.js
Created November 14, 2017 02:35
检查密码规则
/**
* 检查密码是否符合规则,如果符合规则返回true
* @param {string} pwd
* @return {boolean}
*/
function check(pwd) {
return (
notSeries(pwd, "1234567890", 3) &&
notSeries(pwd, "abcdefghijklmnopqrstuvwxyz", 3) &&
notSeries(pwd, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 3) &&
@leizongmin
leizongmin / holyhi.ts
Created October 6, 2017 14:09
简单的状态管理
import * as immutable from 'immutable';
export type State = immutable.Map<string, any>;
export type Listener = () => void;
export const LISTENER_ALL = '@@@@ALL';
export class Store {
protected state: State;
@leizongmin
leizongmin / test_json.go
Created September 25, 2017 07:07
golang JSON
package main
import (
"fmt"
"encoding/json"
"github.com/mitchellh/mapstructure"
)
type A struct {