吾性傲以野

文章 评论 浏览 27

吾性傲以野 2025-02-21 01:47:56

如果有一个 date datatype列(应该为;我们称其为 datum ),则可以例如,

select *
from your_table
where extract(year from datum) in (2018, 2019, 2020, 2021)
  and extract(month from datum) in (1, 2, 3)
order by datum;

如果将日期存储为字符串(中 varchar2 列),然后首先使用 to_date 函数使用适当的格式模型将其转换为有效 date datatype值。

例如,如果将值存储为20220715(这是 yyyymmdd ),则

to_date(datum, 'yyyymmdd')

其余查询是相同的:

select *
from your_table
where extract(year from to_date(datum, 'yyyymmdd')) in ...

当心! Oracle不将字符串作为日期处理!该列中可能有无效的值,例如“ 20AC#713”;将 to_date 应用于它会引起错误(因为这显然不是日期)。或者,如果有“ 20220230”(2月30日),您将再次出现错误。

始终将日期存储到 date 数据类型列!

If there's a DATE datatype column (should be; let's call it datum), then you could e.g.

select *
from your_table
where extract(year from datum) in (2018, 2019, 2020, 2021)
  and extract(month from datum) in (1, 2, 3)
order by datum;

If you stored dates as strings (into a VARCHAR2 column), then first convert it to a valid date datatype value using the TO_DATE function with appropriate format model.

For example, if values are stored as 20220715 (which is yyyymmdd),

to_date(datum, 'yyyymmdd')

The rest of query is just the same:

select *
from your_table
where extract(year from to_date(datum, 'yyyymmdd')) in ...

Beware! Oracle doesn't handle strings as dates! There might be invalid values in that column, e.g. "20ac#713"; applying to_date to it will raise error (as that's obviously not a date). Or, if there were "20220230" (30th of February), you'll get error again.

Always store dates into date datatype columns!

在过去4年的一月到三月之间获取数据

吾性傲以野 2025-02-21 00:10:05

当我遇到此例外时,问题与前卫有关。

就我而言,我能够修复它,包括项目的proguard-rules.pro文件中的以下规则。

# Preserve all public classes, and their public fields and
# methods.
-keep public class * {
    public *;
}

希望这有帮助!

When I encountered this exception the issue was related to proguard.

In my case, I was able to fix it including the following rule inside the project's proguard-rules.pro file.

# Preserve all public classes, and their public fields and
# methods.
-keep public class * {
    public *;
}

Hope this helps!

使用JJWT铸造JWT时的错误 - 无法加载名为[io.jsonwebtoken.impl.defaultjwtparser]的类别

吾性傲以野 2025-02-20 23:07:48

用print()函数替换返回

def shout(phrase):
    if phrase == phrase.upper():
        print("YOU'RE TOO LOUD")
    else:
        print("Can you speak up, I can barely hear you")

shout("I'M INTERESTED IN SHOUTING")

Replace return with the print() function

def shout(phrase):
    if phrase == phrase.upper():
        print("YOU'RE TOO LOUD")
    else:
        print("Can you speak up, I can barely hear you")

shout("I'M INTERESTED IN SHOUTING")

使用此代码,我将如何打印功能的价值,“ shout”&quot?

吾性傲以野 2025-02-20 21:51:31

要更新WooCommerce中的现有订单,您将订单ID添加到URL中,例如此/wp-json/wc/v3/orders/< id> ,并且请求必须是 pot

要存储跟踪URL,我建议您将其保存为订单中的元_field。然后,您可以在WooCommerce中轻松访问它,并将其显示在所需的位置。请求看起来像这样:

{
  "meta_data": [
    {
      "key": "_tracking_number",
      "value": "XXXXXXXXXXXXX"
    }
  ]
}

您可以在此处阅读更多有关它的信息 https://woocommerce.github.io/woocommerce-rest-api-docs/#update-an-cord

To update an existing order in WooCommerce you add the order id to the url like this /wp-json/wc/v3/orders/<id> and the request needs to be an PUT.

To store tracking url I would suggest you save it as a meta_field on the order. You can then easily access it in WooCommerce and display it where you want. Request can look like this:

{
  "meta_data": [
    {
      "key": "_tracking_number",
      "value": "XXXXXXXXXXXXX"
    }
  ]
}

You can read more about it here https://woocommerce.github.io/woocommerce-rest-api-docs/#update-an-order

WooCommerce履行API

吾性傲以野 2025-02-20 16:32:36

您为什么不只是在写语句中写下您所在的子例程的名称?

您无法(动态)(动态)给出或更改子例程的名称,因此,我认为没有理由尝试以这种方式访问​​它(关于该:虽然我不确定是不可能的以某种方式访问​​它,我敢肯定,这是错误的方法...您将使自己更麻烦,而不仅仅是硬编码)。

顺便说一句,你为什么要打印出来?一句话良好的诊断信息不会更有用吗?

Why don't you just hard write the name of the subroutine you're in, in the WRITE statement?

You cannot programmatically (dynamically) give or change the name of the subroutine, therefore I see no reason to try to access it either that way (about that: while I'm not sure that it is impossible to access it somehow, I'm quite sure that it is the wrong way to go ... you will cause yourself more trouble going that way, than just hard coding it).

Btw, why are you trying to print it out anyway? Wouldn't a well phrased diagnostic message be more informative?

fortran查询并打印出功能或子例程名称

吾性傲以野 2025-02-20 15:58:48

除了设计决策,您可以通过在 kernal.php 文件中覆盖名称空间来实现这一目标:

<?php

declare(strict_types=1);

namespace App { 
  // Must use bracket notation in order to use global namespace in the same file
  // See https://www.php.net/manual/en/language.namespaces.definitionmultiple.php#example-295

  use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
  use Symfony\Component\HttpKernel\Kernel as BaseKernel;

  class Kernel extends BaseKernel
  {
      use MicroKernelTrait;
  }
}

namespace {
  // Begin the global namespace

  if(!function_exists('_logger')) {
      // Added my logger() function here works but must be called as 
  \App\_logger()
  }
}

注意:此代码未经测试。

来源:

Design decisions aside, you can achieve this by overriding the namespace in the Kernal.php file:

<?php

declare(strict_types=1);

namespace App { 
  // Must use bracket notation in order to use global namespace in the same file
  // See https://www.php.net/manual/en/language.namespaces.definitionmultiple.php#example-295

  use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
  use Symfony\Component\HttpKernel\Kernel as BaseKernel;

  class Kernel extends BaseKernel
  {
      use MicroKernelTrait;
  }
}

namespace {
  // Begin the global namespace

  if(!function_exists('_logger')) {
      // Added my logger() function here works but must be called as 
  \App\_logger()
  }
}

Note: this code is untested.

Sources:

交响申请中的全局功能

吾性傲以野 2025-02-19 11:53:50

“返回”确实退出了该函数,但是如果要返回大量数据,则可以将其存储在数组中,然后将其返回,而不是试图在循环中返回每个数据1 x 1。

"return" does exit the function but if you want to return large sums of data, you can store it in an array and then return it instead of trying to returning each piece of data 1 by 1 in the loop.

返回停止循环吗?

吾性傲以野 2025-02-19 06:46:12

Edit 7 July:

From your comments I understand you were looking for something different, the assumption I made about why your function was giving multiple values was wrong. Hence this new answer from scratch:


The custom function you've written doesn't lend itself to row-by-row application, because it already processes all rows at once:

Given the following input:

congress <- c(104, 111, 104, 111, 104, 111)
latitude <- c(37.32935, 37.32935, 41.1134016, 41.1134016, 42.1554948, 42.1554948)
longitude <- c(-122.00954, -122.00954, 73.720356, 73.720356, -87.868850502543, -87.868850502543)

point_geo_test contains these values:

> point_geo_test
[...]
  congress                   geometry
1      104 POINT (-122.0095 37.32935)
2      111 POINT (-122.0095 37.32935)
3      104   POINT (73.72036 41.1134)
4      111   POINT (73.72036 41.1134)
5      104 POINT (-87.86885 42.15549)
6      111 POINT (-87.86885 42.15549)

and extract_district() returns this:

> extract_district(point_geo_test, 104)
[...]
[1] "California-14" "California-14" "NA-NA"         "NA-NA"         "Illinois-10"   "Illinois-10"

This is already a result for each row.唯一的问题是,虽然它们是每行的坐标的正确结果,但它们仅在国会104期间仅用于这些坐标的 name 。因此,这些值仅是有效的for the rows in point_geo_test where congress == 104.

Extracting correct values for all rows

We will create a function that returns the correct data for all rows, eg the correct name for the在相关国会期间进行坐标。

我已经稍微简化了您的代码: df_test 不再是中间数据框架,而是直接定义在 point_geo_test 的创建中。我提取的任何值,我也将保存到此数据框架中。

library(tidyverse)
library(sf)
sf_use_s2(FALSE)

districts_104 <- st_read("districts104.shp")
districts_111 <- st_read("districts111.shp")

congress <- c(104, 111, 104, 111, 104, 111)
latitude <- c(37.32935, 37.32935, 41.1134016, 41.1134016, 42.1554948, 42.1554948)
longitude <- c(-122.00954, -122.00954, 73.720356, 73.720356, -87.868850502543, -87.868850502543)

point_geo_test <- st_as_sf(data.frame(congress, latitude, longitude),
                           coords = c(x = "longitude", y = "latitude"),
                           crs = st_crs(districts_104))

To keep the code more flexible and organized, I'll create a generic function that can fetch any parameter for the given coordinates:

extract_values <- function(points, parameter) {
  # initialize return values, one for each row in `points`
  values <- rep(NA, nrow(points))
  
  # for each congress present in `points`, lookup parameter and store in the rows with matching congress
  for(cong in unique(points$congress)) {
    shapefile <- get(paste0("districts_", cong))
    st_join_results <- st_join(points, shapefile, join = st_within)
    values[points$congress == cong] <- st_join_results[[parameter]][points$congress == cong]
  }
  
  return(values)
}

Examples:

> extract_values(point_geo_test, 'STATENAME')
[1] "California" "California" NA           NA           "Illinois"   "Illinois"  
> extract_values(point_geo_test, 'DISTRICT')
[1] "14" "15" NA   NA   "10" "10"

Storing values

point_geo_test$state <- extract_values(point_geo_test, 'STATENAME')
point_geo_test$district <- extract_values(point_geo_test, 'DISTRICT')
point_geo_test$name <- paste(point_geo_test$state, point_geo_test$district, sep = "-")

Result:

> point_geo_test
Simple feature collection with 6 features and 4 fields
Geometry type: POINT
Dimension:     XY
Bounding box:  xmin: -122.0095 ymin: 37.32935 xmax: 73.72036 ymax: 42.15549
Geodetic CRS:  GRS 1980(IUGG, 1980)
  congress      state district          name                   geometry
1      104 California       14 California-14 POINT (-122.0095 37.32935)
2      111 California       15 California-15 POINT (-122.0095 37.32935)
3      104       <NA>     <NA>         NA-NA   POINT (73.72036 41.1134)
4      111       <NA>     <NA>         NA-NA   POINT (73.72036 41.1134)
5      104   Illinois       10   Illinois-10 POINT (-87.86885 42.15549)
6      111   Illinois       10   Illinois-10 POINT (-87.86885 42.15549)

Edit 7 July:

From your comments I understand you were looking for something different, the assumption I made about why your function was giving multiple values was wrong. Hence this new answer from scratch:


The custom function you've written doesn't lend itself to row-by-row application, because it already processes all rows at once:

Given the following input:

congress <- c(104, 111, 104, 111, 104, 111)
latitude <- c(37.32935, 37.32935, 41.1134016, 41.1134016, 42.1554948, 42.1554948)
longitude <- c(-122.00954, -122.00954, 73.720356, 73.720356, -87.868850502543, -87.868850502543)

point_geo_test contains these values:

> point_geo_test
[...]
  congress                   geometry
1      104 POINT (-122.0095 37.32935)
2      111 POINT (-122.0095 37.32935)
3      104   POINT (73.72036 41.1134)
4      111   POINT (73.72036 41.1134)
5      104 POINT (-87.86885 42.15549)
6      111 POINT (-87.86885 42.15549)

and extract_district() returns this:

> extract_district(point_geo_test, 104)
[...]
[1] "California-14" "California-14" "NA-NA"         "NA-NA"         "Illinois-10"   "Illinois-10"

This is already a result for each row. The only problem is, while they are the correct results for the coordinates of each row, they the name for those coordinates only during congress 104. Hence, these values are only valid for the rows in point_geo_test where congress == 104.

Extracting correct values for all rows

We will create a function that returns the correct data for all rows, eg the correct name for the coordinates during the associated congress.

I've simplified your code slightly: the df_test is not an intermediate data frame any more, but defined directly in the creation of point_geo_test. Any values I extract, I'll save into this data frame as well.

library(tidyverse)
library(sf)
sf_use_s2(FALSE)

districts_104 <- st_read("districts104.shp")
districts_111 <- st_read("districts111.shp")

congress <- c(104, 111, 104, 111, 104, 111)
latitude <- c(37.32935, 37.32935, 41.1134016, 41.1134016, 42.1554948, 42.1554948)
longitude <- c(-122.00954, -122.00954, 73.720356, 73.720356, -87.868850502543, -87.868850502543)

point_geo_test <- st_as_sf(data.frame(congress, latitude, longitude),
                           coords = c(x = "longitude", y = "latitude"),
                           crs = st_crs(districts_104))

To keep the code more flexible and organized, I'll create a generic function that can fetch any parameter for the given coordinates:

extract_values <- function(points, parameter) {
  # initialize return values, one for each row in `points`
  values <- rep(NA, nrow(points))
  
  # for each congress present in `points`, lookup parameter and store in the rows with matching congress
  for(cong in unique(points$congress)) {
    shapefile <- get(paste0("districts_", cong))
    st_join_results <- st_join(points, shapefile, join = st_within)
    values[points$congress == cong] <- st_join_results[[parameter]][points$congress == cong]
  }
  
  return(values)
}

Examples:

> extract_values(point_geo_test, 'STATENAME')
[1] "California" "California" NA           NA           "Illinois"   "Illinois"  
> extract_values(point_geo_test, 'DISTRICT')
[1] "14" "15" NA   NA   "10" "10"

Storing values

point_geo_test$state <- extract_values(point_geo_test, 'STATENAME')
point_geo_test$district <- extract_values(point_geo_test, 'DISTRICT')
point_geo_test$name <- paste(point_geo_test$state, point_geo_test$district, sep = "-")

Result:

> point_geo_test
Simple feature collection with 6 features and 4 fields
Geometry type: POINT
Dimension:     XY
Bounding box:  xmin: -122.0095 ymin: 37.32935 xmax: 73.72036 ymax: 42.15549
Geodetic CRS:  GRS 1980(IUGG, 1980)
  congress      state district          name                   geometry
1      104 California       14 California-14 POINT (-122.0095 37.32935)
2      111 California       15 California-15 POINT (-122.0095 37.32935)
3      104       <NA>     <NA>         NA-NA   POINT (73.72036 41.1134)
4      111       <NA>     <NA>         NA-NA   POINT (73.72036 41.1134)
5      104   Illinois       10   Illinois-10 POINT (-87.86885 42.15549)
6      111   Illinois       10   Illinois-10 POINT (-87.86885 42.15549)

R:使用突变()逐行应用自定义功能

吾性傲以野 2025-02-19 03:22:18

截至2020年8月: 现代浏览器对 =“ https://developer.mozilla.org/en-us/docs/web/javascript/reference/global_objects/string/replaceall/replaceall” rel =“ noreferrer”> string.replaceall(replaceall(Replaceall() /a>由ecmascript 2021语言规范定义。


对于较旧/旧的浏览器:

function escapeRegExp(str) {
  return str.replace(/[.*+?^${}()|[\]\\]/g, '\\
amp;'); // 
amp; means the whole matched string
}

function replaceAll(str, find, replace) {
  return str.replace(new RegExp(escapeRegExp(find), 'g'), replace);
}

这是如何演变的:

str = str.replace(/abc/g, '');

回答评论“如果'abc'作为变量是什么

var find = 'abc';
var re = new RegExp(find, 'g');

str = str.replace(re, '');

? stackoverflow.com/users/49153/click-upvote"> click upvote 的评论,您可以更简化它:

function replaceAll(str, find, replace) {
  return str.replace(new RegExp(find, 'g'), replace);
}

注意:正则表达式包含特殊(meta)字符,以及AS在中盲目地通过一个参数在上面找到函数而无需预处理以逃脱这些字符是危险的。 mozilla开发人员网络's javaScript指南正式表达式指南,它们呈现以下实用程序功能(至少已更改了至少已更改由于此答案最初是两次,因此请确保检查MDN站点是否有潜在的更新):

function escapeRegExp(string) {
  return string.replace(/[.*+?^${}()|[\]\\]/g, '\\
amp;'); // 
amp; means the whole matched string
}

因此,为了使 felpaceAll()函数上述更安全,可以将其修改为以下内容。还包括 Escaperegexp

function replaceAll(str, find, replace) {
  return str.replace(new RegExp(escapeRegExp(find), 'g'), replace);
}

As of August 2020: Modern browsers have support for the String.replaceAll() method defined by the ECMAScript 2021 language specification.


For older/legacy browsers:

function escapeRegExp(str) {
  return str.replace(/[.*+?^${}()|[\]\\]/g, '\\
amp;'); // 
amp; means the whole matched string
}

function replaceAll(str, find, replace) {
  return str.replace(new RegExp(escapeRegExp(find), 'g'), replace);
}

Here is how this answer evolved:

str = str.replace(/abc/g, '');

In response to comment "what's if 'abc' is passed as a variable?":

var find = 'abc';
var re = new RegExp(find, 'g');

str = str.replace(re, '');

In response to Click Upvote's comment, you could simplify it even more:

function replaceAll(str, find, replace) {
  return str.replace(new RegExp(find, 'g'), replace);
}

Note: Regular expressions contain special (meta) characters, and as such it is dangerous to blindly pass an argument in the find function above without pre-processing it to escape those characters. This is covered in the Mozilla Developer Network's JavaScript Guide on Regular Expressions, where they present the following utility function (which has changed at least twice since this answer was originally written, so make sure to check the MDN site for potential updates):

function escapeRegExp(string) {
  return string.replace(/[.*+?^${}()|[\]\\]/g, '\\
amp;'); // 
amp; means the whole matched string
}

So in order to make the replaceAll() function above safer, it could be modified to the following if you also include escapeRegExp:

function replaceAll(str, find, replace) {
  return str.replace(new RegExp(escapeRegExp(find), 'g'), replace);
}

如何替换字符串的所有出现?

吾性傲以野 2025-02-19 01:58:53

文档中正在解释的是,您可以通过对“ MuiloAdingButton-root”类造型来对根组件(LoadingButton Container Div)进行样式。

基本上,您需要具有针对此类的CSS样式,并将其称为组件中:

.MuiLoadingButton-root {
  background-color: #FFF;
}

What is being explained in the documentation is that you can style the root component (the LoadingButton container div) by styling the class "MuiLoadingButton-root".

Basically, you need to have a css styling targeting this class and call it inside your component:

.MuiLoadingButton-root {
  background-color: #FFF;
}

您如何更改加载文本颜色和背景颜色或材料UI loadingButton

吾性傲以野 2025-02-18 18:53:00

看完我的特使日志后,我意识到路径被称为标题“:路径”。
pass_through_matcher 数学标题。

然后只添加:

pass_through_matcher:
  - name: ":path"
    prefix_match: "/healthz"
  - name: ":path"
    prefix_match: "/api/v1/myResource1"

在没有LUA过滤器的情况下,在我的conf中(请参阅我以前的答案)。

After looking at my envoy logs, I realized that path is know as header ":path".
The pass_through_matcher math the header.

Then only adding:

pass_through_matcher:
  - name: ":path"
    prefix_match: "/healthz"
  - name: ":path"
    prefix_match: "/api/v1/myResource1"

in my conf without the lua filter (see my previous answer) it works.

用禁用路由实施Enkoy OAuth2过滤器

吾性傲以野 2025-02-18 17:33:06

您可以尝试覆盖模型的保存功能:

class Model(models.Model):
    doucment_image = models.ImageField(upload_to='sellerinfo', null=True, blank=True)

    def save(self, *args, **kwargs):
        super().save(*args, **kwargs)
        # Call scaled_image if doucment_image is provided
        if self.doucment_image:
            self.doucment_image = scaled_image(self.doucment_image.path, self.doucment_image.path)

You could try to override the save function of your Model :

class Model(models.Model):
    doucment_image = models.ImageField(upload_to='sellerinfo', null=True, blank=True)

    def save(self, *args, **kwargs):
        super().save(*args, **kwargs)
        # Call scaled_image if doucment_image is provided
        if self.doucment_image:
            self.doucment_image = scaled_image(self.doucment_image.path, self.doucment_image.path)

如何在ImageField中插入功能

吾性傲以野 2025-02-18 13:16:27

您无权访问 /上传 /在此服务器上。

尝试以下内容:

sudo chmod -R 777 /uploads

You don't have permission to access /uploads/ on this server.

Try the following:

sudo chmod -R 777 /uploads

Inoent:没有这样的文件或目录。

吾性傲以野 2025-02-18 08:39:06

时,请替换并尝试此操作

您可以在注释 @when(“^user Enters(。+)和(。+)$” 。

can you please replace and try this when annotation

@When("^User enters (.+) and (.+)$") public void user_enters_and(String username, String password) throws Throwable { //your code here }

如何在BDD参数化中解决误差?

吾性傲以野 2025-02-17 20:57:36

干得好,

const a = [1, 2, 3]
const b = [1, 2, 3, 4, 5]

const diff = b.filter(e => !a.includes(e))
console.log(diff)

上述大多数答案都不适用于无序列表。
这也适用于无序列表。

const a = [3, 2, 1]
const b = [1, 2, 3, 4, 5]

const diff = b.filter(e => !a.includes(e))
console.log(diff)

如果A的大小大于B

const a = [1, 2, 3, 4, 5]
const b = [3, 2, 1]

const diff = a.length > b.length ? a.filter(e => !b.includes(e)) : b.filter(e => !a.includes(e))
console.log(diff)

Here you go,

const a = [1, 2, 3]
const b = [1, 2, 3, 4, 5]

const diff = b.filter(e => !a.includes(e))
console.log(diff)

Most of the above answers dosen't work for unordered list.
This works for unordered lists too.

const a = [3, 2, 1]
const b = [1, 2, 3, 4, 5]

const diff = b.filter(e => !a.includes(e))
console.log(diff)

If size of a is greater than b,

const a = [1, 2, 3, 4, 5]
const b = [3, 2, 1]

const diff = a.length > b.length ? a.filter(e => !b.includes(e)) : b.filter(e => !a.includes(e))
console.log(diff)

如何在JavaScript中比较数组?

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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