弥繁

文章 评论 浏览 29

弥繁 2025-02-14 07:43:57

您的模型似乎是:每个(唯一)元组(O,U)被分配一个强制性值 d

您可以通过在 program_outcome_unit_lookup 表:

CREATE TABLE `program_outcome_unit_lookup` (
  `program_outcome_unit_lookup_pk` int(6) NOT NULL AUTO_INCREMENT,
  `program_outcome_fk` int(2) NOT NULL,
  `devdata_fk` int(2) NOT NULL,
  `unit_fk` int(2) NOT NULL,
  PRIMARY KEY (`program_outcome_unit_lookup_pk`),
  UNIQUE KEY (`program_outcome_fk`, `unit_fk`)
);

(program_outcome_fk,unit_fk))也可能是您的主要密钥来实现此模型。无论哪种方式,它都必须是唯一的(您当前没有执行此约束)。

现在,每个 u 可以作为您想要的多数 o 的成员/code> per o “按要求”。

到EG商店 u1 从您的更新图( o1-d2-u1 o2-d1-u1 )),您将添加到> (o,d,u)((1,2,1),(2,1,1))。根据要求,您还不能添加例如 o2-d2-u1 ,因为它会违反唯一的约束。

您还应为 d 添加一个新表。如果不是每个 d ,则允许每个 o (例如 o2 分支不允许使用 d1 ),您还需要一个表(O,d),否则不需要。

Your model seems to be: each (unique) tuple (O, U) is assigned a mandatory value D.

You can implement this model by adding a column D to your program_outcome_unit_lookup table:

CREATE TABLE `program_outcome_unit_lookup` (
  `program_outcome_unit_lookup_pk` int(6) NOT NULL AUTO_INCREMENT,
  `program_outcome_fk` int(2) NOT NULL,
  `devdata_fk` int(2) NOT NULL,
  `unit_fk` int(2) NOT NULL,
  PRIMARY KEY (`program_outcome_unit_lookup_pk`),
  UNIQUE KEY (`program_outcome_fk`, `unit_fk`)
);

(program_outcome_fk, unit_fk) could be your primary key as well, but either way it has to be unique (you are currently not enforcing this constraint).

Now each U can be member of as many O as you like, but "each U will be related to only one D per O", as requested.

To e.g. store U1 from your updated graph (O1-D2-U1 and O2-D1-U1), you would add into (O,D,U) the values ((1,2,1),(2,1,1)). As requested, you cannot also add e.g. O2-D2-U1, as it would violate the unique constraint.

You should also add a new table for D. If not every D is allowed for every O (e.g. if O2 branches are not allowed to use D1), you will also need a table (O, D), otherwise it is not necessary.

mysql-复杂的分层关系 - 多个m:n?

弥繁 2025-02-14 06:55:49

for ... in 为您提供对象属性的键。您必须使用密钥访问该值

for (const key in rules)
{
      console.log(key, rules[key]);
}

for...in gives you the key of the object properties. You have to access the value with the key

for (const key in rules)
{
      console.log(key, rules[key]);
}

从for循环中获取每个班级的每个变量

弥繁 2025-02-14 01:08:05

将扩展嵌套 swrconfig 配置。对于您的方案,这意味着如果您调用在第二个 swrconfig 内使用,它将使用在此处定义的fetcher( custicfetch )。

另外,您还可以在上定义fetcher 直接调用以在任何时候覆盖全局。

useSWR('my-key', customFetch)

Nested SWRConfig configurations will be extended. For your scenario, it means if you call useSWR inside the second SWRConfig it will use the fetcher defined there (customFetch).

Alternatively, you can also define the fetcher on the useSWR call directly to override the global one at any point.

useSWR('my-key', customFetch)

当我使用多个嵌套swrconfig时,选择哪些选项?

弥繁 2025-02-13 20:17:04

我终于从Emacs-JP Slack获得了解决方案。我将重印它们,希望他们会为同样困扰的其他人提供帮助。

;; for company

(add-hook 'eglot-managed-mode-hook (lambda ()
                                     (add-to-list 'company-backends
                                                  '(company-capf :with company-yasnippet))))


;; for corfu
(straight-use-package 'cape)

(defun my/eglot-capf ()
  (setq-local completion-at-point-functions
              (list (cape-super-capf
                     #'eglot-completion-at-point
                     (cape-company-to-capf #'company-yasnippet)))))

(add-hook 'eglot-managed-mode-hook #'my/eglot-capf)

I finally got the solution from emacs-jp slack. I will reprint them in the hope that they will be of help to others who are similarly troubled.

;; for company

(add-hook 'eglot-managed-mode-hook (lambda ()
                                     (add-to-list 'company-backends
                                                  '(company-capf :with company-yasnippet))))


;; for corfu
(straight-use-package 'cape)

(defun my/eglot-capf ()
  (setq-local completion-at-point-functions
              (list (cape-super-capf
                     #'eglot-completion-at-point
                     (cape-company-to-capf #'company-yasnippet)))))

(add-hook 'eglot-managed-mode-hook #'my/eglot-capf)

使用EGLOT时如何显示Yasnippets的建议

弥繁 2025-02-13 08:09:20

我不能为开发人员讲话,但是我发现这种行为非常直观。

如果一种方法可在原始对象上使用并将其定为就地,则它不会返回任何内容,因为没有新信息 - 显然您已经对(现在突变)对象有一个引用,那么为什么还要再次返回它呢?

但是,如果方法或函数会创建一个新对象,那么它当然必须返回它。

因此 l.reverse()什么都没有返回(因为现在列表已经相反,但是Identfier l 仍然指向该列表),但是 cretversed(l) 必须返回新生成的列表,因为 l 仍然指向旧的未修改列表。

编辑:我刚刚从另一个答案,该原理称为命令 - 问题分离

I can't speak for the developers, but I find this behavior very intuitive.

If a method works on the original object and modifies it in-place, it doesn't return anything, because there is no new information - you obviously already have a reference to the (now mutated) object, so why return it again?

If, however, a method or function creates a new object, then of course it has to return it.

So l.reverse() returns nothing (because now the list has been reversed, but the identfier l still points to that list), but reversed(l) has to return the newly generated list because l still points to the old, unmodified list.

EDIT: I just learned from another answer that this principle is called Command-Query separation.

为什么这些列表方法(附加,分类,扩展,删除,清除,反向)返回而不是结果列表?

弥繁 2025-02-13 06:30:29

您在项目目录中创建一个称为 dockerfile 的文本文件,然后将所有代码放入其中。

示例:

FROM ubuntu

RUN apt-get update && apt-get install -y <your-dependencys>

COPY . .

第二行安装图像上的软件包。

第三行将当前目录中的每个文件编写为图像。

You create a textfile called Dockerfile in your project directory and put all your code in there.

Example:

FROM ubuntu

RUN apt-get update && apt-get install -y <your-dependencys>

COPY . .

2nd line installs packages on the image.

3rd line copys every file in your current directory to the image.

Dockerfile在哪里以及如何添加线条?

弥繁 2025-02-13 06:06:17

这是一种看法,但是如果我不必这样做,我不喜欢藏匿;如果我在分支A上未完成的工作中间“正在进行的工作”),然后 git提取; git开关分支

无需说提取 - all 。无需推开分支A(这样做可能是个坏主意,因为它还没有烘烤)。无需拉动,因为 fetch 更新了所有内容。

但是,如果您已经拥有本地分支B,则切换到分支B后,您可能需要说 git Merge 才能更新本地分支。

It's sort of a matter of opinion, but I don't like stashing if I don't have to; if I'm in the middle of unfinished work on Branch A and I'm told to work on Branch B, I do an add-and-commit with a wip commit message (to indicate that this is "work in progress"), and then git fetch; git switch branchB.

No need to say fetch --all. No need to push Branch A (and it's probably a bad idea to do so, since it isn't baked yet). No need to pull because the fetch updated everything.

But if you already had a local Branch B, then after you switch to Branch B you might need to say git merge to update the local branch.

如何更改分支并从另一个分支中拉出?

弥繁 2025-02-13 00:44:08

根据他们的迁移指南的这一部分 此先前的修订版。。


pydantic确实允许通过现场验证器。创建一个时,您需要注意处理传入的数据并根据您的要求处理。在您的示例中,它应允许,标准 int s以及代表十六进制字符串的任何 str 。因此,以下实施可以满足上述约束:

from typing import Optional
from pydantic import BaseModel, ValidationInfo, field_validator

class DataTemp(BaseModel):
    aaa: int
    # to allow the assignment of str along with int, even though the
    # value will always be casted back to an int via the field validator,
    # and set the default value to None to permit omitted key in V2
    bbb: Optional[int | str] = None

    @field_validator('bbb')
    @classmethod
    def validate_bbb(cls, v: Optional[int | str], info: ValidationInfo):
        return int(v, 16) if isinstance(v, str) else v

用法:

>>> DataTemp(aaa=4, bbb=33)
DataTemp(aaa=4, bbb=33)
>>> DataTemp(aaa=4, bbb=None)
DataTemp(aaa=4, bbb=None)
>>> DataTemp(aaa=4)  # bbb omitted, defaults to None as specified
DataTemp(aaa=4, bbb=None)
>>> DataTemp(aaa=4, bbb='0x333')
DataTemp(aaa=4, bbb=819)
>>> DataTemp(aaa=4, bbb='32')
DataTemp(aaa=4, bbb=50)
>>> DataTemp(aaa=4, bbb='asdf')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pydantic/main.py", line 164, in __init__
    __pydantic_self__.__pydantic_validator__.validate_python(data, self_instance=__pydantic_self__)
pydantic_core._pydantic_core.ValidationError: 1 validation error for DataTemp
bbb
  Value error, invalid literal for int() with base 16: 'asdf' [type=value_error, input_value='asdf', input_type=str]
    For further information visit https://errors.pydantic.dev/2.5/v/value_error

This answer has been updated for Pydantic V2 (specifically 2.5.x) as per the this section of their migration guide while maintaining the original intent of this prior revision.


Pydantic does allow the attachment of additional validators to a given field by via field validators. When creating one you will need to take care to deal with the incoming data and process it based on your requirements. In your example, it should allow None, standard ints and also any str that represent a hexadecimal string. So the following implementation can satisfy the mentioned constraints:

from typing import Optional
from pydantic import BaseModel, ValidationInfo, field_validator

class DataTemp(BaseModel):
    aaa: int
    # to allow the assignment of str along with int, even though the
    # value will always be casted back to an int via the field validator,
    # and set the default value to None to permit omitted key in V2
    bbb: Optional[int | str] = None

    @field_validator('bbb')
    @classmethod
    def validate_bbb(cls, v: Optional[int | str], info: ValidationInfo):
        return int(v, 16) if isinstance(v, str) else v

Usage:

>>> DataTemp(aaa=4, bbb=33)
DataTemp(aaa=4, bbb=33)
>>> DataTemp(aaa=4, bbb=None)
DataTemp(aaa=4, bbb=None)
>>> DataTemp(aaa=4)  # bbb omitted, defaults to None as specified
DataTemp(aaa=4, bbb=None)
>>> DataTemp(aaa=4, bbb='0x333')
DataTemp(aaa=4, bbb=819)
>>> DataTemp(aaa=4, bbb='32')
DataTemp(aaa=4, bbb=50)
>>> DataTemp(aaa=4, bbb='asdf')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pydantic/main.py", line 164, in __init__
    __pydantic_self__.__pydantic_validator__.validate_python(data, self_instance=__pydantic_self__)
pydantic_core._pydantic_core.ValidationError: 1 validation error for DataTemp
bbb
  Value error, invalid literal for int() with base 16: 'asdf' [type=value_error, input_value='asdf', input_type=str]
    For further information visit https://errors.pydantic.dev/2.5/v/value_error

pydantic如何使用pydantic设置十六进制字符串?

弥繁 2025-02-12 18:37:56

我想您的内容是在file file.txt 中定义的:(我刚刚修改了 source4 的平均水平,以使数据 intactive> intactive> intactive> intactive

---------------------------------------------------------------------------  
Counter Source | Counter Name    |  Unit |   Min |   Max | Average |  Last   
---------------+-----------------+-------+-------+-------+---------+-------  
Source1        | GC1             |     % |  3.00 | 22.00 |    3.01 |  3.00   
Source2        | GC2             |     % |  2.00 |  7.00 |    2.95 |  3.00   
Source3        | GC3             |     % |  2.00 | 12.00 |    3.00 |  3.00   
Source4        | GC4             |     % | 15.00 | 16.00 |    0.00 | 15.00   
Source5        | GC5             |     % | 39.00 | 44.00 |   41.32 | 43.00   
-----------------------------------------------------------------------------

playbook:

- name: "tips1"
  hosts: localhost

  tasks:
    - debug: 
        msg: "the source {{ _s }}  is {{ 'active' if _av|float > 0.00 else 'inactive'}}"   
      loop: "{{ lookup('file', 'file.txt').splitlines() }}"
      vars:
        arr: "{{ item.split('|')|list}}"
        _s: "{{ arr[0]|trim }}"
        _av: "{{ arr[5]|trim|float }}"
      when: '"%" in item'   

结果:

skipping: [localhost] => (item=---------------------------------------------------------------------------  ) 
skipping: [localhost] => (item=Counter Source | Counter Name    |  Unit |   Min |   Max | Average |  Last   ) 
skipping: [localhost] => (item=---------------+-----------------+-------+-------+-------+---------+-------  ) 
ok: [localhost] => (item=Source1        | GC1             |     % |  3.00 | 22.00 |    3.01 |  3.00   ) => {
    "msg": "the source Source1  is active"
}
ok: [localhost] => (item=Source2        | GC2             |     % |  2.00 |  7.00 |    2.95 |  3.00   ) => {
    "msg": "the source Source2  is active"
}
ok: [localhost] => (item=Source3        | GC3             |     % |  2.00 | 12.00 |    3.00 |  3.00   ) => {
    "msg": "the source Source3  is active"
}
ok: [localhost] => (item=Source4        | GC4             |     % | 15.00 | 16.00 |    0.00 | 15.00   ) => {
    "msg": "the source Source4  is inactive"
}
ok: [localhost] => (item=Source5        | GC5             |     % | 39.00 | 44.00 |   41.32 | 43.00   ) => {
    "msg": "the source Source5  is active"
}
skipping: [localhost] => (item=-----------------------------------------------------------------------------) 

为了避免 ,您可以使用 @β.εηοιτ.βε提出的提示,

loop: "{{ lookup('file', 'file.txt').splitlines()[3:-1] }}"

I suppose your content is defined in file file.txt: (I have just modified the Source4 average to have a data inactive)

---------------------------------------------------------------------------  
Counter Source | Counter Name    |  Unit |   Min |   Max | Average |  Last   
---------------+-----------------+-------+-------+-------+---------+-------  
Source1        | GC1             |     % |  3.00 | 22.00 |    3.01 |  3.00   
Source2        | GC2             |     % |  2.00 |  7.00 |    2.95 |  3.00   
Source3        | GC3             |     % |  2.00 | 12.00 |    3.00 |  3.00   
Source4        | GC4             |     % | 15.00 | 16.00 |    0.00 | 15.00   
Source5        | GC5             |     % | 39.00 | 44.00 |   41.32 | 43.00   
-----------------------------------------------------------------------------

the playbook:

- name: "tips1"
  hosts: localhost

  tasks:
    - debug: 
        msg: "the source {{ _s }}  is {{ 'active' if _av|float > 0.00 else 'inactive'}}"   
      loop: "{{ lookup('file', 'file.txt').splitlines() }}"
      vars:
        arr: "{{ item.split('|')|list}}"
        _s: "{{ arr[0]|trim }}"
        _av: "{{ arr[5]|trim|float }}"
      when: '"%" in item'   

result:

skipping: [localhost] => (item=---------------------------------------------------------------------------  ) 
skipping: [localhost] => (item=Counter Source | Counter Name    |  Unit |   Min |   Max | Average |  Last   ) 
skipping: [localhost] => (item=---------------+-----------------+-------+-------+-------+---------+-------  ) 
ok: [localhost] => (item=Source1        | GC1             |     % |  3.00 | 22.00 |    3.01 |  3.00   ) => {
    "msg": "the source Source1  is active"
}
ok: [localhost] => (item=Source2        | GC2             |     % |  2.00 |  7.00 |    2.95 |  3.00   ) => {
    "msg": "the source Source2  is active"
}
ok: [localhost] => (item=Source3        | GC3             |     % |  2.00 | 12.00 |    3.00 |  3.00   ) => {
    "msg": "the source Source3  is active"
}
ok: [localhost] => (item=Source4        | GC4             |     % | 15.00 | 16.00 |    0.00 | 15.00   ) => {
    "msg": "the source Source4  is inactive"
}
ok: [localhost] => (item=Source5        | GC5             |     % | 39.00 | 44.00 |   41.32 | 43.00   ) => {
    "msg": "the source Source5  is active"
}
skipping: [localhost] => (item=-----------------------------------------------------------------------------) 

to avoid the when, you could use the tip proposed by @β.εηοιτ.βε,

loop: "{{ lookup('file', 'file.txt').splitlines()[3:-1] }}"

如何使用Ansible从表中访问和处理文本?

弥繁 2025-02-10 09:23:33

看来您的问题有两个部分。您正在尝试找出WebDriver和用户配置文件路径。请允许我为您回答这两个问题。

在最新版本的Selenium中, executable_path 参数已弃用。现在需要包含可执行路径的服务对象。有两个选择。

服务对象

选项#1:使用可执行路径

附加此导入到您的代码上:

from selenium.webdriver.chrome.service import Service

然后,将服务对象包括在内:

driver = webdriver.Chrome(service=Service("C:\Program Files\Google\Chrome\Application\chrome.exe"))

选项#2:让Web Driver Manager处理它,

这非常适合当驱动程序过时时。无需重载驱动程序。

首先,转到终端中的项目目录。如果您使用的是Pycharm,则无需遍历目录,因为您已经在项目目录中了。

使用PIP安装Web驱动程序管理器:

pip install webdriver_manager

现在,无需输入可执行的路径:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
driver.get("https://www.facebook.com")

选择用户配置文件

这很简单。首先,转到Chrome并输入 Chrome://版本/进入URL地址栏。您将看到配置文件路径。它看起来像 c:\ users \ your -profile \ appdata \ local \ google \ chrome \ chrome \ user data \ default

然后,包括以下镀铬选项:

options = webdriver.ChromeOptions()
options.add_argument(r"--user-data-dir=C:\Users\yourprofile\AppData\Local\Google\Chrome\User Data")
options.add_argument(r"--profile-directory=Default")
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)

It looks like your question has two parts. You are trying to figure out the webdriver and the user profile path. Allow me to answer both of these questions for you.

In the latest version of Selenium the executable_path parameter has been deprecated. Service objects containing the executable path are now required. There are two options for this.

Service objects

Option #1: Use your executable path

Append this import to your code:

from selenium.webdriver.chrome.service import Service

Then, include the service object as such:

driver = webdriver.Chrome(service=Service("C:\Program Files\Google\Chrome\Application\chrome.exe"))

Option #2: Let web driver manager handle it

This is great for when the driver becomes outdated. No need to redownload the driver.

First, go to the project directory in your terminal. If you are using PyCharm, there is no need to traverse to the directory, as you are already in the project directory.

Use pip to install web driver manager:

pip install webdriver_manager

Now, there is no need to enter an executable path:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
driver.get("https://www.facebook.com")

Selecting a user profile

This is fairly simple. First, go to chrome and enter chrome://version/ into the URL address bar. You will see the profile path. It will look like this C:\Users\yourprofile\AppData\Local\Google\Chrome\User Data\Default.

Then, include the following chrome options as such:

options = webdriver.ChromeOptions()
options.add_argument(r"--user-data-dir=C:\Users\yourprofile\AppData\Local\Google\Chrome\User Data")
options.add_argument(r"--profile-directory=Default")
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)

如何使用Selenium/WebDriver打开网站?

弥繁 2025-02-10 08:41:28

对于生产页面或应用程序,您通常只想使用更改字体大小。您将为 body 选择器明确设置字体大小,然后在所有其他元素中使用相对单元, rem em rem 单位更容易使用。然后,您将为不同的屏幕大小设置媒体查询,当触发这些媒体查询时,CSS会在 body 选择器中修改字体大小。由于所有其他元素均设置为相对字体大小,因此当 Body 字体大小增加或减少时,所有其他字体大小都会按比例增加或减小。媒体查询看起来如下:

@media screen and (max-width: 1200px) {
  body {
    font-size: 0.875rem; 
  }
}

不过,为了娱乐,这是一个完全响应的视口大小版式的工作示例。我在 html 选择器中明确设置字体,我使用 em 单元 body 中的字体以及所有段落和标题元素。我将所有内容都包装在另一个元素中,然后在该包装器上应用 vw 单位,以实现响应式的视口大小的版式。

html {
  font: 62.5% sans-serif;
}

body {
  background: #f2f2f2;
  font: 1.6em/1.4 Roboto, sans-serif;
  color: #333;
  margin: 0;
  padding: 0;
}

.wrapper-font-stretch {
  font-size: 0.85vw;
}

h1 {
  font: 5em Lato, sans-serif;
  margin: 0.3em 0;
  text-align: center;
}

h2 {
  font: small-caps 4em Lato, sans-serif;
  margin: 0.5em 0;
  text-align: center;
}

.lorem {
  font-size: 2.25em;
  margin: 0 auto 2em;
  max-width: 60ch;
  text-align: justify;
}
.lorem:first-line {
  font-size: 1.3em;
  line-height: 1;
}
.lorem:first-letter {
  font-family: "Dancing Script", sans-serif;
  font-size: 2.9em;
  font-weight: 700;
}
<div class="wrapper-font-stretch">
  <h1>This is a Heading</h1>
  <p class="lorem">Lorem ipsum dolor sit amet consectetur, adipisicing elit. Nostrum incidunt ducimus voluptas perspiciatis doloremque molestiae voluptate omnis, sequi dolor velit! Recusandae sunt iste tenetur ut nam aperiam? Minima repellat, mollitia ea odio veniam iusto
    fugiat dicta deleniti neque fugit beatae voluptates quo perferendis eaque necessitatibus nihil. Molestias vel voluptatum eum rem quia! Numquam odio ad deserunt mollitia, est ipsum illo ex repellendus molestiae, aspernatur vitae porro saepe nulla,
    
    voluptatum cum exercitationem quisquam? Pariatur accusamus et ratione, obcaecati nisi facilis vero maxime, minus, in sequi expedita ut illum. Cupiditate nesciunt, sint debitis et voluptates quae fugit ex illum. Suscipit, quas, delectus dolorem iure
    maxime dicta quis quidem, exercitationem consequuntur vero doloremque veritatis nihil amet inventore animi eligendi fugiat libero obcaecati facere est ad modi dignissimos alias aperiam. At nesciunt, incidunt iusto laboriosam nemo ducimus ab rerum
    voluptates, quam tenetur fugit vel sapiente impedit quia ut dolores. Amet vel aliquam quia harum voluptatem quidem consectetur, beatae ipsam, incidunt nemo doloribus maiores explicabo quibusdam ipsum dolor alias numquam obcaecati magnam eveniet? Tenetur
    minima dolores iste incidunt vel? Consequuntur, in. Fugit consequuntur, voluptas magnam fuga necessitatibus veritatis quae ipsa eveniet doloribus facere, magni possimus architecto reprehenderit neque. Aperiam dignissimos ut temporibus quas odit repudiandae?</p>
  <h2>this is a subheading</h2>
  <p class="lorem">Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur nam beatae veniam adipisci sunt eos praesentium, consequatur, a accusantium corrupti, dolorem ea in laborum ducimus perspiciatis architecto nulla explicabo. Repudiandae dicta repellat
    impedit quas. Fuga numquam accusantium perspiciatis iste magnam aliquam. Earum eius itaque magni magnam error. Adipisci, unde atque.</p>
</div>

您还可以在Codepen上查看此片段如果您想分叉并使用单位播放。

For a production page or app, you would generally just want to use Media Queries to change the font-size. You would set the font-size explicitly for the body selector, and then in all other elements you use relative units, either rem or em. rem units are much easier to work with. You would then set media queries for different screen sizes and when those media queries are triggered the CSS would modify the font-size in the body selector. Since all other elements are set to relative font-sizes, when the body font-size is increased or decreased, all other font-sizes will increase or decrease proportionately. Media queries may look like the following:

@media screen and (max-width: 1200px) {
  body {
    font-size: 0.875rem; 
  }
}

Just for fun though, here is a working example of fully responsive viewport sized typography. I set the font explicitly in the html selector, I use em units for the fonts in body and all the paragraph and header elements. I wrap everything in another element and apply vw units on that wrapper to achieve responsive, viewport sized typography.

html {
  font: 62.5% sans-serif;
}

body {
  background: #f2f2f2;
  font: 1.6em/1.4 Roboto, sans-serif;
  color: #333;
  margin: 0;
  padding: 0;
}

.wrapper-font-stretch {
  font-size: 0.85vw;
}

h1 {
  font: 5em Lato, sans-serif;
  margin: 0.3em 0;
  text-align: center;
}

h2 {
  font: small-caps 4em Lato, sans-serif;
  margin: 0.5em 0;
  text-align: center;
}

.lorem {
  font-size: 2.25em;
  margin: 0 auto 2em;
  max-width: 60ch;
  text-align: justify;
}
.lorem:first-line {
  font-size: 1.3em;
  line-height: 1;
}
.lorem:first-letter {
  font-family: "Dancing Script", sans-serif;
  font-size: 2.9em;
  font-weight: 700;
}
<div class="wrapper-font-stretch">
  <h1>This is a Heading</h1>
  <p class="lorem">Lorem ipsum dolor sit amet consectetur, adipisicing elit. Nostrum incidunt ducimus voluptas perspiciatis doloremque molestiae voluptate omnis, sequi dolor velit! Recusandae sunt iste tenetur ut nam aperiam? Minima repellat, mollitia ea odio veniam iusto
    fugiat dicta deleniti neque fugit beatae voluptates quo perferendis eaque necessitatibus nihil. Molestias vel voluptatum eum rem quia! Numquam odio ad deserunt mollitia, est ipsum illo ex repellendus molestiae, aspernatur vitae porro saepe nulla,
    
    voluptatum cum exercitationem quisquam? Pariatur accusamus et ratione, obcaecati nisi facilis vero maxime, minus, in sequi expedita ut illum. Cupiditate nesciunt, sint debitis et voluptates quae fugit ex illum. Suscipit, quas, delectus dolorem iure
    maxime dicta quis quidem, exercitationem consequuntur vero doloremque veritatis nihil amet inventore animi eligendi fugiat libero obcaecati facere est ad modi dignissimos alias aperiam. At nesciunt, incidunt iusto laboriosam nemo ducimus ab rerum
    voluptates, quam tenetur fugit vel sapiente impedit quia ut dolores. Amet vel aliquam quia harum voluptatem quidem consectetur, beatae ipsam, incidunt nemo doloribus maiores explicabo quibusdam ipsum dolor alias numquam obcaecati magnam eveniet? Tenetur
    minima dolores iste incidunt vel? Consequuntur, in. Fugit consequuntur, voluptas magnam fuga necessitatibus veritatis quae ipsa eveniet doloribus facere, magni possimus architecto reprehenderit neque. Aperiam dignissimos ut temporibus quas odit repudiandae?</p>
  <h2>this is a subheading</h2>
  <p class="lorem">Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur nam beatae veniam adipisci sunt eos praesentium, consequatur, a accusantium corrupti, dolorem ea in laborum ducimus perspiciatis architecto nulla explicabo. Repudiandae dicta repellat
    impedit quas. Fuga numquam accusantium perspiciatis iste magnam aliquam. Earum eius itaque magni magnam error. Adipisci, unde atque.</p>
</div>

You can also view this snippet on CodePen if you want to fork and play with the units.

我想实现CSS响应迅速设计的字体尺寸

弥繁 2025-02-10 01:26:56

jsoncppconfig.cmake 定义属性 interface_include_directories for targets jsoncpp_lib JSONCPP_LIB_STATIC

您需要查询目标属性并手动设置:

get_target_property(JSON_INC_PATH jsoncpp_lib INTERFACE_INCLUDE_DIRECTORIES)
include_directories(${JSON_INC_PATH})

链接是通过:

target_link_libraries(${PROJECT_NAME} jsoncpp_lib)

尝试以下操作:

cmake_minimum_required(VERSION 3.22.1)
project(ants)

# ".cpp" files in folder "src" into cmake variable "SOURCE"
file(GLOB SOURCE "src/*.cpp")

# Executable
add_executable(${PROJECT_NAME} ${SOURCE})

# Directory where cmake will look for include files
include_directories(include)

# Tells cmake to compile jsoncpp
add_subdirectory(external/jsoncpp)
get_target_property(JSON_INC_PATH jsoncpp_lib INTERFACE_INCLUDE_DIRECTORIES)
include_directories(${JSON_INC_PATH})

target_link_libraries(${PROJECT_NAME} jsoncpp_lib)

The jsoncppConfig.cmake defines property INTERFACE_INCLUDE_DIRECTORIES for targets jsoncpp_lib and jsoncpp_lib_static.

You need to query the target property and set it manually:

get_target_property(JSON_INC_PATH jsoncpp_lib INTERFACE_INCLUDE_DIRECTORIES)
include_directories(${JSON_INC_PATH})

Linking is done via:

target_link_libraries(${PROJECT_NAME} jsoncpp_lib)

Source.

Try this:

cmake_minimum_required(VERSION 3.22.1)
project(ants)

# ".cpp" files in folder "src" into cmake variable "SOURCE"
file(GLOB SOURCE "src/*.cpp")

# Executable
add_executable(${PROJECT_NAME} ${SOURCE})

# Directory where cmake will look for include files
include_directories(include)

# Tells cmake to compile jsoncpp
add_subdirectory(external/jsoncpp)
get_target_property(JSON_INC_PATH jsoncpp_lib INTERFACE_INCLUDE_DIRECTORIES)
include_directories(${JSON_INC_PATH})

target_link_libraries(${PROJECT_NAME} jsoncpp_lib)

cmake无法链接可执行文件-LJSONCPP:没有使用github子模块的此类文件

弥繁 2025-02-10 00:23:26

您可以使用这些代码行将其删除:

function stof_wp_remove_wp_block_library_css(){
    wp_dequeue_style( 'wp-block-library' );
    wp_dequeue_style( 'wp-block-library-theme' );
    wp_dequeue_style( 'wc-blocks-style' );
} 
add_action( 'wp_enqueue_scripts', 'stof_wp_remove_wp_block_library_css', 100 );

you can remove it with these lines of code:

function stof_wp_remove_wp_block_library_css(){
    wp_dequeue_style( 'wp-block-library' );
    wp_dequeue_style( 'wp-block-library-theme' );
    wp_dequeue_style( 'wc-blocks-style' );
} 
add_action( 'wp_enqueue_scripts', 'stof_wp_remove_wp_block_library_css', 100 );

从Gutenberg Block Gallery中删除内联样式

弥繁 2025-02-10 00:20:05

只需使用关键字参数 content 这样:

    content = "text content"
    embed = discord.Embed(title="example", description="embed content")
    await ctx.reply(content=content, embed=embed)

Just use keyword argument content like this:

    content = "text content"
    embed = discord.Embed(title="example", description="embed content")
    await ctx.reply(content=content, embed=embed)

如何在嵌入式消息中包括普通内容?

弥繁 2025-02-09 00:32:50

foo :: xs 的定义是必需的吗?

是的,因为正如Nathanoliver在注释中指出的那样,引用隐含地绑定到 foo :: XS 由基于范围的循环绑定。当您将引用对象绑定时,对象被odr使用。如果使用 std :: array 而不是原始数组,也会发生同样的情况。

如果我们避免基于范围?

好吧,如果您使用原始数组并使用不需要绑定引用的技术获取其大小,则可以避免提供定义:

for (int i = 0; i < sizeof(foo::xs)/sizeof(foo::xs[0]); i++) {
    sum += foo::xs[i];
}

在这种情况下,在这种情况下, sizeof 是而不是odr-uses,因为它们是未化为的,而 foo :: xs foo :: xs [i] ;后一种表达式是非类型的类型,并立即进行lvalue-to-rvalue转换,因此它不使用ODR使用 foo :: xs

Is the definition of foo::xs necessary?

Yes, because as NathanOliver points out in the comments, a reference is implicitly bound to foo::xs by the range-based for loop. When you bind a reference to an object, the object is odr-used. The same would occur if an std::array were used rather than a raw array.

What if we avoid the range based for?

Well, if you use a raw array and get its size using a technique that doesn't require binding a reference to it, then you can avoid providing a definition:

for (int i = 0; i < sizeof(foo::xs)/sizeof(foo::xs[0]); i++) {
    sum += foo::xs[i];
}

In this case, the references inside sizeof are not odr-uses because they are unevaluated, and foo::xs is an element of the set of potential results of foo::xs[i]; this latter expression is of non-class type and immediately undergoes an lvalue-to-rvalue conversion, so it does not odr-use foo::xs.

在数组ODR上使用基于循环的范围吗?

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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