似乎有很多关于如何做到这一点的教程,每个都略有不同.我希望有人能够认出我收到的错误信息,并指出我正确的方向.
我的代码,hm是:
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSLog (@"hello world");
[pool drain];
return 0;
}
Run Code Online (Sandbox Code Playgroud)
在编译之前,我进入控制台:
. /usr/share/GNUstep/Makefiles/GNUstep.sh
Run Code Online (Sandbox Code Playgroud)
我尝试编译:
gcc `gnustep-config --objc-flags` -lgnustep-base h.m -o hello
Run Code Online (Sandbox Code Playgroud)
得到:
/tmp/ccgLOnpY.o: In function `main': /home/ge/objective-c/h.m:4: undefined reference to `objc_get_class' /home/ge/objective-c/h.m:4: undefined reference to `objc_msg_lookup' /home/ge/objective-c/h.m:4: undefined reference to `objc_msg_lookup' /home/ge/objective-c/h.m:5: undefined reference to `NSLog' /home/ge/objective-c/h.m:6: undefined reference to `objc_msg_lookup' /tmp/ccgLOnpY.o: In function `__objc_gnu_init': /home/ge/objective-c/h.m:8: undefined reference to `__objc_exec_class' /tmp/ccgLOnpY.o:(.data.rel+0x0): undefined …
我们用C#和.net编写了一个基本的网络应用程序.对于测试,我们喜欢使用类似于Ruby的VCR.C#/ .net是否存在这样的事情?
有没有办法将请求信息(如HOST标头值)传递给app.get?
我的应用程序需要一个特定的主机,所以当我正常调用它时:
app.get( "foo" 的)
具体来说,我想覆盖
request.env["HTTP_HOST"]
Run Code Online (Sandbox Code Playgroud)
值.
TIA
我使用的是 Ubuntu 12。
我正在尝试使用 clang 编译 Objective-C hello_world 应用程序。这是来源:
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSLog (@"hello world");
[pool drain];
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我使用这个命令行:
. /usr/share/GNUstep/Makefiles/GNUstep.sh
clang h.m `gnustep-config --objc-flags` -lgnustep-base -o hello
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
clang: warning: argument unused during compilation: '--param ssp-buffer-size=4'
In file included from h.m:1:
In file included from /usr/include/GNUstep/Foundation/Foundation.h:30:
In file included from /usr/include/GNUstep/GNUstepBase/GSVersionMacros.h:193:
In file included from /usr/include/GNUstep/GNUstepBase/GSConfig.h:229:
/usr/include/GNUstep/GNUstepBase/preface.h:112:11: fatal error: 'objc/objc.h'
file not …Run Code Online (Sandbox Code Playgroud) 这是我的代码:
EventMachine.run {
conn = EM::Protocols::HttpClient2.connect request.host, 80
req = conn.get(request.query)
req.callback { |response|
p(response.status)
p(response.headers)
p(response.content)
}
}
Run Code Online (Sandbox Code Playgroud)
回调触发,也就是说,我得到状态的字符串输出等.
但我想要它做的是触发回调,然后重复.我计划实施更多逻辑,例如每次调整URL,但就目前而言,我只想要:
我对这种模式的理解是,该循环中的所有内容都会触发,然后返回,然后一直持续到我执行为止EM.stop.
现在,它检索URL数据,似乎挂起了.
我需要做某种回报才能继续吗?它为什么悬挂,而不是一遍又一遍地循环?
如果我用循环包围整个上面的代码块...结束它按预期工作..这是实现这个的正确方法吗?我想我很困惑,因为我认为一切都在EM.run重复时完成.
我知道我可以为自定义错误页面设置一个文件:
location / {
error_page 404 = /mybad.html;
}
Run Code Online (Sandbox Code Playgroud)
但我只是想在配置文件中将我的页面覆盖作为文本内联提供:
location / {
error_page 404 = "<H1>Sorry!</H1>"
}
Run Code Online (Sandbox Code Playgroud)
这可能与nginx有关吗?
鉴于:
s = "foo_bar_path"
Run Code Online (Sandbox Code Playgroud)
我如何评估或限制s,并将参数传递给它,例如我的最终结果将等同于:
foo_bar_path(@myvar, @foobar)
Run Code Online (Sandbox Code Playgroud)
我在尝试,eval(s).send但似乎没有用.constantize似乎只适用于类?
让我们说我有a1和a2:
a1 = [1,2,3]
a2 = [4,2,5]
Run Code Online (Sandbox Code Playgroud)
要查看是否a1共享任何元素a2,我可以遍历每个元素并比较每个元素:
def intersect?(x,y)
a1.each do |x|
a2.each do |y|
if x == y return true
end
end
false
end
Run Code Online (Sandbox Code Playgroud)
但更简单,(a1.to_set & a2.to_set).present?给我同样的答案.
我假设设置操作更快更有效?如果这是真的,考虑到.to_set每个阵列上的操作开销(如果有的话),它仍然是真的吗?
TIA