对于目录中的一堆文本文件(都非常小,大约 100 行),我需要构建一些字符串,然后将所有内容通过管道传输到其中,fzf
以便用户可以选择一个文件。字符串本身取决于文件的前几行 (~20) 行,并使用几个非常简单的正则表达式模式构建。在连续调用之间,预计只有少数文件会发生变化。我正在寻找某种方法来做到这一点,而没有明显的延迟(对于用户而言)大约 50k 个文件。
这是我到目前为止所做的:我对此的第一个解决方案是一个简单的 shell 脚本,即:
cat $dir/**/* | $process_script | fzf
其中 $process_script 是一些 Perl 脚本,它逐行读取每个文本文件,直到它构建了所需的字符串,然后将其打印出来。已经有 1000 个文件要处理,这个脚本不再可用,因为它需要大约两秒钟,因此会给用户带来明显的延迟。所以我通过将字符串存储在一些文本文件中来实现一个穷人的缓存,然后只更新那些实际更改的行(基于文件的 mtime)。新脚本大致执行以下操作:
$find_files_with_mtime_newer_than_last_script_run | $process_script | fzf
Run Code Online (Sandbox Code Playgroud)
其中 $find_files_with_mtime_newer_than_last_script_run 运行fd
(快速查找替换)并且 $process_script 是以下形式的 Perl 脚本
my $cache = slurp($cachefile); #read lines of cachefile into multiline string
my ($string,$id);
while (<>) {
($string, $id) = build_string($_); #open file and build string
$cache = s/^.*$id.*\n//; #delete old string from cache
$cache = $cache . $string; #insert …
Run Code Online (Sandbox Code Playgroud) 我有一个网页,用户在其中指定用户名和密码以对第三个网站进行查询.在Firefox和Chrome中,我可以创建表单的URL http://user:password@example.com
,但Internet Explorer 7表示无法找到该地址.
在Internet Explorer 7的URL中是否有任何形式的用户和密码设置?
我example.com
在GoDaddy注册(并在其他地方托管).我创建了一个子域名sub1.example.com
.
我有一个在EC2上运行良好的虚拟linux机器可访问 ec2-xx-xx-xx-xx.compute-1.amazonaws.com
问题:如何sub1.example.com
指向我的EC2虚拟机?
我尝试在 Windows 8 中将 Spark 与 Hadoop 一起使用。但是,无论我的代码是什么,我都会收到以下错误:
15/08/25 19:29:58 ERROR Shell: Failed to locate the winutils binary in the hadoop binary path
java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries.
at org.apache.hadoop.util.Shell.getQualifiedBinPath(Shell.java:355)
at org.apache.hadoop.util.Shell.getWinUtilsPath(Shell.java:370)
at org.apache.hadoop.util.Shell.<clinit>(Shell.java:363)
at org.apache.hadoop.util.StringUtils.<clinit>(StringUtils.java:79)
at org.apache.hadoop.security.Groups.parseStaticMapping(Groups.java:104)
at org.apache.hadoop.security.Groups.<init>(Groups.java:86)
at org.apache.hadoop.security.Groups.<init>(Groups.java:66)
at org.apache.hadoop.security.Groups.getUserToGroupsMappingService(Groups.java:280)
at org.apache.hadoop.security.UserGroupInformation.initialize(UserGroupInformation.java:271)
at org.apache.hadoop.security.UserGroupInformation.ensureInitialized(UserGroupInformation.java:248)
at org.apache.hadoop.security.UserGroupInformation.loginUserFromSubject(UserGroupInformation.java:763)
at org.apache.hadoop.security.UserGroupInformation.getLoginUser(UserGroupInformation.java:748)
at org.apache.hadoop.security.UserGroupInformation.getCurrentUser(UserGroupInformation.java:621)
at org.apache.spark.util.Utils$$anonfun$getCurrentUserName$1.apply(Utils.scala:2162)
at org.apache.spark.util.Utils$$anonfun$getCurrentUserName$1.apply(Utils.scala:2162)
at scala.Option.getOrElse(Option.scala:120)
at org.apache.spark.util.Utils$.getCurrentUserName(Utils.scala:2162)
at org.apache.spark.SparkContext.<init>(SparkContext.scala:301)
at org.apache.spark.api.java.JavaSparkContext.<init>(JavaSparkContext.scala:61)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) …
Run Code Online (Sandbox Code Playgroud) 我们正在使用rancher docker编排工具:它正在使用HAProxy启用负载平衡。我想知道如果建立与服务的新HTTPS连接,如何处理hanshake。
是在客户端与负载均衡器(牧场主/ HAProxy)之间完成握手,还是负载均衡器仅将HTTPS请求转发到后端服务?
我很难理解go中的接口和结构之间的关系.我已经声明了一个名为Datatype
如下的接口:
package main
type Datatype interface {
Unmarshal(record []string) error
String() string
}
Run Code Online (Sandbox Code Playgroud)
我还创建了几个实现此接口的结构.这是一个简单的例子:
package main
import (
"encoding/csv"
"fmt"
"gopkg.in/validator.v2"
"reflect"
"strconv"
"time"
)
type User struct {
Username string `validate:"nonzero"`
UserId string `validate:"nonzero"`
GivenName string `validate:"nonzero"`
FamilyName string `validate:"nonzero"`
Email string `validate:"regexp=^[0-9a-zA-Z]+@[0-9a-zA-Z]+(\\.[0-9a-zA-Z]+)+$"`
SMS string `validate:"nonzero"`
Phone string `validate:"min=10"`
DateOfBirth time.Time
}
type Users []User
func (u *User) Unmarshal(record []string) error {
s := reflect.ValueOf(u).Elem()
if s.NumField() != len(record) {
return &FieldMismatch{s.NumField(), len(record)}
}
for i := …
Run Code Online (Sandbox Code Playgroud) 在Api Gateway中,我创建了一个自定义域foo.example.com
,用它创建了一个Cloud Front发行版CNAME
.
我还想创建一个通配符域,*.example.com
但在尝试创建它时,CloudFront会抛出一个错误:
CNAMEAlreadyExistsException:您提供的一个或多个CNAME已与不同的资源相关联
AWS在其文档中指出:
但是,您可以添加通配符备用域名,例如*.example.com,其中包含(与其重叠)非通配符备用域名,例如www.example.com.只要两个分发都是使用相同的AWS账户创建的,重叠域名可以位于同一分布中,也可以位于不同的分布中.
所以我可能误解了这一点,是否有可能完成我所描述的内容?
我正在构建一个网络应用程序(例如:)www.mywebapp.example
,允许用户将他们的域 - www.xyz.example
- 指向www.mywebapp.example
. 当用户转到 时www.xyz.example
,他们的内容将从中提供www.mywebapp.example
。用户将被告知如何更新他们的@
和www
A records
在他们的域提供商中的 DNS 设置以连接www.xyz.example
到www.mywebapp.example
.
我可以./certbot-auto -d <domain-name>
为每个域手动创建新的 SSL 证书。我还设置了一个 cron 作业来测试更新。
但是,我想通过运行从 JavaScript 函数触发的 PHP 脚本来自动执行此过程,每次用户将其域连接到www.mywebapp.example
. 我的问题是:
我应该./certbot-auto
使用命令从 PHP执行exec()/shell_exec()
命令吗?我应该编写一个单独的 bash 脚本并运行 bash 脚本吗?
我应该使用 LetsEncrypt 推荐的 ACME PHP 库吗? https://letsencrypt.org/docs/client-options/
我手动为域创建了一个新的 SSL 证书www.xyz2.example
,该证书成功指向www.mywebapp.example
. 但是,这破坏了对所有现有域的 SSL 支持 - *.mywebapp.example, mywebapp.example, www.xyz.example
. 我是否需要为指向的每个域创建虚拟主机www.mywebapp.example
? …
我想要连接一个服务,该服务的所有者告诉我需要使用 TLS 1.2 连接。
问题是我的 Python 使用 TLS 1.3 我用这个命令检查了它python -c "import requests; print(requests.get('https://www.howsmyssl.com/a/check', verify=False).json()['tls_version'])"
是否可以将 TLS 降级至 1.2?
我在两个VPS中有类似100个类似网站的东西.我想使用HAProxy动态切换流量,但同时我想添加SSL证书.
我想使用添加变量来为每个网站调用特定证书.例如:
frontend web-https
bind 0.0.0.0:443 ssl crt /etc/ssl/certs/{{domain}}.pem
reqadd X-Forwarded-Proto:\ https
rspadd Strict-Transport-Security:\ max-age=31536000
default_backend website
Run Code Online (Sandbox Code Playgroud)
我还想检查SSL证书是否真的可用,如果它不可用,请切换到带有重定向的HTTP.
这可能与HAProxy有关吗?