我通过nginx提供单页JavaScript应用程序,当我部署新版本时,我想强制浏览器使其JS缓存无效并请求/使用可用的最新版本.
因此,例如,当我用命名的文件替换服务器文件夹my-app-8e8faf9.js上的文件时my-app-eaea342.js,我不希望浏览器再次my-app-8e8faf9.js从其缓存中提取.但是当没有可用的新版本时,我仍然希望他们从缓存中读取资产.
如何使用nginx配置实现此目的?这是我现有的配置:
server {
listen 80;
server_name my.server.com;
root /u/apps/my_client_production/current;
index index.html;
# ~2 seconds is often enough for most folks to parse HTML/CSS and
# retrieve needed images/icons/frames, connections are cheap in
# nginx so increasing this is generally safe...
keepalive_timeout 10;
client_max_body_size 100M;
access_log /u/apps/my_client_production/shared/log/nginx.access.log;
error_log /u/apps/my_client_production/shared/log/nginx.error.log info;
location / {
try_files $uri $uri/ =404;
gzip_static on;
expires max;
add_header Cache-Control public;
}
# Error pages
error_page 500 502 503 504 …Run Code Online (Sandbox Code Playgroud) 我一直在努力解决这个问题很长一段时间,我找不到一个有效的解决方案.
我有一个wav文件(16位PCM:44kHz 2通道),我想为两个通道中的每一个提取两个数组的样本.据我所知,NAudio库中不存在直接的方法,所以我尝试运行以下代码来读取一些隔行扫描的样本,但缓冲区数组保持为空(只是一堆零):
using (WaveFileReader pcm = new WaveFileReader(@"file.wav"))
{
byte[] buffer = new byte[10000];
using (WaveStream aligned = new BlockAlignReductionStream(pcm))
{
aligned.Read(buffer, 0, 10000);
}
}
Run Code Online (Sandbox Code Playgroud)
任何有关这方面的帮助将非常感激.
在扩展弹出 HTML 中,我放置了一个表情符号,如下所示:
<div>
<input id="user_input" autofocus>
</div
但是当我打开扩展弹出窗口时,会显示以下内容:
我真的很想在扩展 HTML 文档中使用表情符号。我有办法解决这个问题吗?
google-chrome browser-extension google-chrome-extension emoji
我正在使用$ .getJSON获取一些我希望异步绑定到控制器上下文的数据.我已经在我的路线中想出了这个 - 这有效,但我对它并不满意:
setupController: function(controller, model) {
this._super(controller, model);
Em.RSVP.Promise.cast(Em.$.getJSON((this.get('ENV.apiBaseURL')) + "/users/current/live_matchday_stats")).then((function(_this) {
return function(s) {
return _this.controller.set('matchdayStats', Em.Object.create(s));
};
}
Run Code Online (Sandbox Code Playgroud)
然后,在我的模板中,我可以使用:
Foo: {{matchdayStats.foo}}
Run Code Online (Sandbox Code Playgroud)
它工作得很好.有没有更好的方法来编写它(可能没有promise casts和Em.Object创建) - 我知道如果我将Em.$.getJSON放入模型钩子中,这会自动生效.
我有使用后台作业的一个回报率的应用程序,每当和sidekiq宝石.
在开发环境中,当我使用本地redis实例(在localhost上)启动sidekiq时,该作业将继续执行而不会出现问题.但是,当我切换到一个远程redis实例(Heroku附加组件)并重新启动sidekiq时,它说它开始处理,但没有任何反应,工人没有做任何工作.
这是我的config/schedule.rb(适用于每当宝石)
every 2.minutes do
rake "crawler:crawl"
end
Run Code Online (Sandbox Code Playgroud)
这是我的初始化器/ redis.rb:
Sidekiq.configure_server do |config|
config.redis = { :url => 'redis://user:pass@spinyfin.redistogo.com:9098/' }
end
Sidekiq.configure_client do |config|
config.redis = { :url => 'redis://user:pass@spinyfin.redistogo.com:9098/' }
end
Run Code Online (Sandbox Code Playgroud)
如果我在redis.rb中注释掉内容并运行本地redis实例,则会正常处理作业.但是,当我使用这个远程redis实例时,会显示,然后没有任何处理:
2013-11-29T15:09:26Z 95156 TID-ov6y7e14o INFO: Booting Sidekiq 2.13.0 using redis://redistogo:user@spinyfin.redistogo.com:9098/ with options {}
2013-11-29T15:09:26Z 95156 INFO: Running in ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-darwin11.4.2]
2013-11-29T15:09:26Z 95156 INFO: See LICENSE and the LGPL-3.0 for licensing details.
2013-11-29T15:09:26Z 95156 INFO: Starting processing, hit …Run Code Online (Sandbox Code Playgroud) 我正在运行带有两个不同数据库的Rails 4.2.5应用程序.第一个,我们称之为db_main,使用sql模式格式(因为这个DB有一些ruby模式无法处理的数据库结构).我通过把实现此config.active_record.schema_format = :sql在application.rb.
现在,还有第二个DB,我们称之为db_other.这个DB有一个ruby模式,但问题是它的db任务需要一个sql模式.我db为此数据库定义了所有相关任务,如下所示:
namespace :other do
task :set_custom_db_config_paths do
ENV['SCHEMA'] = 'db_other/schema.rb'
Rails.application.config.paths['db'] = ['other']
Rails.application.config.paths['db/migrate'] = ['db_other/migrate']
Rails.application.config.paths['config/database'] = ['config/database_other.yml']
end
namespace :db do
task :migrate => :set_custom_db_config_paths do
Rake::Task["db:migrate"].invoke
end
... other tasks
namespace :test do
task :prepare => :set_custom_db_config_paths do
# Tried setting ActiveRecord::Base.schema_format = :ruby here, but problem remains
Rake::Task["db:test:prepare"].invoke
end
end
end
end
Run Code Online (Sandbox Code Playgroud)
通话时rake other:test:prepare,会发生以下情况
`psql:db_other/schema.rb:135:错误:语法错误在"#"`或附近
我如何配置以便 …
出于生产目的,我需要运行三个进程.这是我的procfile,我使用Foreman启动它们:
web: bundle exec rails s Puma -p $PORT
queuing: bundle exec clockwork clock.rb
workers: bundle exec rake resque:workers
Run Code Online (Sandbox Code Playgroud)
部署我正在使用Mina.在部署任务结束时启动Foreman的适当方法是什么?目前我开始是这样的:
desc "Deploys the current version to the server."
task :deploy => :environment do
deploy do
invoke :'git:clone'
invoke :'deploy:link_shared_paths'
invoke :'bundle:install'
invoke :'rails:db_migrate'
invoke :'rails:assets_precompile'
to :launch do
queue "touch #{deploy_to}/tmp/restart.txt"
queue "bundle exec foreman start"
end
end
end
Run Code Online (Sandbox Code Playgroud)
...但我不认为这是正确的方式,因为"mina deploy"命令永远不会成功退出,本地控制台只是开始输出这些进程正在做的任何事情.
问题二:如何在单独的文件中分别初始化这三个进程中的每个进程的日志记录?
当其中一个进程崩溃时,如何防止杀死所有这三个进程?如何在崩溃时重新启动进程?
谢谢!
我有下表:
links:
created_at active
2017-08-12 15:46:01 false
2017-08-13 15:46:01 true
2017-08-14 15:46:01 true
2017-08-15 15:46:01 false
Run Code Online (Sandbox Code Playgroud)
给定日期范围时,我必须提取时间序列,该时间序列告诉我在等于或小于当前(滚动)日期的日期创建了多少活动链接.
输出(日期范围2017-08-12 - 2017-08-17):
day count
2017-08-12 0 (there are 0 active links created on 2017-08-12 and earlier)
2017-08-13 1 (there is 1 active link created on 2017-08-13 and earlier)
2017-08-14 2 (there are 2 active links created on 2017-08-14 and earlier)
2017-08-15 2 ...
2017-08-16 2
2017-08-17 2
Run Code Online (Sandbox Code Playgroud)
我想出了以下关于生成日期的查询:
SELECT date_trunc('day', dd):: date
FROM generate_series
( '2017-08-12'::timestamp
, '2017-08-17'::timestamp
, '1 day'::interval) …Run Code Online (Sandbox Code Playgroud) 我正在提供一个单页应用程序,该应用程序托管在S3上并通过CloudFront公开到Web。在对API进行维护时,我想进行一次手动切换,以导致对我的应用程序的请求呈现维护页面。
我可以将维护HTML(或json)放入S3。当我打开维护模式时,如何配置CloudFront以返回维护站点?