小编Joh*_*nny的帖子

如何判断我的服务器是否正在提供GZipped内容?

我在NGinx服务器上有一个webapp.我gzip on在conf文件中设置,现在我正在尝试查看它是否有效.YSlow表示不是,但进行测试的6个网站中有5个表示确实如此.我怎样才能得到一个明确的答案,为什么结果有差异?

compression gzip nginx

135
推荐指数
6
解决办法
6万
查看次数

处理nginx 400"普通的HTTP请求被发送到HTTPS端口"错误

我在乘客/ nginx后面运行一个Sinatra应用程序.我试图让它响应http和https调用.问题是,当两者都在服务器块中定义时,https呼叫正常响应但http产生400"普通HTTP请求被发送到HTTPS端口"错误.这是一个静态页面,所以我猜Sinatra与此无关.有想法该怎么解决这个吗?

这是服务器块:

server {
        listen 80;
        listen 443  ssl;
        server_name localhost;
        root /home/myhome/app/public;
        passenger_enabled on;

        ssl on;
        ssl_certificate      /opt/nginx/ssl_keys/ssl.crt;
        ssl_certificate_key  /opt/nginx/ssl_keys/ssl.key;
        ssl_protocols        SSLv3 TLSv1;
        ssl_ciphers          HIGH:!aNULL:!MD5;

        location /static {
            root  /home/myhome/app/public;
            index  index.html index.htm index.php;
        }

        error_page 404 /404.html;

        # redirect server error pages to the static page /50x.html
        error_page 500 /500.html;

        access_log /home/myhome/app/logs/access.log;
        error_log /home/myhome/app/logs/error.log;
}
Run Code Online (Sandbox Code Playgroud)

nginx

107
推荐指数
6
解决办法
15万
查看次数

如何在ruby ActiveRecord中销毁没有ID列的记录?

我有一个没有ID列的表.当我尝试使用ActiveRecord从中删除生成的SQL时DELETE FROM table_name WHERE ID=NULL,显然不起作用.有没有办法使用ActiveRecord从表中删除,或者至少使用占位符运行原始SQL删除查询(因此它不易受SQL注入攻击)?

ruby activerecord ruby-on-rails

20
推荐指数
2
解决办法
5474
查看次数

我的应用程序不断创建数据库连接,我如何追踪原因?

我有一个在Heroku上运行的Ruby on Rails应用程序.我一直在日志中收到这些消息:

2015-05-05T16:11:14Z app[postgres.27102]: [AQUA] connection received: host=xx.xxx.xx.26 port=60278
2015-05-05T16:11:14Z app[postgres.27102]: [AQUA] connection authorized: user=postgres database=somedb
2015-05-05T16:11:14Z app[postgres.27103]: [AQUA] connection received: host=xx.xxx.xx.26 port=60291
2015-05-05T16:11:14Z app[postgres.27103]: [AQUA] connection authorized: user=postgres database=postgres
2015-05-05T16:11:18Z app[postgres.27104]: [AQUA] connection received: host=xx.xxx.x.166 port=54180
2015-05-05T16:11:18Z app[postgres.27104]: [AQUA] connection authorized: user=postgres database=somedb
2015-05-05T16:11:23Z app[postgres.27105]: [AQUA] connection received: host=xx.xxx.x.166 port=55488
2015-05-05T16:11:23Z app[postgres.27105]: [AQUA] connection authorized: user=postgres database=somedb
2015-05-05T16:11:28Z app[postgres.27106]: [AQUA] connection received: host=xx.xxx.x.166 port=56774
2015-05-05T16:11:28Z app[postgres.27106]: [AQUA] connection authorized: user=postgres database=somedb
2015-05-05T16:11:28Z app[postgres.27107]: [AQUA] connection received: host=xx.xxx.x.166 port=56854 …
Run Code Online (Sandbox Code Playgroud)

ruby ruby-on-rails heroku puma rails-activerecord

18
推荐指数
1
解决办法
441
查看次数

什么是devise_mapping变量,我该如何包含它?

我正在尝试在我的Rails应用程序中使用Devise实现身份验证(Rails 2.3.8,Devise 1.0.7,在Windows Vista上运行的mongrel).但是我收到以下错误:

undefined local variable or method `devise_mapping' for #<ActionView::Base:0x6d63890>
Run Code Online (Sandbox Code Playgroud)

这是我使用自动生成的部分_devise_links.html.

<%- if controller_name != 'sessions' %>
  <%= link_to t('devise.sessions.link'), new_session_path(resource_name) %><br />
<% end -%>

<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
  <%= link_to t('devise.registrations.link'), new_registration_path(resource_name) %><br />
<% end -%>

<%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
  <%= link_to t('devise.passwords.link'), new_password_path(resource_name) %><br />
<% end -%>

<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
  <%= link_to t('devise.confirmations.link'), new_confirmation_path(resource_name) %><br />
<% end -%>

<%- …
Run Code Online (Sandbox Code Playgroud)

authentication ruby-on-rails devise

17
推荐指数
2
解决办法
1万
查看次数

如何从维基百科中获取有关人员的所有文章?

从维基百科获取所有关于人的文章的最简单方法是什么?我知道我可以下载所有页面的转储,但是我如何过滤那些只获取有关人员的内容?我需要尽可能多的(最好超过一百万),所以使用任何类型的API可能都不是一种选择.

wikipedia wikipedia-api

14
推荐指数
2
解决办法
3037
查看次数

如何完全替换git存储库中的代码

我在本地计算机上有一个Facebook应用程序,另一个用Heroku创建(Heroku应用程序中的代码由Heroku自动创建).我想用我本地机器上的代码完全替换Heroku应用程序中的代码.我已经在我的机器上的代码所在的目录中初始化了一个git存储库,并且我已经设置了URL git remote add origin git@heroku.com:my-fb-app.git.但是,当我输入时,git push origin master我得到:

To git@heroku.com:my-fb-app.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@heroku.com:blooming-cove-5867.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Run Code Online (Sandbox Code Playgroud)

显然,这不是正确的方法.我应该怎么做呢?

git heroku

14
推荐指数
1
解决办法
4875
查看次数

"加速C++:实例编程"仍然是最新的吗?

我需要学习C++.因为我喜欢这本书的概念而且我已经可以用其他几种语言编程,我认为"加速C++:实例编程实例"将是最好的选择.然而,这本书已有12年历史.是否仍然是一个好主意,或者我会错过太多重要的语言新功能?

c++

11
推荐指数
1
解决办法
9372
查看次数

以编程方式生成属性

我想加载一个属性文件(它是一个.csv文件,每行都有一个名称和相关的数值),然后访问这些属性值,如下所示:FileLoader.PropertyOneFileLoader.PropertyTwo.问题是我不想为每个值写一个属性,我希望它们是从文件生成的.所以

public class FileLoader
{
    public int Property1 { get; private set; }
}
Run Code Online (Sandbox Code Playgroud)

不是我想要的.这可能吗?我看不到任何方法,因为显然编译器不会知道属性名称.也许类似的东西?

c# properties

10
推荐指数
1
解决办法
1万
查看次数

Selenium测试谷歌地图

有人在Google Maps API V3地图上有Selenium测试(或其他一些浏览器测试环境)的代码示例吗?具体来说,我想与标记和弹出窗口进行交互.

selenium automated-tests google-maps-api-3

8
推荐指数
1
解决办法
2万
查看次数