御守

文章 评论 浏览 28

御守 2025-02-21 00:05:20

您可以在 crypt 的帮助下,在扑面而来进行AES CBC-128加密。图书馆。它支持AES CBC加密。以下示例代码接受键串和平坦文本作为参数,并如您提到的那样对其进行加密。您可以在这里传递自己的密钥。对于AES-128,您需要128位键或16个字符串。

import 'package:encrypt/encrypt.dart';

void main() {
    final key = "Your16CharacterK";
    final plainText = "lorem ipsum example example";
    Encrypted encrypted = encrypt(key, plainText);
    String decryptedText = decrypt(key, encrypted);
    print(decryptedText);
}

String decrypt(String keyString, Encrypted encryptedData) {
    final key = Key.fromUtf8(keyString);
    final encrypter = Encrypter(AES(key, mode: AESMode.cbc));
    final initVector = IV.fromUtf8(keyString.substring(0, 16));
    return encrypter.decrypt(encryptedData, iv: initVector);
}

Encrypted encrypt(String keyString, String plainText) {
    final key = Key.fromUtf8(keyString);
    final encrypter = Encrypter(AES(key, mode: AESMode.cbc));
    final initVector = IV.fromUtf8(keyString.substring(0, 16));
    Encrypted encryptedData = encrypter.encrypt(plainText, iv: initVector);
    return encryptedData;
}

在上面的示例中,IV是从密钥本身创建的,以使代码易于阅读。为iv使用随机数据以提高安全性。 flutter加密

You can do AES CBC-128 encryption in flutter with the help of crypt library. It supports the AES cbc encryption. The following sample code accepts key-string and plain-text as arguments and encrypts it as you have mentioned. You can pass your own key here. For AES-128, you need 128 bit key or 16 character string.

import 'package:encrypt/encrypt.dart';

void main() {
    final key = "Your16CharacterK";
    final plainText = "lorem ipsum example example";
    Encrypted encrypted = encrypt(key, plainText);
    String decryptedText = decrypt(key, encrypted);
    print(decryptedText);
}

String decrypt(String keyString, Encrypted encryptedData) {
    final key = Key.fromUtf8(keyString);
    final encrypter = Encrypter(AES(key, mode: AESMode.cbc));
    final initVector = IV.fromUtf8(keyString.substring(0, 16));
    return encrypter.decrypt(encryptedData, iv: initVector);
}

Encrypted encrypt(String keyString, String plainText) {
    final key = Key.fromUtf8(keyString);
    final encrypter = Encrypter(AES(key, mode: AESMode.cbc));
    final initVector = IV.fromUtf8(keyString.substring(0, 16));
    Encrypted encryptedData = encrypter.encrypt(plainText, iv: initVector);
    return encryptedData;
}

In the above example, the IV is created from the key itself to keep the code easy to read. Use random data for IV for better security. Referred article for flutter encryption.

我想解密并在扑来中启用数据

御守 2025-02-20 11:35:13

嘿,您可以使用高度:0.33英寸用于线类和Shift cardnumber J7J8线在第二张卡中 。

检查此样品...

<!doctype html>
<html>

<head>
  <style type="text/css">
    .card {
      width: 3in;
      height: 1in;
      background-image: url(http://www.videofrank.nl/images/jukestrip.jpg);
      background-size: 3in 1in;
    }
    
    .line {
      width: 3in;
      height: 0.33in;
      text-align: center;
      font-family: Georgia, serif;
    }
    
    .cardnumber {
      font-size: 5px;
      top: auto;
      z-index: 100;
    }
  </style>
</head>

<body>

  <table cellspacing="0" cellpadding="0">
    <tr>

      <td class="card">
        <table cellspacing="0" cellpadding="0">
          <tr>
            <td class="line">Let It Be</td>
          </tr>
          <tr>
            <td class="line">Beatles</td>
          </tr>
          <tr>
            <td class="line">Yellow Submarine</td>
          </tr>
        </table>
        <div class="cardnumber">H1<br>H2</div>
      </td>
      
      <td class="card">
        <table cellspacing="0" cellpadding="0">
          <tr>
            <td class="line">Bad</td>
          </tr>
          <tr>
            <td class="line">Michael Jackson</td>
          </tr>
          <tr>
            <td class="line">Liberian Girl</td>
          </tr>
        </table>
        <div class="cardnumber">J7<br>J8</div>
      </td>

    </tr>
  </table>

</body>

</html>

Hey you can use height: 0.33in for line class and shift cardnumber J7J8 line after in the second card.

Check this for sample...

<!doctype html>
<html>

<head>
  <style type="text/css">
    .card {
      width: 3in;
      height: 1in;
      background-image: url(http://www.videofrank.nl/images/jukestrip.jpg);
      background-size: 3in 1in;
    }
    
    .line {
      width: 3in;
      height: 0.33in;
      text-align: center;
      font-family: Georgia, serif;
    }
    
    .cardnumber {
      font-size: 5px;
      top: auto;
      z-index: 100;
    }
  </style>
</head>

<body>

  <table cellspacing="0" cellpadding="0">
    <tr>

      <td class="card">
        <table cellspacing="0" cellpadding="0">
          <tr>
            <td class="line">Let It Be</td>
          </tr>
          <tr>
            <td class="line">Beatles</td>
          </tr>
          <tr>
            <td class="line">Yellow Submarine</td>
          </tr>
        </table>
        <div class="cardnumber">H1<br>H2</div>
      </td>
      
      <td class="card">
        <table cellspacing="0" cellpadding="0">
          <tr>
            <td class="line">Bad</td>
          </tr>
          <tr>
            <td class="line">Michael Jackson</td>
          </tr>
          <tr>
            <td class="line">Liberian Girl</td>
          </tr>
        </table>
        <div class="cardnumber">J7<br>J8</div>
      </td>

    </tr>
  </table>

</body>

</html>

如何用CSS将文本定位在表格中

御守 2025-02-20 02:32:21

只需替换:

while (logs[descNb].Contains(" at "))

... by:by:

while ((logs.Length < descNb) && (logs[descNb].Contains(" at ")))

beed ot:有一个问题:在情况下 logs.length == descnb ,然后 logs [descnb] 生成 indexoutofrangeException < /code>,但是当未满足第一个条件时,C#编译器会停止 - 条件。如果您正在与较旧的编译器打交道,则可能仍然遇到问题(但这不太可能)。

Just replace:

while (logs[descNb].Contains(" at "))

... by:

while ((logs.Length < descNb) && (logs[descNb].Contains(" at ")))

Keep out: there's a catch: in case logs.Length == descNb, then logs[descNb] generates the IndexOutOfRangeException, but the C# compiler stops the while-condition when the first condition is not met. In case you're dealing with an older compiler, you might still encounter a problem (but it's very unlikely).

c#循环内部循环:索引在数组的边界之外

御守 2025-02-20 00:54:40

在此之后,您还必须找到文本字段(用户名和密码),

EditText username = (EditText) findViewById(R.id.username); 
EditText password= (EditText) findViewById(R.id.password);

必须在 openbaslangic()中检查两个字段,例如:

if (username.getText().toString() == "your desired username" && password.getText().toString() == "your desired password") {
    Intent intent = new Intent(this, Baslangic_activity.class);
    startActivity(intent);
    finish();
}

You must also find text fields (username and password)

EditText username = (EditText) findViewById(R.id.username); 
EditText password= (EditText) findViewById(R.id.password);

After that you must check validation both field with Your desired values in openbaslangic() like this:

if (username.getText().toString() == "your desired username" && password.getText().toString() == "your desired password") {
    Intent intent = new Intent(this, Baslangic_activity.class);
    startActivity(intent);
    finish();
}

如果用户名和密码正确,请切换到2.活动性

御守 2025-02-19 23:35:56

有多种方法可以实现这一目标。

使用CSS的Flex属性。

解决方案#1

.parent {
    width: 400px;
    height:200px;
    background: blue;
    display: flex;
    align-items: center;
    justify-content:center;
}

.child {
    width: 75px;
    height: 75px;
    background: yellow;
}
<div class="parent">
    <div class="child"></div>
</div>

或使用使用显示:flex; and 保证金:auto;

解决方案#2

.parent {
    width: 400px;
    height:200px;
    background: blue;
    display: flex;
}

.child {
    width: 75px;
    height: 75px;
    background: yellow;
    margin:auto;
}
<div class="parent">
    <div class="child"></div>
</div>

显示文本中心

解决方案#3

.parent {
    width: 400px;
    height: 200px;
    background: yellow;
    display: flex;
    align-items: center;
    justify-content:center;
}
<div class="parent">Center</div>

使用百分比(%)高度和宽度。

解决方案#4

.parent {
    position: absolute;
    height:100%;
    width:100%;
    background: blue;
    display: flex;
    align-items: center;
    justify-content:center;
}

.child {
    width: 75px;
    height: 75px;
    background: yellow;
}
<div class="parent">
    <div class="child"></div>
</div> 

There are multiple ways to achieve this.

Using flex property of CSS.

Solution #1

.parent {
    width: 400px;
    height:200px;
    background: blue;
    display: flex;
    align-items: center;
    justify-content:center;
}

.child {
    width: 75px;
    height: 75px;
    background: yellow;
}
<div class="parent">
    <div class="child"></div>
</div>

or by using display: flex; and margin: auto;

Solution #2

.parent {
    width: 400px;
    height:200px;
    background: blue;
    display: flex;
}

.child {
    width: 75px;
    height: 75px;
    background: yellow;
    margin:auto;
}
<div class="parent">
    <div class="child"></div>
</div>

show text center

Solution #3

.parent {
    width: 400px;
    height: 200px;
    background: yellow;
    display: flex;
    align-items: center;
    justify-content:center;
}
<div class="parent">Center</div>

Using percentage(%) height and width.

Solution #4

.parent {
    position: absolute;
    height:100%;
    width:100%;
    background: blue;
    display: flex;
    align-items: center;
    justify-content:center;
}

.child {
    width: 75px;
    height: 75px;
    background: yellow;
}
<div class="parent">
    <div class="child"></div>
</div> 

如何使用CSS垂直将DIV元素集成为DIV元素?

御守 2025-02-19 14:27:54

由于您正在为单个用户加载Todos,因此您 can 的确是通过其 Create 属性订购的。为此,请使用

const ref = ref(db, `/${auth.currentUser.uid}`);
const query = query(ref, orderByChild('createdAt'));
onValue(query, (snapshot) => {
  ...

在代码中,您需要确保使用 snapshot.foreach 按顺序循环循环循环 .val()之前将返回JSON对象,而JSON对象中的属性则是定义上的:

snapshot.forEach((child) => {
  console.log(child.key, child.val());
});

Since you are loading the TODOs for a single user, you can indeed order them by their createdAt property. To do this, use a query as shown in the documentation on ordering and filtering data:

const ref = ref(db, `/${auth.currentUser.uid}`);
const query = query(ref, orderByChild('createdAt'));
onValue(query, (snapshot) => {
  ...

Inside the code you'll then need to make sure to use snapshot.forEach to loop over the children in order, as calling .val() before that will return a JSON object and the properties in a JSON object are by definition not ordered:

snapshot.forEach((child) => {
  console.log(child.key, child.val());
});

firebase数据库订单按日期订购

御守 2025-02-19 11:57:13

您应该以不同的方式编写一些功能,也许您想要以下内容:

library(dplyr)
paneldata2 %>% 
  group_by(uniqueid) %>%
  mutate(balance = cumsum(ethamount)) %>%
  ungroup()

输出:

# A tibble: 40 × 11
   period uniqueid ethamount date       dollvalue ispurchase isunrealgain Freq    day holdingtime balance
    <int>    <int>     <dbl> <chr>          <dbl> <chr>      <chr>        <chr> <int> <chr>         <dbl>
 1      1        1     0     <NA>             0   <NA>       <NA>         <NA>     NA <NA>          0    
 2      2        1     0     <NA>             0   <NA>       <NA>         <NA>     NA <NA>          0    
 3      3        1     0     <NA>             0   <NA>       <NA>         <NA>     NA <NA>          0    
 4      4        1     0     <NA>             0   <NA>       <NA>         <NA>     NA <NA>          0    
 5      5        1     0     <NA>             0   <NA>       <NA>         <NA>     NA <NA>          0    
 6      6        1     0     <NA>             0   <NA>       <NA>         <NA>     NA <NA>          0    
 7      7        1     0.295 2017-12-10    -127.  1          0            3       641 134           0.295
 8      8        1     0.126 2018-03-29     -48.3 1          0            3       750 134           0.421
 9      8        1    -0.139 2018-04-23      89.6 0          0            3       775 134           0.281
10      9        1     0     <NA>             0   <NA>       <NA>         <NA>     NA <NA>          0.281
# … with 30 more rows

You should write some functions differently, maybe you want this:

library(dplyr)
paneldata2 %>% 
  group_by(uniqueid) %>%
  mutate(balance = cumsum(ethamount)) %>%
  ungroup()

Output:

# A tibble: 40 × 11
   period uniqueid ethamount date       dollvalue ispurchase isunrealgain Freq    day holdingtime balance
    <int>    <int>     <dbl> <chr>          <dbl> <chr>      <chr>        <chr> <int> <chr>         <dbl>
 1      1        1     0     <NA>             0   <NA>       <NA>         <NA>     NA <NA>          0    
 2      2        1     0     <NA>             0   <NA>       <NA>         <NA>     NA <NA>          0    
 3      3        1     0     <NA>             0   <NA>       <NA>         <NA>     NA <NA>          0    
 4      4        1     0     <NA>             0   <NA>       <NA>         <NA>     NA <NA>          0    
 5      5        1     0     <NA>             0   <NA>       <NA>         <NA>     NA <NA>          0    
 6      6        1     0     <NA>             0   <NA>       <NA>         <NA>     NA <NA>          0    
 7      7        1     0.295 2017-12-10    -127.  1          0            3       641 134           0.295
 8      8        1     0.126 2018-03-29     -48.3 1          0            3       750 134           0.421
 9      8        1    -0.139 2018-04-23      89.6 0          0            3       775 134           0.281
10      9        1     0     <NA>             0   <NA>       <NA>         <NA>     NA <NA>          0.281
# … with 30 more rows

在r中使用暨用于面板数据

御守 2025-02-19 08:46:15

您可以首先从A和B列创建数组。然后,收集进入字典理解。

from pyspark.sql import functions as F
df = spark.createDataFrame(
    [('case1', '%', 'case description1'),
     ('case2', 'ab', 'case description2'),
     ('case3', 'gh', 'case description3'),
     ('case4', 'sg', 'case description4')],
    ['ID', 'A', 'B'])

df = df.select('ID', F.array('A', 'B'))
dic = {k: v for k, v in df.collect()}

print(dic)
# {'case1': ['%', 'case description1'], 'case2': ['ab', 'case description2'], 'case3': ['gh', 'case description3'], 'case4': ['sg', 'case description4']}

You could first create an array from columns A and B. Then, collect into a dictionary comprehension.

from pyspark.sql import functions as F
df = spark.createDataFrame(
    [('case1', '%', 'case description1'),
     ('case2', 'ab', 'case description2'),
     ('case3', 'gh', 'case description3'),
     ('case4', 'sg', 'case description4')],
    ['ID', 'A', 'B'])

df = df.select('ID', F.array('A', 'B'))
dic = {k: v for k, v in df.collect()}

print(dic)
# {'case1': ['%', 'case description1'], 'case2': ['ab', 'case description2'], 'case3': ['gh', 'case description3'], 'case4': ['sg', 'case description4']}

将dataframe转换为带有列表为值的字典

御守 2025-02-19 02:57:27

您并没有真正“获取分支”(无论是什么意思:术语 branch 在git中是模棱两可的)。 1 您真的很fet fetch consist em>。但是,在提交提交过程结束时, git提取 can 也可以在本地存储库中更新各种名称。通常这些是远程跟踪名称(git正式调用远程跟踪分支名称,但是那个可怜的单词 branch ,已经几乎被杀死了,在这句话中没有做任何有用的事情)。

我一直在克隆单个分支[via]
git克隆-b v1.1.1 -single -branch [myrepo] .git

这创建了git所谓的“单脑克隆”。那是一个克隆,其中 git获取操作默认为:

  • 从远程存储库中的单个特定分支名称中获取consits ;并
  • 仅更新本地存储库中的一个远程跟踪名称。

git通过设置 remote.origin.fetch (假设遥控器命名为 Origin )到+refs/heads/v1.1.1:refs/remotes/remotes/oincom /V1.1.1

我正在尝试将v1.1.2获取到我现有的repo

,换句话说,如果我们遵循git提供的模型(不是一个很好的模型,而是。 )。这需要更改默认的获取设置。幸运的是,您无需直接使用 remote.origin.fetch line(s)来做到这一点。 git Remote 命令可以为您执行此操作:

git remote set-branches --add origin v1.1.2

将完成工作,添加正确的第二 remote.origin.fetch line。

(旁注: v 名称在许多存储库中都保留用于 tag 名称,而不是 branch 名称。但这只是一个约定,显然是一个您的存储库拒绝。 /code> git存储库中的分支在 Origin 中。

然后将我所有的所有文件从v1.1.1移动到v1.1.2

May 可能会有可能:您可以尝试运行 git switch v1.1.2 (使用 - -猜猜模式基于 v.1.1.2 基于 onement/v1.1.2 )。但这可能是不可能的。 (有关何时可能的血腥详细信息,请参阅当前分支上有未承诺的更改时,请结帐另一个分支。如果您不能切换,要么进行提交,也许使用 git stash 。代码> git switch -c 或 git Checkout -b ,然后提交,然后切换到 v1.1.2 ,然后cherry cherry cherry pick pick the the the the临时提交分支。)


1 ,由于术语 branch 的定义很差,我们可以说,我们获取的任何提议都是“分支”,然后我们提取了“一个分支” 。但这是定义 glory> glorory 。我发现整个事情不满意:太接近 begggggggggggg begggggge 的哲学谬论。也就是说,我们首先说“ git取出分支”,然后将“分支”定义为任何git提取的东西,而我们最终没有比开始时更明智的。

You don't really "fetch a branch" (whatever that would mean: the term branch is ambiguous, in Git).1 You really fetch commits. However, at the end of the commit-fetching process, git fetch can update various names in your local repository as well. Normally these are remote-tracking names (which Git formally calls remote-tracking branch names, but that poor word branch, already nearly bludgeoned to death, is doing nothing useful in that phrase).

I have been cloning a single branch only [via]
git clone -b v1.1.1 --single-branch [myrepo].git

This creates what Git calls a "single-branch clone". What that is, is a clone in which git fetch operations default to:

  • fetching commits reachable from a single particular branch name in the remote repository; and
  • updating only that one remote-tracking name in the local repository.

Git achieves this by setting remote.origin.fetch (assuming the remote is named origin) to +refs/heads/v1.1.1:refs/remotes/origin/v1.1.1.

I'm trying to fetch v1.1.2 to my existing repo

What you want, in other words, is what we might call a "two-branch clone" if we follow the model Git provides (not a very good model, but...). This requires altering the default fetch setting. Fortunately, you don't have to fiddle directly with the remote.origin.fetch line(s) to do this. The git remote command can do this for you:

git remote set-branches --add origin v1.1.2

will do the job, adding a correct second remote.origin.fetch line.

(Side note: v names, in many repositories, are reserved for tag names rather than branch names. But that's just a convention, and apparently one your repository rejects.) After that, just run git fetch origin and origin/v1.1.2 will appear, assuming of course that there's a v1.1.2 branch in the Git repository over in origin.

then move all my uncommitted files from v1.1.1 to v1.1.2

That may be possible: you can try running git switch v1.1.2 (using the --guess mode to create a v.1.1.2 based on origin/v1.1.2). But it may not be possible. (For the gory details on when it's possible, see Checkout another branch when there are uncommitted changes on the current branch. If you can't just switch, either make a commit, or perhaps use git stash. I personally don't like git stash: I'd make a new branch first with git switch -c or git checkout -b, then commit, then switch to v1.1.2, then cherry-pick the commit made on the temporary branch.)


1Since the term branch is so poorly defined, we could just say that whatever commits we fetched were "the branch", and then we fetched "a branch". But that's kind of the Humpty Dumpty way of defining glory. I find the whole thing unsatisfying: too close to the philosophical fallacy of begging the question. That is, we start by saying "git fetch fetches a branch", then define "branch" as whatever git fetch fetches, and we end up no wiser than when we started.

将远程分支获取到仅包含一个分支的现有存储库中

御守 2025-02-19 01:44:23

您在控制台中获得的结果是对象的 hashcode值。由于该对象具有没有ToString 方法来确定应如何将其打印为字符串。相反,它打印了您要接收的输出的哈希码值。

有多种解决这个问题的方法。这是一个示例:在课程中添加一种ToString方法:

 public String toString(){//overriding the toString() method  
  return "Name: "+name+", Credit: "+credit;  
 } 

The result you get in your console is the hashcode value of an object. Since the object has no toString method to determine how it should be printed as a String. It instead prints the hashcode value which is the output you are receiving.

There are multiple ways to solve this issue. Here is one example: Add a toString method to your Lesson class:

 public String toString(){//overriding the toString() method  
  return "Name: "+name+", Credit: "+credit;  
 } 

Week23.UniversityProblem.LESSON@77459877是什么意思?

御守 2025-02-18 14:25:36

我找到了软件包 entityframeworkcore.rawsqlextensions 在GitHub上。要使用它,请添加Nuget软件包。

<PackageReference Include="EntityFrameworkCore.RawSQLExtensions" Version="1.2.0" />

该库没有记录,但以下是我使用.NET 6 + EF Core 6 + NPGSQL 6

public class DbResult
{
    public string Name { get; set; }
    public int Age { get; set; }
}
using EntityFrameworkCore.RawSQLExtensions.Extensions;
var results = await context.Database
    .SqlQuery<DbResult>(
        @"select name, age from ""users"" where age > @Age",
        new NpgsqlParameter("@Age", 15))
    .ToListAsync();

I found the package EntityFrameworkCore.RawSQLExtensions on github. To use it, add the nuget package.

<PackageReference Include="EntityFrameworkCore.RawSQLExtensions" Version="1.2.0" />

The library is not documented but below is my using of it with .NET 6 + EF Core 6 + Npgsql 6

public class DbResult
{
    public string Name { get; set; }
    public int Age { get; set; }
}
using EntityFrameworkCore.RawSQLExtensions.Extensions;
var results = await context.Database
    .SqlQuery<DbResult>(
        @"select name, age from ""users"" where age > @Age",
        new NpgsqlParameter("@Age", 15))
    .ToListAsync();

RAW SQL查询无DBSET-实体框架核心

御守 2025-02-18 14:03:46

确保包含您的TMP组件的画布没有启用像素完美。该设置将在每个滚动事件上触发GenerateText调用,并以大量方式触发坦克性能。

如果您需要Pixel Perfect,则可以将文本组件放入带Pifts Perfect的儿童画布中,并将其他元素保留在父帆布中。

Make sure the Canvas that contains your TMP components doesn't have pixel perfect enabled. That setting will trigger GenerateText calls on every scroll event and potentially tank performance in a massive way.

If you need the pixel perfect, you can put the text components in a child canvas with pixel perfect off and keep the other elements in a parent canvas.

具有大量动态内容的Unity TextMeshPro(或替代性)的性能

御守 2025-02-18 06:06:43

您需要迭代单词列表,对于每个单词,您需要检查是否存在。是否存在。如果存在,则分为2个部分,请并发布部分。将这些预先和帖子附加到最终列表,以及Word中没有在结果列表中添加该单词并跳过该单词

# your code goes here
wordlist = ['example:', 'Test', 'example:         ', 'IGNORE_ME_EXAMPLE']
result = []
for word in wordlist:
    index = -1
    part1, part2 = None, None
    if ':' in word:
        index = word.index(':')
    else:
        result.append(word)
        continue

    part1, part2 = word[:index+1], word[index+1:]
    if part1 is not None and len(part1)>0:
        result.append(part1)
    if part2 is not None and len(part2)>0:
        result.append(part2)
    
print(result)
    

输出的其他操作

['example:', 'Test', 'example:', '         ', 'IGNORE_ME_EXAMPLE']

you need to iterate over your list of words, for each word, you need to check if : present or not. if present the then split the word in 2 parts, pre : and post part. append these pre and post to final list and if there is no : in word add that word in the result list and skip other operation for that word

# your code goes here
wordlist = ['example:', 'Test', 'example:         ', 'IGNORE_ME_EXAMPLE']
result = []
for word in wordlist:
    index = -1
    part1, part2 = None, None
    if ':' in word:
        index = word.index(':')
    else:
        result.append(word)
        continue

    part1, part2 = word[:index+1], word[index+1:]
    if part1 is not None and len(part1)>0:
        result.append(part1)
    if part2 is not None and len(part2)>0:
        result.append(part2)
    
print(result)
    

output

['example:', 'Test', 'example:', '         ', 'IGNORE_ME_EXAMPLE']

python在保留订单的同时分开字符串?

御守 2025-02-18 05:29:40

该组件用作页面加载时应用的初始屏幕。

import React, { useState, useEffect } from 'react';

import { useLocation } from '@reach/router';
import { initializeAndTrack } from 'gatsby-plugin-gdpr-cookies';
import Cookies from 'js-cookie';

import CookieSettings from './Settings';

const CookieBanner = () => {
    const [showBanner, setShowBanner] = useState(false);
    const [showSettings, setShowSettings] = useState(false);
    const location = useLocation();

    // showSettings -> use this state property to open a configuration
    // window which may open up more information on the cookie(s) being applied

    useEffect(() => {
        setShowBanner(Cookies.get('gatsby-gdpr-responded') !== 'true');
    }, [])

    useEffect(() => {
        initTracking();
    }, [Cookies.get('gatsby-gdpr-responded')])

    const initTracking = () => {
        initializeAndTrack(location)
    }

    const handleAccept = () => {
        Cookies.set('gatsby-gdpr-google-analytics', true, { expires: 365 })
        handleCloseAll();
    }

    const handleDecline = () => {
        Cookies.remove('gatsby-gdpr-google-analytics');
        handleCloseAll();
    }

    const handleCloseAll = () => {
        setShowSettings(false);
        setShowBanner(false);

        Cookies.set('gatsby-gdpr-responded', true, { expires: 365 });
    }

    return (
        // add your component logic here
        // Take not of the different functions that are available above, like handleAccept / handleDecline / handleCloseAll 
        // handleCloseAll -> if a user declines / closes the banner
        // handleAccept -> a button to accept by default
        // handleDecline -> a button to decline the cookies

    )
}

export default CookieBanner

下一个组件更多是配置屏幕,它提供有关所应用的cookie的更多信息,如果您注意切换的导入,我们会使用切换来允许用户在任何时候专门关闭或关闭其cookie,您当然,如果您有很多GDPR合规,则可能需要创建单独的功能来处理删除cookie的函数,或者是通过要删除 /应用的cookie名称的可重复使用功能。

import React, { useState } from 'react';

import Cookies from 'js-cookie';

import Button from '@components/Button';
import Toggle from '@components/Inputs/Toggle';

const CookieSettings = ({
    handleAccept,
    handleDecline,
    initTracking,
    handleCloseAll
}) => {
    const [trackAnalytics, setTrackAnalytics] = useState(Cookies.get('gatsby-gdpr-google-analytics') === 'true')

    const handleToggle = () => {
        Cookies.set('gatsby-gdpr-responded', true, { expires: 365 });

        setTrackAnalytics((prevState) => {
            if (prevState) {
                Cookies.remove('gatsby-gdpr-google-analytics');
            } else {
                Cookies.set('gatsby-gdpr-google-analytics', true, { expires: 365 })
            }

            return !prevState
        })

        initTracking();
    }

    return (
        // your JSX code here
    )
}

export default CookieSettings;

编辑


// A some what reusable function that you can pass a cookie name too and switch over the name provided and set the required cookie.
const handleToggle = (cookieName) => {
        Cookies.set('gatsby-gdpr-responded', true, { expires: 365 });

        switch (cookieName) {
            case 'gatsby-gdpr-google-analytics':
                return setTrackAnalytics((prevState) => {
                    if (prevState) {
                        Cookies.remove(cookieName);
                    } else {
                        Cookies.set(cookieName, true, {
                            expires: 365
                        });
                    }

                    return !prevState
                })
            case 'gatsby-gdpr-google-tagmanager':
                return setTagAnalytics((prevState) => {
                    if (prevState) {
                        Cookies.remove(cookieName);
                    } else {
                        Cookies.set(cookieName, true, {
                            expires: 365
                        });
                    }

                    return !prevState
                })
            case 'gatsby-gdpr-facebook-pixel':
                return setFacebookAnalytics((prevState) => {
                    if (prevState) {
                        Cookies.remove(cookieName);
                    } else {
                        Cookies.set(cookieName, true, {
                            expires: 365
                        });
                    }

                    return !prevState
                })
            default:
                break;
        }

        initTracking()
    }

// A JSX toggle within your cookie setting
<Toggle active={trackAnalytics} toggleActive={() => handleToggle('gatsby-gdpr-google-analytics')} />
// The toggle component itself
import React from 'react';
import cx from 'classnames'
import PropTypes from 'prop-types'
import './styles.scss';

export default function Toggle({
    active = false,
    toggleActive,
}) {

    return (
        <div onClick={typeof toggleActive === 'function' && toggleActive} className={cx('toggle relative cursor-pointer', { active })} />
    )
}


Toggle.propTypes = {
    active: PropTypes.bool,
    toggleActive: PropTypes.func.isRequired
}

Toggle.defaultProps = {
    active: false,
}

This component is used as the initial screen that applies when the page loads.

import React, { useState, useEffect } from 'react';

import { useLocation } from '@reach/router';
import { initializeAndTrack } from 'gatsby-plugin-gdpr-cookies';
import Cookies from 'js-cookie';

import CookieSettings from './Settings';

const CookieBanner = () => {
    const [showBanner, setShowBanner] = useState(false);
    const [showSettings, setShowSettings] = useState(false);
    const location = useLocation();

    // showSettings -> use this state property to open a configuration
    // window which may open up more information on the cookie(s) being applied

    useEffect(() => {
        setShowBanner(Cookies.get('gatsby-gdpr-responded') !== 'true');
    }, [])

    useEffect(() => {
        initTracking();
    }, [Cookies.get('gatsby-gdpr-responded')])

    const initTracking = () => {
        initializeAndTrack(location)
    }

    const handleAccept = () => {
        Cookies.set('gatsby-gdpr-google-analytics', true, { expires: 365 })
        handleCloseAll();
    }

    const handleDecline = () => {
        Cookies.remove('gatsby-gdpr-google-analytics');
        handleCloseAll();
    }

    const handleCloseAll = () => {
        setShowSettings(false);
        setShowBanner(false);

        Cookies.set('gatsby-gdpr-responded', true, { expires: 365 });
    }

    return (
        // add your component logic here
        // Take not of the different functions that are available above, like handleAccept / handleDecline / handleCloseAll 
        // handleCloseAll -> if a user declines / closes the banner
        // handleAccept -> a button to accept by default
        // handleDecline -> a button to decline the cookies

    )
}

export default CookieBanner

The next component is more of a Configuration screen, which provides more information on the cookies being applied, if you take note on the import of Toggle, we use a toggle to allow users to specifically toggle on or off their cookies at any point, you of course if you have many GDPR compliances, may want to either create separate functions that handle the removal of cookies or a reusable function that is passed the name of the cookie to be removed / applied.

import React, { useState } from 'react';

import Cookies from 'js-cookie';

import Button from '@components/Button';
import Toggle from '@components/Inputs/Toggle';

const CookieSettings = ({
    handleAccept,
    handleDecline,
    initTracking,
    handleCloseAll
}) => {
    const [trackAnalytics, setTrackAnalytics] = useState(Cookies.get('gatsby-gdpr-google-analytics') === 'true')

    const handleToggle = () => {
        Cookies.set('gatsby-gdpr-responded', true, { expires: 365 });

        setTrackAnalytics((prevState) => {
            if (prevState) {
                Cookies.remove('gatsby-gdpr-google-analytics');
            } else {
                Cookies.set('gatsby-gdpr-google-analytics', true, { expires: 365 })
            }

            return !prevState
        })

        initTracking();
    }

    return (
        // your JSX code here
    )
}

export default CookieSettings;

EDIT


// A some what reusable function that you can pass a cookie name too and switch over the name provided and set the required cookie.
const handleToggle = (cookieName) => {
        Cookies.set('gatsby-gdpr-responded', true, { expires: 365 });

        switch (cookieName) {
            case 'gatsby-gdpr-google-analytics':
                return setTrackAnalytics((prevState) => {
                    if (prevState) {
                        Cookies.remove(cookieName);
                    } else {
                        Cookies.set(cookieName, true, {
                            expires: 365
                        });
                    }

                    return !prevState
                })
            case 'gatsby-gdpr-google-tagmanager':
                return setTagAnalytics((prevState) => {
                    if (prevState) {
                        Cookies.remove(cookieName);
                    } else {
                        Cookies.set(cookieName, true, {
                            expires: 365
                        });
                    }

                    return !prevState
                })
            case 'gatsby-gdpr-facebook-pixel':
                return setFacebookAnalytics((prevState) => {
                    if (prevState) {
                        Cookies.remove(cookieName);
                    } else {
                        Cookies.set(cookieName, true, {
                            expires: 365
                        });
                    }

                    return !prevState
                })
            default:
                break;
        }

        initTracking()
    }

// A JSX toggle within your cookie setting
<Toggle active={trackAnalytics} toggleActive={() => handleToggle('gatsby-gdpr-google-analytics')} />
// The toggle component itself
import React from 'react';
import cx from 'classnames'
import PropTypes from 'prop-types'
import './styles.scss';

export default function Toggle({
    active = false,
    toggleActive,
}) {

    return (
        <div onClick={typeof toggleActive === 'function' && toggleActive} className={cx('toggle relative cursor-pointer', { active })} />
    )
}


Toggle.propTypes = {
    active: PropTypes.bool,
    toggleActive: PropTypes.func.isRequired
}

Toggle.defaultProps = {
    active: false,
}

Google同意模式使用Gatsby实施

御守 2025-02-17 13:12:06

使用 noreferrer“> <<”代码>系列 S1,S2

#if necessary
df = df.replace('Nan', pd.NA)

s1 = 194 * df.Cr - 1.094 * df.age - 0.287
s2 = 194 * df.Cr - 1.094 * df.age - 0.287 * 0.739
   
df['eGFR'] = df['eGFR'].fillna(s1.where(df['gender'].eq(1), s2))
print (df)
   gender  age    Cr       eGFR
0       1   76  0.56  60.700000
1       1   50  0.76  70.600000
2       2   64  0.62  55.900000
3       1   62  0.45  19.185000
4       1   68  0.88  80.200000
5       2   69  0.65  50.401907
6       1   70  0.64  62.800000
7       2   65  0.39  60.200000

Use Series.fillna with Series created by Series.where by s1, s2:

#if necessary
df = df.replace('Nan', pd.NA)

s1 = 194 * df.Cr - 1.094 * df.age - 0.287
s2 = 194 * df.Cr - 1.094 * df.age - 0.287 * 0.739
   
df['eGFR'] = df['eGFR'].fillna(s1.where(df['gender'].eq(1), s2))
print (df)
   gender  age    Cr       eGFR
0       1   76  0.56  60.700000
1       1   50  0.76  70.600000
2       2   64  0.62  55.900000
3       1   62  0.45  19.185000
4       1   68  0.88  80.200000
5       2   69  0.65  50.401907
6       1   70  0.64  62.800000
7       2   65  0.39  60.200000

如何根据pandas dataframe中的另一列值填充列中的丢失值?

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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