添加新项目类型是很好的选择。
class MyAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
companion object {
const val ITEM_TYPE_CONTENT = 0
const val ITEM_TYPE_BUTTON = 1
}
val dataList: List<String>? = null
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
if (viewType == ITEM_TYPE_CONTENT) {
// TODO return a content holder
}else {
// TODO return a button holder
}
}
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
TODO("Not yet implemented")
}
override fun getItemCount(): Int {
return (dataList?.size ?: 0) + 1
}
override fun getItemViewType(position: Int): Int {
return if (position == itemCount - 1) {
ITEM_TYPE_BUTTON
} else {
ITEM_TYPE_CONTENT
}
}
}
我遇到了GitHub Actions的同一问题,这仅仅是由于我对NPM的代币已过期。
您可以将一个月分成日历周。 (例如,在2022年7月,将是:7月1-2日,3-9、10-16,ECT…)
然后,取决于当天,占据的第一周或下半年。
在过滤的几周内迭代,计算工作日。
我选择在本月上半年的第三周内包括5周,但是您可以通过更改 MATH.CEIL
MATH.Floor
来更改此操作。
/**
* Get the last item in an array, or undefined if the array is empty.
* @template T
* @param {[T]} array
* @returns {T|undefined}
*/
const lastItem = array => array[array.length - 1];
const getWeekdays = current => {
/** @type {[[Date]]} */
const weeks = [];
// Get the weeks
/**
* Get the calendar week of the given date.
* @param {Date} firstDay The first day of the week.
* @returns {[Date]}
*/
const getWeek = firstDay => {
/** @type {[Date]} */
let days = [];
let dateToTest = new Date(firstDay);
// Continue until the end of the week or month, whichever comes first.
while (
dateToTest.getDay() <= 6 &&
dateToTest.getMonth() == firstDay.getMonth()
) {
days.push(new Date(dateToTest));
dateToTest.setDate(dateToTest.getDate() + 1);
}
return days;
};
// The first day of the month
const firstDay = new Date(current.getFullYear(), current.getMonth());
let dateToTest = new Date(firstDay);
do {
weeks.push(getWeek(dateToTest));
dateToTest = new Date(lastItem(lastItem(weeks)));
dateToTest.setDate(dateToTest.getDate() + 1);
} while (dateToTest.getMonth() == firstDay.getMonth());
// Filter to half of the month
// Get the week of the given date
let currentWeek = 0;
weekLoop: for (let i = 0; i < weeks.length; i++) {
const week = weeks[i];
for (const day of week) {
if (day == current) {
currentWeek = i;
break weekLoop;
}
}
}
/** @type {[[Date]]} */
let weeksInHalf = [];
const numOfWeeksInFirstHalf = Math.ceil(weeks.length / 2),
numOfWeeksInSecondHalf = weeks.length - numOfWeeksInFirstHalf;
for (
let i = 0;
i <
(currentWeek < numOfWeeksInFirstHalf
? numOfWeeksInFirstHalf
: numOfWeeksInSecondHalf);
i++
) {
weeksInHalf.push(weeks[i]);
}
// Filter out weekends
// Format dates
return weeksInHalf
.flat()
.filter(day => day.getDay() > 0 && day.getDay() < 6)
.map(
day => `${day.getFullYear()}-${day.getMonth() + 1}-${day.getDate()}`
);
};
// Tests
for (let i = 0; i < 12; i++) {
const weekdays = getWeekdays(new Date(2022, i));
weekdays.forEach(dateString => {
const [year, month, day] = dateString.split("-");
const date = new Date(year, month - 1, day);
if (date.getDay() == 0 || date.getDay() == 6)
throw new Error("Invalid day: (day)");
else console.log(dateString)
});
}
注释十六进制编码,每对十六进制字符代表字节的价值。 128个字符 - &GT; 64字节 by jps 可以在python (1)可以照亮(并解决) >在更多方面,例如:
hexstr = '3f5b2e3acfd36066b8cb4114e706d79d270c7c4219a6312c4b40f995f138c2ba5ba2b62aa4831e0bdac8f8802626d3c4f8872b8996d8bebc5ab697e0c702a6eb'
print( len(hexstr))
print( hexstr)
bytes_object = bytes.fromhex(hexstr)
import binascii
print( bytes_object == binascii.unhexlify(hexstr))
import codecs
print( bytes_object == codecs.decode(hexstr, 'hex_codec'))
print( len(bytes_object))
print( bytes_object)
结果: 。\ so \ 72880674.py
128
3f5b2e3acfd36066b8cb4114e706d79d270c7c4219a6312c4b40f995f138c2ba5ba2b62aa4831e0bdac8f8802626d3c4f8872b8996d8bebc5ab697e0c702a6eb
True
True
64
b"?[.:\xcf\xd3`f\xb8\xcbA\x14\xe7\x06\xd7\x9d'\x0c|B\x19\xa61,K@\xf9\x95\xf18\xc2\xba[\xa2\xb6*\xa4\x83\x1e\x0b\xda\xc8\xf8\x80&&\xd3\xc4\xf8\x87+\x89\x96\xd8\xbe\xbcZ\xb6\x97\xe0\xc7\x02\xa6\xeb"
(1)我想您知道 python basics ,因为您的另一个问题…
所以我终于想到了一个主意。因此,我的想法是,而不是在if语句中使用if语句,而是认为这可能是为语句做多次的更好的解决方案。一个是一年,一个是一个月,一个是一天,所以我可以根据一个月的一年首先基于一年的代码进行排序,最后也是一天的。这是代码:
#include <stdio.h>
typedef struct
{
int month;
int day;
int year;
float T_degC;
float PO4uM;
float SiO3uM;
float NO2uM;
float NO3uM;
float Salnty;
float O2ml_L;
}
hello;
int insertionSort(hello hellos[], int records);
int main()
{
FILE *file;
file = fopen("ocean.csv", "r");
if(file == NULL)
{
printf("Error opening file. \n");
return 1;
}
hello hellos[1405];
int read = 0;
int records = 0; //dhladh struct
do
{
read = fscanf(file,
"%d/%d/%d, %f, %f, %f, %f, %f, %f, %f",
&hellos[records].month,
&hellos[records].day,
&hellos[records].year,
&hellos[records].T_degC,
&hellos[records].PO4uM,
&hellos[records].SiO3uM,
&hellos[records].NO2uM,
&hellos[records].NO3uM,
&hellos[records].Salnty,
&hellos[records].O2ml_L);
if(read == 10)
{
records++;
}
if(read != 10 && feof(file) ==0)
{
printf("File format incorrect.\n");
return 1;
}
if(ferror(file))
{
printf("Error reading file.\n");
return 1;
}
} while (!feof(file));
fclose(file);
printf("\n%d records read.\n\n", records);
insertionSort(hellos, records);
//insertionSort(hellos, records);
//Εκτυπωση των αποτελεσματων.
for(int i=0; i<records; i++)
{
printf("\n%d, %d, %d, %f, %f, %f, %f, %f, %f, %f",
hellos[i].month,
hellos[i].day,
hellos[i].year,
hellos[i].T_degC,
hellos[i].PO4uM,
hellos[i].SiO3uM,
hellos[i].NO2uM,
hellos[i].NO3uM,
hellos[i].Salnty,
hellos[i].O2ml_L);
printf("\n");
}
return 0;
}
int insertionSort(hello hellos[], int records)
{
int i;
hello key;
for(int j=1; j<records; j++)
{
key = hellos[j];
i = j-1;
if(key.year < hellos[i].year)
{
while(i >= 0 && (key.year < hellos[i].year))
{
hellos[i+1] = hellos[i];
i = i-1;
}
hellos[i+1] = key;
}
}
for(int k=1; k<records; k++)
{
key = hellos[k];
i = k-1;
if((key.month < hellos[i].month) && (key.year == hellos[i].year))
{
while(i >= 0 && (key.month < hellos[i].month) && (key.year == hellos[i].year))
{
hellos[i+1] = hellos[i];
i = i-1;
}
hellos[i+1] = key;
}
}
for(int l=1; l<records; l++)
{
key = hellos[l];
i = l-1;
if((key.day < hellos[i].day) && (key.month == hellos[i].month) && (key.year == hellos[i].year))
{
while(i >= 0 && (key.day < hellos[i].day) && (key.month == hellos[i].month) && (key.year == hellos[i].year))
{
hellos[i+1] = hellos[i];
i = i-1;
}
hellos[i+1] = key;
}
}
return 0;
}
问题在于您要匹配这些单字符样本的部分。 \w。+
需要至少两个字符要匹配。因此,对于当您获得“ E \ hich”时,第一个后斜线会匹配到Regex中的DOT,并持续到下一个后背(这是Regex的正面LookAhead部分中列出的“终结者”之一)。
您可能需要使用*
而不是+
。
现在,我说明了读取Maven创建资源目录的字体的源代码,
scr/main/resources/calibril.ttf
Font getCalibriLightFont(int fontSize){
Font font = null;
try{
URL fontURL = OneMethod.class.getResource("/calibril.ttf");
InputStream fontStream = fontURL.openStream();
font = new Font(Font.createFont(Font.TRUETYPE_FONT, fontStream).getFamily(), Font.PLAIN, fontSize);
fontStream.close();
}catch(IOException | FontFormatException ief){
font = new Font("Arial", Font.PLAIN, fontSize);
ief.printStackTrace();
}
return font;
}
你,享受!
Hibernate搜索检测Hibernate Orm Session
/ EntityManager
中发生的实体更改事件。这不包括 insert
/更新
/ delete
您在jpql或本机SQL查询中写的语句。
也记录下来的解决方法:
一个解决方法是在运行jpql/sql查询后明确依次扣押,要么使用 massIndexer 或手动。
编辑:当然,您的解决方法也可能有效,如果 deletebyid
在删除它之前会加载实体(我不太熟悉Spring Data JPA的内部内容):
我可以通过简单地使用标准JPA方法DeleteById()轻松解决此问题,但是我想知道为什么定制的JPA方法DeletealBbyIdin()不会导致Hibernate搜索以更新Lucene索引。
。
尝试一下
<ArticleBoxes
key={newsArticle.source.id}
src={newsArticle.urlToImage}
href={newsArticle.url}
blogTitleAnchor={newsArticle.title}
/>
,我猜想如果您检查了控制台,您会发现 ID
不确定。您也需要为每个ID定义唯一ID,因为在数据中,大多数ID是 null
首先,我们首先需要一种创建安全的随机值以生成IV和键的方法。您还可以使用Cryptokit的 SymmetricKey
生成键并从中提取数据,但是现在,我将使用此功能。
extension Data {
static func secureRandom(ofSize size: Int) -> Data {
var output = [UInt8](repeating: 0, count: size)
_ = SecRandomCopyBytes(kSecRandomDefault, size, &output)
return Data(output)
}
}
然后,我们需要计算AES CBC密文的可能性,可以使用CommonCrypto进行。
func encrypt(plaintext: Data, key: Data, iv: Data) -> Data {
var encryptor: CCCryptorRef?
defer {
CCCryptorRelease(encryptor)
}
var key = Array(key)
var iv = Array(iv)
var plaintext = Array(plaintext)
CCCryptorCreate(CCOperation(kCCEncrypt), CCAlgorithm(kCCAlgorithmAES), CCOperation(kCCOptionPKCS7Padding), &key, key.count, &iv, &encryptor)
var outputBytes = [UInt8](repeating: 0, count: CCCryptorGetOutputLength(encryptor, plaintext.count, false))
CCCryptorUpdate(encryptor, &plaintext, plaintext.count, &outputBytes, outputBytes.count, nil)
var movedBytes = 0
var finalBytes = [UInt8](repeating: 0, count: CCCryptorGetOutputLength(encryptor, 0, true))
CCCryptorFinal(encryptor, &finalBytes, finalBytes.count, &movedBytes)
return Data(outputBytes + finalBytes[0 ..< movedBytes])
}
以及具有SHA-256哈希功能的HMAC。我建议在此处使用Cryptokit的HMAC实现,但是为了使事情变得简单,我选择了CommonCrypto实施。
func computeHMAC(_ data: Data, using key: Data) -> Data {
var data = Array(data)
var key = Array(key)
var macOut = [UInt8](repeating: 0, count: Int(CC_SHA256_DIGEST_LENGTH))
CCHmac(CCHmacAlgorithm(kCCHmacAlgSHA256), &key, key.count, &data, data.count, &macOut)
return Data(macOut)
}
这将所有这些融合到以下
let plaintext = Data("Hello world!".utf8)
let signingKey = Data.secureRandom(ofSize: kCCKeySizeAES128)
let cryptoKey = Data.secureRandom(ofSize: kCCKeySizeAES128)
let fernetKey = (signingKey + cryptoKey).base64EncodedString()
let version: [UInt8] = [0x80]
let timestamp: [UInt8] = {
let timestamp = Int(Date().timeIntervalSince1970).bigEndian
return withUnsafeBytes(of: timestamp, Array.init)
}()
let iv = Data.secureRandom(ofSize: kCCBlockSizeAES128)
let ciphertext = encrypt(plaintext: plaintext, key: cryptoKey, iv: iv)
let hmac = computeHMAC(version + timestamp + iv + ciphertext, using: signingKey)
let fernetToken = (version + timestamp + iv + ciphertext + hmac).base64EncodedString()
print("Fernet key: \(fernetKey)")
print("Fernet token: \(fernetToken)")
示例输出中,
Fernet key: 7EwFlYNKTGfj+2fSgL3AUqtrRqRs4D1TWNK7t2XbGJQ=
Fernet token: gAAAAABivCLM0y0poDtGOohT1yK4XTDJppYPJdu4fuDTZ5tb9P9KP5ACgX8aJq4imsSdbzOCcvY3Tueo4FYbwyG+ZugozILL+Q==
我们可以在Python中使用Cryptography.io的实现来使用它。
from cryptography.fernet import Fernet
key = b'7EwFlYNKTGfj+2fSgL3AUqtrRqRs4D1TWNK7t2XbGJQ='
token = b'gAAAAABivCLM0y0poDtGOohT1yK4XTDJppYPJdu4fuDTZ5tb9P9KP5ACgX8aJq4imsSdbzOCcvY3Tueo4FYbwyG+ZugozILL+Q=='
Fernet(key).decrypt(token)
# b'Hello world!'
我看起来您可能有一些不匹配的角度。您的标题说Angular版本4.4.7。您的树说Angular-CLI 6.2.9,您的打字稿版本在2.7.2上。对于角度和角度CLI,打字稿要求将有所不同。我会首先通过降低CLI或升级角度来对齐这些版本。然后擦除node_modules文件夹,然后安装新的NPM。 Angular/Angular-CLI升级的有用工具
使用 tidyverse
和a for循环:
library(tidyverse)
df <- data.frame(V1 = c("a","b","c"))
for(i in 1:3){
print(paste("The values are",
df |>
slice(1:i) |>
pull(V1) |>
str_c(collapse = " "),
"now."))
}
输出:
[1] "The values are a now."
[1] "The values are a b now."
[1] "The values are a b c now."
当您说
char *msg = "HI!";
几个特殊的事情正在发生时。首先,字符串文字“ hi!”
被视为匿名数组
char anonymous_array[] = "HI!";
(这种对字符串文字的处理是C语言 dos 支持的唯一方法 “字符串类型”的概念。)
第二,当您尝试使用此数组的值时,您得到的(就像在C中一样)是指向数组的第一个元素的指针:
char *msg = &anonymous_array[0];
而且效果很好。另一方面,当您
int *p = 2;
没有这样说时。如果有的话,这告诉编译器不是您想要一个指向整数2的指针> p ,而是您想要一个指针 p
指向内存地址2 。但是您的程序可能无法访问内存地址2,即使这样做,对于普通程序,也无法知道该地址的内容,您无能为力。 (另一方面,如果您进行嵌入式编程,您可能会知道,该地址在特定体系结构上有一些有趣的东西。)
如果您想要 p
指向带有值的整数对象2,您需要以某种方式创建该整数对象。您可以做
int i = 2;
int *p = &i;
或
int array[] = { 2 };
int *p = array;
或 - 这最终更接近字符串初始化的工作方式 - 您可以使用一种特殊的语法,称为a compound compound literal :
int *p = (int []){ 2 };
我试图在环境中复制相同的错误,并获得了与以下相同的错误:
请注意,您需要通过
应用程序对象ID
而不是应用程序ID:此处能够成功地创建扩展属性,如下所示:
参考:
创建ExtensionProperty -Microsoft Graph V1.0 |微软文档
I tried to reproduce the same in my environment and got the same error as below:
Please note that, you need to pass
Application Object ID
instead of Application ID:When I passed the
Application Object ID
, I was able create the extension property successfully like below:Reference:
Create extensionProperty - Microsoft Graph v1.0 | Microsoft Docs
无法使用“ Jobrole”创建扩展属性。邮差