何以畏孤独

文章 评论 浏览 28

何以畏孤独 2025-02-20 20:13:49

在我看来,时区只是在不同地理位置上的同一时间戳的表示(由于Unix时间0到处都是相同的秒数,因此经过的秒数不超过)。因此,请小心从现有时间戳手动添加/删除时间。

您可以使用 moment.js 这样做:

var someday = moment('2022-07-03T10:51:09+02:00');
console.log(someday.utc().format());
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment-with-locales.min.js"></script>

In my view, timezone is simply the representation of the same timestamp across different geographies (no. of seconds elapsed since unix time 0 is the same everywhere). So be careful while adding/removing time manually from the existing timestamp.

You can do that using moment.js like this:

var someday = moment('2022-07-03T10:51:09+02:00');
console.log(someday.utc().format());
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment-with-locales.min.js"></script>

使用时区转换日期为UTC?

何以畏孤独 2025-02-20 04:27:53

len(text)是文件“ train.txt”中字符的总数(假设ASCII文本,这将与您的文件大小相同)。

len(text.split(...))是文件中令牌的总数(由定界符确定)。

Sidenote:假设您的定界符是 \ n 您可以在UNIX上与 CAT Train.txt |在UNIX上进行验证。 WC -L

len(text) is the total number of characters in the file 'train.txt' (assuming ASCII text, this will be the same as your file-size).

len(text.split(...)) is the total number of tokens in the file (as determined by your delimiter).

Sidenote: Assuming your delimiter is \n you can cross verify this on unix with cat train.txt | wc -l.

为什么在使用Python中使用拆分时只能获得一部分文字

何以畏孤独 2025-02-20 00:42:26

对于您的特定问题,即使在某些人建议的情况下,即使在调试构建上也不需要进行任何运行时检查,因为该值本身为 constexpr 。您可以编写一个简单的实用程序,以将价值投入到能够保持它的最小类型。

template<size_t N>
inline constexpr auto minuint = []{
    if constexpr(N >= 1ull << 32)
        return N;
    else if constexpr(N >= 1ull << 16)
        return uint32_t(N);
    else if constexpr(N >= 1ull << 8)
        return uint16_t(N);
    else
        return uint8_t(N);
}();

另一方面,没有功能或模板可以接受表达式和类型。
模仿 sizeof 行为的唯一可能的方法是使用宏。

#define Sizeof(x) minuint<sizeof(x)>

有了这个,您永远不会收到有关缩小转换的错误警告:如果有警告,您做错了什么。

For your specific problem, there need not be any runtime checks even on debug builds as some has suggested, since the value is itself a constexpr. You can write a simple utility to cast a value to the smallest type that is able to hold it.

template<size_t N>
inline constexpr auto minuint = []{
    if constexpr(N >= 1ull << 32)
        return N;
    else if constexpr(N >= 1ull << 16)
        return uint32_t(N);
    else if constexpr(N >= 1ull << 8)
        return uint16_t(N);
    else
        return uint8_t(N);
}();

On the other hand, no function or template can ever accept both expressions and types.
The only possible way to imitate sizeof behaviour is to use a macro.

#define Sizeof(x) minuint<sizeof(x)>

With this, you never get false warnings on narrowing conversions: if there is a warning, you are doing something wrong.

创建自定义sizeof()返回较窄类型

何以畏孤独 2025-02-19 23:37:18

这在很大程度上取决于您的视觉风格。您可以尝试不同的纹理压缩,但不能尝试无需可见伪像的每个纹理。

您可以在每个平台的纹理导入设置中更改压缩,并在检查员的预览部分中检查结果(也许您需要首先更改编辑器中的目标平台,以便能够查看结果)。

无论如何,框架动画不是很常用。正是由于构建尺寸的增加。特别是如果您有很多大框架。可以使用

这是压缩和结果大小的简单示例。相同的图片,不同的压缩:

It highly depends on your visual style. You can try different texture compressions but not each of them can be applied to every texture without visible artifacts.

You can change compression in the texture import settings for every platform and check the result in the preview section of the inspector (perhaps, you will need to change the target platform in the editor first to be able to see the result).

Anyway, frame animations are not very commonly used. Exactly because of the increase in the build size. Especially if you have a lot of big frames. Complex 2d animations can be created using tools like Spine.

Here is a simple example of compressions and result size. The same picture, different compressions:
enter image description here
enter image description here

如何压缩APK构建的2D动画?

何以畏孤独 2025-02-19 20:45:48

重量列告诉您功能在呼叫堆栈上的时间。您的列表说 heapmatrix :: pivot 在呼叫堆栈上持续了10.31秒,这不会告诉您太多。

在使用时剖面仪器进行分析时,自重量列更为重要。自重列告诉您函数在呼叫堆栈的顶部有多长时间。在自重列中具有高价值的功能是您应该优化的功能。

以下文章更详细地介绍了时期探索器仪器:

使用时间分析器仪器查找代码中的慢斑

The Weight column tells you the amount of time the function was on the call stack. Your listing says that HeapMatrix::pivot was on the call stack for 10.31 seconds, which doesn't tell you much.

When profiling with the Time Profiler instrument, the Self Weight column is more important. The Self Weight column tells you how long the function was at the top of the call stack. Functions with a high value in the Self Weight column are the ones you should look to optimize.

The following article covers the Time Profiler instrument in more detail:

Finding the Slow Spots in Your Code with the Time Profiler Instrument

如何读取Xcode Instruments&#x27;个人资料树视图?

何以畏孤独 2025-02-19 08:21:53

看起来 @spybean 无法找到您服务类的实例。快速替代方案是从 comicservice comicservice; &amp;在您的 @beforeeach 中进行关注:

@BeforeEach
    public void setUp() {
        this.comicService = Mockito.spy(new ComicService("ae78641e8976ffdf3fd4b71254a3b9bf", "eb9fd0d8r8745cd0d554fb2c0e7896dab3bb745", marvelClient));

    }

在这里,您正在创建间谍&amp;然后在测试课内使用它。

It looks like @SpyBean is unable to find instance of your service class. Quick alternative for this is just remove @SpyBean from ComicService comicService; & do following in your @BeforeEach:

@BeforeEach
    public void setUp() {
        this.comicService = Mockito.spy(new ComicService("ae78641e8976ffdf3fd4b71254a3b9bf", "eb9fd0d8r8745cd0d554fb2c0e7896dab3bb745", marvelClient));

    }

Here, you are creating spy & then using it inside your test class.

如何在接收构造函数参数的类中使用@spybean?

何以畏孤独 2025-02-18 06:17:27
few_strings = ('this is foo bar', 'this is not a foo bar', 'some other foo bar here')
  1. 句子划分的每个句子(“” )创建一组
  2. 单词
  3. 为每个 一个句子
# 1.
sets = [set(s.split(" ")) for s in few_strings]
# 2.
result = sets[0]
# 3.
for i in range(len(sets)):
    result = result.intersection(sets[i])

现在,您有一个python set 单词的单词>,这在所有句子中发生。
您可以将集合转换为列表:

result = list(result)

或与

result = " ".join(result)
few_strings = ('this is foo bar', 'this is not a foo bar', 'some other foo bar here')
  1. Create sets of words for each sentence splitting by space (" ")
  2. Add the first string to results
  3. Loop over the sentences and update result variable with the interesction of the current result and one sentence
# 1.
sets = [set(s.split(" ")) for s in few_strings]
# 2.
result = sets[0]
# 3.
for i in range(len(sets)):
    result = result.intersection(sets[i])

Now you have a Python Set of words which occured in all sentences.
You can convert the set to list with:

result = list(result)

or to string with

result = " ".join(result)

比较字符串,找到每个字符串中存在的部分

何以畏孤独 2025-02-17 19:11:54

我做了一个宏

#include <utility>

// Based on https://en.cppreference.com/mwiki/index.php?title=cpp/utility/as_const&oldid=151976#Possible_implementation
template <typename T> constexpr T &as_non_const(const T &t) noexcept { return const_cast<T &>(t); }

#define NON_CONST_GETTER(const_getter)                                                                                 \
  auto &const_getter() { return as_non_const(std::as_const(*this).const_getter()); }

// Example
class C {
private:
  int secret = 42;
public:
  const int &get() const { return secret; }
  NON_CONST_GETTER(get);
};

I made a macro
https://gist.github.com/esnosy/947565a4e651991dc6a25f3e9f467285

#include <utility>

// Based on https://en.cppreference.com/mwiki/index.php?title=cpp/utility/as_const&oldid=151976#Possible_implementation
template <typename T> constexpr T &as_non_const(const T &t) noexcept { return const_cast<T &>(t); }

#define NON_CONST_GETTER(const_getter)                                                                                 \
  auto &const_getter() { return as_non_const(std::as_const(*this).const_getter()); }

// Example
class C {
private:
  int secret = 42;
public:
  const int &get() const { return secret; }
  NON_CONST_GETTER(get);
};

如何在类似的const和非CONST成员功能之间删除代码重复?

何以畏孤独 2025-02-17 18:00:55

最简单的解决方案是将Qgridlayout用作主布局,然后使用 span 参数, addwidget-1“ rel =” nofollow noreferrer“> addwidget() as groupBox的“ 2”,这意味着小部件将在布局中占据两个水平单元。

class MyWidget(QWidget):
    def __init__(self, *args, **kwargs):
        super().__init__()

        self.setWindowTitle('Wydbid - Center')
        self.setGeometry(0, 0, 1920, 1080)

        self.setupUI()

    def setupUI(self):
        datetime = QGroupBox(parent=self, title='Datum und Uhrzeit')
        datetime.setFixedHeight(150)

        action_list = QGroupBox(parent=self, title='Aktionen')
        action_list.setFixedWidth(200)

        actionLayout = QGridLayout(action_list)
        actionLayout
        actionLayout.setAlignment(Qt.AlignTop| Qt.AlignHCenter)

        customer_note = QLabel(parent=action_list, text='Kunden')
        add_customer = ActionButton.ActionButton(parent=action_list, text='Kunde hinzufügen ➜')

        actionLayout.addWidget(customer_note, 0, 0, 1, 0, Qt.AlignLeft)
        actionLayout.addWidget(add_customer, 1, 0, 1, 0, Qt.AlignCenter)

        customer_list_box = QGroupBox(parent=self, title='Kundenliste')

        mainLayout = QGridLayout(self)
        mainLayout.setContentsMargins(30, 30, 30, 30)
        # the "datetime" widget will occupy the first row, spanning two
        # columns of the grid
        mainLayout.addWidget(datetime, 0, 0, 1, 2)
        # the other widgets are added to the second row, placed in the
        # first and second column respectively
        mainLayout.addWidget(action_list, 1, 0)
        mainLayout.addWidget(customer_list_box, 1, 1)

请注意,在同一函数中连续调用 layout()是毫无意义的,因为它会创建不必要的样板,并使代码不那么可读;如您所见,保留布局的本地参考更为清晰(更清洁)。

网格布局可能并不总是最佳解决方案,尤其是对于可以动态创建/删除儿童或的小部件而言每当布局更复杂并且需要不同的行/列跨度以实现所需的结果时。

QT布局可以是嵌套,这意味着您可以在“父”布局中添加“孩子”布局。这样,尽管布局的层次结构更为复杂,但同时允许整个结构更加清晰。

在以下代码中,主布局是垂直的布局,并且两个底部小部件添加到嵌套的水平布局中。

class MyWidget(QWidget):
    # ...
    def setupUI(self):
        # ...
        mainLayout = QVBoxLayout(self)
        mainLayout.setContentsMargins(30, 30, 30, 30)
        mainLayout.addWidget(datetime)

        bottomLayout = QHBoxLayout()
        mainLayout.addLayout(bottomLayout)

        bottomLayout.addWidget(action_list)
        bottomLayout.addWidget(customer_list_box)

The simplest solution would be to use a QGridLayout as main layout, then use the column span argument of addWidget() as "2" for the groupbox, meaning that the widget will occupy two horizontal cells in the layout.

class MyWidget(QWidget):
    def __init__(self, *args, **kwargs):
        super().__init__()

        self.setWindowTitle('Wydbid - Center')
        self.setGeometry(0, 0, 1920, 1080)

        self.setupUI()

    def setupUI(self):
        datetime = QGroupBox(parent=self, title='Datum und Uhrzeit')
        datetime.setFixedHeight(150)

        action_list = QGroupBox(parent=self, title='Aktionen')
        action_list.setFixedWidth(200)

        actionLayout = QGridLayout(action_list)
        actionLayout
        actionLayout.setAlignment(Qt.AlignTop| Qt.AlignHCenter)

        customer_note = QLabel(parent=action_list, text='Kunden')
        add_customer = ActionButton.ActionButton(parent=action_list, text='Kunde hinzufügen ➜')

        actionLayout.addWidget(customer_note, 0, 0, 1, 0, Qt.AlignLeft)
        actionLayout.addWidget(add_customer, 1, 0, 1, 0, Qt.AlignCenter)

        customer_list_box = QGroupBox(parent=self, title='Kundenliste')

        mainLayout = QGridLayout(self)
        mainLayout.setContentsMargins(30, 30, 30, 30)
        # the "datetime" widget will occupy the first row, spanning two
        # columns of the grid
        mainLayout.addWidget(datetime, 0, 0, 1, 2)
        # the other widgets are added to the second row, placed in the
        # first and second column respectively
        mainLayout.addWidget(action_list, 1, 0)
        mainLayout.addWidget(customer_list_box, 1, 1)

Note that continuously calling layout() in the same function is pointless, as it creates unnecessary boilerplate and makes code less readable; as you can see, it's much clearer (and cleaner) to keep a local reference for the layout.

A grid layout might not always be the optimal solution, though, especially for widgets that could dynamically create/remove children, or whenever the layout is more complex and requires different row/column spans to achieve the wanted result.

Qt layouts can be nested, meaning that you can add a "child" layout to a "parent" layout. In this way, while the hierarchy of the layout is a bit more complex, allows at the same time more clarity of the whole structure.

In the following code, the main layout is a vertical one, and the two bottom widgets are added to a nested horizontal layout.

class MyWidget(QWidget):
    # ...
    def setupUI(self):
        # ...
        mainLayout = QVBoxLayout(self)
        mainLayout.setContentsMargins(30, 30, 30, 30)
        mainLayout.addWidget(datetime)

        bottomLayout = QHBoxLayout()
        mainLayout.addLayout(bottomLayout)

        bottomLayout.addWidget(action_list)
        bottomLayout.addWidget(customer_list_box)

将qgroupbox添加到qhboxlayout的顶部

何以畏孤独 2025-02-17 17:54:09

以下grok模式应该适合您

grok
{
match => {"message" => "%{GREEDYDATA:PATH}/%{GREEDYDATA:filename}.log"}
}

保持发布!!!谢谢 !!!

The below grok pattern should work for you

grok
{
match => {"message" => "%{GREEDYDATA:PATH}/%{GREEDYDATA:filename}.log"}
}

Keep Posted!!! Thanks !!!

如何使用grok滤波器过滤掉文件路径并添加为新字段

何以畏孤独 2025-02-17 17:43:42

setState 将重建小部件,即 build 函数将再次调用,因此 icondata 变量将再次设置为 iCONS。 grid_view

移动 icondata 声明和函数 _toggleViewicon 在构建功能之外

setState will rebuild the widget, i.e the build function will be called again, thus the iconData variable will be set again to Icons.grid_view

move the iconData declaration and the function _toggleViewIcon outside of the build function

在Iconbutton中切换图标

何以畏孤独 2025-02-17 16:28:09

基本上,初始化后不应修改 ListBox 元素的高度或宽度,或者窗口的大小也将更改,也许不在屏幕之外。

没有任何选项可以更改Pysimplegui中ListBox元素的高度或宽度,但是您可以通过TKINTER代码, element.widget.configure(高度=高度,width = width)来完成。

示例代码

import PySimpleGUI as sg

name_list = sorted(['James', 'Robert',  'John', 'Michael', 'David', 'William', 'Richard', 'Joseph', 'Thomas', 'Charles'])
layout = [
    [sg.Input('', key='Name'), sg.Button('Add')],
    [sg.Listbox(name_list, size=(20, len(name_list)), expand_x=True, key='Names')],
]
window = sg.Window('Title', layout, finalize=True)
window['Name'].bind('<Return>', ' Return')

while True:

    event, values = window.read()

    if event == sg.WINDOW_CLOSED:
        break
    elif event in ('Add', 'Name Return'):
        name = values['Name']
        if name and name not in name_list:
            name_list = sorted(name_list+[name])
            window['Names'].Widget.configure(height=len(name_list))
            window['Names'].update(values=name_list)
            window.move_to_center()

window.close()

Basically, the height or the width of a Listbox element should not be revised after initialized, or the size of window will be also changed and maybe out of screen.

There's no option provided to change the height or the width of the Listbox element in PySimpleGUI, but you can do it by tkinter code, element.Widget.configure(height=height, width=width).

Example Code

import PySimpleGUI as sg

name_list = sorted(['James', 'Robert',  'John', 'Michael', 'David', 'William', 'Richard', 'Joseph', 'Thomas', 'Charles'])
layout = [
    [sg.Input('', key='Name'), sg.Button('Add')],
    [sg.Listbox(name_list, size=(20, len(name_list)), expand_x=True, key='Names')],
]
window = sg.Window('Title', layout, finalize=True)
window['Name'].bind('<Return>', ' Return')

while True:

    event, values = window.read()

    if event == sg.WINDOW_CLOSED:
        break
    elif event in ('Add', 'Name Return'):
        name = values['Name']
        if name and name not in name_list:
            name_list = sorted(name_list+[name])
            window['Names'].Widget.configure(height=len(name_list))
            window['Names'].update(values=name_list)
            window.move_to_center()

window.close()

根据列表的长度在pysimplegui中调整列表框

何以畏孤独 2025-02-17 12:57:02

JoinHandle 不是一个特征,因此不适用完整的合格特征语法。直接调用该方法,而没有完全限定的特质语法:

std::thread::JoinHandle::join(self).unwrap()

错误消息当然不好。

JoinHandle isn't a trait, so full qualified trait syntax isn't applicable. Invoke the method directly, without the fully qualified trait syntax:

std::thread::JoinHandle::join(self).unwrap()

The error message is certainly bad.

在`std :: thread :: joinhandle`中都找不到方法或关联的常数`join``

何以畏孤独 2025-02-17 12:47:22

在SlidEnavigationController中,您必须添加此行

[self.view.superview insertsubview:menuviewController.view atIndex:0];

in SlideNavigationController you have to add this line

[self.view.superview insertSubview:menuViewController.view atIndex:0];

iPad Pro iOS iOS 11英寸OBJ C中的侧面菜单不可点击

何以畏孤独 2025-02-17 12:30:20

尝试调整冲洗设置。例如,将Flushlevel设置为调试。有关flushlevel的文档:

我已经看到了您所描述的问题,当时您所描述的问题是当应用程序未配置为直接刷新到STDOUT/ stderr。

Try adjusting the flushing settings. For example, set flushLevel to DEBUG. Docs about flushLevel: https://docs.spring.io/spring-cloud-gcp/docs/current/reference/html/logging.html#_log_via_api

I've seen the issue you described when applications aren't configured to flush logs directly to stdout/stderr.

在云日志记录上丢失了GKE的日志

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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