轮廓§

文章 评论 浏览 29

轮廓§ 2025-02-20 20:54:32

gtklabel 具有“可选”属性,可以做到这一点。它在a 文档

GtkLabel has a "selectable" property which does just that. It's also mentioned in a separate section of the GtkLabel docs

在GTK应用中显示静态的,可选的文本

轮廓§ 2025-02-20 05:09:08

如何利用 strings。 count

package main

import (
    "fmt"
    "strings"
)

func main() {
    word := "cèòài"
    letter := "è"
    letterOccurences := strings.Count(word, letter)
    fmt.Printf("No. of occurences of \"%s\" in \"%s\": %d\n", letter, word, letterOccurences)
}

输出:

No. of occurences of "è" in "cèòài": 1

How about utilizing strings.Count:

package main

import (
    "fmt"
    "strings"
)

func main() {
    word := "cèòài"
    letter := "è"
    letterOccurences := strings.Count(word, letter)
    fmt.Printf("No. of occurences of \"%s\" in \"%s\": %d\n", letter, word, letterOccurences)
}

Output:

No. of occurences of "è" in "cèòài": 1

我如何使用GO中的字符串中找到重音字母?

轮廓§ 2025-02-20 02:19:11

我刚刚重新启动mysql(从这里开始提示: https://stackoverflow.com/a/142388800 )解决了问题。

我在MacOS(10.10.2)和MySQL(5.6.21)上安装了相同的问题自制。

令人困惑的是,我的一个应用程序之一连接到数据库罚款,而另一个则不是。

在尝试在应用程序上抛出例外情况的许多事情之后,该问题所接受的答案所暗示的,毫无用处,我感到惊讶的是,重新启动mysql。

我问题的原因可能是上述链接中答案中建议的以下内容:

您正在使用连接池吗?如果是,请尝试重新启动
服务器。连接池中的连接可能很少。

I just restarted MySQL (following a tip from here: https://stackoverflow.com/a/14238800) and it solved the issue.

I had the same issue on MacOS (10.10.2) and MySql (5.6.21) installed via homebrew.

The confusing thing was that one of my apps connected to the database fine and the other was not.

After trying many things on the app that threw the exception com.mysql.jdbc.CommunicationsException as suggested by the accepted answer of this question to no avail, I was surprised that restarting MySQL worked.

The cause of my issue might have been the following as suggested in the answer in the aforementioned link:

Are you using connection pool ? If yes, then try to restart the
server. Probably few of the connections in your connection pool are in closed state.

求解“通信链接链接失败”与JDBC和MySQL

轮廓§ 2025-02-20 00:39:25

如果您只有两种选择可以从中选择,则使用 <代码> np.Where

df['color'] = np.where(df['Set']=='Z', 'green', 'red')

,例如,

import pandas as pd
import numpy as np

df = pd.DataFrame({'Type':list('ABBC'), 'Set':list('ZZXY')})
df['color'] = np.where(df['Set']=='Z', 'green', 'red')
print(df)

产量

  Set Type  color
0   Z    A  green
1   Z    B  green
2   X    B    red
3   Y    C    red

如果您有两个以上的条件,则 ,请使用 np.Select 。例如,如果您想要颜色

  • yellow (df ['set'] =='z')&amp; (df ['type'] =='a')
  • 否则 blue <代码>(df ['set'] =='z'))&amp; (df ['type'] =='b')
  • 否则 purple (df ['type''] =='b')
  • 否则黑色

然后使用

df = pd.DataFrame({'Type':list('ABBC'), 'Set':list('ZZXY')})
conditions = [
    (df['Set'] == 'Z') & (df['Type'] == 'A'),
    (df['Set'] == 'Z') & (df['Type'] == 'B'),
    (df['Type'] == 'B')]
choices = ['yellow', 'blue', 'purple']
df['color'] = np.select(conditions, choices, default='black')
print(df)

产生的

  Set Type   color
0   Z    A  yellow
1   Z    B    blue
2   X    B  purple
3   Y    C   black

If you only have two choices to select from then use np.where:

df['color'] = np.where(df['Set']=='Z', 'green', 'red')

For example,

import pandas as pd
import numpy as np

df = pd.DataFrame({'Type':list('ABBC'), 'Set':list('ZZXY')})
df['color'] = np.where(df['Set']=='Z', 'green', 'red')
print(df)

yields

  Set Type  color
0   Z    A  green
1   Z    B  green
2   X    B    red
3   Y    C    red

If you have more than two conditions then use np.select. For example, if you want color to be

  • yellow when (df['Set'] == 'Z') & (df['Type'] == 'A')
  • otherwise blue when (df['Set'] == 'Z') & (df['Type'] == 'B')
  • otherwise purple when (df['Type'] == 'B')
  • otherwise black,

then use

df = pd.DataFrame({'Type':list('ABBC'), 'Set':list('ZZXY')})
conditions = [
    (df['Set'] == 'Z') & (df['Type'] == 'A'),
    (df['Set'] == 'Z') & (df['Type'] == 'B'),
    (df['Type'] == 'B')]
choices = ['yellow', 'blue', 'purple']
df['color'] = np.select(conditions, choices, default='black')
print(df)

which yields

  Set Type   color
0   Z    A  yellow
1   Z    B    blue
2   X    B  purple
3   Y    C   black

如何创建一个新列,其中根据现有列选择值?

轮廓§ 2025-02-20 00:23:45

您可以将整个字符串匹配,但可以将5位数字捕获到一个捕获组中,并替换为捕获组的反向注册:

regexReplace("{{ticket.description}}", "^(?:[\w\W]*\s)?(\d{5})(?:\s[\w\W]*)?$", "$1")

请参阅 Regex Demo

详细信息

  • ^ - 字符串的启动
  • (?:[\ w \ w \ w]*\ s)?更多的字符,然后是Whitespace char
  • (\ d {5}) - 组1( $ 1 包含此组模式捕获的文本):五位数字
  • (?:\ s [\ w \ w]*)? - Whitespace Char的可选子字符串,然后尽可能多的零或更多char。
  • $ - 字符串结尾。

You can match the whole string but capture the 5-digit number into a capturing group and replace with the backreference to the captured group:

regexReplace("{{ticket.description}}", "^(?:[\w\W]*\s)?(\d{5})(?:\s[\w\W]*)?
quot;, "$1")

See the regex demo.

Details:

  • ^ - start of string
  • (?:[\w\W]*\s)? - an optional substring of any zero or more chars as many as possible and then a whitespace char
  • (\d{5}) - Group 1 ($1 contains the text captured by this group pattern): five digits
  • (?:\s[\w\W]*)? - an optional substring of a whitespace char and then any zero or more chars as many as possible.
  • $ - end of string.

匹配除5位数字之外的所有内容的模式

轮廓§ 2025-02-19 13:56:44

问题在于,从俄罗斯向俄罗斯人的翻译尚未完成,因此从俄罗斯译成乌克兰人的翻译就被采取了。

虽然默认值为俄罗斯人,但根本没有翻译,因为默认语言中没有翻译到该节点的翻译。当它成为乌克兰人时,在没有翻译的情况下,开始使用翻译为乌克兰人。

The problem was that the translation from Russian into Russian was not completed, so the translation from Russian into Ukrainian was taken.

While the default was Russian, no translation was made at all, since there is no translation to this node in the default language. And when it became Ukrainian, in the absence of a translation, translation into Ukrainian began to be used.

django,i18n,更改Lanaging_code后翻译问题

轮廓§ 2025-02-18 19:06:08

什么是 myInfo ?状态,班级或参考变量?还要考虑到 MAP 返回一个全新的数组,因此不会突变。

您可以尝试此操作,应该在mynewinfo中查看更新的阵列:

useEffect(() => {
  const myNewInfo = myInfo.map((info, index) => ({
    ...info,
    vals: getAdditionalData(info.myId, index)
  }));
}, []);

What is myInfo? A state, class or ref variable? Also take into consideration that map returns a brand new array so it doesn't mutate.

You can try this and you should see the updated array in myNewInfo:

useEffect(() => {
  const myNewInfo = myInfo.map((info, index) => ({
    ...info,
    vals: getAdditionalData(info.myId, index)
  }));
}, []);

将新属性添加到现有的对象数组中

轮廓§ 2025-02-18 17:34:48

您还需要将属性标记为 Dynamic ,以使其符合KVO。 Publisher(for:)仅适用于KVO符合KVO的属性,因为它在引擎盖下使用KVO。

@objc class SampleClass: NSObject {
    @objc dynamic var name: NSString = "1"
}

这样做后,KVO发布者会按预期发出更新的值。

有关 @OBJC vs @Objc Dynamic 的更多信息-objc“>此Q&amp; a 。

请记住,与无法更改的代码交互时,您只能使用KVO发布者。当您要观察控制的类型的属性值时,请改用 @publed

You also need to mark the property as dynamic in order for it to be KVO compliant. publisher(for:) only works with KVO compliant properties, since it uses KVO under the hood.

@objc class SampleClass: NSObject {
    @objc dynamic var name: NSString = "1"
}

Once you do that, the KVO publisher emits the updated values as expected.

For more information on @objc vs @objc dynamic, see this Q&A.

Bear in mind that you should only use KVO publishers when interacting with code that you cannot change. When you want to observe property values of types that you control, use @Published instead.

KVO发行商未发送有关属性更改的信号

轮廓§ 2025-02-18 15:25:30

在Zookeeper

  1. Docker容器运行-NAME ZOOKEEPER -P 2181:2181 ZOOKEEPER

之后Kafka

  1. Docker容器运行-Name Kafka -P 9092:9092 -E KAFKA_ZOOKEEPER_COMEPER_COMEPER_CONNECT _your_computer_but_not_localhost! :9092 -E KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR = 1 confluentinc/cp -kafka

在Kafka消费者和Producer config I中

@Bean
public ProducerFactory<String, String> producerFactory() {
    Map<String, Object> configProps = new HashMap<>();
    configProps.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "192.168.8.128:9092");
    configProps.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
    configProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
    return new DefaultKafkaProducerFactory<>(configProps);
}

@Bean
public ConsumerFactory<String, String> consumerFactory() {
    Map<String, Object> props = new HashMap<>();
    props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "192.168.8.128:9092");
    props.put(ConsumerConfig.GROUP_ID_CONFIG, "group_id");
    props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
    props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
    return new DefaultKafkaConsumerFactory<>(props);
}

使用这些规定运行我的项目。祝你好运。

before zookeeper

  1. docker container run --name zookeeper -p 2181:2181 zookeeper

after kafka

  1. docker container run --name kafka -p 9092:9092 -e KAFKA_ZOOKEEPER_CONNECT=192.168.8.128:2181 -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://ip_address_of_your_computer_but_not_localhost!!!:9092 -e KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1 confluentinc/cp-kafka

in kafka consumer and producer config

@Bean
public ProducerFactory<String, String> producerFactory() {
    Map<String, Object> configProps = new HashMap<>();
    configProps.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "192.168.8.128:9092");
    configProps.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
    configProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
    return new DefaultKafkaProducerFactory<>(configProps);
}

@Bean
public ConsumerFactory<String, String> consumerFactory() {
    Map<String, Object> props = new HashMap<>();
    props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "192.168.8.128:9092");
    props.put(ConsumerConfig.GROUP_ID_CONFIG, "group_id");
    props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
    props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
    return new DefaultKafkaConsumerFactory<>(props);
}

I run my project with these regulations. Good luck dude.

连接到在Docker中运行的Kafka

轮廓§ 2025-02-18 01:57:31

另一种回答这一点的方法,而不是陷入序列点和未定义行为的神秘细节,只是问,他们应该是什么意思? 程序员试图做什么?

​没有人会在真实的程序中写下它,这并不明显,它的作用并不能想到有人可能一直试图编码会导致这种特殊的操作顺序。而且,由于对您和我来说并不明显,如果编译器不知道应该做什么,这在我的书中很好。

第二个片段 i = i ++ ,更容易理解。看起来有人正在尝试增加 i ,并将结果分配回 i 。但是有几种方法可以在C中执行此操作。在几乎任何编程语言中相同:

i = i + 1

c当然都有一个方便的快捷方式:

i++

这也意味着:“取 i 的值,添加1,然后将结果分配回 i “。 的值,则构造了两者的杂物。

i = i++

因此,如果我们通过编写我们真正说的是“取 i 的值,则添加1,将结果分配给 i ,将结果分配给 并将结果分配回 i ”。我们感到困惑,因此,如果编译器也感到困惑,这不会打扰我太多。

实际上,这些疯狂表达式唯一写的是人们将它们用作人工示例 ++ 应该如何工作的时候。当然,重要的是要了解 ++ 的工作原理。但是,使用 ++ 的一个实际规则是,“如果不明显使用 ++ 的表达式是什么意思,请不要写。”

我们曾经在comp.lang.c上花费无数小时讨论这样的表情,而为什么它们不确定。我的两个更长的答案,试图真正解释原因,在网上存档:

? > c FAQ列表

Another way of answering this, rather than getting bogged down in arcane details of sequence points and undefined behavior, is simply to ask, what are they supposed to mean? What was the programmer trying to do?

The first fragment asked about, i = i++ + ++i, is pretty clearly insane in my book. No one would ever write it in a real program, it's not obvious what it does, there's no conceivable algorithm someone could have been trying to code that would have resulted in this particular contrived sequence of operations. And since it's not obvious to you and me what it's supposed to do, it's fine in my book if the compiler can't figure out what it's supposed to do, either.

The second fragment, i = i++, is a little easier to understand. It looks like someone is trying to increment i, and assign the result back to i. But there are a couple ways of doing this in C. The most basic way to take i's value, add 1, and assign the result back to i, is the same in almost any programming language:

i = i + 1

C, of course, has a handy shortcut:

i++

This also means, "take i's value, add 1, and assign the result back to i". So if we construct a hodgepodge of the two, by writing

i = i++

what we're really saying is "take i's value, add 1, assign the result back to i, and assign the result back to i". We're confused, so it doesn't bother me too much if the compiler gets confused, too.

Realistically, the only time these crazy expressions get written is when people are using them as artificial examples of how ++ is supposed to work. And of course it is important to understand how ++ works. But one practical rule for using ++ is, "If it's not obvious what an expression using ++ means, don't write it."

We used to spend countless hours on comp.lang.c discussing expressions like these and why they're undefined. Two of my longer answers, that try to really explain why, are archived on the web:

See also question 3.8 and the rest of the questions in section 3 of the C FAQ list.

为什么这些构造使用未定义前后的不确定行为?

轮廓§ 2025-02-17 12:54:44

您可以为长效边框创建一个容器,并在文本元素上应用一个短裤

.flexbox {
  display: flex;
}

.text-container {
  padding: 1rem 0; /*Create a top-bottom padding for text container*/
  width: 50%;
}

.text-container span {
  padding: 0 1rem; /*Create a left-right padding for text*/
  display: block;
}

.text-container:first-of-type {
  border-right: 1px solid #ccc; /*Border on text container*/
}

.text-container:first-of-type span {
  border-right: 4px solid #ddd; /*Border on text*/
  margin-right: -2.5px;
}
<div class="flexbox">
  <div class="text-container">
    <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</span>
  </div>
  <div class="text-container">
    <span>Lorem ipsum dolor sit amet</span>
  </div>
</div>

You can create a container for the long-stick border, and apply a short-stick border on text elements

.flexbox {
  display: flex;
}

.text-container {
  padding: 1rem 0; /*Create a top-bottom padding for text container*/
  width: 50%;
}

.text-container span {
  padding: 0 1rem; /*Create a left-right padding for text*/
  display: block;
}

.text-container:first-of-type {
  border-right: 1px solid #ccc; /*Border on text container*/
}

.text-container:first-of-type span {
  border-right: 4px solid #ddd; /*Border on text*/
  margin-right: -2.5px;
}
<div class="flexbox">
  <div class="text-container">
    <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</span>
  </div>
  <div class="text-container">
    <span>Lorem ipsum dolor sit amet</span>
  </div>
</div>

将分隔线添加到CSS列

轮廓§ 2025-02-17 05:34:04

使用基本形式的单个按钮是一种方法,然后使用CSS隐藏实际输入,同时保持标签

保持其功能的同时

然后,您只是在设计标签,

 <form action="form action goes here">
   <input type="radio" value="1">
   <label for="1">1</label> 
   <input type="radio" value="2">
   <label for="2">2</label> 
   <input type="radio" value="3">
   <label for="3">3</label> 
   <input type="radio" value="1">
   <label for="3">3</label> 
...and so on
</form>

Using a basic form a radio button would be one way to do it and then hide the actual input using css while keeping the label

Hide radio button while keeping its functionality

then you are just styling the labels how you want them

 <form action="form action goes here">
   <input type="radio" value="1">
   <label for="1">1</label> 
   <input type="radio" value="2">
   <label for="2">2</label> 
   <input type="radio" value="3">
   <label for="3">3</label> 
   <input type="radio" value="1">
   <label for="3">3</label> 
...and so on
</form>

如何使用水平对齐的选项创建选择输入?

轮廓§ 2025-02-16 14:41:02

最近,Visual Studio代码更改了Azure扩展资源的用户界面

步骤1

“

  • 当您单击创建功能选项,它将询问您的每个步骤,例如选择语言,运行时,触发类型,授权级别,功能名称,工作区路径等
  • 。除触发类型外,所有以上所有选项,因为该选项仅创建HTTP触发器,这是创建它的捷径。

步骤2

所需的资源是:

  1. Visual Studio Code IDE
  2. .NET SDK 3.1、5、6取决于您的要求
  3. azure function core core core tools (v3和v4 as v3是.net 3.1是必需的.NET Core 6需要5和V4。
  4. VS代码扩展名(Azure帐户,Azure函数,C#)
  5. Azure Storage Emulator或Azurite

输出1使用新文件夹中使用VS Code 在新文件夹中使用vs Code :

​使用VS代码:

”使用optioncreatehttpfunction“

3使用命令调色板创建Azure函数.NET 6项目。

输出 href =“ https://i.sstatic.net/ubclk.gif” rel =“ nofollow noreferrer”>

Recently, Visual Studio Code has changed the User Interface for the Azure Extension Resources.

Step 1:

enter image description here

  • When you click on Create Function option, it will ask you every step like Select language, Runtime, Type of Trigger, Authorization Level, Function Name, Workspace Path, etc.
  • When you click on Create HTTP Function option, it will ask you all the above options except Type of Trigger because the option creates only HTTP Trigger which is a shortcut of creating it.

Step 2:

Resources required are:

  1. Visual Studio Code IDE
  2. .NET SDK 3.1, 5, 6 depends on your requirement
  3. Azure Functions Core Tools (v3 and v4 as v3 is required for .NET 3.1 and 5 and v4 is required for .NET Core 6).
  4. VS Code Extensions (Azure Account, Azure Functions, C#)
  5. Azure Storage Emulator or Azurite

Output 1 using Create Function option in a New Folder using VS Code:

UsingOption1VSCodeAzF

Output 2 using Create HTTP Function option in a sub folder of the Frontend Project using VS Code:

UsingOptionCreateHTTPFunction

Output 3 using Command Palette for Creating Azure Functions .NET 6 Project in VS Code:

usingcmdpalettevscode

无法在文件夹中找到CSPROJ文件 - 无法在VSCODE中创建C#模板

轮廓§ 2025-02-16 08:59:49

这是 basemap 与Geos&gt; = 3.9使用时的已知

问题basemap-fillcontinents-with-color-causes-error/71972997#71972997“>使用带有颜色的baseMap fillcontinents带有颜色原因的错误

,直到用 baseMap 修补了这一点使用旧版本的Geos。如果您安装 baseMap 使用 baseMap 1.3.x的Windows 在PYPI中可用,则您应该没有问题,因为它们与GEOS 3.5.1链接在一起

python -m pip install basemap

。 >编辑(2022-10-26):由于 basemap 版本1.3.5,解决了与绘制南极的绘制的错误。 PYPI中的预编译车轮仍链接到GEOS 3.5.1,但是从源分布安装的用户将能够链接 baseMap geos&gt; = 3.9,现在也将正确绘制南极洲的绘制。 OP的情况。

This is a known problem in basemap when used in combination with GEOS >= 3.9, see e.g. this other question:

Using basemap fillcontinents with color causes error

Until this is patched in basemap, your only way to solve it is to use an older version of GEOS. If you install basemap for Windows using the official wheels for basemap 1.3.x available in PyPI, you should have no problem because they are linked against GEOS 3.5.1:

python -m pip install basemap

EDIT (2022-10-26): Since basemap version 1.3.5, the bug related to the drawing of Antarctica is solved. The precompiled wheels in PyPI are still linked to GEOS 3.5.1, but a user installing from the source distribution will be able to link basemap to GEOS >= 3.9 and now Antarctica would also be drawn correctly for the case of the OP.

基emap仅显示一半的南极洲

轮廓§ 2025-02-16 08:38:50

使用org.apache.commons.lang3.stringutils.join(*)方法可以是一种选项
例如:

String[] strArray = new String[] { "John", "Mary", "Bob" };
String arrayAsCSV = StringUtils.join(strArray, " , ");
System.out.printf("[%s]", arrayAsCSV);
//output: [John , Mary , Bob]

我使用以下依赖性

<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.3.2</version>

Using org.apache.commons.lang3.StringUtils.join(*) methods can be an option
For example:

String[] strArray = new String[] { "John", "Mary", "Bob" };
String arrayAsCSV = StringUtils.join(strArray, " , ");
System.out.printf("[%s]", arrayAsCSV);
//output: [John , Mary , Bob]

I used the following dependency

<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.3.2</version>

什么是打印Java数组的最简单方法?

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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