有人能告诉我如何根据自定义字符串对嵌套数组进行排序吗?例如,有没有办法排序:
[['Red','Blue'],['Green','Orange'],['Purple','Yellow']]
Run Code Online (Sandbox Code Playgroud)
by "Orange","Yellow"然后"Blue"呢?最终结果如下:
[['Green','Orange'],['Purple','Yellow'],['Red','Blue']]
Run Code Online (Sandbox Code Playgroud)
它不按字母顺序排序.我很想知道我是否可以定义值来排序以实现上述目标.
虽然我不是专家,但我已经在内部开发了一些rails应用程序,用于一些相对较小/中等规模的项目,并且没有任何类似于此之前的问题.
我只是想创建一个新的应用程序,然后是一个脚手架,我得到一个关于sqlite3 gem的错误.看看这个(我的问题的例子):
[user:ubuntu:~/Documents/rails_apps]$ rails new goku
[user:ubuntu:~/Documents/rails_apps]$ cd goku
[user:ubuntu:~/Documents/rails_apps/goku]$ rails g scaffold FindingName name:text
Error loading the 'sqlite3' Active Record adapter. Missing a gem it depends on? can't activate sqlite3 (~> 1.3.6), already activated sqlite3-1.4.0. Make sure all dependencies are added to Gemfile. (LoadError)
Run Code Online (Sandbox Code Playgroud)
我看到另一个线程(replace_gem:错误加载'sqlite3'活动记录适配器 - 创建模型时)建议添加gem 'sqlite3', '~> 1.3', '>= 1.3.6'到gemfile,但这对我没有任何作用.
[user:ubuntu:~/Documents/rails_apps/goku]$ bundle install 4:47PM/02.06
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler …Run Code Online (Sandbox Code Playgroud) 在 Linux 服务器上,我已成功使用 添加了 ssh 密钥,将其添加到使用ssh-keygen中可用的密钥列表中,然后将该公钥添加到我组织的私有存储库中的部署密钥部分。该部署密钥还具有写入权限。ssh-agentssh-add ~/.ssh/my_new_private_key
但是,当我使用 SSH 链接运行时git clone,出现以下错误:
# git clone git@github.myorg/myprivaterepo.git
Cloning into 'myprivaterepo'...
ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)
我缺少什么?我已按照此处的指南https://docs.github.com/en/developers/overview/managing-deploy-keys#deploy-keys成功添加部署密钥,但尝试克隆时没有成功。
我只是想构建 Kali Linux 的 arm64 映像,但遇到了 qemu 问题。在为 armv7l 构建该映像时,一切似乎都运行良好,但在 arm64 上则不然。
我刚刚安装,qemu-user-static所以它运行的是最新版本。这是我的Dockerfile样子(仅用于测试目的):
FROM kalilinux/kali-rolling
# Set environment variable for non-interactive install
ARG DEBIAN_FRONTEND=noninteractive
# Run basic commands to update the image and install basic stuff.
RUN apt update && \
apt dist-upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"
Run Code Online (Sandbox Code Playgroud)
这是我的docker版本:
ubuntu@ip-10-20-38-44:~$ docker -v
Docker version 20.10.6, build 370c289
Run Code Online (Sandbox Code Playgroud)
这是我为重现此错误而运行的命令:
ubuntu@ip-10-20-38-44:~$ sudo docker buildx build -t [myusername]/test:latest --platform linux/arm64 .
Run Code Online (Sandbox Code Playgroud)
这是运行上面的命令时得到的错误输出:
[+] Building 39.9s (5/5) FINISHED …Run Code Online (Sandbox Code Playgroud) 我正在使用Bootstrap和tinymce-rails,这样我就可以为我的一些文本区域提供一个很好的文本编辑器.但是,我有一个模式渲染,其中包含一个文本和"TinyMCE的"类的表单,但这种模式实际上只是显示了TinyMCE的文本编辑器,一个时间.关闭并重新打开模态后,它只会看起来像常规文本字段.
这是正在呈现的表单:
<%= form_for @paragraph_section, html: {class: "form-horizontal"} do |f| %>
<div class="form-group">
<%= f.label :paragraph, nil, class: "col-sm-3 control-label" %>
<div class="col-sm-6">
<%= f.text_area :paragraph, placeholder: "(e.g. Hello World)", class: "form-control tinymce" %>
</div>
</div>
<div class="modal-footer">
<%= f.submit "Add paragraph", class: "btn btn-xs btn-primary" %>
</div>
<% end %>
Run Code Online (Sandbox Code Playgroud)
现在,当我点击"New paragraph"链接,它发送一个远程调用new.js.erb时,这个模式弹出,并且tinymce文本编辑器实际上工作.但是,再次,一旦我关闭它并再次用"新段落"链接重新打开mdoal,tinymce文本编辑器不起作用.
这是new.js.erb文件的样子:
$('#modalOne').modal({show: true});
$('#modal_content').html("<%= j render 'form' %>");
$('#modal_header').html("New Paragraph");
tinymce.init({
selector: "textarea",
width: '100%',
height: 270,
plugins: [ "anchor link" ],
statusbar: false,
menubar: …Run Code Online (Sandbox Code Playgroud) 我对 sidekiq 有点陌生,但最近我设法让它工作得很好。但是,我注意到我需要将并发数从 5 增加到 20-25。当我编辑我的sidekiq.yml文件时,它显示了这一点:
development:
:concurrency: 5
production:
:concurrency: 20
:queues:
- default
Run Code Online (Sandbox Code Playgroud)
从 5 到 25,它给我一个错误,说明:
您的 Redis 连接池太小,Sidekiq 无法工作。您的池有 20 个连接,但实际上至少需要有 27 个
这个错误究竟指的是什么?我什至将“生产”从 20 改为 30,它仍然声称我的池有 20 个连接。
如果我增加并发,为什么突然变小了?任何澄清将不胜感激。
注册 Amazon SSM 代理时,它在 SSM 托管实例控制台中注册成功,但连接显示“连接丢失”。
当我尝试手动启动该服务时,出现以下错误:
Error occurred fetching the seelog config file path: open /etc/amazon/ssm/seelog.xml: no such file or directory
Initializing new seelog logger
New Seelog Logger Creation Complete
2020-12-09 10:20:01 ERROR error occurred when starting amazon-ssm-agent: failed to start message bus, failed to start health channel: failed to listen on the channel: ipc:///var/lib/amazon/ssm/ipc/health, address in use
Run Code Online (Sandbox Code Playgroud)
我究竟该如何解决这个问题?我尝试过几次重新启动该服务,但没有成功。
我正在 AWS Workspaces 中设置新的开发环境,我注意到当我运行 时docker build,出现以下错误:
---> Running in d18733d53c16
W: Failed to fetch http://deb.debian.org/debian/dists/buster/InRelease Temporary failure resolving 'deb.debian.org'
W: Failed to fetch http://security.debian.org/debian-security/dists/buster/updates/InRelease Temporary failure resolving 'security.debian.org'
W: Failed to fetch http://deb.debian.org/debian/dists/buster-updates/InRelease Temporary failure resolving 'deb.debian.org'
W: Some index files failed to download. They have been ignored, or old ones used instead.
Run Code Online (Sandbox Code Playgroud)
Reddit 上有人提到这是一个已知问题,但 AWS 文档似乎没有提到这个问题,而且我在网上找不到更多相关信息。
它只是一个标准的 Docker 文件,已经使用了大约一年,没有出现任何问题。这似乎正在发生在适用于 Linux 的 AWS Workspaces 中。
我一直在努力争取让这个工作在最后几个小时,我出于某种原因我不能.我几乎完全遵循github存储库链接上指示的步骤.
我使用以下所有步骤创建了一个新应用程序:
# rails new demo_app
# cd demo_app/
+++ added gem 'cocoon' to the Gemfile
+++ added //= require cocoon to the application.js file
# rails g scaffold Project name:string description:string
# rails g model Task description:string done:boolean project:belongs_to
+++ added has_many :tasks to the Project model
+++ added :_destroy to the permit in my projects_controller.rb file
# bundle install
Run Code Online (Sandbox Code Playgroud)
这是我的views/projects/_form.html.erb文件:
<%= form_for(@project) do |f| %>
<% if @project.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@project.errors.count, "error") %> prohibited this project …Run Code Online (Sandbox Code Playgroud) 我正在尝试解决为什么 Ruby 没有用空格分割我的字符串。例如:
[1] pry(#<irb>)> msg
=> "!iex <http://test-domain.com.au|test-domain.com.au> <mailto:first.last@test-domain.com.au|first.last@test-domain.com.au> FirstName"
[2] pry(#<irb>)> msg.split(" ")
=> ["!iex <http://test-domain.com.au|test-domain.com.au> <mailto:first.last@test-domain.com.au|first.last@test-domain.com.au> FirstName"]
[3] pry(#<irb>)> msg.include? " "
=> false
[8] pry(#<irb>)> msg.inspect
=> "\"!iex <http://test-domain.com.au|test-domain.com.au> <mailto:first.last@test-domain.com.au|first.last@test-domain.com.au> FirstName\""
[9] pry(#<irb>)>
Run Code Online (Sandbox Code Playgroud)
正如您在上面看到的,我的字符串似乎包含空格,但该split方法不起作用。我试图inspect在字符串上运行只是为了查看是否正在显示其他内容,但这对我来说并没有多大意义。
docker ×2
ruby ×2
aws-ssm ×1
cocoon-gem ×1
git ×1
javascript ×1
jquery ×1
qemu ×1
sidekiq ×1
ssh ×1