小编Rav*_*mar的帖子

以非常有效的方式从哈希中获取多个值

我的代码是

a={"1"=>"adi","2"=>"amar","3"=>"rave","4"=>"sum"}
arr=["1","5","3"]
Run Code Online (Sandbox Code Playgroud)

如果哈希中存在数组值,我想提取所有这样的值

result =["adi","rave"]
Run Code Online (Sandbox Code Playgroud)

没有使用任何循环.这是可能的

ruby hash

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

Omniauth与Google出错

当我与谷歌联系时,它给了我们

OAuth2::Error ({"errors"=>[{"domain"=>"usageLimits", "reason"=>"accessNotConfigured", "message"=>"Access Not Configured. Please use Google Developers Console to activate the API for your project."}], "code"=>403, "message"=>"Access Not Configured. Please use Google Developers Console to activate the API for your project."}:
{
 "error": {
  "errors": [
   {
    "domain": "usageLimits",
    "reason": "accessNotConfigured",
    "message": "Access Not Configured. Please use Google Developers Console to activate the API for your project."
   }
  ],
  "code": 403,
  "message": "Access Not Configured. Please use Google Developers Console to activate the API for your …
Run Code Online (Sandbox Code Playgroud)

ruby oauth oauth-2.0 omniauth ruby-on-rails-4

5
推荐指数
1
解决办法
677
查看次数

LDAP集成后无法在计算机(RHEL7)中使用本地用户登录

我是RedHat IDM的新手.以下是我的要求.请帮忙.

假设我们有两台RHEL7机器

  1. Redhat IDM服务器
  2. Redhat IDM客户端机器

    现在我们在IDM客户端计算机上创建了两个用户,条件如下

    • 使用简单的linux命令创建第一个用户

useradd ravendra

第二个我们使用IPA命令创建用户

IPA用户添加JSMITH --first =约翰--last =史密斯--manager = bjensen --email=johnls@example.com --homedir = /家庭/工作/约翰 - 密码

现在我们有以下要求.

  1. 如果IDM服务器正在运行,那么我们想要限制通过普通linux命令创建的用户"ravendra"的ssh.只有"jsmith"可以在IDM客户端计算机上使用sshs
  2. 如果IDM服务器已停止,则两个用户都可以在IDM客户端计算机上执行ssh.

所以请建议我任何插件或任何方式我如何能够实现这一目标.

提前致谢

linux redhat ldap

5
推荐指数
1
解决办法
79
查看次数

以有效的方式将字符串拆分为多个部分

我的代码在这里

str = "Early in his first term in office, Obama signed into law economic stimulus legislation in response"
arr= str.split(" ")
set_element= arr.each_cons(2).to_a
sub_str = set_element.map {|i| i.join(' ')}
Run Code Online (Sandbox Code Playgroud)

如果我有一个像大字符串这样的大字符串,那么这个过程需要6.50秒,因为我想要这种类型的结果

sub_str= ["Early in", "in his", "his first", "first term", "term in", "in office,", "office, Obama", "Obama signed", "signed into", "into law", "law economic", "economic stimulus", "stimulus legislation", "legislation in", "in response"]
Run Code Online (Sandbox Code Playgroud)

是否有可能采用其他有效方式

ruby arrays

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

两个elasticsearch服务器之间的负载平衡

我有两个ElasticSearch服务器:

http://12.13.54.333:9200
Run Code Online (Sandbox Code Playgroud)

http://65.98.54.10:9200
Run Code Online (Sandbox Code Playgroud)

在第一台服务器中,我有100k的数据(id= 1到id= 100k),在第二台服务器中我有100k的数据(id= 100k + 1到200k).

我希望obama在两台服务器上的一个请求中对该关键字进行文本搜索.这可能吗?

load-balancing elasticsearch

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

字符串连接的有效方式

我的代码在这里

a="524398447598973,12312345,1234567"
b="524398447598973,123,123456789"
c=a << b
Run Code Online (Sandbox Code Playgroud)

而且我想

c="524398447598973,12312345,1234567,524398447598973,123,123456789"
Run Code Online (Sandbox Code Playgroud)

我怎么能这样做.请有人帮助我.

谢谢

ruby

0
推荐指数
1
解决办法
118
查看次数