在关于如何创建socket.io组播组的问题上取得进展后,我发现制作房间是一种很好的方式来完成我需要的工作.
但是,如果没有额外的数据结构,了解所有房间会很棒.
是否可以从服务器套接字获取服务器上所有房间的列表?
我需要从我的应用资源文件夹中加载javascript文件.截至目前,它确实从资源中读取图像,但由于某种原因,它不会读取javascripts.
如果html文件本身被写入资源,我已经能够呈现引用这些javascripts的html文档,但是我想通过设置UIWebView的html来呈现html/js,这样它就可以是动态的.
这是我在做的事情:
NSString * html = @"<!DOCTYPE html><html><head><title>MathJax</title></head><body><script type=\"text/x-mathjax-config\">MathJax.Hub.Config({tex2jax: {inlineMath: [[\"$\",\"$\"],[\"\\(\",\"\\)\"]]}});</script><script type=\"text/javascript\" src=\"/MathJax/MathJax.js\"></script>$$\\int_x^y f(x) dx$$<img src=\"coffee.png\"></body></html>";
NSString * path = [[NSBundle mainBundle] resourcePath];
path = [path stringByReplacingOccurrencesOfString:@"/" withString:@"//"];
path = [path stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
NSString * resourcesPath = [[NSString alloc] initWithFormat:@"file://%@/", path];
[webview loadHTMLString:html baseURL:[NSURL URLWithString:resourcesPath]];
Run Code Online (Sandbox Code Playgroud)
现在,如果我将基本URL更改为具有所需文件的服务器,则会正确加载.不需要互联网连接会很棒.任何帮助表示赞赏!;)
我发现这对于显示图像很有用:iPhone Dev:UIWebView baseUrl到Documents文件夹中的资源而不是App bundle
编辑:
我没有做字符串替换和URL编码,而是通过简单地在mainBundle上调用resourceURL来获取图像,但仍然没有执行javascript.
NSString * setHtml = @"<!DOCTYPE html><html><head><title>MathJax</title></head><body><script type=\"text/x-mathjax-config\">MathJax.Hub.Config({tex2jax: {inlineMath: [[\"$\",\"$\"],[\"\\(\",\"\\)\"]]}});</script><script type=\"text/javascript\" src=\"/MathJax/MathJax.js\"></script>$$\\int_x^y f(x) dx$$<img src=\"images/test.png\"></body></html>";
[webview loadHTMLString:setHtml baseURL:[[NSBundle mainBundle] resourceURL]];
Run Code Online (Sandbox Code Playgroud)
编辑
如果你想帮助我做一个镜头,我通过创建一个示例项目让你更容易!
https://github.com/pyramation/math-test
git clone git@github.com:pyramation/math-test.git
Run Code Online (Sandbox Code Playgroud) 我需要这两种类型的重写:
subdomain.domain.com => domain.com/website/subdomain
otherdomain.com => domain.com/userdomain/otherdomain.com
我的问题是我希望用户看到subdomain.domain.com,而otherdomain.com不是重定向的版本.我目前在nginx中的重写工作,但用户的URL显示重写,我希望这对用户透明,任何想法?:
upstream domain_server { server localhost:8000 fail_timeout=0; }
server {
listen 80;
root /var/www/domain.com;
server_name domain.com ~^(?<subdomain>.*)\.domain\.com$ ~^(?<otherdomain>.*)$;
if ( $subdomain ) {
rewrite ^ http://domain.com/website/$subdomain break;
}
if ( $otherdomain ) {
rewrite ^ http://domain.com/userdomain/$otherdomain break;
}
location / {
proxy_redirect off;
proxy_buffering off;
proxy_set_header Host $http_host;
proxy_set_header X-forwarded-for $proxy_add_x_forwarded_for;
if (!-f $request_filename) {
proxy_pass http://domain_server;
break;
}
}
}
Run Code Online (Sandbox Code Playgroud) 我需要在包内容中存储一个文件夹,而不是项目中的所有文件都在一个根文件夹中.
我怎么能在XCode 4.0中这样做?
现在我要进入Build Phases> Copy Bundle Resources来尝试这些更改.
查看此页面:http://www.mikeash.com/pyblog/friday-qa-2010-12-31-c-macro-tips-and-tricks.html
我发现这段代码带有^{... }()语法,插入/括号有什么作用?
#define MAX(x, y) (^{ \
int my_localx = (x); \
int my_localy = (y); \
return my_localx > my_localy ? (my_localx) : (my_localy); \
}())
Run Code Online (Sandbox Code Playgroud)
看起来它创建了一个匿名函数或其他东西.这个概念叫什么?我在哪里可以阅读它?
我正在尝试编写一个查询,以生成给定根的树中所有节点的列表,以及路径(使用父级给他们孩子的名称)到达那里的路径.我工作的递归CTE是直接来自这里的文档的教科书CTE ,然而,事实证明在这种情况下使路径工作很困难.
在git模型之后,由于遍历树创建的路径,父母会将名称提供给子级.这意味着映射到git的树结构等子id.
我一直在网上寻找递归查询的解决方案,但它们似乎都包含使用父ID或物化路径的解决方案,这些都会破坏Rich Hickey的数据库作为价值谈话的结构共享概念.
想象一下,对象表很简单(为简单起见,我们假设整数id):
drop table if exists objects;
create table objects (
id INT,
data jsonb
);
-- A
-- / \
-- B C
-- / \ \
-- D E F
INSERT INTO objects (id, data) VALUES
(1, '{"content": "data for f"}'), -- F
(2, '{"content": "data for e"}'), -- E
(3, '{"content": "data for d"}'), -- D
(4, '{"nodes":{"f":{"id":1}}}'), -- C
(5, '{"nodes":{"d":{"id":2}, "e":{"id":3}}}'), -- B
(6, …Run Code Online (Sandbox Code Playgroud) 我正在尝试在运行nginx + thin的服务器上设置多个域.例如,我希望www.domain1.com和www.domain2.com转到不同的应用程序,这些应用程序具有到各自应用程序的不同根路径.
如果您熟悉nginx,我已在本文的底部发布了我的nginx.conf文件.
我以为我可以尝试使用多个服务器块,但后来我遇到了一个问题,服务器默认选择随机瘦端口,两个域都转到同一个应用程序.*主要原因是两个应用程序的所有端口都位于thin_cluster内部.*
我想我的主要担心是有一个与特定服务器无关的thin_cluster.然后是服务器块,它具有server_name等.但是,thin_cluster不能嵌套在服务器块内.
关于如何服务多个主机的任何想法?
这是我的/etc/nginx/nginx.conf文件
user nginx;
worker_processes 5;
error_log /var/log/nginx.error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx.access.log main;
sendfile on;
keepalive_timeout 65;
upstream thin_cluster {
server 0.0.0.0:3000;
server 0.0.0.0:3001;
server 0.0.0.0:3002;
server 0.0.0.0:3003;
server 0.0.0.0:3004;
}
server {
listen 80;
server_name www.domain1.com;
root /home/ec2-user/helloCloud/public;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header …Run Code Online (Sandbox Code Playgroud) ios ×2
nginx ×2
resources ×2
xcode ×2
bundle ×1
caret ×1
django ×1
javascript ×1
mathjax ×1
multicast ×1
node.js ×1
objective-c ×1
postgresql ×1
proxy ×1
rewrite ×1
socket.io ×1
syntax ×1
thin ×1
virtualhost ×1
xcode4 ×1