爱的那么颓废

文章 评论 浏览 777

爱的那么颓废 2025-02-20 21:19:04

有一篇非常好的文章解释了Azure SDK的客户如何工作 - azure sdk .net客户端的寿命管理

  • 客户lifetime :Azure SDK客户端寿命管理的主要规则是:将客户视为Singletons
  • 线程安全:客户端是线程安全。模型不是线程安全。
  • 客户是不可变的
  • 客户不可销售:共享httpclient作为默认值:一个问题经常出现的问题是,为什么不基于HTTP的Azure客户端实现 iDisposable ,而内部则使用代码> httpclient 可容纳的?默认情况下,所有Azure SDK客户端都使用单个共享 httpclient 实例,并且不要创建任何需要积极释放的其他资源。共享客户端实例在整个应用程序寿命中都存在。

来自 azure键保管库秘密客户端库.net ,有关于如何使用新客户的许多示例:

// Create a new secret client using the default credential from Azure.Identity using environment variables previously set,
// including AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, and AZURE_TENANT_ID.
var client = new SecretClient(vaultUri: new Uri(vaultUrl), credential: new DefaultAzureCredential());

// Create a new secret using the secret client.
KeyVaultSecret secret = client.SetSecret("secret-name", "secret-value");

// Retrieve a secret using the secret client.
secret = client.GetSecret("secret-name");

There is a really good article explaining how Azure SDK's clients work - Lifetime management for Azure SDK .NET clients:

  • Client lifetime: The main rule of Azure SDK client lifetime management is: treat clients as singletons.
  • Thread-safety: Clients are thread-safe. Models are not thread-safe.
  • Clients are immutable
  • Clients are not disposable: Shared HttpClient as default: One question that comes up often is why aren’t HTTP-based Azure clients implementing IDisposable while internally using an HttpClient that is disposable? All Azure SDK clients, by default, use a single shared HttpClient instance and don’t create any other resources that need to be actively freed. The shared client instance persists throughout the entire application lifetime.

From Azure Key Vault secret client library for .NET, there are lots of samples on how to use the new clients:

// Create a new secret client using the default credential from Azure.Identity using environment variables previously set,
// including AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, and AZURE_TENANT_ID.
var client = new SecretClient(vaultUri: new Uri(vaultUrl), credential: new DefaultAzureCredential());

// Create a new secret using the secret client.
KeyVaultSecret secret = client.SetSecret("secret-name", "secret-value");

// Retrieve a secret using the secret client.
secret = client.GetSecret("secret-name");

创建和处置秘密

爱的那么颓废 2025-02-20 21:04:47

首先,值得记住的是,所有Java存档文件( .jar / .war /etct ...)都是基本上只是幻想。 zip 文件,带有一些添加的清单和元数据。

其次,要解决这个问题,我个人使用了几种在所有级别上处理此问题的工具:

  • jad < /a> + jadclipse 在IDE工作时进行分解 .class 文件
  • winrar ,我最喜欢的压缩工具本身支持Java档案 段落)。
  • 超越比较 ,当正确配置时,我最喜欢的diff工具可以在the-the-the-上进行在任何存档文件之间进行比较,包括 jar s。值得一试。

所有上述所有的优点是,我不需要拥有任何其他外部工具来影响我的工作环境。这些文件之一可以从我的IDE内部处理我所需要的一切,也可以与其他文件一起散布。

First of all, it's worth remembering that all Java archive files (.jar/.war/etc...) are all basically just fancy.zip files, with a few added manifests and metadata.

Second, to tackle this problem I personally use several tools which handle this problem on all levels:

  • Jad + Jadclipse while working in IDE for decompiling .class files
  • WinRAR, my favorite compression tool natively supports Java archives (again, see first paragraph).
  • Beyond Compare, my favorite diff tool, when configured correctly can do on-the-fly comparisons between any archive file, including jars. Well worth a try.

The advantage of all the aforementioned, is that I do not need to hold any other external tool which clutters my work environment. Everything I will ever need from one of those files can be handled inside my IDE or diffed with other files natively.

如何对整个JAR文件进行反复编译?

爱的那么颓废 2025-02-20 13:25:33

有一个问题 - https://github.com/github.com/facebook/createbook/create-reactct- -app/eskay/9904

解决方法将以下代码放在index.js中以启用重新加载

if (module.hot) {
  module.hot.accept();
}

您必须进行此更改后重新启动服务器

There was an issue - https://github.com/facebook/create-react-app/issues/9904

A workaround is putting the below code in index.js to enable reloading

if (module.hot) {
  module.hot.accept();
}

you must restart your server after making this change

React App在热刷新后被卡在DEV模式下的互动

爱的那么颓废 2025-02-20 09:46:16

程序员将使用 flush()要确保在继续之前将上一个代码的输出和/或效果写入电子表格时。如果您不 flush(),则可以使用一些内置的缓存和操作捆绑来自动“优化”代码。通常,您不需要使用 flush(),直到您具体 do 需要...如果有意义。

首先,Ye Olde官方文件:

flush()

应用所有等待的电子表格更改。电子表格操作有时会捆绑在一起以提高性能,例如在对range.getValue()进行多个呼叫时。但是,有时您可能需要确保立即进行所有待处理更改,例如,在脚本执行时向用户显示数据。

like likeimfive ableOgh 类比:假设您要在树上计算100个苹果在树上的苹果。

可以计数并单独记录每个苹果,例如:

1 2 3 4 5 6 ...等

。每次计数之后编写操作。您最终将写入纸张 100次,并假设用手写作要比用眼睛算得更长的时间。

“优化”过程(在这种情况下)是在写下一个数字之前使用您的内存/缓冲区,并计算5个苹果,因此您要写

5 10 15 20 ...等

。必须计算相同数量的苹果,您已经减少了写作数量您必须这样做,因此您会看到通过减少运行时的巨大性能优势。

这大致转化为应用程序脚本操作的工作方式。与所有计算中一样,内存操作是最快执行的,并且读取/写入(又称输入/输出)操作是最慢的(检查您的执行成绩单以获取进一步的证明)。这就是为什么您只需要在代码执行中的特定点将数据写入电子表格时才应使用 flush()

希望这会有所帮助。

A programmer will use flush() when they want to ensure that the previous code's output and/or effects are written to the spreadsheet before continuing. If you do not flush(), then the code may be automatically "optimized" by using some built-in caching and bundling of operations. In general, you do not need to use flush() until you specifically DO need to... if that makes sense.

First, ye olde official documentation:

flush()

Applies all pending Spreadsheet changes. Spreadsheet operations are sometimes bundled together to improve performance, such as when doing multiple calls to Range.getValue(). However, sometimes you may want to make sure that all pending changes are made right away, for instance to show users data as a script is executing.

How about an explainlikeimfive analogy: Let's say you're counting apples on a tree with 100 apples.

You could count and record each apple individually, like so:

1, 2, 3, 4, 5, 6... etc.

This is like doing a flush() within a loop, since you are literally writing after each count operation. You will end up writing to your paper 100 times, and let's assume it takes longer to write with your hand than it does to count with your eyes.

An "optimized" process (in this case) would be to use your memory/buffer and count 5 apples before writing a number down, so you'd write

5, 10, 15, 20... etc.

Now you will end up writing to your paper 20 times (an 80% reduction), and despite having to count the same number of apples, you've reduced the number of writes you have to do, so you'll see a drastic performance benefit by way of reduced runtime.

This translates roughly to how Apps Script operations work. As in all computing, the in-memory operations are the quickest to execute, and the read/write (aka input/output) operations are the slowest (check your Execution Transcript for further proof). That's why you should only use flush() when you specifically need to write your data to the spreadsheet at a particular point in your code's execution.

Hope this helps.

为什么我们要使用vredrathapp.flush()?

爱的那么颓废 2025-02-20 08:17:33

如果您想与招待连接,则必须首先创建它:

  1. 通过win+x在左图中的win+x访问计算机管理,请访问localuser和groups,然后在右图中使用用户名toduser和password添加新用户1234
  2. 接下来,您必须转到MSSQL MS,然后转到安全&gt;右键单击右图默认DB上的todouser&gt;在用户映射中检查ToDoApp数据库。

if you want to connect with todouser you must first create it:

  1. go to computer management via win+x next in left panel go to LocalUser and Groups and next in right panel add new user with username todouser and password 1234
  2. next you must go to MSSQL MS and go to security>login>right click on todouser>properties on right set default db to todoapp -- in User Mapping check the todoapp database.

我无法连接到我的本地SQL Server

爱的那么颓废 2025-02-20 06:30:35

我对这个问题感兴趣,因为它适用于从 base :: summary()函数中提取值。您可能需要考虑从表中提取值的另一个选项是构建一个函数,该函数将您的 summary()表的任何条目转换为有用的数字。例如,如果得到:

(s <- summary(dataset))

sv_final_num_beneficiarios  sv_pfam_rec        sv_area_transf    
Min.   :    1.0            Min.   :0.0000036   Min.   :0.000004  
1st Qu.:   67.5            1st Qu.:0.0286363   1st Qu.:0.010107  
Median :  200.0            Median :0.0710803   Median :0.021865  
Mean   :  454.6            Mean   :0.1140274   Mean   :0.034802  
3rd Qu.:  515.8            3rd Qu.:0.1527177   3rd Qu.:0.044234  
Max.   :17516.0            Max.   :0.8217923   Max.   :0.360924  

您可能需要提取 sv_pfam_rec 的第一个Qu ,并为此读取第二col的第二行。为了获得格式化的单个值,我制作了一个函数,

s_extract <- function(summary_entry){
separate(as_tibble(summary_entry),
sep = ":",
col = value, 
remove = FALSE, 
into = c("bad", "good"))[[3]] %>% 
as.numeric() 
}

您只需要喂食摘要条目,例如 summary_entry = s [3,3] 才能获得中间 sv_area_transf

鉴于此函数基于单独(),它使浏览该变量名称还包含数字的某些情况变得更加容易,这是无值得的。

I am interested in this question as it applies to extracting values from the base::summary() function. Another option you might want to consider to extract values from a table is to build a function that takes any entry of your summary() table and transforms it into a useful number. For example if you get:

(s <- summary(dataset))

sv_final_num_beneficiarios  sv_pfam_rec        sv_area_transf    
Min.   :    1.0            Min.   :0.0000036   Min.   :0.000004  
1st Qu.:   67.5            1st Qu.:0.0286363   1st Qu.:0.010107  
Median :  200.0            Median :0.0710803   Median :0.021865  
Mean   :  454.6            Mean   :0.1140274   Mean   :0.034802  
3rd Qu.:  515.8            3rd Qu.:0.1527177   3rd Qu.:0.044234  
Max.   :17516.0            Max.   :0.8217923   Max.   :0.360924  

you might want to extract that 1st Qu for sv_pfam_rec and for that read the 2nd row of the 2nd col. In order to get the formatted single value I made a function

s_extract <- function(summary_entry){
separate(as_tibble(summary_entry),
sep = ":",
col = value, 
remove = FALSE, 
into = c("bad", "good"))[[3]] %>% 
as.numeric() 
}

You just have to feed a summary entry, for example summary_entry = s[3,3] to obtain the Median of sv_area_transf.

It is worth nothing that given that this function is based on separate() it makes it easier to navigate certain cases in which the name of the variable also contains numbers

从字符串向量提取数字

爱的那么颓废 2025-02-20 03:30:07

derive partialeq eq )并使用!=

#[derive(PartialEq)]
pub enum Letters { ... }

if letter != Letters::A { ... }

或使用 else 子句:

if let Letters::A = letter {
    // Empty.
} else {
    // ...
}

或负 匹配!()

if !matches!(letter, Letters::A) {
    // ...
}

Derive PartialEq (perhaps also Eq) and use !=:

#[derive(PartialEq)]
pub enum Letters { ... }

if letter != Letters::A { ... }

Or use an empty if with an else clause:

if let Letters::A = letter {
    // Empty.
} else {
    // ...
}

Or negate matches!():

if !matches!(letter, Letters::A) {
    // ...
}

生锈如果不是mystruct :: myVariant = my_struct,是否有可能?

爱的那么颓废 2025-02-19 22:29:28

我在某个地方阅读了这篇文章,但找不到来源。博客文章简短,标题为“直觉到 .some() .every()”或类似的内容。

every = true && fn(val1) && fn(val2) && ...
some = false || fn(val1) || fn(val2) || ...

这是我见过的最伟大的迷你博客文章之一。希望有人能找到它。

I read this somewhere, but can't find the source anymore. The blog post is short, titled "Intuition to .some() and .every()" or something like that.

every = true && fn(val1) && fn(val2) && ...
some = false || fn(val1) || fn(val2) || ...

This is one of the greatest mini blog post I've ever seen. Hope someone can find it.

为什么array.protype.是否在空数组上返回true?

爱的那么颓废 2025-02-19 14:28:47

settimeout()运行 getcpuhand() 3秒钟后,但它不在等待。它立即返回,然后行 cpu_item.textContent =“ Computer:” + GetCpuhand(); 运行。您应该将显示计算机手显示的代码放在 settimeout()调用中。

clearTimeOut()的参数应为 settimeout()返回的值。因此,将该值分配给重新启动时使用的全局变量。

let p_item = document.getElementById("player-item");
let cpu_item = document.getElementById("computer-item");
let items = ["Rock", "Paper", "Scissors"];
let timer;

function getPlayerHand() {
  //for (i = 0; i < items.length; i++)
  let p_index = Math.floor(Math.random() * 3);
  return items[p_index];
}

function getCPUHand() {
  //for (i = 0; i < items.length; i++)
  let cpu_index = Math.floor(Math.random() * 3);
  return items[cpu_index];
}

function startGame() {
  p_item.textContent = "Player: " + getPlayerHand();
  cpu_item.textContent = "Computer: Processing output...";
  timer = setTimeout(() => cpu_item.textContent = "Computer: " + getCPUHand(), 3000);
}

function playAgain() {
  clearTimeout(timer);
  p_item.textContent = "Player: ";
  cpu_item.textContent = "Computer: ";
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <p id="player-item">Player:</p>
  <p id="computer-item">Computer:</p>

  <button onclick="startGame()">START GAME</button>

  <p>GAME HAS FINISHED
    <button onclick="playAgain()">PLAY AGAIN</button>
  </p>

  <script src="index.js"></script>
</body>

</html>

setTimeout() runs getCPUHand() 3 seconds later, but it doesn't wait for it. It returns immediately, and then the line cpu_item.textContent = "Computer: " + getCPUHand(); runs. You should put the code that displays the computer hand in the setTimeout() call.

The argument to clearTimeout() should be the value that was returned by setTimeout(). So assign that value to a global variable, which you use when restarting.

let p_item = document.getElementById("player-item");
let cpu_item = document.getElementById("computer-item");
let items = ["Rock", "Paper", "Scissors"];
let timer;

function getPlayerHand() {
  //for (i = 0; i < items.length; i++)
  let p_index = Math.floor(Math.random() * 3);
  return items[p_index];
}

function getCPUHand() {
  //for (i = 0; i < items.length; i++)
  let cpu_index = Math.floor(Math.random() * 3);
  return items[cpu_index];
}

function startGame() {
  p_item.textContent = "Player: " + getPlayerHand();
  cpu_item.textContent = "Computer: Processing output...";
  timer = setTimeout(() => cpu_item.textContent = "Computer: " + getCPUHand(), 3000);
}

function playAgain() {
  clearTimeout(timer);
  p_item.textContent = "Player: ";
  cpu_item.textContent = "Computer: ";
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <p id="player-item">Player:</p>
  <p id="computer-item">Computer:</p>

  <button onclick="startGame()">START GAME</button>

  <p>GAME HAS FINISHED
    <button onclick="playAgain()">PLAY AGAIN</button>
  </p>

  <script src="index.js"></script>
</body>

</html>

在JavaScript运行时,声明正在跳过

爱的那么颓废 2025-02-19 14:16:35

我看不到您在哪里调用 _fetchactivities(),但是对于您的情况,它应该使用 initstate()来工作。使用此功能,您可以在初始页面加载上确保调用功能一次。 initstate()不支持 async ,因此以这样的方式调用它:

@override
  void initState() {
    super.initState();
    asyncMethod();
  }

  void asyncMethod() async {
    await _fetchActivities()
    // ....
  }

更多ON Initstate() 在这里

I can't see where you are calling _fetchActivities() but for your case it should work by using initState(). With this you can make sure calling functions on initial page load once. initState() doesn't support async, so call it like this:

@override
  void initState() {
    super.initState();
    asyncMethod();
  }

  void asyncMethod() async {
    await _fetchActivities()
    // ....
  }

More on initState() here

ListView.builder每次页面刷新时处置卡小部件

爱的那么颓废 2025-02-19 05:28:29

这可能是因为 workspaces 基于getter,而getter是只读的。如您引用的博客 VUE 2.7中的数组不支持:

readonly()确实创建了一个单独的对象,但是它不会跟踪新添加的属性,在数组上不起作用

它(部分)支持 vue 2.6 coption Api插件虽然:

ReadOnly()仅提供类型级别的READONLY检查。

因此,这可能导致错误。如果对您来说是强制性的,则可能需要升级到VUE3,或者持续一段时间。保留组成的API插件直到今年年底...

解决方法可能是跳过Getter并直接访问状态,因为这是一个非常简单的Getter,仅返回 Workspaces 。

希望这会有所帮助。

This might be because workspaces is based on a getter, which are read-only. As mentioned in the blog you were referring to, readonly is not supported for arrays in Vue 2.7:

readonly() does create a separate object, but it won't track newly added properties and does not work on arrays.

It was (partially) supported for arrays in the Vue 2.6 Composition Api Plugin though:

readonly() provides only type-level readonly check.

So that might be causing the error. If it is mandatory for you, you might need to upgrade to vue3, or stick with 2.6 for a while. The composition Api plugin is maintained until the end of this year...

A workaround may be to skip the getter and access the state directly, since it is a quite simple getter which only returns the current state of Workspaces.

Hope this helps.

升级到Vue 2.7,现在得到一堆警告:[Vue警告]:VUE 2不支持ReadOnly Arrays

爱的那么颓废 2025-02-19 00:50:36

您使用调试器在此处显示查询的值

rc = sqlite3_prepare_v2(db, query.c_str(), -1, &pStmt, NULL);

如果 /代码>您认为是的语句。

这是因为较早的几行:

colorIndex = getColorByLabel(object.color);

这最终使 QUERY 变量杂乱无章,将其设置为“选择”,仅一个占位符。

您可以将其用作学习如何使用调试器的千载难逢的机会,这使得解决这些Scooby-Doo的谜团变得简单。尝试在调试器中使用显示的程序, 完全按照 ,在 sqlite3_prepare_v2 line createbject ,然后检查查询中的内容,并拥有自己的“ eureka!”片刻。

If you used your debugger to show the value of query here, the problem becomes very easy to see:

rc = sqlite3_prepare_v2(db, query.c_str(), -1, &pStmt, NULL);

You will discover that this query is not really the INSERT statement that you think it is.

This is because just a few lines earlier:

colorIndex = getColorByLabel(object.color);

And this ends up clobbering the query variable, setting it to a "SELECT" with just one ? placeholder.

You can use this as a golden opportunity to learn how to use a debugger, which makes solving these Scooby-Doo mysteries simple. Try to use the shown program in your debugger, exactly as is, setting a breakpoint at the sqlite3_prepare_v2 line in createObject, and then inspecting what's in the query, and having your own "Eureka!" moment.

sqlite3如何处理列索引以外的范围

爱的那么颓废 2025-02-18 23:24:07

您可以使用 pathlib itertools 模块将文件分组:

import pandas as pd
from itertools import groupby
from pathlib import Path

key = lambda x: x.stem.split('-')[0]
for name, files in groupby(sorted(Path('.').glob('*.xlsx'), key=key), key=key):
    df = pd.concat([pd.read_excel(file, header=None) for file in files])
    df.to_excel(f"{name}.xlsx", index=None)

You can group your files by prefix using pathlib and itertools module:

import pandas as pd
from itertools import groupby
from pathlib import Path

key = lambda x: x.stem.split('-')[0]
for name, files in groupby(sorted(Path('.').glob('*.xlsx'), key=key), key=key):
    df = pd.concat([pd.read_excel(file, header=None) for file in files])
    df.to_excel(f"{name}.xlsx", index=None)

使用Glob函数合并(CONCAT)每个N Excel文件中的每个excel文件

爱的那么颓废 2025-02-18 01:11:06

根据我在代码中看到的内容,您正在导出类 someService ,而不是其内部 getsomething 方法。因此,您肯定需要将测试代码更改为以下内容:

import axios from "axios";

import { getSomething } from "../SomeService.js";

jest.mock("axios");

describe("getSomething", () => {
    describe("when API call is successful", () => {
        it("should return some details", () => {
            //...
            // when
            const service = new SomeService();
            const result = service.getSomething(123);

            // ...
            

From what I can see in your code you are exporting the class SomeService, not its internal getSomething method. So surely you need to change your test code to something like the following:

import axios from "axios";

import { getSomething } from "../SomeService.js";

jest.mock("axios");

describe("getSomething", () => {
    describe("when API call is successful", () => {
        it("should return some details", () => {
            //...
            // when
            const service = new SomeService();
            const result = service.getSomething(123);

            // ...
            

Jest说TypeError:(0,className.functionName)不是函数

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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