我使用Xamarin Android出现了类似的错误。我通过编辑 androidManifest.xml Microsoft Docs
<meta-data android:name="com.google.android.geo.API_KEY" android:value="YOUR_MAP_IP_KEY"></meta-data>
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
<!-- Necessary for apps that target Android 9.0 or higher -->
<uses-library android:name="org.apache.http.legacy" android:required="false" />
要将某种类型转换为 ctypes
该类型的数组,直接的成语是:
(element_type * num_elements)(*list_of_elements)
在这种情况下:
(c_char_p * len(array))(*array)
请注意,(*array)
将数组展开元素作为参数传递,这是初始化数组所需的。
完整示例:
test.c - 验证参数已按预期传递。
#include <stdio.h>
#ifdef _WIN32
# define API __declspec(dllexport)
#else
# define API
#endif
API int foo(int numOfProp, const char** propName, const char** propValue) {
for(int i = 0; i < numOfProp; i++)
printf("name = %s value = %s\n", propName[i], propValue[i]);
return 1;
}
test.py
import ctypes as ct
dll = ct.CDLL('./test')
# Always define .argtypes and .restype to help ctypes error checking
dll.foo.argtypes = ct.c_int, ct.POINTER(ct.c_char_p), ct.POINTER(ct.c_char_p)
dll.foo.restype = ct.c_int
# helper function to build ctypes arrays
def make_charpp(arr):
return (ct.c_char_p * len(arr))(*(s.encode() for s in arr))
def foo(arr1, arr2):
if len(arr1) != len(arr2):
raise ValueError('arrays must be same length')
return dll.foo(len(arr1) ,make_charpp(arr1), make_charpp(arr2))
foo(['PropName1', 'PropName2'], ['10', '20'])
输出:
name = PropName1 value = 10
name = PropName2 value = 20
arrays.deeptostring(arr)
仅在一行上打印。
int[][] table = new int[2][2];
要实际获取一个表作为二维表打印的表,我必须这样做:
System.out.println(Arrays.deepToString(table).replaceAll("],", "]," + System.getProperty("line.separator")));
似乎 arrays.deeptostring(arr)
方法应该采用一个分隔符字符串,但不幸的是不是。
对于测试简单对象,请使用:
if (obj[x] !== undefined)
如果您不知道它是哪种对象类型,请使用:
if (obj.hasOwnProperty(x))
所有其他选项都较慢...
详细介绍了
Node.js下100,000,000个周期的性能评估,以便在此处建议的五个选项
function hasKey1(k,o) { return (x in obj); }
function hasKey2(k,o) { return (obj[x]); }
function hasKey3(k,o) { return (obj[x] !== undefined); }
function hasKey4(k,o) { return (typeof(obj[x]) !== 'undefined'); }
function hasKey5(k,o) { return (obj.hasOwnProperty(x)); }
:评估告诉我们,除非我们特别想检查对象的原型链以及对象本身,我们不应使用常见的形式:
if (X in Obj)...
它慢于2至6倍,取决于用例
hasKey1 execution time: 4.51 s
hasKey2 execution time: 0.90 s
hasKey3 execution time: 0.76 s
hasKey4 execution time: 0.93 s
hasKey5 execution time: 2.15 s
底线,如果您的OBJ不一定是一个简单的对象,并且您希望避免检查对象的原型链并确保直接obj直接拥有x,请使用 if(obj.hasownproperty(x)) )...
。
否则,使用简单对象而不担心对象的原型链时,使用 if(typeof(obj [x])!=='undefined')...
是最安全,最快的方法。
如果您将简单的对象用作哈希表,并且永远不会做任何问题,则我会使用如果(obj [x])...
,因为我发现它更可读。
您正在使用 tag_name
,这两个评论和答复都是相同的。因此,导致 2个节点
(可能有很多取决于您的 html-dom
)。
如果您想区分节点,我会发现 data-service-review-date-time-ago
属性是唯一的。
因此,将其更改为CSS/XPath将完成工作。
css: 时间[data-service-review-date-date time-ago]
xpath: // time [@data-service -review-date time-ago]
您可以使用 driver.find_element(by.xpath,“ // time [@dation-service-review-date-date-time-ago)调用它们)< /code>或
driver.find_element(by.css_selector,“ time [data-service-review-date-time-ago]”)
等
。 /代码>将返回Web元素列表,如果您针对第一个节点,则可能要使用 find_element
。
根据上述答案,我试图提出一个版本的下个月和最后一天的第一天。让我知道您的想法:
月开始:
Get-Date -Format "yyyy-MM-ddT00:00:00Z" -Date ([datetime](Get-Date -Day 1).AddMonths(1))
输出:2022-07-01T00:00:00:00Z
月末:
Get-Date -Format "yyyy-MM-ddT23:59:59Z"-Date (([datetime](Get-Date -Day 1).AddMonths(2)).AddDays(-1))
输出:2022-07-31T23:59:59Z
这是@Steven Rumbalski的答案 验证 entrac> widget值,通过追踪到 StringVar
- 我已经通过将其编辑到位,在某种程度上进行了调试并改进。
下面的版本将所有内容都放入 stringvar
subclass 以封装更好的事情,更重要的是,允许同一时间同时存在多个独立实例,而不会彼此干扰 - 他的实现一个潜在的问题,因为它利用函数属性而不是实例属性,这些属性与全局变量基本相同,并且在这种情况下可能会导致问题。
try:
from tkinter import *
except ImportError:
from Tkinter import * # Python 2
class ValidateFloatVar(StringVar):
"""StringVar subclass that only allows valid float values to be put in it."""
def __init__(self, master=None, value=None, name=None):
StringVar.__init__(self, master, value, name)
self._old_value = self.get()
self.trace('w', self._validate)
def _validate(self, *_):
new_value = self.get()
try:
new_value == '' or float(new_value)
self._old_value = new_value
except ValueError:
StringVar.set(self, self._old_value)
root = Tk()
ent = Entry(root, textvariable=ValidateFloatVar(value=42.0))
ent.pack()
ent.focus_set()
ent.icursor(END)
root.mainloop()
可以在聚类的索引视图上创建一个唯一的约束,
您可以创建这样的视图:
CREATE VIEW dbo.VIEW_OfYourTable WITH SCHEMABINDING AS
SELECT YourUniqueColumnWithNullValues FROM dbo.YourTable
WHERE YourUniqueColumnWithNullValues IS NOT NULL;
以及这样的唯一约束:
CREATE UNIQUE CLUSTERED INDEX UIX_VIEW_OFYOURTABLE
ON dbo.VIEW_OfYourTable(YourUniqueColumnWithNullValues)
尝试使用此类:
class AddressTile extends StatelessWidget {
final SystemData systemData;
final int index;
const AddressTile({required this.systemData, required this.index, Key? key})
: super(key: key);
@override
Widget build(BuildContext context) {
if (systemData.addresses == null || systemData.addresses!.length < index) {
return Container();
}
Address address = systemData.addresses![index];
return Container(
padding: const EdgeInsets.symmetric(
horizontal: 10,
),
width: MediaQuery.of(context).size.width,
margin: const EdgeInsets.only(bottom: 12, top: 12),
child: Container(
padding: const EdgeInsets.all(5),
// width: SizeConfig.screenWidth * 0.78,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16),
color: Theme.of(context).backgroundColor),
child: Row(children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Icon(
Icons.location_pin,
//size: 30,
),
const SizedBox(width: 4),
Flexible(
child: AutoSizeText(
address.line1Address!,
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
),
],
),
const SizedBox(
height: 10,
),
Container(
padding: const EdgeInsets.only(left: 20),
child: Column(
children: [
AutoSizeText(
'${address.line2Address!} ${address.township!} ${address.state!} ${address.country!} ${address.postalCode}',
//maxLines: 1,
style: const TextStyle(fontSize: 16),
),
],
),
),
const SizedBox(
height: 10,
),
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Icon(
Icons.phone_outlined,
//size: 30,
),
const SizedBox(width: 4),
Row(
children: [
//const SizedBox(height: 30),
TextButton(
style: TextButton.styleFrom(
textStyle: const TextStyle(fontSize: 16),
),
onPressed: () {
launchURL("tel:${address.phone1!}");
},
child: Text(address.phone1!),
),
const SizedBox(height: 10),
TextButton(
style: TextButton.styleFrom(
textStyle: const TextStyle(fontSize: 16),
),
onPressed: () {
launchURL("tel:${address.phone2!}");
},
child: Text(address.phone2!),
),
],
)
],
),
Divider(
color: Theme.of(context).scaffoldBackgroundColor,
thickness: 2.0,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
TextButton.icon(
onPressed: () {
launchURL(systemData.facebook!);
},
icon: const Icon(Icons.facebook_outlined),
label: const AutoSizeText("Facebook"),
),
TextButton.icon(
onPressed: () {
launchURL(systemData.messenger!);
},
icon: const Icon(Icons.messenger_outline_sharp),
label: const AutoSizeText("Chat"),
),
TextButton.icon(
onPressed: () {
launchURL(systemData.youtube!);
},
icon: const Icon(Icons.videocam),
label: const AutoSizeText("Youtube"),
),
],
)
],
),
),
]),
),
);
}
}
尽管对象声明不允许您引用先验属性,但函数声明中的默认值确实如此。
因此,您可以做到这一点:
const foo = ((a=5, b=6, c=a+b) => ({a,b,c}))()
console.log(foo)
使用此行:
setTimeout(clearInterval(myInterval),2000);
clearInterval(myinterval)
部分正在立即执行,而从该调用中的返回值是在计时器的2000毫秒延迟命中后将执行的。
此函数调用的返回值不是 settimeout()
需要的第一个参数。它需要功能参考。因此,要进行电话等待计时器的时间,您需要将该调用包装在函数参考中。
setTimeout(function(){ clearInterval(myInterval) },2000);
基于 @Edchum对他的回答的评论的答案。评论就是这样 -
groupby is notoriously slow and memory hungry, what you could do is sort by column A, then find the idxmin and idxmax (probably store this in a dict) and use this to slice your dataframe would be faster I think
让我们首先创建一个数据框,在第一列中具有500K类别,而总DF Shape则为2000万。
df = pd.DataFrame(columns=['a', 'b'])
df['a'] = (np.random.randint(low=0, high=500000, size=(20000000,))).astype(str)
df['b'] = list(range(20000000))
print(df.shape)
df.head()
# Sort data by first column
df.sort_values(by=['a'], ascending=True, inplace=True)
df.reset_index(drop=True, inplace=True)
# Create a temp column
df['temp_idx'] = list(range(df.shape[0]))
# Take all values of b in a separate list
all_values_b = list(df.b.values)
print(len(all_values_b))
# For each category in column a, find min and max indexes
gp_df = df.groupby(['a']).agg({'temp_idx': [np.min, np.max]})
gp_df.reset_index(inplace=True)
gp_df.columns = ['a', 'temp_idx_min', 'temp_idx_max']
# Now create final list_b column, using min and max indexes for each category of a and filtering list of b.
gp_df['list_b'] = gp_df[['temp_idx_min', 'temp_idx_max']].apply(lambda x: all_values_b[x[0]:x[1]+1], axis=1)
print(gp_df.shape)
gp_df.head()
上面的代码在第一列中需要2分钟的2000万行和500K类别。
根据不再起作用:
使用ForcenetworkSerializeByMemcpy目前是从此版本开始的方法。我们正在考虑带回旧的行为,该行为允许自己使用固定的字符串。
使用以下结构绕过此问题(CF ):
using System;
using Unity.Collections;
using Unity.Netcode;
public struct NetworkString : INetworkSerializable
{
private ForceNetworkSerializeByMemcpy<FixedString32Bytes> data;
public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
{
serializer.SerializeValue(ref data);
}
public override string ToString() => data.Value.ToString();
public static implicit operator string(NetworkString networkString) => networkString.ToString();
public static implicit operator NetworkString(string s) => new NetworkString { data = new FixedString32Bytes(s) };
}
在您的 netlify.toml
中有一个 [functions]
的选项 nater node_node_modules
,它允许您指定节点模块数组以从捆绑包中排除。
以下将忽略所有功能上的模块。
[functions]
ignored_node_modules = ["aws-sdk"]
或者,您可以按名称来定位特定功能
[functions.render]
ignored_node_modules = ["aws-sdk"]
,请注意,所有运行节点的lambdas(甚至节点16 lts)仍在使用 aws-sdk
(版本2)而不是@aws-aws-sdk
(版本3)。
For anyone curious, I discovered this option here< /a>在Netlify CLI源中。
我也对此感到好奇,但从略有不同的角度来看。我试图避免直接从MSAL中乱扔代码库,以防我们想在某个时候交换身份提供商。这样做的主要方法是将钩子用作抽象层,例如通过该钩子而不是MSAL组件库本身揭示iShauthenticatientical层。
UseAuth Hook将直接使用MSAL包。但是,对于包装器组件,我认为我们只需要创建一个单独的组件,该组件要么返回MSALPROVIDER或您选择的模拟Auth提供商。由于MSALPROVIDER在引擎盖下使用Usecontext,因此我认为您不需要在另一个上下文提供商中包装它。
希望这些想法在您通过做到这一点的方式思考时会有所帮助。知道这不是您问题的直接答案。
I am also curious about this, but from a slightly different perspective. I am trying to avoid littering the code base with components directly from msal in case we want to swap out identity providers at some point. The primary way to do this is to use a hook as an abstraction layer such as exposing isAuthenticated through that hook rather than the msal component library itself.
The useAuth hook would use the MSAL package directly. For the wrapper component however, I think we have to just create a separate component that either returns the MsalProvider OR a mocked auth provider of your choice. Since MsalProvider uses useContext beneath the hood I don't think you need to wrap it in another context provider.
Hope these ideas help while you are thinking through ways to do this. Know this isn't a direct answer to your question.
测试MSAL React应用程序时嘲笑身份验证