八巷

文章 评论 浏览 28

八巷 2025-02-03 13:49:15

由于 fs.ReadFile 方法是一种异步方法,因此在此方法运行之前运行循环的过程在异步过程之前运行。异步过程有望花费更多的时间,因此测序阶段将转移到同步过程中。
要解决问题,您可以使用 fs.ReadFilesync 方法,即同步替代方案,而不是 fs.ReadFile ,如下:

const fs = require('fs');

let arr;
arr = fs.readFileSync('test.tsv', 'utf-8').split('\t');

// Now you are able to access the data here
for (const element of arr) {
    console.log(element);
}

注意不建议同步读取文件的数据。如果有大量数据,则可以阻止事件循环。这可能导致服务器无法响应其他请求。

Since the fs.readFile method is an asynchronous method, the for loop runs before this method runs, so the arr variable is not iterable, synchronous processes run before asynchronous processes. The asynchronous process is expected to take more time, so the sequencing phase is transferred to the synchronous process.
To fix your problem, you can use the fs.readFileSync method, which is a synchronous alternative instead of fs.readFile, as follows:

const fs = require('fs');

let arr;
arr = fs.readFileSync('test.tsv', 'utf-8').split('\t');

// Now you are able to access the data here
for (const element of arr) {
    console.log(element);
}

Note that it is not recommended to read data from a file synchronously. The event loop can be blocked if there is a large amount of data. This may cause the server to fail to respond to other requests.

无法从nodejs中的fs.ReadFile获取数据

八巷 2025-02-03 08:58:38

我对IIS的重写并不非常熟悉,但是我已经检查了他们的doc ,它似乎非常接近nginx。

在NGINX上,建议使用返回(如果可能)( doc在这里)。 {r:0} 在这种情况下,

您也可以与〜*结合使用,这是“正则表达式”,该表达式用前面的“〜*”修饰符(对于不敏感的匹配)( doc there )。 ^/... 表示它需要从它开始(例如,以/wuneng-platform-web 以及此后的其他任何内容开始(。*)

http {
  ## ...

  server {
    ## ...

    location ~* ^/(auth|platform-admin|product|substation-admin)(.*) {
        return 301 https://google.com$request_uri;
    }

    location ~* ^/(wuneng-platform-web|wuneng-channel-web|wuneng-web|wuneng-user-web|mini-program)(.*) {
        return 301 https://api.google.com$request_uri;
    }

    ## ...
  }

  ## ...

}

I'm not super familiar with IIS rewrite, but I have checked their doc and it seems pretty close to NGINX.

On NGINX, is recommended to use return if possible (doc here). The {R:0} is similar to the NGINX vars, in this case, the $request_uri.

You can also combine with the ~*, this is a "Regular expressions are specified with the preceding “~*” modifier (for case-insensitive matching)" (doc here). The ^/... means that it needs to start with it (e.g. starts with /wuneng-platform-web and anything else after that (.*).

The code will be something like:

http {
  ## ...

  server {
    ## ...

    location ~* ^/(auth|platform-admin|product|substation-admin)(.*) {
        return 301 https://google.com$request_uri;
    }

    location ~* ^/(wuneng-platform-web|wuneng-channel-web|wuneng-web|wuneng-user-web|mini-program)(.*) {
        return 301 https://api.google.com$request_uri;
    }

    ## ...
  }

  ## ...

}

I hope this will help you out :)

从IIS重写转换为nginx

八巷 2025-02-03 08:23:56

一如既往地感谢@asperi和他的回答:

现在有效:

            .onDrop(of: [UTType.utf8PlainText], isTargeted: $isDropping) { providers in
                
                _ = providers.first?.loadItem(forTypeIdentifier: "public.utf8-plain-text") { data, error in
                    if let error = error { print(error.localizedDescription) }
                    if let data = data as? Data {
                        DispatchQueue.main.async {
                            let string = NSString(data: data, encoding: 4) ?? "failed"
                            print(string)
                            self.array2.insert(Item(title: string as String, url: URL(string: "http://www.apple.com")!), at: 0)
                        }
                    }
                }
                return true
            }

As always thanks to @Asperi and his answer here:
SwiftUI: Not getting dropped NSString value in DropDelegate

This now works:

            .onDrop(of: [UTType.utf8PlainText], isTargeted: $isDropping) { providers in
                
                _ = providers.first?.loadItem(forTypeIdentifier: "public.utf8-plain-text") { data, error in
                    if let error = error { print(error.localizedDescription) }
                    if let data = data as? Data {
                        DispatchQueue.main.async {
                            let string = NSString(data: data, encoding: 4) ?? "failed"
                            print(string)
                            self.array2.insert(Item(title: string as String, url: URL(string: "http://www.apple.com")!), at: 0)
                        }
                    }
                }
                return true
            }

拖动Drop drop with URL可用,但不使用字符串–为什么?

八巷 2025-02-03 07:39:56

vadeout文档: https://api.jquery.com/fadeout/

代码>需要2个参数 - 持续时间和回调。因此,只需将其设置为较慢并在第二个元素上调用 fadein 即可;

function fadeImages($first, $second){
    $first.fadeOut(1000, () => $second.fadeIn(1000));
}

工作示例:

/////////////////scripts///////////////////////

function fadeSquares($el1, $el2){
  $el1.fadeOut(2000, ()=>{
    $el2.fadeIn(2000);
  });
}

/////////////////execute///////////////////////

let $el1 = $('#red');
let $el2 = $('#blue');

fadeSquares($el1, $el2);
.square {
  height: 100px;
  width: 100px;
}

#red {
  background-color: red;
}

#blue {
  background-color: blue;
  display: none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id='wrapper'>
  <div id='red' class='square'>a red square</div>
  <div id='blue' class='square'>a blue square</div>
</div>

FadeOut documentation: https://api.jquery.com/fadeout/

fadeOut takes 2 parameters - duration and a callback. So just set it to slower and call fadeIn on the second element;

function fadeImages($first, $second){
    $first.fadeOut(1000, () => $second.fadeIn(1000));
}

Working example:

/////////////////scripts///////////////////////

function fadeSquares($el1, $el2){
  $el1.fadeOut(2000, ()=>{
    $el2.fadeIn(2000);
  });
}

/////////////////execute///////////////////////

let $el1 = $('#red');
let $el2 = $('#blue');

fadeSquares($el1, $el2);
.square {
  height: 100px;
  width: 100px;
}

#red {
  background-color: red;
}

#blue {
  background-color: blue;
  display: none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id='wrapper'>
  <div id='red' class='square'>a red square</div>
  <div id='blue' class='square'>a blue square</div>
</div>

setInterval()之后淡入(然后在)部分

八巷 2025-02-03 06:51:49

请注意,V5的此更改

是通过标头,不再使用标题类。使用RequestConfiguration修饰符添加标题如下

var user = await graphServiceClient
.Users["{user-id}"]
.GetAsync(requestConfiguration => requestConfiguration.Headers.Add("ConsistencyLevel","eventual"));

Note this change in v5

To pass headers, the HeaderOption class is no longer used. Headers are added using the requestConfiguration modifier as follows

var user = await graphServiceClient
.Users["{user-id}"]
.GetAsync(requestConfiguration => requestConfiguration.Headers.Add("ConsistencyLevel","eventual"));

如何在MSGRAPH .NET SDK中设置用户代理字符串

八巷 2025-02-03 05:30:12

按照您发布的内容,您在tbl_api_data -id,cui_id上有一个复合索引。在SQL中,您将使用“ CUI_ID”字段的另一个表加入此表,并且您还将此字段用于组。但是,您还没有在此字段上添加索引。那可能是原因。
请记住,您发布的复合索引不能用于此连接和组,因为“ CUI_ID”不是最左侧的字段(或复合索引中的第一个字段)。
因此,尝试在“ CUI_ID”上添加单独的索引

Going by what you posted, you have a composite index on tbl_api_data - id,cui_id. In the SQL you are joining this table with another table using "cui_id" field and you are also using this field for group by. However, you havent added index on this field. That can be a reason.
Remember that the composite index you posted cant be used for this join and group by because "cui_id" is not the leftmost field (or first field in composite index).
So try adding a separate index on "cui_id"

通过加入的MySQL优化,将大量数据组成

八巷 2025-02-02 23:02:20

由于您的时间重叠跨度,我认为我们可以 lapply 在您的结束日期上,稍微突变一些数据,然后使用普通 ggplot2 审美学来为它们着色。

spans <- bind_rows(lapply(mdy("11/10/2010", "11/10/2011", "11/10/2012", "11/10/2013"), function(end) {
  filter(minex, between(dts, end - (365 + 180), end)) %>%
    mutate(day = day - min(day), end = end)
}))

ggplot(spans, aes(day, v1)) +
  geom_point(aes(color = factor(end)))

您可以通过快速摘要看到每个范围:

spans %>%
  group_by(end) %>%
  summarize(startdate = min(dts), enddate = max(dts))
# # A tibble: 4 x 3
#   end        startdate  enddate   
#   <date>     <date>     <date>    
# 1 2010-11-10 2010-01-01 2010-11-10
# 2 2011-11-10 2010-05-14 2011-11-10
# 3 2012-11-10 2011-05-15 2012-11-10
# 4 2013-11-10 2012-05-14 2013-11-10

Since you have overlapping spans of time, I think we can lapply over your end dates, mutate the data a little, then use normal ggplot2 aesthetics to color them.

spans <- bind_rows(lapply(mdy("11/10/2010", "11/10/2011", "11/10/2012", "11/10/2013"), function(end) {
  filter(minex, between(dts, end - (365 + 180), end)) %>%
    mutate(day = day - min(day), end = end)
}))

ggplot(spans, aes(day, v1)) +
  geom_point(aes(color = factor(end)))

enter image description here

You can see the range of each with a quick summary:

spans %>%
  group_by(end) %>%
  summarize(startdate = min(dts), enddate = max(dts))
# # A tibble: 4 x 3
#   end        startdate  enddate   
#   <date>     <date>     <date>    
# 1 2010-11-10 2010-01-01 2010-11-10
# 2 2011-11-10 2010-05-14 2011-11-10
# 3 2012-11-10 2011-05-15 2012-11-10
# 4 2013-11-10 2012-05-14 2013-11-10

如何用每日数据绘制多个重叠的18个月重叠?

八巷 2025-02-02 19:48:59

我将实现我在评论中所说的禁用属性策略:

$("#myfile").on("change", function() {
if ($("#myfile")[0].files.length > 4) {
    alert("You can select only 4 images");
    $(".form-control").prop("disabled",true);
 } 
});

使用上述代码,用户将无法提交表格

I will implement the disable attribute strategy as I said in the comments:

$("#myfile").on("change", function() {
if ($("#myfile")[0].files.length > 4) {
    alert("You can select only 4 images");
    $(".form-control").prop("disabled",true);
 } 
});

With the above code the user will not be able to submit the form

如何清除用户上传的图像,如果jQuery中的文件限制

八巷 2025-02-02 13:28:29

您正在有条件地渲染 picker 组件, showemojis 也在同一单击“侦听器”中设置状态。状态更新可能是异步的,您正在拨打不存在的元素上的scrollintoview。

为了在打开选择器后滚动到视图中,您需要从 useffect 打开后调用scrollintoview。

useEffect(() => {
  if(showEmojis) {
    document.getElementById('picker').scrollIntoView(true)
  }
} , [showEmojis])

You are conditionally rendering the picker Component and the showEmojis state is also being set in the same click listener. State updates may be async and you are calling scrollIntoView on element which doesn't exist.

In order to scroll into view once the picker is opened, you need to call scrollIntoView from useEffect once it is opened.

useEffect(() => {
  if(showEmojis) {
    document.getElementById('picker').scrollIntoView(true)
  }
} , [showEmojis])

滚动到某个Div

八巷 2025-02-02 09:16:48

CLI适用于Windows 8和更高版本。我在较旧的笔记本电脑上发现了这个问题,尝试了所有内容使其在这家笔记本电脑上使用。
现在,当我将操作系统升级到Win11 ..工作时,它可以工作。

CLI works for windows 8 and later versions. I get this issue on my older laptop , tried everything to make it work on this laptop.
Now it works when I had my OS upgraded to Win11..works like a charm a.

如何避免安装后AWS CLI错误

八巷 2025-02-01 21:42:03

-pix_fmt 选项需要是输出选项,而不是输入以使输出格式为灰度。尝试

ffmpeg -framerate 1 -r 30 -i C:\%d.png \
       -vcodec libx264 -pix_fmt gray -crf 0 C:\test.mkv

-pix_fmt option needs to be an output option not input to make the output format to be grayscale. Try

ffmpeg -framerate 1 -r 30 -i C:\%d.png \
       -vcodec libx264 -pix_fmt gray -crf 0 C:\test.mkv

FFMPEG-编码和解码8位PNG图像

八巷 2025-02-01 18:12:34

说明

这里有几个基本的OOP 错误。

首先,为什么当您的 Maze 类创建一个实例时,当您的 generateMaze 类是 static ,然后返回迷宫作为<代码>布尔值[] [] 而不是迷宫。您可能打算将数组作为类的字段,而不是直接通过迷宫实例访问数组。

接下来, walk 方法是非静态的,并且是 Walker 实例的一部分。因此,您需要创建该类的实例并在该实例上调用该方法。


迷宫生成

您可能打算这样做:

public final class Maze {
  // Arrays as field of maze instances
  private boolean[][] mazeArray;

  // return maze instance instead of array
  public static Maze generateMaze(int width, int height) {
    // create maze instance
    Maze maze = new Maze();
    // manipulate array of that maze instance
    maze.mazeArray = new boolean[width][height];

    for (int x = 0; x < width; x++) {
        maze.mazeArray[x][0] = true;
    }
    for (int y = 0; y < height; y++) {
        maze.mazeArray[0][y] = true;
    }

    // return the maze, not its array
    return maze;
  }
}

呼叫

Maze maze = Maze.generateMaze(2, 2);

使用构造函数

或更好的

public final class Maze {
  private final boolean[][] mazeArray;

  public Maze(int width, int height) {
    mazeArray = new boolean[width][height];

    for (int x = 0; x < width; x++) {
        mazeArray[x][0] = true;
    }
    for (int y = 0; y < height; y++) {
        mazeArray[0][y] = true;
    }
  }
}

,使用构造函数:并在 main 中这样称呼它:

Maze maze = new Maze(2, 2);

工厂

您仍然可以将其与出厂方法相结合,如果您真的想要。但是创建逻辑应该在(可能 private )构造函数中:尽管如此,

public final class Maze {
  private final boolean[][] mazeArray;

  private Maze(int width, int height) {
    mazeArray = new boolean[width][height];

    for (int x = 0; x < width; x++) {
        mazeArray[x][0] = true;
    }
    for (int y = 0; y < height; y++) {
        mazeArray[0][y] = true;
    }
  }

  public static Maze generate(int width, int height) {
    return new Maze(width, height);
  }
}

请将其称为:

Maze maze = Maze.generate(2, 2);

Walker

现在,您需要一个 Walker 类的实例,并在此上调用该方法,让它成为您刚刚产生的迷宫:

Maze maze = new Maze(2, 2);
Walker walker = new Walker();

walker.walk(maze);

Explanation

There are several basic OOP mistakes here.

First of all, why do you even create an instance of the Maze class when your generateMaze class is static and returns the maze as instance of boolean[][] instead of Maze. You probably intended to have the array as a field of the class instead and not access the array directly but via a maze instance.

Next, the walk method is non-static and part of Walker instances. So you would need to create an instance of that class and call the method on that instance.


Maze generation

You probably intended to do this instead:

public final class Maze {
  // Arrays as field of maze instances
  private boolean[][] mazeArray;

  // return maze instance instead of array
  public static Maze generateMaze(int width, int height) {
    // create maze instance
    Maze maze = new Maze();
    // manipulate array of that maze instance
    maze.mazeArray = new boolean[width][height];

    for (int x = 0; x < width; x++) {
        maze.mazeArray[x][0] = true;
    }
    for (int y = 0; y < height; y++) {
        maze.mazeArray[0][y] = true;
    }

    // return the maze, not its array
    return maze;
  }
}

with a call like

Maze maze = Maze.generateMaze(2, 2);

Constructor

Or even better, use a constructor:

public final class Maze {
  private final boolean[][] mazeArray;

  public Maze(int width, int height) {
    mazeArray = new boolean[width][height];

    for (int x = 0; x < width; x++) {
        mazeArray[x][0] = true;
    }
    for (int y = 0; y < height; y++) {
        mazeArray[0][y] = true;
    }
  }
}

And call it like this in your main:

Maze maze = new Maze(2, 2);

Factory

You can still couple that with a factory method, if you really want. But the creation logic should be in a (possibly private) constructor nonetheless:

public final class Maze {
  private final boolean[][] mazeArray;

  private Maze(int width, int height) {
    mazeArray = new boolean[width][height];

    for (int x = 0; x < width; x++) {
        mazeArray[x][0] = true;
    }
    for (int y = 0; y < height; y++) {
        mazeArray[0][y] = true;
    }
  }

  public static Maze generate(int width, int height) {
    return new Maze(width, height);
  }
}

calling it like:

Maze maze = Maze.generate(2, 2);

Walker

Now, you need an instance of the Walker class and call the method on that, giving it the maze you just generated:

Maze maze = new Maze(2, 2);
Walker walker = new Walker();

walker.walk(maze);

如何调用在另一堂课中启动的2D数组?

八巷 2025-02-01 16:45:50

使用 pack cli,您可以运行 pack config config concortry-mirrors add&lt;登记室&gt; [-m&lt; irrile ...] [flags] ,ex: pack config config注册表添加index.docker.io - mirror 10.0.0.1 其中 10.0。 0.1 是您的私人注册表。

在Spring Boot的Gradle支持中,您拥有 docker.builderregistry docker.publishremegrighregistry 设置,但是这些主要用于提供凭证,以提供用于用于用于用于使用的凭据。从注册表中获取或发布图像。他们在这里不完全做我们需要的事情。

支持镜像功能,例如 pack pack pack pack cli,目前不是一个选项。一个已经打开了以跟踪此的支持'将在以后的版本中提供。

同时,您可以将 pack cli带有上面的镜像选项来构建图像。

测试/验证的快速方法:

  1. 运行 docker run -d -d -p 5000:5000 -restart = ewland -name = registry -e consistry_proxy_remoteurl = https://registry-1.docker.io cumigistr :2 。这将运行一个本地注册表,该注册表镜像docker hub

  2. 运行 PACK配置注册表 - mirrors add'*' - mirror localhost:5000 告诉 pack cli使用注册表镜子。

  3. 运行 Pack Build 针对您的应用程序。您应该看到以下输出:

Using mirror localhost:5000/paketobuildpacks/builder:base for index.docker.io/paketobuildpacks/builder:base
base: Pulling from paketobuildpacks/builder
83525de54a98: Pulling fs layer
807f554cf05f: Pulling fs layer
...

如果看到该行,则知道它的工作正常。

您还应该在 pack config:

> cat ~/.pack/config.toml
[registry-mirrors]
  "*" = "localhost:5000"

这意味着您已经正确设置了注册表镜子。

With the pack cli, you can run pack config registry-mirrors add <registry> [-m <mirror...] [flags], ex: pack config registry-mirrors add index.docker.io --mirror 10.0.0.1 where 10.0.0.1 is your private registry.

https://buildpacks.io/docs/tools/pack/cli/pack_config_registry-mirrors_add/

In Spring Boot's Gradle support you have the docker.builderRegistry and docker.publishRegistry settings, but these are primarily used to supply credentials to be used to fetch or publish images from the registry. They do not quite do what we need here.

https://docs.spring.io/spring-boot/docs/2.6.7/gradle-plugin/reference/htmlsingle/#build-image.docker-registry

Support for mirror functionality, like with pack cli, isn't presently an option. An issue has been opened to track support for this, so hopefully it'll be available in a future release.

In the meantime, you can use pack cli with the mirror option above to build images.

A quick way to test/validate:

  1. Run docker run -d -p 5000:5000 --restart=always --name=registry -e REGISTRY_PROXY_REMOTEURL=https://registry-1.docker.io registry:2. This will run a local registry that mirrors Docker Hub.

  2. Run pack config registry-mirrors add '*' --mirror localhost:5000 to tell pack cli to use the registry mirror.

  3. Run pack build against your app. You should see output like:

Using mirror localhost:5000/paketobuildpacks/builder:base for index.docker.io/paketobuildpacks/builder:base
base: Pulling from paketobuildpacks/builder
83525de54a98: Pulling fs layer
807f554cf05f: Pulling fs layer
...

If you see that line, you know it's working properly.

You should also see this in your pack config:

> cat ~/.pack/config.toml
[registry-mirrors]
  "*" = "localhost:5000"

That means you've got the registry mirror set up correctly.

使用自定义Docker注册表使用Spring Native

八巷 2025-02-01 11:01:38

You can start using TypeScript 3.7 features in VS Code today by installing the JavaScript and TypeScript Nightly extension.

Typescript升级到3.7.2之后的Expression.TS(1109)(1109)

八巷 2025-02-01 08:31:50

的确,没有办法将过滤器传递给pandas的'或dask的read_csv函数,因此这是Intake的CSV驱动程序支持的选项。

但是,进气口支持数据集变换: https://intake.readthedocs.io/en//en/最新/变换。将在每个访问中执行转换/计算,过滤的数据集不会存储任何地方(除非您还使用持久功能)。

There is, indeed, no way to pass a filter to pandas' or dask's read_csv functions, and therefore this is nt an option supported by Intake's CSV driver.

However, Intake does support dataset transforms: https://intake.readthedocs.io/en/latest/transforms.html This means, that you can operate on the output of one data source, and assign a new catalogue entry to the result. The transform/computation would be performed on every access, the filtered dataset is not stored anywhere (unless you also use the persist functionality).

我可以用进气目录定义数据过滤器吗?

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文