大姐,你呐

文章 评论 浏览 28

大姐,你呐 2025-02-14 08:12:53

尝试以下操作:


        label1_2 = QtWidgets.QLabel(self.centralwidget)
        label1_2.setObjectName("label1")
        label1_2.setText("Uploaded files: ")
        self.grid1.addWidget(label1_2, 1, 1)
        self.labels = []
        self.labels.append(label1_2)
        #---------------------------------------------------------------------------------------------------------

        self.setCentralWidget(self.centralwidget)
        self.retranslateUi(self)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "Data quality controller"))



    def open_mdb1(self):
        mdb_paths1, _ = QFileDialog.getOpenFileNames(
            self.centralwidget,'Select file','./','Access Files (*.mdb *.accdb)'
        )
        total = len(mdb_paths1)
        num_labels = len(self.labels)
        for i in range(total):
            if i < num_labels:
                label = self.labels[i]
                label.setText(mdb_paths1[i])
            else:
                label = QLabel(self.centralwidget)
                label.setText(mdb_paths1[i])
                self.grid1.addWidget(label,self.grid1.rowCount(), 1)
                self.labels.append(label)

Try this:


        label1_2 = QtWidgets.QLabel(self.centralwidget)
        label1_2.setObjectName("label1")
        label1_2.setText("Uploaded files: ")
        self.grid1.addWidget(label1_2, 1, 1)
        self.labels = []
        self.labels.append(label1_2)
        #---------------------------------------------------------------------------------------------------------

        self.setCentralWidget(self.centralwidget)
        self.retranslateUi(self)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "Data quality controller"))



    def open_mdb1(self):
        mdb_paths1, _ = QFileDialog.getOpenFileNames(
            self.centralwidget,'Select file','./','Access Files (*.mdb *.accdb)'
        )
        total = len(mdb_paths1)
        num_labels = len(self.labels)
        for i in range(total):
            if i < num_labels:
                label = self.labels[i]
                label.setText(mdb_paths1[i])
            else:
                label = QLabel(self.centralwidget)
                label.setText(mdb_paths1[i])
                self.grid1.addWidget(label,self.grid1.rowCount(), 1)
                self.labels.append(label)

如何在标签中求解覆盖文本 - &gt; PYQT标签?

大姐,你呐 2025-02-14 02:36:17

这是一些相对较新的代码中的错误,可以加快基础函数crosspairs.ppp()。在使用spatstat.geom的新版本之前,您可以通过设置spatstat.options(“ crosspairs.newcode” = false)如所建议的。

This is a bug in some relatively new code to speed up the underlying function crosspairs.ppp(). Until a new version of spatstat.geom is available you can workaround the problem by setting spatstat.options("crosspairs.newcode" = FALSE) as suggested.

KCROSS和CROSSPAIRS中的SpatStat Integer溢出误差

大姐,你呐 2025-02-14 02:17:47

可能您需要一个bridging-header.h然后导入iOS标头:

#import "iOS/ADBMobile.h"

Possibly you need a Bridging-Header.h then import your iOS header as:

#import "iOS/ADBMobile.h"

访问用XCFramework包裹的静态库

大姐,你呐 2025-02-13 20:25:51

行= ['123','456','789']

1.使用列表理解,地图功能和lambda
2.在字符串列表

结果=列表中重新定位子字符串=列表(MAP(Lambda ST:str.Replace(ST,“ 3”,“ 0”),行))))))
结果 - &gt; ['120','456','789']

rows = ['123', '456', '789']

1.using list comprehension, map function and lambda
2.Replace substring in list of strings

result = list(map(lambda st: str.replace(st, "3", "0"), rows))
result -> ['120', '456', '789']

如何在Python中的字符串列表中修改特定的子字符串?

大姐,你呐 2025-02-13 19:04:30

您在readfile函数中使用回调。您需要将async版本用于readdir

  const { readdir } = require('fs/promises')

let filesToMove = [];

async function readFiles() {
  const testFolder = "./files_to_move/";
   
  const files = await readdir(testFolder)
  files.forEach((file) => {
     filesToMove.push(file);
     console.log("done");
  });
}

async function printFiles() {
  await readFiles();

  console.log(filesToMove.length);
 filesToMove.forEach((item) => {
    console.log(item);
 });
}

You using callback in readFile function. You need to use the async version for readdir.

  const { readdir } = require('fs/promises')

let filesToMove = [];

async function readFiles() {
  const testFolder = "./files_to_move/";
   
  const files = await readdir(testFolder)
  files.forEach((file) => {
     filesToMove.push(file);
     console.log("done");
  });
}

async function printFiles() {
  await readFiles();

  console.log(filesToMove.length);
 filesToMove.forEach((item) => {
    console.log(item);
 });
}

在node.js中使用等待

大姐,你呐 2025-02-13 14:11:47

我从本教程中学到了: https://github.com/github.com/jnyh/pytube/ blob/master/pytube_sample_code.ipynb

我使用了以下2种方法,它们都为我工作:

audio = ffmpeg.input('audio.mp3')
video = ffmpeg.input('video.mp4')

ffmpeg.output(audio, video, 'my_file.mp4').run()

ffmpeg.concat(video, audio, v=1, a=1).output('my_file.mp4').run(overwrite_output=True)

I learnt from this tutorial: https://github.com/JNYH/pytube/blob/master/pytube_sample_code.ipynb

I used below 2 ways and they both worked for me:

audio = ffmpeg.input('audio.mp3')
video = ffmpeg.input('video.mp4')

ffmpeg.output(audio, video, 'my_file.mp4').run()

or

ffmpeg.concat(video, audio, v=1, a=1).output('my_file.mp4').run(overwrite_output=True)

使用python中的ffmpeg合并音频和视频

大姐,你呐 2025-02-13 10:45:24

没有XSL的版本:分析弦如下。它使用一个单独的文件存储CodePoint/String关系。

因此,在此示例中,一个称为codes.xml的文件包含映射(必须先将HEX值转换为十进制 - 这里已经完成)

<CharKey>
    <Char cp="8209"  string="hyphen" />
    <Char cp="61623" string="page" />
</CharKey>

: 3.0,但它与XSLT-2.0一起使用,也可以在字符串的编码点上进行一些次要修改):

<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" omit-xml-declaration="yes"/>    
    <xsl:variable name="codes" select="document('codes.xml')/CharKey" />
    <!-- text() node is matched here -->   
    <xsl:template match="/Record/Text">
        <xsl:variable name="cps" select="string-to-codepoints(.)" />
        <xsl:for-each select="$cps">
            <xsl:variable name="curCP" select="$codes/Char[@cp=current()]" />
            <xsl:choose>
                <xsl:when test="$curCP"><xsl:processing-instruction name="xxx" expand-text="yes">character output="{$curCP/@string}"</xsl:processing-instruction></xsl:when>
                <xsl:otherwise><xsl:value-of select="codepoints-to-string(.)" /></xsl:otherwise>
            </xsl:choose>                
        </xsl:for-each>
    </xsl:template>
    
</xsl:stylesheet>

这可以进一步简化,但是作为示例,它应该可以工作。

样本的

<Record>
    <Text>Hello‑End</Text>
</Record>

输出是

Hello<?xxx character output="hyphen"?><?xxx character output="page"?>End

A version without xsl:analyze-string is the following. It uses a separate file to store the codepoint/string relations.

So, in this example, a file called codes.xml contains the mapping(the hex values have to be converted to decimal first - here this is already done):

<CharKey>
    <Char cp="8209"  string="hyphen" />
    <Char cp="61623" string="page" />
</CharKey>

And the stylesheet (here it is XSLT-3.0, but it works with XSLT-2.0 also with some minor modifications) iterates over the codepoint of the string:

<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" omit-xml-declaration="yes"/>    
    <xsl:variable name="codes" select="document('codes.xml')/CharKey" />
    <!-- text() node is matched here -->   
    <xsl:template match="/Record/Text">
        <xsl:variable name="cps" select="string-to-codepoints(.)" />
        <xsl:for-each select="$cps">
            <xsl:variable name="curCP" select="$codes/Char[@cp=current()]" />
            <xsl:choose>
                <xsl:when test="$curCP"><xsl:processing-instruction name="xxx" expand-text="yes">character output="{$curCP/@string}"</xsl:processing-instruction></xsl:when>
                <xsl:otherwise><xsl:value-of select="codepoints-to-string(.)" /></xsl:otherwise>
            </xsl:choose>                
        </xsl:for-each>
    </xsl:template>
    
</xsl:stylesheet>

This could be further simplified, but as an example it should work.
The sample's

<Record>
    <Text>Hello‑End</Text>
</Record>

output is

Hello<?xxx character output="hyphen"?><?xxx character output="page"?>End

XSLT 2-将单个字符转换为处理 - 指导

大姐,你呐 2025-02-13 06:22:53

层次结构分离器包含在list响应中。请参阅例如 rfc 显示出IMAP服务器响应,例如IMAP服务器响应此:

* LIST (\Noselect) "/" ~/Mail/foo

响应的第二个字段(“/”)是层次结构分隔符。

在Python中,调用list方法有效地为您提供了原始IMAP响应。请回想一下列表返回(状态,数据)元组,因此:

>>> res = server.list()
>>> res[0]
'OK'
>>> len(res[1])
83

如果我们在响应中在邮箱中进行邮箱:

>>> res[1][0]
b'(\\HasNoChildren) "/" "INBOX"'

我们在预期的位置找到邮箱分离器。

解析这将需要一些工作; imaplib没有提供任何解析IMAP响应的设施(至少它并没有持续到我看),因此您必须弄清楚如何提取该值。

The hierarchy separator is included in the LIST response. See e.g. the RFC, which shows an IMAP server response like this:

* LIST (\Noselect) "/" ~/Mail/foo

The second field of the response ("/") is the hierarchy separator.

In Python, calling the list method effectively gives you the raw IMAP response. Recall that list returns a (status, data) tuple, so:

>>> res = server.list()
>>> res[0]
'OK'
>>> len(res[1])
83

If we take at mailbox in the response:

>>> res[1][0]
b'(\\HasNoChildren) "/" "INBOX"'

We find the mailbox separator in the expected location.

Parsing that out will require a little work; imaplib doesn't provide any facilities for parsing IMAP responses (at least, it didn't last I looked), so you'll have to figure out how to extract that value.

一些电子邮件使用 /和一些电子邮件使用。在列出子文件夹时,如何解释这一点?

大姐,你呐 2025-02-12 20:41:12

因此,显然,我正在使用sudo执行命令,并使用另一个用户到pm2 List,这就是为什么我看不到该过程。

So apparently, I'm using sudo to execute the command, and using another user to pm2 list, that's why I cannot see the process.

github动作完成后,PM2停止了我的应用程序

大姐,你呐 2025-02-12 02:08:52

您可以这样使用。

async sendGetRequest(){
  res = await axios.get('https://nba-players.herokuapp.com/players-stats', this.state)
  localStorage.setItem('data', JSON.stringify(res.data));
}

componentDidMount(){
  this.sendGetRequest().then(() => { 
     let result = JSON.parse(localStorage.getItem('data'));
     let playerList = [];
     for (let i = 0; i < 10; i++) {
       playerList[i] = {nome: result[i].name, team: result[i].team_name}
     }
     console.log(playerList)
  }).catch((err) => console.log(err));

 }

You can use it like so.

async sendGetRequest(){
  res = await axios.get('https://nba-players.herokuapp.com/players-stats', this.state)
  localStorage.setItem('data', JSON.stringify(res.data));
}

componentDidMount(){
  this.sendGetRequest().then(() => { 
     let result = JSON.parse(localStorage.getItem('data'));
     let playerList = [];
     for (let i = 0; i < 10; i++) {
       playerList[i] = {nome: result[i].name, team: result[i].team_name}
     }
     console.log(playerList)
  }).catch((err) => console.log(err));

 }

将localstorage数据保存在状态中的对象中

大姐,你呐 2025-02-11 18:36:01

就可以解决第一个问题

class Contact(db.Model):
    __tablename__ = 'contact'

    contactid = db.Column(db.BigInteger, primary_key=True, autoincrement=True, server_default=db.text("nextval('contact_contactid_seq'::regclass)"))
    ...

我认为,将通过设置自动启动= true 第二个问题实际上是正常工作,因为您将表单类定义为这样,

。此外,您想要的查询和sqlalchemy生成的查询是相同的,因为在where子句中的contrentId和集合子句中的contractid中的consctionId相同。

但是,如果要更改查询,请更改模型对象的值。

r = Contact.query.get_or_404(id)
form = ContactForm(obj=r)
    if form.validate_on_submit():
        r.firstname = form.firstname.data
        r.lastname = form.lastname.data
        db.session.commit()
        ...

I think the first problem will be solved by setting autoincrement=True

class Contact(db.Model):
    __tablename__ = 'contact'

    contactid = db.Column(db.BigInteger, primary_key=True, autoincrement=True, server_default=db.text("nextval('contact_contactid_seq'::regclass)"))
    ...

the second problem is actually working properly because you defined the form class like that.

In addition, the query you want and the query generated by SQLAlchemy are the same because the contractid in the where clause and the contractid in the set clause is same.

Nevertheless, if you want to change the query, change the value of the model object.

r = Contact.query.get_or_404(id)
form = ContactForm(obj=r)
    if form.validate_on_submit():
        r.firstname = form.firstname.data
        r.lastname = form.lastname.data
        db.session.commit()
        ...

如何阻止sqlalchemy生成插入或更新主键的SQL?

大姐,你呐 2025-02-11 13:59:11
Future<MesureModel?> postMeasurement(String description) async {
final response = await http.post(
    Uri.parse('${baseUrl}/api/v1/measurements/create'),
headers: {
  'Content-Type': 'application/json',
},
    body: json.encode({"input_description": description}));
var data = response.body;
return MesureModel.fromJson(jsonDecode(response.body));
}

JSON发送之前编码身体

Future<MesureModel?> postMeasurement(String description) async {
final response = await http.post(
    Uri.parse('${baseUrl}/api/v1/measurements/create'),
headers: {
  'Content-Type': 'application/json',
},
    body: json.encode({"input_description": description}));
var data = response.body;
return MesureModel.fromJson(jsonDecode(response.body));
}

Json encode the body before sending

颤动中的形成

大姐,你呐 2025-02-11 13:45:46

尝试以下操作:

df["E"] = np.nan

# Use boolean indexing to set no-yes to placeholder value
df.loc[(df["A"] == "no") & (df["B"] == "yes"), "E"] = "PL"

# Shift placeholder down by one, as it seems from your example
# that you want X to be on the no-yes "stopping" row
df["E"] = df.E.shift(1)

# Then set the X value on the yes-no rows
df.loc[(df.A == "yes") & (df.B == "no"), "E"] = "X"
df["E"] = df.E.ffill() # Fill forward

# Fix placeholders
df.loc[df.E == "PL", "E"] = np.nan

结果:

    A   B   C   D   E
0   no  no  nan nan NaN
1   no  no  nan nan NaN
2   yes no  X   X   X
3   yes no  nan X   X
4   no  no  nan X   X
5   no  yes nan X   X
6   no  yes nan nan NaN
7   yes no  X   X   X
8   no  no  nan X   X
9   yes no  X   X   X
10  yes no  nan X   X
11  no  no  nan X   X
12  no  yes nan X   X
13  no  no  nan nan NaN

Try this:

df["E"] = np.nan

# Use boolean indexing to set no-yes to placeholder value
df.loc[(df["A"] == "no") & (df["B"] == "yes"), "E"] = "PL"

# Shift placeholder down by one, as it seems from your example
# that you want X to be on the no-yes "stopping" row
df["E"] = df.E.shift(1)

# Then set the X value on the yes-no rows
df.loc[(df.A == "yes") & (df.B == "no"), "E"] = "X"
df["E"] = df.E.ffill() # Fill forward

# Fix placeholders
df.loc[df.E == "PL", "E"] = np.nan

Results:

    A   B   C   D   E
0   no  no  nan nan NaN
1   no  no  nan nan NaN
2   yes no  X   X   X
3   yes no  nan X   X
4   no  no  nan X   X
5   no  yes nan X   X
6   no  yes nan nan NaN
7   yes no  X   X   X
8   no  no  nan X   X
9   yes no  X   X   X
10  yes no  nan X   X
11  no  no  nan X   X
12  no  yes nan X   X
13  no  no  nan nan NaN

如何根据其他两个列中的条件创建和填充新列?

大姐,你呐 2025-02-11 10:54:58

我找到了一个解决方案,该解决方案涉及抓住第一个搜索框(Ruby之外)的值并将其作为参数传递。我认为这就是@max关于单独的端点所指的,但我不知道端点是什么。

我仍然不知道如何获得控制器内部范围内所有对象的列表。因此,出于这个原因,我不知道表单数据的范围是否从控制器内部开始。

这是修订后的工作代码,该代码获得了第一个搜索框的值,并在为第二个搜索框的查询中使用它。

首先,获得要添加到参数字符串的值的JavaScript:

document.addEventListener("turbolinks:load", function() {
  
  $input = $('*[name="Description"]')
  var options = {
    url: function(phrase) {
      
      /* Get the value of the payto box */
      var payto = document.getElementById("transaction_PayTo").value;

      return "/quickentry/DescSearch.json?q=" + phrase + "&payto=" + payto ;
    },
    getValue: "Description",
  };

  $input.easyAutocomplete(options);
  console.log("Description function end");

});

以及使用传递参数的代码:

  # search code for the quickentry Description box
  def DescSearch
    q = params[:q]
    payto = params[:payto]
    @transactions = Transaction.select("distinct Description").where( "PayTo = ? and Description like ?", "#{payto}", "#{q}%")
  end

I have found a solution for this which involves grabbing the value of the first search box (outside of Ruby) and passing it in as a parameter. I assume that this was what @max was alluding to about separate endpoints, but I don't know what an endpoint is.

I still don't know how to obtain a list of all objects that are in-scope within the controller. So for that reason, I don't know if the form data is in scope to begin with inside the controller.

Here is the revised working code that obtains the value of the first search box and uses it in the query that feeds the second search box.

First, the javascript that obtains the value to be added to the parameters string:

document.addEventListener("turbolinks:load", function() {
  
  $input = $('*[name="Description"]')
  var options = {
    url: function(phrase) {
      
      /* Get the value of the payto box */
      var payto = document.getElementById("transaction_PayTo").value;

      return "/quickentry/DescSearch.json?q=" + phrase + "&payto=" + payto ;
    },
    getValue: "Description",
  };

  $input.easyAutocomplete(options);
  console.log("Description function end");

});

And the code that uses the passed parameter:

  # search code for the quickentry Description box
  def DescSearch
    q = params[:q]
    payto = params[:payto]
    @transactions = Transaction.select("distinct Description").where( "PayTo = ? and Description like ?", "#{payto}", "#{q}%")
  end

如何从控制器访问用户输入的形式数据

大姐,你呐 2025-02-11 08:08:12

好消息:

  • 原始文本没有保存(您的应用程序中的某个地方)
  • slate.js正在为每种样式呈现一个新元素。多亏了您发布的实时演示链接,很明显,DOM正在保存降价的状态(这表明我们可以在需要时在板岩上添加操作)

坏消息:

  • 实施编辑器是头痛。使用现有的并不总是像我们预期的那样直观和容易。这就是为什么我喜欢摩纳哥编辑项目太多了vs Code免费的经验

简单的方法:

在我们的项目中使用摩纳哥编辑。根据我的经验 - 在编码和格式化技术文本方面,它更好(也许这是vs code的引擎

不太容易的方法:

我们可以进行更简单的实现 - 带有原始文本的面板和另一个用于预览的面板(顺便说一句 - 这正是当您在vs code中编辑Markdown文件无论如何都会发生这种情况。这样,我们总是可以呈现观点以反映我们最近的变化。对于初学者 - 您可以使用这个项目做到这一点,并添加调整,以便适合您的需求

困难的方式:

使用slate.js命令(读取对于一般概念 +有用的示例)。这种方法将使板岩处理负载,但也需要您深入研究该项目。请注意,您可以注册自定义命令和查询以适合您的需求而无需打破工作管道(阅读 this

疯狂的方式

尝试通过在渲染元素上使用自定义事件来覆盖板岩。这可能很棘手,但是如果您喜欢玩即时进行内部设备和注入值的项目,则可以实现。尽管

我的建议

创建一个自定义命令,该命令将应用Markdown样式(例如: BOLD

使用Slate处理程序来跟踪Space 键命中并使用我知道的命令

function onKeyDown(event, editor, next) {
  if (event.key == 'Enter') {
    // TODO: add markdown style 
    editor.applyMarkdownBold() // applyMarkdownBold is a made-up name for your custom command
  } else {
    return next()
  }
}

- 此示例将应用 BOLD 样式对所有文本进行应用,但是 - 如果您将其与range选择相结合,则将获得您的样式需要编辑器中的相关区域(再次 - docs 从这一点开始)

- 通过键按下特定选择或通过单击它添加Markdown字符(使用事件 + Query +命令)只是时间问题

The good news:

  • The original text is saved unharmed (somewhere in your application)
  • Slate.js is rendering a new element for each style. thanks to the live demonstration link you've posted it is clear that the DOM is saving the state of your markdown (which suggest that we can add manipulations on-top of slate if required)

The bad news:

  • Implementing an editor is a headache. Using an existing one is not always as intuitive and easy as we expected. That's why I love the Monaco editor project so much (a free editable editor that gives me the experience of VS code for free? yes please!)

What we can do?

the easy way:

Use Monaco editor in our project. From my experience - it is better in terms of coding and formatting technical texts (and maybe this is the engine behind VS code)

The not-so-easy way:

We can make a simpler implementation - a panel with the raw text and another panel for preview (by the way - this is exactly what happens when you edit markdown files in VS code anyways). That way we can always render the view to reflect our most recent changes. For starters - you can use this project to do it and add tweaks to it so suit your demands

The hard way:

Using slate.js commands (read this doc for the general concept + useful examples). This approach will let slate handle the load but requires you to deep-dive into that project as well. Note that you can register custom commands and queries to suit your need without breaking your work pipeline (read this)

The insane way:

Try to override slate by using custom events on-top of rendered elements. This can be tricky but achievable if you love to play with projects internals and inject values on the fly. Not very recommended though

My Recommendation

Create a custom command that will apply the markdown style you want (for instance: bold)

Use slate handler for tracking the space key hit and use your command

function onKeyDown(event, editor, next) {
  if (event.key == 'Enter') {
    // TODO: add markdown style 
    editor.applyMarkdownBold() // applyMarkdownBold is a made-up name for your custom command
  } else {
    return next()
  }
}

I know - this example will apply bold style to all text but - if you combine it with a range selection you will get the style you need for the relevant area in you editor (again - docs for the rescue)

From this point - applying a specific selection via key press or adding the markdown characters by clicking it (using an event + query + command) is only a matter of time

使用slate.js实现实时降压渲染

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

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