猥琐帝

文章 评论 浏览 27

猥琐帝 2025-02-05 19:26:39

答案是

@SuppressWarnings("squid:S2245") // this PRNG usage is safe
private static final Random random = new Random();

向Sonarqube提供的道具,以吸引抑制作用的注释,以标识符的名称倾斜

The answer is

@SuppressWarnings("squid:S2245") // this PRNG usage is safe
private static final Random random = new Random();

Props to SonarQube for hooking into the SuppressWarnings annotation, slops for the name of the identifier

我的prng使用是安全的;我怎么告诉Sonarqube不要对我大喊大叫

猥琐帝 2025-02-05 16:26:14

您是否尝试使用cstdlib使用系统函数来执行cls命令在询问密码之前清除控制台。

示例用法:

system("cls");

因此,在输入电子邮件和密码后,将您的代码修改为以下以清除终端。

#include <iostream> 
#include <windows.h>
#include <String>
#include <thread>
#include <cstdlib>

int main() {
    int money = 1000000;
    std::string password;
    std::string email;
    std::string Inpassword;
    std::string Inemail;
    std::cout << ("Welcome to the bank of jack!\n");
    Sleep(2000);
    std::cout << ("Enter your email:  ");
    std::cin >> email;
//the user enters the email and then once the user inputs the email the computer clears the text containing the email 
    Sleep(3000);
    system("cls");
    std::cout << ("create your password: ");
    std::cin >> password;
//user inputs password and then once its pasted the computer clears it 
    Sleep(1000); 
    system("cls");
    std::cout << ("Account created\n");
Sleep(1000);
//after that the entire terminal is cleared
    system("cls");
    std::cout << ("Log in\n");
    Sleep(1000);
    std::cout << ("enter your email\n");
    std::cin >> Inemail;
    if (Inemail == email) {
        std::cout << ("user ") << email << (" located");
    }
    else {
        std::cout << ("incorrect email");
        exit(0);
    }

如果您在Linux/Mac环境上,请确保用cls命令用clear替换。
希望这会有所帮助

Have you tried using the system function from cstdlib to execute the cls command to clear the console before Asking for Password.

Example Usage:

system("cls");

So Your Code is modified as below to clear the terminal after inputting the email and password.

#include <iostream> 
#include <windows.h>
#include <String>
#include <thread>
#include <cstdlib>

int main() {
    int money = 1000000;
    std::string password;
    std::string email;
    std::string Inpassword;
    std::string Inemail;
    std::cout << ("Welcome to the bank of jack!\n");
    Sleep(2000);
    std::cout << ("Enter your email:  ");
    std::cin >> email;
//the user enters the email and then once the user inputs the email the computer clears the text containing the email 
    Sleep(3000);
    system("cls");
    std::cout << ("create your password: ");
    std::cin >> password;
//user inputs password and then once its pasted the computer clears it 
    Sleep(1000); 
    system("cls");
    std::cout << ("Account created\n");
Sleep(1000);
//after that the entire terminal is cleared
    system("cls");
    std::cout << ("Log in\n");
    Sleep(1000);
    std::cout << ("enter your email\n");
    std::cin >> Inemail;
    if (Inemail == email) {
        std::cout << ("user ") << email << (" located");
    }
    else {
        std::cout << ("incorrect email");
        exit(0);
    }

If you are on a Linux/Mac Environment be sure to replace the cls command with clear.
Hope this Helps

如何使终端要求字符串,然后在接收字符串后删除它

猥琐帝 2025-02-05 10:46:58

清理您的脚本并使用引号添加了一些安全性,并检查已经处理过的文件,以防文件系统触发器重复事件。

#!/usr/bin/env bash

# Prevents expanding pattern without matches
shopt -s nullglob

# Expands pattern into an array
target=(/home/*/ftp/files/)

# Creates temporary directory and cleanup trap
declare -- tmpdir=
if tmpdir=$(mktemp -d); then
  trap 'rm -fr -- "$tmpdir"' EXIT INT
else
  # or exit error if it fails
  exit 1
fi

# In case no target matches, exit error
[ "${#target[@]}" -gt 0 ] || exit 1

s3move() {
  local -- p=$1
  local -- tmp="$tmpdir/$p"
  printf 'Copy path is: %s\n' "$p"
  # Moves the file to temporary dir
  # so it is away from inotify watch dir ASAP
  mv -- "$p" "$tmp"

  # Then perform the slow remote copy to s3 bucket
  # Remove the echo onces it is ok
  echo aws s3 mv "$p" s3://bucket
  
  # File has been copied to s3, tmp file no longer needed
  rm -f -- "$tmp"
}

while read -r -d '' p; do
  # Skip if file does not exist, as it has already been moved away
  # case of a duplicate event for already processed file
  [ -e "$p" ] || continue
  s3move "$p"
done < <(
  # Good practice to spell long option names in a script
  # --format will print null-delimited full file path
  inotifywait \
    --monitor \
    --recursive \
    --event close_write \
    --includei '.*\.mp4
 \
    --format '%w%f%0' \
    "${target[@]}" 2>/dev/null
)

Cleaned-up your script and added some safety with quotes and check for already processed file in case the filesystem triggers duplicate events for same file.

#!/usr/bin/env bash

# Prevents expanding pattern without matches
shopt -s nullglob

# Expands pattern into an array
target=(/home/*/ftp/files/)

# Creates temporary directory and cleanup trap
declare -- tmpdir=
if tmpdir=$(mktemp -d); then
  trap 'rm -fr -- "$tmpdir"' EXIT INT
else
  # or exit error if it fails
  exit 1
fi

# In case no target matches, exit error
[ "${#target[@]}" -gt 0 ] || exit 1

s3move() {
  local -- p=$1
  local -- tmp="$tmpdir/$p"
  printf 'Copy path is: %s\n' "$p"
  # Moves the file to temporary dir
  # so it is away from inotify watch dir ASAP
  mv -- "$p" "$tmp"

  # Then perform the slow remote copy to s3 bucket
  # Remove the echo onces it is ok
  echo aws s3 mv "$p" s3://bucket
  
  # File has been copied to s3, tmp file no longer needed
  rm -f -- "$tmp"
}

while read -r -d '' p; do
  # Skip if file does not exist, as it has already been moved away
  # case of a duplicate event for already processed file
  [ -e "$p" ] || continue
  s3move "$p"
done < <(
  # Good practice to spell long option names in a script
  # --format will print null-delimited full file path
  inotifywait \
    --monitor \
    --recursive \
    --event close_write \
    --includei '.*\.mp4
 \
    --format '%w%f%0' \
    "${target[@]}" 2>/dev/null
)

删除事件是否在InotifyWait中考虑了Close_write?

猥琐帝 2025-02-05 01:02:56

对于中心一个div,使用:

justify-self: center;

对于底部的div,请使用:

justify-self: flex-end;

然后您可以正确定位边距

For the center one div, use:

justify-self: center;

And for the bottom ones, use:

justify-self: flex-end;

Then you can position it with margins correctly

Flexbox的中间元素和下面的其余部分

猥琐帝 2025-02-04 23:47:18

您可以尝试以下代码(给定n&lt; - 1e5k&lt; - 5):

n <- ceiling(N^(1 / k))
S <- sample(c(LETTERS, letters, 0:9), n)
ID <- head(do.call(paste0, expand.grid(rep(list(S), k))),N)

其中

  • n给出了整个子集的一个子集支持所有唯一组合的空间n,例如,n&lt; - 100000
  • s表示我们绘制的子空间字母或数字
  • Expand.Grid提供所有组合

You can try the code below (given N <- 1e5 and k <- 5):

n <- ceiling(N^(1 / k))
S <- sample(c(LETTERS, letters, 0:9), n)
ID <- head(do.call(paste0, expand.grid(rep(list(S), k))),N)

where

  • n gives a subset of the whole space that supports all unique combinations up to given number N, e.g., N <- 100000
  • S denotes a sub-space from which we draw the alphabets or digits
  • expand.grid gives all combinations

如何为具有5个字符的100000创建唯一标识符?

猥琐帝 2025-02-04 23:11:14

首先,我建议您在访问txtDocid字段中将医生ID转换为小写(string#tolowercase),因为这会阻止用户输入仅使用不同的外壳复制ID。

我不确定您的AddDoctor方法做了什么,我猜它只是将其添加到GUI中。如果您包含了代码,这将很有用。如果是这样,那么您假设问题是正确的是prishings.doctors地图未链接到保存文件。

您可以解决此操作的一种方法是将医生保存到保存文件后,将医生添加到cravie.doctors.doctors地图。

但是,我建议您参加一个单独的课程来处理医生的保存和存储。这样,您可以简单地调用doctormanager#savedoctor之类的东西,然后将其写入文件并保存到内部地图。也值得封装地图。

最后,关于有关数据库的评论,听起来您尚未被教导有关它们,无论如何,这可能不值得麻烦。将您的代码抽象以使用单独的类来管理医生存储是理想的选择。

Firstly, I'd recommend converting the doctor id in the txtDocID field to lowercase (String#toLowerCase) when you access it, as that'd prevent the user from inputting a duplicate ID just with different casing.

I'm not sure what your addDoctor method does, I'm guessing it just adds it to the GUI. It'd be useful if you included the code for that. If that's the case, then you are correct in assuming the problem is that the administrative.doctors Map is not linked to your save file.

One way you could fix this is by also adding the doctor to the administrative.doctors Map after saving it to the save file.

However, I'd advice that you make a separate class for handling the saving and storage of doctors. This way you could simply call something like DoctorManager#saveDoctor and it would write to the file and save to the internal Map. It'd also be worth encapsulating the Map.

Finally, regarding the comment on a database, it sounds like you haven't been taught about them yet and its probably not worth the hassle for your use-case anyway. Abstracting your code to use a separate class for managing storage of doctors is likely ideal.

有没有一种方法可以从保存的文件中读取信息来检查是否已保存了DoctorID?

猥琐帝 2025-02-04 04:31:12

@Andrew Hall的解决方案为我工作。我不得不改变它,因为我使用RESTTEMPLATE将FHIR R4患者资源对象从我的专有APP代码发送到FHIR服务器的代替,而是使用RESTTEMPLATE将FHIR R4患者资源对象发送到FHIR APP代码。

我做了安德鲁·霍尔(Andrew Hall)的解决方案指出的事情,只是我不必将Hapimessageconverter注册到MVCCONFIGURER,而是必须将它们注册到REST模板中。在这里为其他遇到这种变化的其他人提供代码。

 @Bean(name = "intAppFhirRestClient")
public RestTemplate fhirRestTemplate() {
    RestTemplate restTemplate = new RestTemplate();
    restTemplate.getMessageConverters().add(0,new HapiHttpMessageConverter(FhirContext.forR4()));
    return restTemplate;
}

另外,只有在专有代码依赖项中具有FHIRCONTEXT和R4的情况下,注册转换器才能正常工作。

<dependency>
            <groupId>ca.uhn.hapi.fhir</groupId>
            <artifactId>hapi-fhir-structures-r4</artifactId>
            <version>5.5.7</version>
        </dependency>
        <dependency>
            <groupId>ca.uhn.hapi.fhir</groupId>
            <artifactId>hapi-fhir-base</artifactId>
            <version>5.5.7</version>
        </dependency>

The solution of @Andrew Hall worked for me. I had to vary it because instead of a controller, I was using sending a FHIR R4 Patient resource object to from my proprietary app code to a FHIR server using RestTemplate.

I did what Andrew Hall's solution points to except that instead of registering the HapiMessageConverter to a MvcConfigurer, I had to register them to a Rest Template. Fleshing out the code here for others who come across this variation.

 @Bean(name = "intAppFhirRestClient")
public RestTemplate fhirRestTemplate() {
    RestTemplate restTemplate = new RestTemplate();
    restTemplate.getMessageConverters().add(0,new HapiHttpMessageConverter(FhirContext.forR4()));
    return restTemplate;
}

Also, registering the converter will only work if you have FhirContext and R4 in your proprietary code dependencies.

<dependency>
            <groupId>ca.uhn.hapi.fhir</groupId>
            <artifactId>hapi-fhir-structures-r4</artifactId>
            <version>5.5.7</version>
        </dependency>
        <dependency>
            <groupId>ca.uhn.hapi.fhir</groupId>
            <artifactId>hapi-fhir-base</artifactId>
            <version>5.5.7</version>
        </dependency>

接受FHIR资源&#x27;患者&#x27;作为春季启动中的请求机构

猥琐帝 2025-02-03 20:44:11

您的OPC UA客户端需要创建一个扫描对象并将其作为extensionObject传递到函数。
您将首先需要从服务器上加载扫描类型定义并使用它来创建Scansettings对象。

为此,最简单的方法是使用opcfoundation.netstandard.ua.ua.client.client.complextypes nuget软件包中使用loadType

ComplexTypeSystem complexTypeSystem = new ComplexTypeSystem(this.Session);

NodeId nid = new NodeId((uint)3010, (ushort)3);
ExpandedNodeId eni = new ExpandedNodeId(nid); 

Type scanSettingsType = await complexTypeSystem.LoadType(eni).ConfigureAwait(false);
dynamic scanSettings = Activator.CreateInstance(scanSettingsType);
scanSettings.Duration = 0.0; //edited
scanSettings.Cycles = (Int32)0;
scanSettings.DataAvailable = (Boolean)false;
scanSettings.LocationType = (Int32)0; //optional

,然后您应该能够像这样呼叫:

IList<object> result  = session.Call(readPoint1Object, scanMethodNode, new ExtensionObject(scanSettings));

Your OPC UA Client need to create a ScanSetting object and pass it to the function as an ExtensionObject.
You will need first to load the ScanSetting Type definition from the Server and use it to create a ScanSettings object.

To do so, the easiest way will be to use LoadType from OPCFoundation.NetStandard.Opc.Ua.Client.ComplexTypes Nuget package

ComplexTypeSystem complexTypeSystem = new ComplexTypeSystem(this.Session);

NodeId nid = new NodeId((uint)3010, (ushort)3);
ExpandedNodeId eni = new ExpandedNodeId(nid); 

Type scanSettingsType = await complexTypeSystem.LoadType(eni).ConfigureAwait(false);
dynamic scanSettings = Activator.CreateInstance(scanSettingsType);
scanSettings.Duration = 0.0; //edited
scanSettings.Cycles = (Int32)0;
scanSettings.DataAvailable = (Boolean)false;
scanSettings.LocationType = (Int32)0; //optional

Then you should be able to call Call like that:

IList<object> result  = session.Call(readPoint1Object, scanMethodNode, new ExtensionObject(scanSettings));

为什么我会遇到错误:;

猥琐帝 2025-02-03 09:48:43

Lombok的原因

是公共API-您假定可以与之互动的东西。例如,这将是@Lombok.getter注释。这些只是该罐子中的类文件,目的只是:将该jar添加到您的类路径中,而您的IDE自动完成对话框等将自动开始建议这些对话。

但是,Lombok也有很多“让它打勾”的课程,这些都不是为了公众消费。 Lombok.eclipse.handlegetter之类的东西,它是用于处理@getter Eclipse Agent内部的@getter的实现。在任何项目中,都没有意义或目的参考该课程 - 这是内部伦波克的事情。如果我们只是将该JAR文件插入JAR,然后输入hander并点击IDE的自动完成快捷键,那么您仍然会得到建议。

同样,我们直接将一些依赖项运送到Lombok.jar-这是一个“阴影罐”(包含所有deps的罐子),尽管我们没有很多,请保留lombok.jar.jar尺寸。尽管如此,ASM(一个字节码操纵库)仍在其中,这很受欢迎。

大多数阴影工具提供的标准阴影解决方案是将某些内容前缀到名称上。 ASM的org.objectweb.asm.m.annotationVisitor类将成为org.projectlombok.shading.org.objectweb.asm.m.anm.annotationvisitor。重点是,您的IDE不知道这一点,并且您还在项目中使用ASM(您也使用Lombok),并且想要AnnotationVisitor,因此您键入Annv并点击CMD+Space或What,您的IDE都建议您兼而有之。这很丑陋,我们想避免这种情况。

因此,我们构建了自己的着色器,它的工作原理是首先没有类文件。这样,IDE和任何其他自动化工具甚至都不知道我们的ASM类,或者我们的实现细节甚至存在。此类工具(例如IDE)看到的唯一文件是您要看到的类型:Lombok.builderLombok.extern.slf4j.slf4j.slf4j,<代码> lombok.ceperment.utilityClass 等。

它如何工作

Java的Class Loader架构:您可以自己制作。类加载程序提供的原始词仅仅是:“将包含字节字节(即类文件的内容)转换为class&lt;?当您编写自己的classloader时,应该实现重点:

  • 这是一个资源密钥,例如“/com/foo/load.png”。请为我提供一个带有此数据的InputStream。
  • 这是一个完全合格的班级名称,例如“ com.foo.myapp”。请为我提供代表它的class&lt;?&gt;实例。

开箱即用,Java带有默认的classloader发货。此默认的classloader通过检查您的classPath来回答这些问题 - 可以通过各种方式提供(通过JAR清单的class-path条目,或通过-CP参数到JVM可执行文件或类Pather环境变量),并在类路径上扫描每个条目所请求的资源,能够读取文件系统以及打开JAR文件。

但这只是 classloader。一般原则的一种实施,该原则被烘烤到Java中。你可以写自己的。您可以编写一个类动态生成资源的classloader,也可以从网络中加载它们。

或者,就像Lombok一样,通过打开自己的jar并寻找.scl.lombok文件来加载它们。

因此,Lombok的工作原理:当您启动它时,“入口点”(包含public static void main - 或在Lombok的情况下,对于Javac模式,它是注释处理器入口点,对于Eclipse,它的<是<代码>代理商),我们使用一些奇特的骗局向您“隐藏”它:AgentMain不需要在public> public类中(它不能是.scl。 LOMBOK文件 - 我们的ClassLoader尚不可用,我们需要先引导它!)。注释处理器确实必须参加公开班,但是,它是包装私有班级中的公共类,因此,几乎每个IDE都知道它是“隐形的”,并且不会显示它,但是Javac的注释跑步者接受了它。

从那里,我们注册了一个能够通过.scl.lombok文件来加载类的classloader,这使我们可以隐藏我们想要隐藏的所有其他所有内容。

我想开发伦波克,这正在妨碍您!

不需要;只需克隆我们的存储库,运行ant Eclipseant Intellij,然后就可以了。没有先施加它,就无法扩展Lombok。我们希望Lombok能够没有它可以扩展,但是这要比仅仅不做.scl.lombok事物要复杂得多。 Eclipse在Equinox(一个运行时模块化系统)上运行,使该工作正常工作需要各种各样的东西,这些东西将使“只需在classPath上扔一些额外的操作员”,这不是一条可行的路线,以便首先扩展Lombok。

The reason for it

Lombok has a public API - the stuff you're supposed to interact with. That'd be, for example, the @lombok.Getter annotation. Those are just class files in that jar, the aim is simply: add that jar to your classpath and your IDE autocomplete dialogs and the like will automatically start suggesting these, as per design.

But, lombok also has lots of classes that just 'make it tick', these aren't meant for public consumption. Things like lombok.eclipse.HandleGetter, which is the implementation for handling the @Getter annotation inside the eclipse agent. There is no point or purpose to referring to this class anywhere, in any project - it's an internal lombok thing. If we just stuck that jar file into the jar, and you typed Handle and hit your IDE's autocomplete shortcut key, you'd still get the suggestion.

Similarly, we ship a few dependencies straight into lombok.jar - it's a 'shaded jar' (a jar with all deps included), though we don't have many, keeping lombok.jar a nice small size. Still, ASM (a bytecode manipulation library) is in it, and that is fairly popular.

The standard shading solution offered by most shading tools is to prefix something to the name. ASM's org.objectweb.asm.AnnotationVisitor class would become org.projectlombok.shading.org.objectweb.asm.AnnotationVisitor. Point is, your IDE doesn't know that, and if you ALSO use asm in your project (where you also use lombok), and you want AnnotationVisitor thus you type AnnV and hit cmd+space or whatnot, your IDE suggests both. That's ugly and we'd like to avoid this.

Hence, we built our own shader, and it works by not having class files in the first place. This way, IDEs and any other automated tool doesn't even know either our ASM classes, or our implementation details, even exists. The only files that such tools (such as your IDE) sees are the types you're meant to see: lombok.Builder, lombok.extern.slf4j.Slf4j, lombok.experimental.UtilityClass, etcetera.

How does it work

Java's classloader architecture is abstracted: You can make your own. The primitives offered by a class loader is simply this: "Convert this byte array containing bytecode (i.e. the contents of a class file) into a Class<?> definition", and the primitives that you're supposed to implement when you write your own classloader is twofold:

  • Here is a resource key, such as "/com/foo/load.png". Please provide me an InputStream with this data.
  • Here is a fully qualified class name, such as "com.foo.MyApp". Please provide me with a Class<?> instance representing it.

Out of the box, java ships with a default classloader. This default classloader answers these questions by checking your CLASSPATH - which can be provided in various ways (via the jar manifest's Class-Path entry, or via the -cp argument to the JVM executable, or the CLASSPATH environment variable), and scanning each entry on the classpath for the resource requested, capable of reading the file system as well as opening jar files.

But that's just a classloader. One implementation of the general principle that's baked into java. You can write your own. You can write a classloader that generates resources on the fly, or that loads them from a network.

Or, as lombok does, that loads them by opening its own jar and looking for .SCL.lombok files.

Thus, lombok works like this: When you launch it, the 'entrypoint' (the class containing public static void main - or in lombok's case, for javac mode it's the annotation processor entrypoint and for eclipse it's agentmain), we 'hide' it from you using some fancy trickery: agentmain does not need to be in a public class (it can't be .SCL.lombok files - our classloader isn't available yet, we need to bootstrap that up first!). annotation processors do have to be in a public class, but, it's a public class inside a package private class, thus, just about every IDE knows it's 'invisible' and won't show it, but javac's annotation runner accepts it.

From there, we register a classloader that is capable of loading classes by way of reading in an .SCL.lombok file, and this lets us hide everything else we want to hide.

I want to develop lombok and this is getting in the way!

No need; just clone our repo, run ant eclipse or ant intellij, and off you go. There is no way to extend lombok without first forking it; we'd like lombok to be able to be extensible without it, but that would be far more complicated than simply not doing the .SCL.lombok thing. Eclipse runs on top of equinox, a runtime modularization system, and making that work properly requires all sorts of stuff that would make 'just toss some extra handlers on the classpath' not a feasible route to extending lombok in the first place.

带有.scl.lombok扩展的文件

猥琐帝 2025-02-03 08:44:33

您可以将sum用作窗口函数。这将有效地将相同的总和写入每个订单项目的多行;就像价格一样。

例如

SELECT ......
, SUM(price) OVER (PARTITION BY order_item)
....
FROM ....
GROUP BY ....

you can use SUM as a window function. this will effectively write the same sum to multiple rows for each order-item; just like the price.

for example

SELECT ......
, SUM(price) OVER (PARTITION BY order_item)
....
FROM ....
GROUP BY ....

将订单项目从每小时到每天进行分组

猥琐帝 2025-02-03 04:52:15

df.Rolling(n).mean()似乎是解决方案之一。

n在这种情况下应为4。

但是,您应该将字符串(我的意思是2%,似乎是字符串)转换为浮子。最后,按照您希望,用-替换NAN。

希望它有帮助。

df.rolling(n).mean() seems to be one of the solutions.

n should be 4 in this case.

But, you should transform the strings(I mean the 2%, it seems to be the string) into floats. And finally replace the NaN with the - as you wish in the format of the pic.

Hope it helps.

如何选择n行数,然后移动1

猥琐帝 2025-02-02 19:02:13

这是a 相关子提法。实际上,外部表的每个匹配行运行一次,使用联接条件作为滤波器标准,即它将计算所有行的所有行,然后从外部表中进行ID =第一个ID,然后ID = second ID来自外部表格,因此在。然后,每个ID的结果计数将传递到滤波外表行的哪个子句。

您也可以写一个等效的查询:

SELECT s.salesman_id,s.name 
FROM salesman a
INNER JOIN customer b
ON a.salesman_id = b.salesman_id
GROUP BY a.salesman_id
HAVING count(b.customer_id) >  1

This is an example of a correlated subquery. In effect, the subquery is run once for each matching row of the outer table, using the join condition as filter criteria i.e. it will count for all rows with id = first id from outer table, then id = second id from outer table and so on. The resulting count for each id is then passed to the WHERE clause for filtering the rows of the outer table.

You could also write an equivalent query like so:

SELECT s.salesman_id,s.name 
FROM salesman a
INNER JOIN customer b
ON a.salesman_id = b.salesman_id
GROUP BY a.salesman_id
HAVING count(b.customer_id) >  1

有人可以深入说明查询吗?

猥琐帝 2025-02-02 17:53:43

使用RESHAPE提供的基本R选项

transform(
    reshape(
        df,
        direction = "long",
        idvar = c("id", "name"),
        sep = "_",
        varying = -c(1:2)
    ),
    id = seq_along(id)
)

给出

         id name time fixed current
1.A.2020  1    A 2020  2300    3000
1.A.2019  2    A 2019  2100    3100
1.A.2018  3    A 2018  2600    3200
1.A.2017  4    A 2017  2600    3300
1.A.2016  5    A 2016  1900    3400

A base R option using reshape

transform(
    reshape(
        df,
        direction = "long",
        idvar = c("id", "name"),
        sep = "_",
        varying = -c(1:2)
    ),
    id = seq_along(id)
)

gives

         id name time fixed current
1.A.2020  1    A 2020  2300    3000
1.A.2019  2    A 2019  2100    3100
1.A.2018  3    A 2018  2600    3200
1.A.2017  4    A 2017  2600    3300
1.A.2016  5    A 2016  1900    3400

在r中将数据帧从宽到长

猥琐帝 2025-02-02 15:21:25

我们可以使用list上循环,然后将跨使用 at as _at/_all /代码>已弃用。

library(purrr)
library(dplyr)
library(stringr)
files <- map(files, ~ .x %>%
    mutate(across(everything(), ~ str_squish(as.character(.x)))))

We can loop over the list with map, then use mutate with across as _at/_all are deprecated.

library(purrr)
library(dplyr)
library(stringr)
files <- map(files, ~ .x %>%
    mutate(across(everything(), ~ str_squish(as.character(.x)))))

创建purrr地图等效

猥琐帝 2025-02-01 20:51:14

为了一行回答您的问题,最好的做法是避免微服务之间的相互依存关系。

根据我的经验,我在下面列出了选项,需要根据性能和amp;可容忍您的系统应符合

  1. 您的前端致电卡API,然后用户API

  2. 将用户服务视为组件 - 如果您的用户服务始终由另一个微服务消费,那么这将是一个更好的选择

To answer your question in one line, the best practice is to avoid interdependencies between microservices.

Based on my experience I have listed below the options, which needs to be chosen based on the performance & fault tolerance that your system should meet

  1. Your front end to call card api and then user api

  2. Consider user service as a component - if your user service is always going to be consumed by another microservice, then this would be a better option

微服务加入的最佳实践

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

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