我正在使用Rails 4.2.6开发Ruby On Rails应用程序.我正在使用Turbolinks和jquery.turbolinks(抱歉,我不能发布链接到这些元素,因为我是网站上的新手).我的问题很简单,但我无法解决.这是:我有一个通过AJAX获取的表单
<div class="card-footer">
<a class="btn btn-sm btn-primary-outline" data-remote="true" href="/profiles/Mke5kA/positions/new"><i class="fa fa-plus"></i> Nouvelle expérience professionnelle</a>
<div id="new_position_form"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
表单包含通过AJAX获取数据的Select2元素
= simple_form_for [profile, position], remote: true, html: {id: 'positionForm', class: 'm-b-1'} do |f|
= f.input :company_id, as: :select, input_html: {:'data-behaviour' => 'company-select2', :'data-kind' => 'company'}
= f.input :title
= f.input :summary
- location = f.object.build_location
= f.simple_fields_for :location do |l|
= render 'locations/fields', l: l, city: position.city
= render "profiles/shared/date_fields", f: f, model: position
= f.input :skill_list, as: :select, …Run Code Online (Sandbox Code Playgroud) 我一直在尝试使用sidekiq-limit_fetch gem 来限制每个队列的工作量,而Sidekiq似乎"看到"了日志中强加的限制,但是当我看到工作人员时,忽略了限制.
这是Sidekiq看到限制的日志中的部分:
2013-04-02T05:47:19Z 748 TID-11ilcw DEBUG: {:queues=>
["recommendvariations",
"recommendvariations",
"recommendvariations",
"recommendphenotypes",
"recommendphenotypes",
"recommendphenotypes",
"preparse",
"preparse",
"preparse",
"parse",
"parse",
"parse",
"zipgenotyping",
"zipgenotyping",
"zipfulldata",
"deletegenotype",
"fitbit",
"frequency",
"genomegov",
"mailnewgenotype",
"mendeley_details",
"mendeley",
"pgp",
"plos_details",
"plos",
"snpedia",
"fixphenotypes"],
:concurrency=>5,
:require=>".",
:environment=>"production",
:timeout=>8,
:profile=>false,
:verbose=>true,
:pidfile=>"/tmp/sidekiq.pid",
:logfile=>"./log/sidekiq.log",
:limits=>
{"recommendvariations"=>1,
"recommendphenotypes"=>1,
"preparse"=>2,
"parse"=>2,
"zipgenotyping"=>1,
"zipfulldata"=>1,
"fitbit"=>3,
"frequency"=>10,
"genomegov"=>1,
"mailnewgenotype"=>1,
"mendeley_details"=>1,
"mendeley"=>1,
"pgp"=>1,
"plos_details"=>1,
"plos"=>1,
"snpedia"=>1,
"fixphenotypes"=>1},
:strict=>false,
:config_file=>"config/sidekiq.yml",
:tag=>"snpr"}
Run Code Online (Sandbox Code Playgroud)
和这里的sidekiq.yml.从sidekiq的web界面来看,这些限制被忽略了 - 现在,我在"推荐变量"上得到了2名工人 - 但这应该是1.
我开始工人了bundle exec sidekiq -e …
我正在寻找在 h2 数据库中使用 Java(或在运行时使用 Java 应用程序计算的 SQL)导入任何 csv 文件的解决方案。一种可能性是首先编写一个动态文件并在创建后在 h2 数据库连接上运行“脚本”。我的主要问题是我动态创建 csv 文件,列号和标签值可能不同。用于获取连接、在 h2 上运行脚本并在应用程序运行期间创建文件的环境仍然存在。
现在我找到了很多解决方案,如果我知道 csv 结构,但我以前不知道。另一个问题是类型永远不确定(如果更容易找到解决方案,可以说都是双重的。
我需要这个的原因是,我想在图表(折线图)中显示数据集。有时我需要前两行作为 x 轴。有时我必须显示一行有时更多(所以在 csv 中有一个 ylabel 或更多)
我想在数据库中保存这些数据的原因是我想根据 x 轴标准显示该集合的最小最大值和平均值。(smt。显示每月,每天,每周)。所以这个想法是通过创建数据并通过读取 Chart i Group by 数据来设置日期格式DATE(DATE,TIME)。
示例:我的基本 csv 示例
DATE,TIME,label1 , y2 ,line3 ,... (labelNames have no equality)
20160101,0115, any int,any double ,any int,...
20160101,0130, ... , ... , ... ,.. (if there is no messure
20160101,0145, ... , ..... , --- ,.. the placefolder is '---')
20160101,0200, ....
20160102,...
Run Code Online (Sandbox Code Playgroud)
所以有时我得到的 …
我最近和一位朋友就这样的代码争论过:
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* See memory consistency effects in a Java Executor.
*/
public class PrivateFieldInEnclosing {
private long value;
PrivateFieldInEnclosing() {}
void execute() {
value = initializeValue();
ExecutorService executor = Executors.newCachedThreadPool();
executor.submit(new Y());
}
class Y implements Runnable {
@Override
public void run() {
System.out.println(value);
}
}
private long initializeValue() {
return 20;
}
public static void main(String[] args) {
new PrivateFieldInEnclosing().execute();
}
}
Run Code Online (Sandbox Code Playgroud)
我认为,这是可能的,value可以为可见0的Y,因为有不能保证分配value = initializeValue()是在执行程序的线程是可见的.我说他需要做value …
这是正在使用的代码 Net::HTTP::Post
request = Net::HTTP::Post.new(url)
...
form_data = [
['attachments[]', File.open('file1.txt')],
['attachments[]', File.open('file2.txt')]
]
request.set_form form_data, 'multipart/form-data'
http.request(request)
Run Code Online (Sandbox Code Playgroud)
现在,我正在尝试httparty像下面这样使用,但是它不起作用。
body = { attachments: [ File.open('file1.txt'), File.open('file2.txt') ] }
HTTParty.post(url, body: body)
Run Code Online (Sandbox Code Playgroud)
我从Web服务呼叫获得的响应如下:
#<HTTParty::Response:0x557d7b549f90 parsed_response={"error"=>true, "error_code"=>"invalid_attachment", "error_message"=>"Attachmen
t(s) not found or invalid."}, @response=#<Net::HTTPBadRequest 400 Bad Request readbody=true>, @headers={"server"=>["nginx"], "date"=>[
"Mon, 20 May 2019 07:41:50 GMT"], "content-type"=>["application/json"], "content-length"=>["102"], "connection"=>["close"], "vary"=>["
Authorization"], "set-cookie"=>["c18664e1c22ce71c0c91742fbeaaa863=uv425hihrbdatsql1udrlbs9as; path=/"], "expires"=>["Thu, 19 Nov 1981
08:52:00 GMT", "-1"], "cache-control"=>["no-store, no-cache, must-revalidate", "private, must-revalidate"], "pragma"=>["no-cache", "no
-cache"], "x-ratelimit-limit"=>["60"], "x-ratelimit-remaining"=>["59"], …Run Code Online (Sandbox Code Playgroud) 总是一样的错误:
AilixdeMacBook-Pro:~ Ailix$ ruby -v
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]
AilixdeMacBook-Pro:~ Ailix$ ruby -d
Exception `LoadError' at /Library/Ruby/Site/2.0.0/rubygems.rb:1240 - cannot load such file -- rubygems/defaults/operating_system
Exception `LoadError' at /Library/Ruby/Site/2.0.0/rubygems.rb:1249 - cannot load such file -- rubygems/defaults/ruby
Exception `NameError' at /Library/Ruby/Site/2.0.0/rubygems.rb:1257 - uninitialized constant Gem::Specification
/Library/Ruby/Site/2.0.0/rubygems.rb:1257:in `': uninitialized constant Gem::Specification (NameError)
from :1:in `require'
from :1:in `'
AilixdeMacBook-Pro:~ Ailix$ gem -v
/Library/Ruby/Site/2.0.0/rubygems.rb:1257:in `': uninitialized constant Gem::Specification (NameError)
from :1:in `require'
from :1:in `'
AilixdeMacBook-Pro:~ Ailix$ brew -v
/Library/Ruby/Site/2.0.0/rubygems.rb:1257:in `': uninitialized …Run Code Online (Sandbox Code Playgroud) 我有一个类方法,我想修改当前由ActiveRecord::Relation对象抓取的记录.但我不知道如何在类方法中引用当前作用域. self不这样做.
例:
class User < ActiveRecord::Base
...
def self.modify_those_records
#thought implicitly #to_a would be called on currently grabbed records but doesn't work
temp_users_to_a = to_a
...
end
end
Run Code Online (Sandbox Code Playgroud)
我会像这样使用它:
User.some_scope.modify_those_records
Run Code Online (Sandbox Code Playgroud)
所以User.some_scope会回到我身边ActiveRecord::Relation,其中包含一堆User记录.然后,我想修改该类方法中的那些记录,然后返回它们.
问题是:我不知道如何在类方法中明确引用"那组记录".
我的VS Code集成终端仅切换了一秒钟,然后消失了Ctrl+`(尝试对其进行了更改-仍然无法运行:)),显示了Integrated terminal exited with code 1错误。
有修复的想法吗?
我有一个关于在 git 中重命名文件的问题。
我想重命名一个文件。所以我重命名它。据我所知,如果我不更改文件的内容,git 会检测到移动,因为文件的哈希值是相同的。
我正在使用 C++,所以重命名后我必须更改文件中的包含路径(我已重命名),所以问题是 git 没有检测到移动,而是认为一个文件被删除,另一个文件被删除添加。我正在寻找 git 检测到此更改的解决方案。
有人对此有什么好的策略吗?
在此先感谢
通卡
当我在终端中运行命令时(使用 El Capitan)
ld -m elf_i386 -T linker.ld -o kernel kasm.o kc.o
Run Code Online (Sandbox Code Playgroud)
它显示以下错误:
ld: warning: option -m is obsolete and being ignored
ld: file not found: elf_i386
Run Code Online (Sandbox Code Playgroud)
有人能帮我解决这个问题吗?
ruby ×4
java ×2
terminal ×2
activerecord ×1
concurrency ×1
csv ×1
elf ×1
gcc ×1
git ×1
gnu ×1
h2 ×1
httparty ×1
httpclient ×1
integrated ×1
javascript ×1
macos ×1
osx-yosemite ×1
rename ×1
rubygems ×1
sidekiq ×1
web-services ×1