Skip to content

Instantly share code, notes, and snippets.

View nomospace's full-sized avatar

Luke Jin nomospace

  • Shanghai, China
  • 16:23 (UTC +08:00)
View GitHub Profile
@nomospace
nomospace / gist:3348672
Created August 14, 2012 11:59
node 下的 http status code
var CRLF = '\r\n';
var STATUS_CODES = exports.STATUS_CODES = {
100 : 'Continue',
101 : 'Switching Protocols',
102 : 'Processing', // RFC 2518, obsoleted by RFC 4918
200 : 'OK',
201 : 'Created',
202 : 'Accepted',
203 : 'Non-Authoritative Information',
204 : 'No Content',
@nomospace
nomospace / gist:3357290
Created August 15, 2012 07:08
node-imap 依次执行函数队列
var box, cmds, next = 0,
cb = function(err) {
if (err) die(err);
else if (next < cmds.length) cmds[next++].apply(this, Array.prototype.slice.call(arguments).slice(1));
};
cmds = [
function() {
imap.connect(cb);
}, function() {
@nomospace
nomospace / gist:3652199
Created September 6, 2012 06:42
匹配形如 /* ... */ 的简单注释
/\*.{0,}/
@nomospace
nomospace / gist:3696859
Created September 11, 2012 08:19
parseUri
// parseUri 1.2.2
// (c) Steven Levithan <stevenlevithan.com>
// MIT License
function parseUri(str) {
var o = parseUri.options;
var m = o.parser[o.strictMode ? "strict" : "loose"].exec(str);
var uri = {};
var i = 14;
while (i--) uri[o.key[i]] = m[i] || "";
<!DOCTYPE HTML>
<html>
<head>
<title>桌面创建快捷方式</title>
</head>
<body>
<script>
function createDesktop(sUrl, sName) {
try {
@nomospace
nomospace / gist:b4f9e60875d2a5a63dac
Created December 16, 2014 10:32
javascript test for existence of nested object key
function checkNested(obj /*, level1, level2, ... levelN*/) {
var args = Array.prototype.slice.call(arguments),
obj = args.shift();
for (var i = 0; i < args.length; i++) {
if (!obj || !obj.hasOwnProperty(args[i])) {
return false;
}
obj = obj[args[i]];
}
(function() {
function timer(delay) {
var self = this;
this._queue = [];
setInterval(function() {
for (var i = 0; i < self._queue.length; i++) {
self._queue[i]();
}
},
@nomospace
nomospace / pass_proxy
Created November 19, 2018 10:04
Nginx使用url参数做反射代理
---
title: Nginx使用url参数做反射代理
---
```
server {
server_name www.demo.com;
listen 80;
location / {