落叶缤纷

文章 评论 浏览 26

落叶缤纷 2025-02-20 19:40:22

我相信 @SOM-1的答案是有益的,但没有通过信息或调试数据证实。我相信假设并不总是正确的。

我调试了这两种情况下形成的mySQL查询

-1- metadata.objects.update(value = cast(cast(f cast('value'),output_field = integerfield()) + 1,output_field = charfield = charfield()) )

2- metadata.objects.update(value = cast(cast('value',integerfield()),integerfield()) + 1, charfield()))
两者都给出与预期的相同输出。

UPDATE Metadata SET value = CAST((CAST(value AS signed integer) + 1) AS char) WHERE ( key = 'EVENT' AND  type = 'COUNT' )

请找到将mysqld选项添加到我的cnf并调试查询的链接。 https .com/blog/2018/10/how-to-show-queries-log-in-mysql.html

I believe the answer from @som-1 was informative but not substantiated with info or debugged data. I believe assuming is not always right.

I debugged the mysql queries formed in these two cases -

1 - Metadata.objects.update(value=Cast(Cast(F('value'), output_field=IntegerField()) + 1, output_field=CharField()))

2 - Metadata.objects.update(value=Cast(Cast('value', IntegerField()) + 1, CharField())) and
both give the same output as expected.

UPDATE Metadata SET value = CAST((CAST(value AS signed integer) + 1) AS char) WHERE ( key = 'EVENT' AND  type = 'COUNT' )

Please find the link to add mysqld options to my.cnf and debug your queries. Location of my.cnf file on macOS
enabling queries - https://tableplus.com/blog/2018/10/how-to-show-queries-log-in-mysql.html

如何使用f表达式首先将字符串施放到int,然后将1添加到其上,然后施放到字符串和更新

落叶缤纷 2025-02-20 15:20:03

用参数重定向到Django中的另一页

return HttpResponseRedirect(reverse(viewname='the view to which it should redirect', args=(parameters to be passed)))

To redirect to another page in Django with parameters use this

return HttpResponseRedirect(reverse(viewname='the view to which it should redirect', args=(parameters to be passed)))

将一页重定向到Django中的另一页时出错

落叶缤纷 2025-02-20 07:32:38

首先,请勿命名任何变量元组这是一个内置功能,当您命名变量 tuple 时,您会错过该 method> method

def changer(data):
    if type(data) == str:
        return data.replace("-", " ")
    elif type(data) == list:
        return [changer(x) for x in data]
    elif type(data) == tuple:
        return tuple(changer(x) for x in data)
tpl = [('Hi', 'Hello-World', 'Earth'), ('Hello-World', 'Hi')]

changer(tpl)

输出:

[('Hi', 'Hello World', 'Earth'), ('Hello World', 'Hi')]

first of everything, don't name any variable tuple it's a builtin function and when you name a variable tuple you miss that method

def changer(data):
    if type(data) == str:
        return data.replace("-", " ")
    elif type(data) == list:
        return [changer(x) for x in data]
    elif type(data) == tuple:
        return tuple(changer(x) for x in data)
tpl = [('Hi', 'Hello-World', 'Earth'), ('Hello-World', 'Hi')]

changer(tpl)

output:

[('Hi', 'Hello World', 'Earth'), ('Hello World', 'Hi')]

用元组的所有元素替换破折号?

落叶缤纷 2025-02-20 06:55:11

当您查看查找 它说它返回 first 值,而不是全部。

改用过滤

const post = posts.filter(post => post.category === "SHORT_STORIES");

When you take a look at the documentation of find it says that it returns the first value instead of all.

Use filter instead

const post = posts.filter(post => post.category === "SHORT_STORIES");

我如何将我的所有帖子分类中的所有帖子出现在React中?

落叶缤纷 2025-02-19 23:00:29

您只需要使用 max 来获取组中的最大日期, sum 获得总计:

select type, sum(value_1), sum(value_2), max(standby_date)
from t
where type = 'a'
group by type

You just need to use max to get the greatest date in a group, and sum to get the totals:

select type, sum(value_1), sum(value_2), max(standby_date)
from t
where type = 'a'
group by type

mysql查询帮助 - 获取最大(日期)

落叶缤纷 2025-02-19 03:45:17

当从另一个人调用一个run-script时,我遇到了这个问题。使用npm-run-all和 run-s 在某些情况下启动命令解决了我的问题。我怀疑NPM基于“平台”或不正确地内省运行的外壳对外壳和路径分离器做出了一些假设。

I've encountered this issue when calling one run-script from another. Using npm-run-all and run-s to launch commands fixed my issues in some scenarios. I suspect that npm is making some assumptions about the shell and path separator based on the 'platform' or not properly introspecting the running shell.

NPM运行:找不到命令

落叶缤纷 2025-02-18 18:45:24

我建议使用 pgfplots ,然后您对颜色尺度的控制最多:

\documentclass[tikz, margin=5pt]{standalone}

\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
    axis equal=true,
    hide axis,     
    domain=0:180,
    domain y=0:1,
    view={0}{90},
    shader=interp,
    colormap={redblue}{
        color=(red)  color=(blue)
    },
    data cs=polar,
]
    \addplot3 [surf] {x};
\end{axis}
\end{tikzpicture}

\end{document}

“在此处输入图像说明”

I suggest to use pgfplots, then you have the most control over the colour scale:

\documentclass[tikz, margin=5pt]{standalone}

\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
    axis equal=true,
    hide axis,     
    domain=0:180,
    domain y=0:1,
    view={0}{90},
    shader=interp,
    colormap={redblue}{
        color=(red)  color=(blue)
    },
    data cs=polar,
]
    \addplot3 [surf] {x};
\end{axis}
\end{tikzpicture}

\end{document}

enter image description here

tikz:用角度填充阴影颜色

落叶缤纷 2025-02-18 14:44:23

更高版

=SUM(COUNTIFS(A2:P2;FILTERXML("<c><e>"&SUBSTITUTE(A1;";";"</e><e>")&"</e></c>";"//e")))

假设您使用Excel 2013或 array公式如果您没有动态阵列)

Assuming that you're using Excel 2013 or later, and that A1 contains the text PH;V;O the formula below should work

=SUM(COUNTIFS(A2:P2;FILTERXML("<c><e>"&SUBSTITUTE(A1;";";"</e><e>")&"</e></c>";"//e")))

(this will have to be entered as an array formula if you don't have dynamic arrays)

具有来自相关单元格的一系列标准的Excel Countif

落叶缤纷 2025-02-18 08:42:24

警告:将实现放入标题文件中是不是,请参见本答案末尾的替代解决方案。

无论如何,您的代码失败的原因是,在实例化模板时,编译器会使用给定的模板参数创建新类。例如:

template<typename T>
struct Foo
{
    T bar;
    void doSomething(T param) {/* do stuff using T */}
};

// somewhere in a .cpp
Foo<int> f; 

阅读此行时,编译器将创建一个新类(我们称其为 fooint ),这等同于以下内容:

struct FooInt
{
    int bar;
    void doSomething(int param) {/* do stuff using int */}
};

因此,编译器需要访问方法的实现。 ,用模板参数实例化(在这种情况下 int )。如果这些实现不在标题中,则将无法访问它们,因此编译器将无法实例化模板。

一个常见的解决方案是在标题文件中写入模板声明,然后在实现文件中实现类(例如.tpp),然后在标题末尾包含此实现文件。

foo.h

template <typename T>
struct Foo
{
    void doSomething(T param);
};

#include "Foo.tpp"

foo.tpp

template <typename T>
void Foo<T>::doSomething(T param)
{
    //implementation
}

以这种方式,实施仍然与声明分开,但编译器可以访问。

另一种解决

方案是将实现分开,并明确实例化所需的所有模板实例:

foo.h

// no implementation
template <typename T> struct Foo { ... };

foo.cpp

// implementation of Foo's methods

// explicit instantiations
template class Foo<int>;
template class Foo<float>;
// You will only be able to use Foo with int or float

如果我的解释不够清楚,您可以查看 c ++ super-faq在此主题上

Caveat: It is not necessary to put the implementation in the header file, see the alternative solution at the end of this answer.

Anyway, the reason your code is failing is that, when instantiating a template, the compiler creates a new class with the given template argument. For example:

template<typename T>
struct Foo
{
    T bar;
    void doSomething(T param) {/* do stuff using T */}
};

// somewhere in a .cpp
Foo<int> f; 

When reading this line, the compiler will create a new class (let's call it FooInt), which is equivalent to the following:

struct FooInt
{
    int bar;
    void doSomething(int param) {/* do stuff using int */}
};

Consequently, the compiler needs to have access to the implementation of the methods, to instantiate them with the template argument (in this case int). If these implementations were not in the header, they wouldn't be accessible, and therefore the compiler wouldn't be able to instantiate the template.

A common solution to this is to write the template declaration in a header file, then implement the class in an implementation file (for example .tpp), and include this implementation file at the end of the header.

Foo.h

template <typename T>
struct Foo
{
    void doSomething(T param);
};

#include "Foo.tpp"

Foo.tpp

template <typename T>
void Foo<T>::doSomething(T param)
{
    //implementation
}

This way, implementation is still separated from declaration, but is accessible to the compiler.

Alternative solution

Another solution is to keep the implementation separated, and explicitly instantiate all the template instances you'll need:

Foo.h

// no implementation
template <typename T> struct Foo { ... };

Foo.cpp

// implementation of Foo's methods

// explicit instantiations
template class Foo<int>;
template class Foo<float>;
// You will only be able to use Foo with int or float

If my explanation isn't clear enough, you can have a look at the C++ Super-FAQ on this subject.

为什么仅在标题文件中实现模板?

落叶缤纷 2025-02-18 00:11:16

使用 itertools.chain

from itertools import chain

out = {k: [list(chain.from_iterable(l))]
       for k,l in dic.items()}

输出:

{1: [[1, 2, 3, 4, 5, 6, 7, 5, 1, 4, 34, 3, 65, 0, 2, 2, 5, 4, 5, 7, 8, 4, 7]],
 2: [[1, 5, 4, 5, 0, 1, 4, 6, 2, 2, 3, 5, 6, 6, 3, 9]],
 3: [[12, 35, 42, 53, 70, 71, 74, 76, 6, 11, 16, 17, 38, 62, 66, 77]]}

Using itertools.chain:

from itertools import chain

out = {k: [list(chain.from_iterable(l))]
       for k,l in dic.items()}

Output:

{1: [[1, 2, 3, 4, 5, 6, 7, 5, 1, 4, 34, 3, 65, 0, 2, 2, 5, 4, 5, 7, 8, 4, 7]],
 2: [[1, 5, 4, 5, 0, 1, 4, 6, 2, 2, 3, 5, 6, 6, 3, 9]],
 3: [[12, 35, 42, 53, 70, 71, 74, 76, 6, 11, 16, 17, 38, 62, 66, 77]]}

单个字典包含同一键下的多个列表。希望将同一键下的所有值组合到一个列表中

落叶缤纷 2025-02-17 21:54:45

在您的应用程序上搜索此内容。如果可用,您应该可以在此处下载和安装插件和“现代”项目。

单击修改。

然后选择所需的平台。

Search this up on your apps. If it is available, you should be able to download and install plugins and "modern" projects there.
enter image description here

Click on modify.
enter image description here

Then choose desired platforms.
enter image description here

Visual Studio-添加新项目 - 为什么可用的选项很少?

落叶缤纷 2025-02-17 17:52:39

您可以使用通用物来说对象 value 的键是该密钥的类型

interface Object {
   name: string
   age: number
}

let obj: Object = {};

function updateObject<K extends keyof Object>(key: K, value: Object[K]) {
   obj[key] = value;
}

updateObject('name', 'foo'); // Fine
updateObject('name', 1); // Error
updateObject('age', 'foo'); // Error
updateObject('age', 1); // Fine

You can use generics to say that key is a key of Object and value is the type of that key

interface Object {
   name: string
   age: number
}

let obj: Object = {};

function updateObject<K extends keyof Object>(key: K, value: Object[K]) {
   obj[key] = value;
}

updateObject('name', 'foo'); // Fine
updateObject('name', 1); // Error
updateObject('age', 'foo'); // Error
updateObject('age', 1); // Fine

可以使用KeyOF在打字条中更新对象吗?

落叶缤纷 2025-02-17 12:18:19

我相信您的目标如下。

  • 通过访问授权URL,例如 https://www.reddit.com/api/v1/authorize?client_client_id=client_Id&Ampponseponse_tepe_type = code = code = code = code = code = code = random_state = random_state = random_state&am代码>使用浏览器,您需要使用Google Apps脚本创建的Web应用程序检索访问令牌。

在这种情况下,以下curl命令的请求由Google Apps脚本通过检索授权代码运行。

 curl -X POST https://www.reddit.com/api/v1/access_token \\
   -H 'content-type: application/x-www-form-urlencoded' \\
   -A 'CLIENT_NAME' \\
   -u CLIENT_ID:APP_SECRET \\
   -d 'grant_type=authorization_code&code=CODE&redirect_uri=REDIRECT_URL'

在这种情况下,以下Web应用程序的示例脚本如何?

示例脚本:

function doGet(e) {
  const clientId = "###"; // Please set your client ID.
  const secret = "###"; // Please set your secret.
  const redirectUrl = "https://script.google.com/macros/s/###/exec"; // Please set your Web Apps URL that you are using it as the redirect URL.

  const url = "https://www.reddit.com/api/v1/access_token";
  const params = {
    method: "post",
    headers: { "Authorization": "Basic " + Utilities.base64Encode(`${clientId}:${secret}`) },
    payload: {
      "code": e.parameter.code,
      "grant_type": "authorization_code",
      "redirect_uri": redirectUrl
    }
  };
  const res = UrlFetchApp.fetch(url, params);
  return ContentService.createTextOutput(res.getContentText());
}
  • 在脚本中设置变量后,请将修改后的脚本反映为Web应用程序。

  • 在此脚本中将 修改的脚本反映为Web应用程序。 .com/api/v1/authorize?client_id=xxxxxxxxxxxx&response_type=code&redirect_uri=https%3A%2F%2Fscript.google.com%2Fmacros%2Fd%2F1Nh3AKooeG8XH4rSTvEWLTf5l3Sgo3nPgK01qiusSany43fFNaUgg2q6b%2Fusercallback&state=ADEpC8xyajUigAfm1arE-N3gjrw-OLvI08gR23Y1ouQJpLpGtZ6ZPWTcpQRa8kW79ABqkxha1B8d90tb8B4eianNmJjFgzKzjCGwdxJ8lpDUdyNF7YjNq_3ak8d6Co_arPUDuP-BnbH0qRSwuEacP2Zif4wTt- YapR8VBbrkhr0tc6aScewnQPe9sCsOccRK6dITZ2SWFP_ZNA5rd03uP -f2hrjfmeormpfflzvfys9cvgdbziopee4k_6jqieg02zk_buqsoijkuweb3obtgpcqxhsu1qcrmxoxuzjucnuf8m_mbwkhoho-69 g9rnkchm_gnqmnkmchmhwqmhhw&and-24-thp4-thp4-thp4-thp4-thp4-thp4-thp4-thp4-tp ; scope = adsRead%20历史&amp; lisation = enderent ,然后单击“箭头”按钮,授权代码已发送到您的Web应用程序,并且访问令牌和刷新令牌被检索为以下。

      {“ access_token”:“ ###”,“ token_type”:“ bearer”,“ expires_in”:86400,“ refresh_token”:“ ###”,“ scope”,“ scope”:“ adsread历史”}
     

注意:

  • 在此修改后的脚本中,它假设您的函数 batcharchiveemail()正常工作。请小心。

  • 如果您禁用V8运行时,我认为可以在没有上述修改的情况下使用脚本。但是在这种情况下,循环的过程成本将变得很高。 ref ref 在此上

  • 在这种情况下,Web应用程序的设置必须为执行为:ME 谁可以访问该应用程序:任何人 for New IDE。请小心。

I believe your goal is as follows.

  • By accessing the authorization URL like https://www.reddit.com/api/v1/authorize?client_id=CLIENT_ID&response_type=code&state=RANDOM_STRING&redirect_uri=REDIRECT_URL&duration=DURATION&scope=SCOPE_STRING with your browser, you want to retrieve the access token using Web Apps created by Google Apps Script.

In this case, the request of the following curl command is run by Google Apps Script by retrieving the authorization code.

 curl -X POST https://www.reddit.com/api/v1/access_token \\
   -H 'content-type: application/x-www-form-urlencoded' \\
   -A 'CLIENT_NAME' \\
   -u CLIENT_ID:APP_SECRET \\
   -d 'grant_type=authorization_code&code=CODE&redirect_uri=REDIRECT_URL'

In this case, how about the following sample script of Web Apps?

Sample script:

function doGet(e) {
  const clientId = "###"; // Please set your client ID.
  const secret = "###"; // Please set your secret.
  const redirectUrl = "https://script.google.com/macros/s/###/exec"; // Please set your Web Apps URL that you are using it as the redirect URL.

  const url = "https://www.reddit.com/api/v1/access_token";
  const params = {
    method: "post",
    headers: { "Authorization": "Basic " + Utilities.base64Encode(`${clientId}:${secret}`) },
    payload: {
      "code": e.parameter.code,
      "grant_type": "authorization_code",
      "redirect_uri": redirectUrl
    }
  };
  const res = UrlFetchApp.fetch(url, params);
  return ContentService.createTextOutput(res.getContentText());
}
  • After you set the variables in the script, please reflect the modified script to the Web Apps.

  • In this script, when you access your authorization URL of https://www.reddit.com/api/v1/authorize?client_id=xxxxxxxxxxxx&response_type=code&redirect_uri=https%3A%2F%2Fscript.google.com%2Fmacros%2Fd%2F1Nh3AKooeG8XH4rSTvEWLTf5l3Sgo3nPgK01qiusSany43fFNaUgg2q6b%2Fusercallback&state=ADEpC8xyajUigAfm1arE-N3gjrw-OLvI08gR23Y1ouQJpLpGtZ6ZPWTcpQRa8kW79ABqkxha1B8d90tb8B4eianNmJjFgzKzjCGwdxJ8lpDUdyNF7YjNq_3ak8d6Co_arPUDuP-BnbH0qRSwuEacP2Zif4wTt- YapR8VBbrkhr0tc6aScewnQPe9sCsOccRK6dITZ2SWFP_ZNA5rd03uP-f2HRJfMEoRMPFFLzvfYs9CvgDbzIopee4k_6jqiEg02zK_BuQSOijkUweB3oBTGpcQxHsU1QcRmXoXuzjucN8uF8M_MbWKhOhO-69g9rnKcHmH-Cto_hgnP8-53tn_ViCsqM2xf2dQ_w&scope=adsread%20history&duration=permanent and click "Arrow" button, the authorization code is sent to your Web Apps, and the access token and the refresh token are retrieved as follows.

      {"access_token": "###", "token_type": "bearer", "expires_in": 86400, "refresh_token": "###", "scope": "adsread history"}
    

Note:

  • In this modified script, it supposes that your function batchArchiveEmail() works fine. Please be careful about this.

  • If you disable the V8 runtime, I thought that the script might be worked without the above modification. But in that case, the process cost of the loop will become high. Ref By this, I would like to introduce this workaround.

  • In this case, the setting of Web Apps is required to be Execute as: Me and Who has access to the app: Anyone for new IDE. Please be careful about this.

无法使用气体从Reddit API获取访问令牌

落叶缤纷 2025-02-17 11:39:59

如文档中所述

options: {
  plugins: {
    legend: {
      labels: {
        font: {
          size: 20
        }
      }
    }
  }
}

As described in the docs you can set the size in the options.plugins.legend.labels.font.size namespace

options: {
  plugins: {
    legend: {
      labels: {
        font: {
          size: 20
        }
      }
    }
  }
}

如何在图表的传说中增加字体大小。

落叶缤纷 2025-02-17 06:47:07

将每个值推入数组,然后使用 .join()制作逗号限制的字符串。

const response = {
  chartstatus: [{
      abs_status: "Bekerja",
      total: "12"
    },
    {
      abs_status: "Tanpa Keterangan",
      total: "5"
    },
    {
      abs_status: "Hari Libur",
      total: "1"
    }
  ]
}

let nama_status = [];
let jumlah = [];

$.each(response.chartstatus, function(key, value) {
  status = value.abs_status.toString();
  nama_status.push('"' + status + '"');
  jumlah.push(value.total)

});
console.log(nama_status.join(', ')); 
console.log(jumlah.join(', '));
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

Push each value into an array and then use .join() to make a comma-delimited string.

const response = {
  chartstatus: [{
      abs_status: "Bekerja",
      total: "12"
    },
    {
      abs_status: "Tanpa Keterangan",
      total: "5"
    },
    {
      abs_status: "Hari Libur",
      total: "1"
    }
  ]
}

let nama_status = [];
let jumlah = [];

$.each(response.chartstatus, function(key, value) {
  status = value.abs_status.toString();
  nama_status.push('"' + status + '"');
  jumlah.push(value.total)

});
console.log(nama_status.join(', ')); 
console.log(jumlah.join(', '));
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

json对象成逗号分隔的字符串

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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