回梦

文章 评论 浏览 30

回梦 2025-02-15 05:01:44

添加java kotlin答案的版本

@Bean
GroupedOpenApi publicApi() {
    return GroupedOpenApi.builder()
        .group("add-user-id-header")
        .addOperationCustomizer((operation, $) -> {
            operation.addParametersItem(
                new HeaderParameter()
                    .name("Authorization")
                    .description("Access Token")
                    .required(true)
            );
            return operation;
        })
        .build();
}

Adding a java version of the Kotlin answer

@Bean
GroupedOpenApi publicApi() {
    return GroupedOpenApi.builder()
        .group("add-user-id-header")
        .addOperationCustomizer((operation, $) -> {
            operation.addParametersItem(
                new HeaderParameter()
                    .name("Authorization")
                    .description("Access Token")
                    .required(true)
            );
            return operation;
        })
        .build();
}

将自定义请求标头添加到Spring Boot中的每个API

回梦 2025-02-15 00:23:07

在MySQL中,您可以设置您的batch_id和其他您不想具有独特键的重复项,然后使用插入物忽略到插入数据中。

In MySQL, you can set your batch_id and other fields you don't want to have duplicates with a unique key then use INSERT IGNORE INTO to insert the data.

在插入挂钩之前同时插入记录时,请避免重复

回梦 2025-02-14 17:03:39

在Oracle 12.2中,您可以使用json_dataguide

WITH table_name (value) AS (
  SELECT json_Array(
           json_object (
             'a' VALUE 1,
             'b' VALUE json_Array(
                         json_object ('a' VALUE 1),
                         'abcd',
                         123
                       )
           )
         )
  FROM   DUAL
)
SELECT j.path,
       j.type
FROM   table_name t
       CROSS JOIN LATERAL(
         SELECT JSON_DATAGUIDE(t.value) AS data
         FROM   DUAL
       ) d
       CROSS JOIN LATERAL(
         SELECT *
         FROM   JSON_TABLE(
                  d.data,
                  '$[*]'
                  COLUMNS(
                    path VARCHAR2(200) PATH '$."o:path"',
                    type VARCHAR2(200) PATH '$.type',
                    len  INTEGER       PATH '$."o:length"'
                  )
                )
       ) j;

输出:

路径type
$array
$。a数字
$。barray
$。b [*]字符串
$。ba数字

如果您想要更详细的内容,那么您可能必须在PL/SQL(或Java和Java and)中编写自己的JSON Parser将其编译在数据库中)。

db<>>

From Oracle 12.2, You can use JSON_DATAGUIDE:

WITH table_name (value) AS (
  SELECT json_Array(
           json_object (
             'a' VALUE 1,
             'b' VALUE json_Array(
                         json_object ('a' VALUE 1),
                         'abcd',
                         123
                       )
           )
         )
  FROM   DUAL
)
SELECT j.path,
       j.type
FROM   table_name t
       CROSS JOIN LATERAL(
         SELECT JSON_DATAGUIDE(t.value) AS data
         FROM   DUAL
       ) d
       CROSS JOIN LATERAL(
         SELECT *
         FROM   JSON_TABLE(
                  d.data,
                  '$[*]'
                  COLUMNS(
                    path VARCHAR2(200) PATH '$."o:path"',
                    type VARCHAR2(200) PATH '$.type',
                    len  INTEGER       PATH '$."o:length"'
                  )
                )
       ) j;

Which outputs:

PATHTYPE
$array
$.anumber
$.barray
$.b[*]string
$.b.anumber

If you want something more detailed then you are probably going to have to write your own JSON parser in PL/SQL (or Java and compile it in the database).

db<>fiddle here

如何获得JSON元素的结构?

回梦 2025-02-14 02:39:42

另一个基本技巧是strsplit

> sapply(strsplit(s, split = "\\d+"), `[[`, 2)
[1] "DT" "MF"

gsub

> gsub("^.*?(?<=\\d)(\\D+).*", "\\1", s, perl = TRUE)
[1] "DT" "MF"

Another base R trick is strsplit

> sapply(strsplit(s, split = "\\d+"), `[[`, 2)
[1] "DT" "MF"

or gsub

> gsub("^.*?(?<=\\d)(\\D+).*", "\\1", s, perl = TRUE)
[1] "DT" "MF"

正则语法用于选择字符的第二个事件

回梦 2025-02-14 00:30:06

siglongjmp跳回到sigsetjmp的位置,使其看起来像sigsetjmp返回了siglongjmp传递的值。因此,在这种情况下,如果siglongjmp以非零值调用,则它将跳回sigsetjmp(*coffeecatch_get_ctx(),1),1)== 0条件,将评估false,因此将无法满足,并且else块将执行。

但是,您不太可能从Sigsegv中有意义地恢复。当Sigsegv发生的时候,您的程序已经徘徊在不确定的行为中,以至于不可能推理其当前状态。数据很有可能被损坏,/或您的呼叫堆栈已被破坏。唯一有意义的行动是终止过程。


注意:使用(sig)?setJMP/(sig)?longjmp在C ++中是一个非常糟糕的主意。他们不会执行对象驱动器,因此可以轻松泄漏内存和/或违反类别不变的剂量。

siglongjmp jumps back to where sigsetjmp was called, and makes it look like sigsetjmp returned the value that siglongjmp was passed. So in this case, if siglongjmp is called with a non-zero value, then it will jump back to the sigsetjmp(*coffeecatch_get_ctx(), 1) == 0 condition, which will evaluate to false and thus the if will not be satisfied and the else block will execute.

It's very unlikely you can meaningfully recover from a SIGSEGV however. By the time a SIGSEGV happens your program has wandered so far off into undefined behavior that it is impossible to reason about its current state. There is a high chance that data has been corrupted and/or your call stack has been destroyed. The only meaningful action is to terminate the process.


Note: Using (sig)?setjmp/(sig)?longjmp in C++ is a very bad idea. They do not execute object destructors, and thus can easily leak memory and/or violate class invariants.

CoffeeCatch如何跳回Coffee_catch子句?

回梦 2025-02-13 22:22:12

只是为了帮助用户有兴趣打开像我一样实现此线程的Excel上的文件。

我已经使用了下面的向导,它对我来说很好,导入了一个UTF-8文件。
不透明,但如果您已经拥有该文件,则有用。

  1. 打开Microsoft Excel 2007。
  2. 单击数据菜单栏选项。
  3. 单击文本图标。
  4. 导航到要导入的文件的位置。单击文件名,然后单击“导入”按钮。文本导入向导 - 步骤1或3窗口现在将出现在屏幕上。
  5. 选择最能描述您数据的文件类型 - 界定或固定宽度。
  6. 选择65001:Unicode(UTF-8)从文件原点旁边出现的下拉列表中。
  7. 单击下一个按钮以显示文本导入向导 - 步骤2或3窗口。
  8. 将一个复选标记放在您希望将其导入到Microsoft Excel 2007的文件中使用的定界符旁边。数据预览窗口将向您展示您的数据将如何根据您选择的定界符出现。
  9. 单击下一个按钮以显示文本导入向导 - 步骤3 of 3。
  10. 为要导入的每列数据选择适当的数据格式。如果需要,您还可以选择不导入一个或多个数据列。
  11. 单击“完成”按钮以完成将数据导入Microsoft Excel 2007。

来源: https://www.itg.ias.edu/content/how-import-csv-file-uss-us-us-utf-8-character-concoter-concoding-0

Just for help users interested on opening the file on Excel that achieve this thread like me.

I have used the wizard below and it worked fine for me, importing an UTF-8 file.
Not transparent, but useful if you already have the file.

  1. Open Microsoft Excel 2007.
  2. Click on the Data menu bar option.
  3. Click on the From Text icon.
  4. Navigate to the location of the file that you want to import. Click on the filename and then click on the Import button. The Text Import Wizard - Step 1 or 3 window will now appear on the screen.
  5. Choose the file type that best describes your data - Delimited or Fixed Width.
  6. Choose 65001: Unicode (UTF-8) from the drop-down list that appears next to File origin.
  7. Click on the Next button to display the Text Import Wizard - Step 2 or 3 window.
  8. Place a checkmark next to the delimiter that was used in the file you wish to import into Microsoft Excel 2007. The Data preview window will show you how your data will appear based on the delimiter that you chose.
  9. Click on the Next button to display the Text Import Wizard - Step 3 of 3.
  10. Choose the appropriate data format for each column of data that you want to import. You also have the option to not import one or more columns of data if you want.
  11. Click on the Finish button to finish importing your data into Microsoft Excel 2007.

Source: https://www.itg.ias.edu/content/how-import-csv-file-uses-utf-8-character-encoding-0

是否可以自动强迫Excel识别UTF-8 CSV文件?

回梦 2025-02-12 08:24:45

您应该使用索引来移动完整的行。另外,无需使用int数组,因为单元格(列)只能具有2个状态,这是使用bool的理想情况:

var rowsCount = 20;
var columnsInRowCount = 10;

var playingGrid = new bool[rowsCount][];

for (var rowIndex = 0; rowIndex < playingGrid.Length; rowIndex++)
{
    playingGrid[rowIndex] = new bool[columnsInRowCount];
}

var rowIndexesToMove = new List<int>(rowsCount);
var firstNonEmptyRowIndex = Array.FindIndex(playingGrid, row => row.Contains(true));

// save full row indexes (start from first non-empty one, no need to check top empty rows)
for (var rowIndex = firstNonEmptyRowIndex; rowIndex < playingGrid.Length; rowIndex++)
{
    var row = playingGrid[rowIndex];

    if (!row.Contains(false))
    {
        rowIndexesToMove.Add(rowIndex);
    }
}

// move full rows to top
for (var fullRowIndex = 0; fullRowIndex < rowIndexesToMove.Count; fullRowIndex++)
{
    for (var rowIndex = rowIndexesToMove[fullRowIndex]; rowIndex >= firstNonEmptyRowIndex + fullRowIndex; rowIndex--)
    {
        for (var c = 0; c < playingGrid[firstNonEmptyRowIndex + fullRowIndex].Length; c++)
        {
            playingGrid[rowIndex][c] = false;
        }

        if (rowIndex > 0)
        {
            var temp = playingGrid[rowIndex];
            playingGrid[rowIndex] = playingGrid[rowIndex - 1];
            playingGrid[rowIndex - 1] = temp;
        }
    }
}

You should play with indexes to move full rows. Also, no need to use int array as the cell (column) can have only 2 states which is the perfect case for using bool:

var rowsCount = 20;
var columnsInRowCount = 10;

var playingGrid = new bool[rowsCount][];

for (var rowIndex = 0; rowIndex < playingGrid.Length; rowIndex++)
{
    playingGrid[rowIndex] = new bool[columnsInRowCount];
}

var rowIndexesToMove = new List<int>(rowsCount);
var firstNonEmptyRowIndex = Array.FindIndex(playingGrid, row => row.Contains(true));

// save full row indexes (start from first non-empty one, no need to check top empty rows)
for (var rowIndex = firstNonEmptyRowIndex; rowIndex < playingGrid.Length; rowIndex++)
{
    var row = playingGrid[rowIndex];

    if (!row.Contains(false))
    {
        rowIndexesToMove.Add(rowIndex);
    }
}

// move full rows to top
for (var fullRowIndex = 0; fullRowIndex < rowIndexesToMove.Count; fullRowIndex++)
{
    for (var rowIndex = rowIndexesToMove[fullRowIndex]; rowIndex >= firstNonEmptyRowIndex + fullRowIndex; rowIndex--)
    {
        for (var c = 0; c < playingGrid[firstNonEmptyRowIndex + fullRowIndex].Length; c++)
        {
            playingGrid[rowIndex][c] = false;
        }

        if (rowIndex > 0)
        {
            var temp = playingGrid[rowIndex];
            playingGrid[rowIndex] = playingGrid[rowIndex - 1];
            playingGrid[rowIndex - 1] = temp;
        }
    }
}

C#:将锯齿状阵列的行移动到顶部

回梦 2025-02-11 18:00:08

一个问题是,它取决于fetch_and_decrement的精确语义。以及(假定的)内存和执行模型的其他方面。这些事情需要在一个人可以自信地的原因上,就需要指定这些内容。

第二期是线程将忙于等待。

第三期是似乎有种族条件。假设线程从Central_barrier调用后立即调用Centry_barrier。然后,它可以执行fetch_and_decrement(&amp; count) 所有其他线程都有机会结束他们的重复,直到count == p循环。如果是这样,那么其中一些线程将继续循环,障碍物将陷入僵局。

这是带有p == 3线程的示例序列,该序列说明了比赛条件。

  1. 计数以3个
  2. 线程A调用Central_barrier,Count&lt; -2开始进入环路。
  3. 线程B调用central_barrier,count&lt; - 1,进入循环。
  4. 线程C调用central_barrier,count&lt; - 0,重置count&lt; -3,返回。
  5. 线程C立即调用central_barrier 再次,count&lt; - 2,进入循环。
  6. 线程A,B和C现在全部粘在循环中,因为计数== 2,没有其他线程可以更改它。他们都在等待计数== 3,这将永远不会发生。

现在,如果线程A和B都可以在步骤3和4之间测试计数,那么它们将脱离循环...一切都会很好。但是我们不能保证。一个或两个都可能被抢占或取消。 (想象一下线程比物理内核更多的情况。)

One issue is that it depends on the precise semantics of fetch_and_decrement. And of other aspects of the (assumed) memory and execution models. These things would need to be specified before one can confidently reason about the behavior of your pseudo-code.

A 2nd issue is that the threads will be busy-waiting.

A 3rd issue is that there appears to be a race condition. Suppose that a thread immediately calls central_barrier after returning from a central_barrier call. It could then execute the fetch_and_decrement(&count) before all of the other threads have had a chance to end their repeat until count == P loops. If it does, then some of those threads will keep on looping and the barrier will deadlock.

Here is an example sequence with P == 3 threads that illustrates the race condition.

  1. count starts at 3
  2. Thread A calls central_barrier, count <- 2, enters loop.
  3. Thread B calls central_barrier, count <- 1, enters loop.
  4. Thread C calls central_barrier, count <- 0, resets count <- 3, returns.
  5. Thread C immediately calls central_barrier again, count <- 2, enters loop.
  6. Thread A, B and C are now all stuck in the loop because count == 2 and no other threads can change it. They are all waiting for count == 3, and that will never happen.

Now if threads A and B are both able to test count between steps 3 and 4, then they will break out of the loop ... and all will be well. But we can't guarantee that. One or both may have been preempted or descheduled. (Imagine the case where there are more threads than physical cores to run them all.)

对于同步屏障的伪代码,该伪代码有什么问题?

回梦 2025-02-11 16:40:54

循环是最好的选择。

const array1 = ["124542", "112244", "112245", "112246"]
let array2 = [];
for (let i = 0; i < array1.length; i + 2) {
  array2[i] = {
    "comparableId": array2[i],
    "comparatorId": array2[i + 1]
  }
  console.log(array2[i])
}

array2不会是const变量,因为将要修改每个循环。如果您确实需要它是一个常数,则必须在代码末尾定义一个新常数:const array3 = array2;

A loop is the best option.

const array1 = ["124542", "112244", "112245", "112246"]
let array2 = [];
for (let i = 0; i < array1.length; i + 2) {
  array2[i] = {
    "comparableId": array2[i],
    "comparatorId": array2[i + 1]
  }
  console.log(array2[i])
}

array2 won't be a const variable as it is going to be modified each loop. If you really need it to be a constant then you'll have to define a new constant like so: const array3 = array2; at the end of your code.

从一个具有第一个值的字符串ID数组中创建对象数组

回梦 2025-02-11 11:52:59

好的
尝试遇到奇怪的错误后
将“单个实例” QuerySelector按钮更改为带有索引的QuerySelectorall的按钮,并将所有按钮类元素放回其中。

var cardContent = `[{
        "taskName": "Test Head",
        "image": "./images/test.jpg",
        "description": "Test description",
        "importance": 0

      },
      {
        "taskName": "Test Head",
        "image": "./images/test.jpg",
        "description": "Test description",
        "importance": 0

      },
      {
        "taskName": "Test Head",
        "image": "./images/test.jpg",
        "description": "Test description",
        "importance": 0

      },
      {
        "taskName": "Test Head",
        "image": "./images/test.jpg",
        "description": "Test description",
        "importance": 0

      },
      {
        "taskName": "Test Head",
        "image": "./images/test.jpg",
        "description": "Test description",
        "importance": 0

      },
      {
        "taskName": "Test Head",
        "image": "./images/test.jpg",
        "description": "Test description",
        "importance": 0

      },
      {
        "taskName": "Test Head",
        "image": "./images/test.jpg",
        "description": "Test description",
        "importance": 0

      },
      {
        "taskName": "Test Head",
        "image": "./images/test.jpg",
        "description": "Test description",
        "importance": 0

      },
      {
        "taskName": "Test Head",
        "image": "./images/test.jpg",
        "description": "Test description",
        "importance": 0

      }
    ]
    `


const journalObj = JSON.parse(cardContent);
var cardContainer = document.getElementById("card-space");
// svgs

const trashSvg = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-trash-fill" viewBox="0 0 16 16">
             <path d="M2.5 1a1 1 0 0 0-1 1v1a1 1 0 0 0 1 1H3v9a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2V4h.5a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1H10a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1H2.5zm3 4a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-1 0v-7a.5.5 0 0 1 .5-.5zM8 5a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-1 0v-7A.5.5 0 0 1 8 5zm3 .5v7a.5.5 0 0 1-1 0v-7a.5.5 0 0 1 1 0z"/>
           </svg>`;
const checkSvg = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-check-circle" viewBox="0 0 16 16">
             <path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/>
             <path d="M10.97 4.97a.235.235 0 0 0-.02.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-1.071-1.05z"/>
           </svg>`;

const printCards = () => {
  cardContainer.innerHTML = "";
  journalObj.forEach((card) => {
    cardContainer.innerHTML += `
        <div class="card">
            <div class="card-header">
              <div class="btn bg-info text-start">task</div>
            </div>
            <img src="${card.image}" class="card-img-top img-fluid" alt="...">
            <div class="card-body">
              <div class="card-title text-center h5">${card.taskName}</div><br>
              <div class="card-text text-center">${card.description}</div>
              <hr>
              <div class="card-text"> Importance: <button type="button" data-sortable=“true" class="btn btn-success prio-btn importance" value="${card.importance}"><span class="priority-count">${card.importance}</span></button></div>
              <div class="card-text fst-italic">Deadline</div>
            </div>
            <div class="card-footer bg-transparent text-end">
              <button type="button" class="bg-danger">${trashSvg} Delete</button>
              <button type="button" class="bg-success">${checkSvg} Done</button>
              </div>
        </div> 
        `;
  });
};
printCards();

const increasePriority = () => {
  // assign querySelector All to variable
  const priorityIncrement = document.querySelectorAll(".prio-btn");
  // loop every instance of ".prio-btn"
  priorityIncrement.forEach((button, i) => {
    // assign to every instance an eventlistener
    button.addEventListener("click", () => {
      // on click increment the calue of importance
      journalObj[i].importance++;
      //assing Selector to variable
      const buttonValue = button.querySelector(".priority-count");
      //write the value into the inner value of the cards button
      buttonValue.innerHTML = journalObj[i].importance;
      /*--------------------button colour change-----------------------------------------------------*/
      button.addEventListener("click", () => {
        // checking values, assiging correct colour
        if (journalObj[i].importance < 2) {
          priorityIncrement[i].setAttribute(
            "class",
            "btn btn-success prio-btn importance bg-success"
          );
        } else if (
          journalObj[i].importance > 1 &&
          journalObj[i].importance < 4
        ) {
          priorityIncrement[i].setAttribute(
            "class",
            "btn btn-warning prio-btn importance bg-warning"
          );
        } else if (
          journalObj[i].importance > 4 &&
          journalObj[i].importance < 6
        ) {
          priorityIncrement[i].setAttribute(
            "class",
            "btn btn-danger prio-btn importance bg-danger"
          );
        }
      });
      /* -----------------------------------------------------------------------*/
    });
  });
};
increasePriority();
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">
<div class="container main-content" id="main-content">
  <div class="deckbox">
    <div class="row">
      <!-- row for title of row -->
      <div class="col text-start my-3  fw-bold fs-3 ">Weekly Tasks</div>
      <!-- not yet implemented= line through -->
      <div class="col text-end my-3 fw-normal">Sort by priority:<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" type="button" class="bi bi-sort-up-alt sort" viewBox="0 0 16 16">
                            <path
                                d="M3.5 13.5a.5.5 0 0 1-1 0V4.707L1.354 5.854a.5.5 0 1 1-.708-.708l2-1.999.007-.007a.498.498 0 0 1 .7.006l2 2a.5.5 0 1 1-.707.708L3.5 4.707V13.5zm4-9.5a.5.5 0 0 1 0-1h1a.5.5 0 0 1 0 1h-1zm0 3a.5.5 0 0 1 0-1h3a.5.5 0 0 1 0 1h-3zm0 3a.5.5 0 0 1 0-1h5a.5.5 0 0 1 0 1h-5zM7 12.5a.5.5 0 0 0 .5.5h7a.5.5 0 0 0 0-1h-7a.5.5 0 0 0-.5.5z" />
                        </svg>
      </div>

      <!-- start of row for cards -->
      <div class="row row-cols-sm-1 row-cols-md-2 row-cols-lg-3 row-cols-xl-3 row-cols-xxl-3 g-0" id="card-space">

      </div>
    </div>
  </div>
</div>
</div>

OK
After trying around and running into weird errors
changing the "single instance" querySelector button to the one for querySelectorAll with an index, AND putting all button class elements back in it worked.

var cardContent = `[{
        "taskName": "Test Head",
        "image": "./images/test.jpg",
        "description": "Test description",
        "importance": 0

      },
      {
        "taskName": "Test Head",
        "image": "./images/test.jpg",
        "description": "Test description",
        "importance": 0

      },
      {
        "taskName": "Test Head",
        "image": "./images/test.jpg",
        "description": "Test description",
        "importance": 0

      },
      {
        "taskName": "Test Head",
        "image": "./images/test.jpg",
        "description": "Test description",
        "importance": 0

      },
      {
        "taskName": "Test Head",
        "image": "./images/test.jpg",
        "description": "Test description",
        "importance": 0

      },
      {
        "taskName": "Test Head",
        "image": "./images/test.jpg",
        "description": "Test description",
        "importance": 0

      },
      {
        "taskName": "Test Head",
        "image": "./images/test.jpg",
        "description": "Test description",
        "importance": 0

      },
      {
        "taskName": "Test Head",
        "image": "./images/test.jpg",
        "description": "Test description",
        "importance": 0

      },
      {
        "taskName": "Test Head",
        "image": "./images/test.jpg",
        "description": "Test description",
        "importance": 0

      }
    ]
    `


const journalObj = JSON.parse(cardContent);
var cardContainer = document.getElementById("card-space");
// svgs

const trashSvg = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-trash-fill" viewBox="0 0 16 16">
             <path d="M2.5 1a1 1 0 0 0-1 1v1a1 1 0 0 0 1 1H3v9a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2V4h.5a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1H10a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1H2.5zm3 4a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-1 0v-7a.5.5 0 0 1 .5-.5zM8 5a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-1 0v-7A.5.5 0 0 1 8 5zm3 .5v7a.5.5 0 0 1-1 0v-7a.5.5 0 0 1 1 0z"/>
           </svg>`;
const checkSvg = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-check-circle" viewBox="0 0 16 16">
             <path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/>
             <path d="M10.97 4.97a.235.235 0 0 0-.02.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-1.071-1.05z"/>
           </svg>`;

const printCards = () => {
  cardContainer.innerHTML = "";
  journalObj.forEach((card) => {
    cardContainer.innerHTML += `
        <div class="card">
            <div class="card-header">
              <div class="btn bg-info text-start">task</div>
            </div>
            <img src="${card.image}" class="card-img-top img-fluid" alt="...">
            <div class="card-body">
              <div class="card-title text-center h5">${card.taskName}</div><br>
              <div class="card-text text-center">${card.description}</div>
              <hr>
              <div class="card-text"> Importance: <button type="button" data-sortable=“true" class="btn btn-success prio-btn importance" value="${card.importance}"><span class="priority-count">${card.importance}</span></button></div>
              <div class="card-text fst-italic">Deadline</div>
            </div>
            <div class="card-footer bg-transparent text-end">
              <button type="button" class="bg-danger">${trashSvg} Delete</button>
              <button type="button" class="bg-success">${checkSvg} Done</button>
              </div>
        </div> 
        `;
  });
};
printCards();

const increasePriority = () => {
  // assign querySelector All to variable
  const priorityIncrement = document.querySelectorAll(".prio-btn");
  // loop every instance of ".prio-btn"
  priorityIncrement.forEach((button, i) => {
    // assign to every instance an eventlistener
    button.addEventListener("click", () => {
      // on click increment the calue of importance
      journalObj[i].importance++;
      //assing Selector to variable
      const buttonValue = button.querySelector(".priority-count");
      //write the value into the inner value of the cards button
      buttonValue.innerHTML = journalObj[i].importance;
      /*--------------------button colour change-----------------------------------------------------*/
      button.addEventListener("click", () => {
        // checking values, assiging correct colour
        if (journalObj[i].importance < 2) {
          priorityIncrement[i].setAttribute(
            "class",
            "btn btn-success prio-btn importance bg-success"
          );
        } else if (
          journalObj[i].importance > 1 &&
          journalObj[i].importance < 4
        ) {
          priorityIncrement[i].setAttribute(
            "class",
            "btn btn-warning prio-btn importance bg-warning"
          );
        } else if (
          journalObj[i].importance > 4 &&
          journalObj[i].importance < 6
        ) {
          priorityIncrement[i].setAttribute(
            "class",
            "btn btn-danger prio-btn importance bg-danger"
          );
        }
      });
      /* -----------------------------------------------------------------------*/
    });
  });
};
increasePriority();
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">
<div class="container main-content" id="main-content">
  <div class="deckbox">
    <div class="row">
      <!-- row for title of row -->
      <div class="col text-start my-3  fw-bold fs-3 ">Weekly Tasks</div>
      <!-- not yet implemented= line through -->
      <div class="col text-end my-3 fw-normal">Sort by priority:<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" type="button" class="bi bi-sort-up-alt sort" viewBox="0 0 16 16">
                            <path
                                d="M3.5 13.5a.5.5 0 0 1-1 0V4.707L1.354 5.854a.5.5 0 1 1-.708-.708l2-1.999.007-.007a.498.498 0 0 1 .7.006l2 2a.5.5 0 1 1-.707.708L3.5 4.707V13.5zm4-9.5a.5.5 0 0 1 0-1h1a.5.5 0 0 1 0 1h-1zm0 3a.5.5 0 0 1 0-1h3a.5.5 0 0 1 0 1h-3zm0 3a.5.5 0 0 1 0-1h5a.5.5 0 0 1 0 1h-5zM7 12.5a.5.5 0 0 0 .5.5h7a.5.5 0 0 0 0-1h-7a.5.5 0 0 0-.5.5z" />
                        </svg>
      </div>

      <!-- start of row for cards -->
      <div class="row row-cols-sm-1 row-cols-md-2 row-cols-lg-3 row-cols-xl-3 row-cols-xxl-3 g-0" id="card-space">

      </div>
    </div>
  </div>
</div>
</div>

如果仅单击一个按钮,如何避免更改所有按钮上的颜色? JavaScript

回梦 2025-02-11 08:46:22

使用mysqli_fetch_row()。尝试这个,

$query = "SELECT ssfullname, ssemail FROM userss WHERE user_id = ".$user_id;
$result = mysqli_query($conn, $query);
$row   = mysqli_fetch_row($result);

$ssfullname = $row['ssfullname'];
$ssemail    = $row['ssemail'];

Use mysqli_fetch_row(). Try this,

$query = "SELECT ssfullname, ssemail FROM userss WHERE user_id = ".$user_id;
$result = mysqli_query($conn, $query);
$row   = mysqli_fetch_row($result);

$ssfullname = $row['ssfullname'];
$ssemail    = $row['ssemail'];

使用mysqli的数据库结果

回梦 2025-02-09 23:53:46

如果您使用VS代码通过提供所有依赖项,包括Psycopg2和psycopg2-binary。

If you're using VS code recreate environment by giving requiremnet.txt with all the dependencies included psycopg2 and psycopg2-binary.

没有名称&#x27; psycopg2&#x27;即使成功安装psycopg2之后,错误

回梦 2025-02-09 16:28:01

如果我正确理解,您的身高不是100%。如果适合图像,则可以添加object-fit:coverobject-fit:包含

这样

.gallery-img{
     width: 100%;
     height: 100%;
     object-fit: cover;
     filter: brightness(75%);
}

If I understood correctly, your height is not 100%. If you fit the image you can add object-fit: cover or object-fit: contain

Like this

.gallery-img{
     width: 100%;
     height: 100%;
     object-fit: cover;
     filter: brightness(75%);
}

如何调整网格列?

回梦 2025-02-08 12:26:57

如果您只知道包装名称而不是活动,则可以使用 androidViewClient/culebra 解决方案的方法。

例如,如果您只知道Chrome软件包名称com.android.chrome可以运行

#! /usr/bin/env python3

from com.dtmilano.android.viewclient import ViewClient


device, serialno = ViewClient.connectToDeviceOrExit()
device.startActivity(package='com.android.chrome')

,则可以解决到主要活动,然后开始。

如果您想在不使用python的情况下从adb进行此操作,则可以查看源blob/master/src/com/dtmilano/android/adb/adbclient.py#l787“ rel =“ nofollow noreferrer”>在这里。

If you only know the package name and not the Activity you can use AndroidViewClient/culebra which resolves it.

For example, if you only knows the Chrome package name com.android.chrome you can run

#! /usr/bin/env python3

from com.dtmilano.android.viewclient import ViewClient


device, serialno = ViewClient.connectToDeviceOrExit()
device.startActivity(package='com.android.chrome')

and it is resolved to the main Activity and then started.

If you want to do it from adb without using python you can take a look at the source here.

如何通过ADB在设备上启动Android APK?

回梦 2025-02-08 09:27:10

对于火花版本&gt; = 3.1.0
您可以提取所有包含“具有以下代码的短语”的实例:

import pyspark.sql.functions as f

df = spark.createDataFrame([
    ("I've never had somebody couldn't [redacted-number] [redacted-number] [redacted-number] not.",),
    ("A phone USAA my name won't is.",)
], ['Category'])

df = (
    df
    .withColumn('regexp_extract', f.expr("""regexp_extract_all(Category, "(?:^| )([a-zA-Z]+'[a-zA-Z]+)(?: |$|\.)")"""))
)

df.show()

+--------------------+----------------+
|            Category|  regexp_extract|
+--------------------+----------------+
|I've never had so...|[I've, couldn't]|
|A phone USAA my n...|         [won't]|
+--------------------+----------------+

一旦您构建了想要进行的更改字典:

dictionary_of_changes = {
    "I've": "I have",
    "couldn't": "could not",
    "won't": "will not"
}

df = (df
      .withColumn('dictionary_of_changes', f.map_from_arrays(f.array(*[f.lit(key) for key in dictionary_of_changes.keys()]), f.array(*[f.lit(value) for value in dictionary_of_changes.values()])))
      .withColumn('CategoryRefined', f.expr('aggregate(regexp_extract, Category, (final_string, element) -> regexp_replace(final_string, element, element_at(dictionary_of_changes, element)))'))
     )

输出将是:

For Spark version >= 3.1.0
You can extract all instances of phrases containing ' with the following code:

import pyspark.sql.functions as f

df = spark.createDataFrame([
    ("I've never had somebody couldn't [redacted-number] [redacted-number] [redacted-number] not.",),
    ("A phone USAA my name won't is.",)
], ['Category'])

df = (
    df
    .withColumn('regexp_extract', f.expr("""regexp_extract_all(Category, "(?:^| )([a-zA-Z]+'[a-zA-Z]+)(?: |$|\.)")"""))
)

df.show()

+--------------------+----------------+
|            Category|  regexp_extract|
+--------------------+----------------+
|I've never had so...|[I've, couldn't]|
|A phone USAA my n...|         [won't]|
+--------------------+----------------+

Once you've constructed your the dictionary of changes that you wanna make:

dictionary_of_changes = {
    "I've": "I have",
    "couldn't": "could not",
    "won't": "will not"
}

df = (df
      .withColumn('dictionary_of_changes', f.map_from_arrays(f.array(*[f.lit(key) for key in dictionary_of_changes.keys()]), f.array(*[f.lit(value) for value in dictionary_of_changes.values()])))
      .withColumn('CategoryRefined', f.expr('aggregate(regexp_extract, Category, (final_string, element) -> regexp_replace(final_string, element, element_at(dictionary_of_changes, element)))'))
     )

and the output will be:
enter image description here

Pyspark从文本列中替换缩写

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

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