好吧,忽略它.我已经打开了一个问题https://github.com/joyent/node/issues/793
试图运行http://www.catonmat.net/http-proxy-in-nodejs
var http = require('http');
http.createServer(function(request, response) {
var proxy = http.createClient(80, request.headers['host'])
var proxy_request = proxy.request(request.method, request.url, request.headers);
proxy_request.addListener('response', function (proxy_response) {
proxy_response.addListener('data', function(chunk) {
response.write(chunk, 'binary');
});
proxy_response.addListener('end', function() {
response.end();
});
response.writeHead(proxy_response.statusCode, proxy_response.headers);
});
request.addListener('data', function(chunk) {
proxy_request.write(chunk, 'binary');
});
request.addListener('end', function() {
proxy_request.end();
});
}).listen(8080);
Run Code Online (Sandbox Code Playgroud)
在发出大量请求后失败:
net.js:695
self.fd = socket(self.type);
^
Error: EMFILE, Too many open files
at net.js:695:19
at dns.js:171:30
at IOWatcher.callback (dns.js:53:15)
Run Code Online (Sandbox Code Playgroud)
OSX 10.6上的节点0.4.2
是否有一种简单的方法可以刮取谷歌并为给定的搜索编写前N个(比如1000).html(或其他)文档的文本(只是文本)?
例如,想象一下搜索短语"大坏狼"并从前1000个点击下载文本 - 即实际从这1000个网页下载文本(但只是那些页面,而不是整个网站).
我假设这会使用urllib2库?如果有帮助我使用Python 3.1.
我使用以下安装文件使用cx_freeze创建可执行文件.是否可以使用除可执行脚本名称之外的其他名称生成exe?
from cx_Freeze import setup, Executable
import xlrd
buildOptions = dict(
compressed = True,
optimize=2,
path=sys.path+[".\\uitls", “.\\supported”],
include_files=[“Doc"],
includes=[“xlrd”, "win32com"],
packages=["utils", ”supported"],
append_script_to_exe=True,
copy_dependent_files=True,
)
setup(
name = "TestExecutable",
version = "0.1",
options = dict(build_exe = buildOptions),
executables = [Executable(script=r".\\codebase\\runner.py",
icon=".\\icon.ico",
base="Win32GUI")]
)
Run Code Online (Sandbox Code Playgroud)
所以现在创建的exe文件名为runner.exe,我希望它与myexecutable.exe不同,重命名可执行文件,如果脚本不能正常运行,则脚本模块会进一步引用该脚本.
(以下问题涉及OCaml语言并且在OCaml中有示例,但问题非常普遍,对于任何其他计算机语言来说,正确答案也可能解决我的问题.所以,只需用您最喜欢的语言来假设这个问题.)
我想编写一个函数,它将OCaml中的任意程序作为字符串,并决定程序是正确还是不正确,在后一种情况下,我是否可以通过在最后连接适当的字符使其成为正确的程序.
我假设有一个语言的编译器,我可以应用它并得到一个回复,说"编译"或"不编译 - 错误在第X行,字符Y"(大多数情况下)语言无论如何).总之,我想有一个函数,它接受一个程序并返回:
例如,OCaml程序let x = f不正确,因为f它在使用时尚未定义.它不能继续,因为你在f之后写的东西总是一些以前没有定义过的标识符.该程序let x =也是不正确的; 但如果我们延伸到let x = 5那时我们有一个完全有效的程序.所以,我的函数应该在第一种情况下返回Erroneous而在第二种情况下返回Incomplete.
如果我们有这个计划,事情可能会变得棘手
let ans = 5
let x = a
Run Code Online (Sandbox Code Playgroud)
因为我的功能必须要看到如果我继续该程序,ns那么程序就变得正确了.
我的问题是:你认为有可能编写这样的函数/算法吗?如果是这样,那么一般的想法是什么?如果没有,试着说服我,事实并非如此.
(我会对任何见解或部分答案感到满意,例如暗示不完整的东西.例如,我相信如果语言编译器说第3行有错误并且程序有100行,那么就没有可能继续该计划.)
compiler-construction ocaml programming-languages compiler-theory
我已经使用C/C++大约7个月了,目前我正在尝试编写一小组线性代数程序.现在我正在尝试测试我的vector类,但是收到错误消息:
In file included from /usr/include/machine/_types.h:34,
from /usr/include/sys/_types.h:33,
from /usr/include/_types.h:27,
from /usr/include/unistd.h:71,
from /usr/include/c++/4.2.1/i686-apple-darwin10/x86_64/bits/os_defines.h:61,
from /usr/include/c++/4.2.1/i686-apple-darwin10/x86_64/bits/c++config.h:41,
from /usr/include/c++/4.2.1/cstdlib:50,
from linalgtest.cpp:8:
/usr/include/i386/_types.h:37: error: two or more data types in declaration of ‘__int8_t’
Run Code Online (Sandbox Code Playgroud)
在/usr/include/c++/4.2.1/stdexcept:43中包含的文件中,来自vector.cpp:8:/usr/include/c++/4.2.1/exception:40:错误:'#pragma'不允许这里
shell returned 1
Run Code Online (Sandbox Code Playgroud)
我正在运行Mac OS X 10.6.5,并检查了我的/usr/include/i386_types.h文件与http://www.opensource.apple.com/source/xnu/xnu-1456.1.26/bsd/i386/_types.h中找到的文件.无论价值多少,它们看起来都是一样的.
以下是我的测试人员文件的内容
#include "linalg.h" // L7
#include <cstdlib> // L8: the offending line
#include <cmath> // L9
using namespace std;
double drand(double d) { return d*((double)rand()/RAND_MAX); }
int main(void) {
int n = 10;
double comps[10];
for (int …Run Code Online (Sandbox Code Playgroud) List<String> strings; // contains "foo", "bar", "baz", "xyz"
Run Code Online (Sandbox Code Playgroud)
如果给定输入,"baz"则函数重新排列(String输入)应该返回字符串
"baz", "foo", "bar", "xyz"
Run Code Online (Sandbox Code Playgroud)
如果给定输入,"bar"则函数重新排列(String输入)应该返回字符串
"bar", "foo", "baz", "xyz"
Run Code Online (Sandbox Code Playgroud) 是否有内置库或者是否有人可以使用函数将字符串时区(如"America/New_York")转换为datetime.tzinfo对象?
谢谢.
我有这样的网址.http:// localhost:8080/steer/trip/create/3.在我的页面中我想使用jquery获取值"3".请帮我
是否有任何unix命令可以duplicate files在特定的位置显示directory。请让我知道您的意见。
什么是linux中的核心转储文件?它提供的所有信息是什么?