清音悠歌

文章 评论 浏览 28

清音悠歌 2025-02-06 17:34:09

您在这里所做的只是定义一个函数,该函数复制已传递到其中的数组的内容。您需要调用功能
验证具有适当的值。

const results = []

const validate = arr => {
  for(let i = 0; i < arr.length; i++){
    results.push(arr[i])
  }

}
validate([1,2,3,4,5,6,7,8]);
console.log(results);

What you have done here is simply define a function that copies the contents of the array that has been passed into it. You need to call the function
validate with the appropriate value.

const results = []

const validate = arr => {
  for(let i = 0; i < arr.length; i++){
    results.push(arr[i])
  }

}
validate([1,2,3,4,5,6,7,8]);
console.log(results);

通过阵列循环时,我希望将元素推向新数组。但是数组保持空

清音悠歌 2025-02-06 16:16:50

想到了几种解决方案:

  1. 将依赖项转移到容器中,首先
  2. 使您的其他服务在外部访问中,并与外部IP连接
  3. 您的容器,而无需网络隔离
  4. 避免通过网络连接,请使用安装的套接字作为音量,而是

原因。这是不合时宜的,默认情况下,容器以其自己的网络名称空间运行。这意味着Localhost(或指向回环接口的127.0.0.1)是每个容器唯一的。连接到此,将连接到容器本身,而不是在Docker之外或其他Docker容器内部运行的服务。

选项1 :如果您的依赖性可以移至容器中,我将首先执行此操作。当其他人试图在自己的环境上运行您的容器时,它使您的应用程序堆栈可移植。您仍然可以在主机上发布端口,其中未迁移的其他服务仍然可以达到。您甚至可以将端口发布到Docker主机上的Localhost接口,以避免使用以下语法在外部访问: -p 127.0.0.0.1:3306:3306 已发布的端口。

选项2 :有多种方法可以从容器内部检测主机IP地址,但是每个方案都有有限的情况(例如,需要Mac的Docker)。最便携的选项是将主机IP注入包含环境变量或配置文件之类的内容,例如:

docker run --rm -e "HOST_IP=$(ip route get 1 | sed -n 's/^.*src \([0-9.]*\) .*$/\1/p')" ...

这确实要求您的服务在该外部接口上侦听,这可能是安全问题。对于其他方法从容器内部获取主机IP地址,请参阅此帖子

便携式稍小,是使用 host.docker.internal 。这在当前版本的Windows docker和Mac的Docker中起作用。在20.10中,当您通过以下特殊主机条目时,该功能已添加到Linux的Docker中:

docker run --add-host host.docker.internal:host-gateway ...

主机-Gateway 是Docker 20.10中添加的特殊值,该值将自动扩展到主机IP。有关更多详细信息,请参见此pr

选项3 :在没有网络隔离的情况下运行,即使用 - NET HOST 运行,表示您的应用程序正在主机网络名称空间上运行。对于容器而言,这是不太隔离的,这意味着您无法通过具有DNS的共享Docker网络访问其他容器(而是需要使用已发布的端口来访问其他容器化应用程序)。但是,对于需要访问主机上其他仅在 127.0.0.0.1 上侦听其他服务的应用程序,这可能是最简单的选项。

选项4 :各种服务还允许访问基于文件系统的套接字。该插座可以作为绑定的插入体积安装到容器中,从而可以访问主机服务而无需越过网络。对于访问Docker引擎,您经常看到安装/var/run/docker.sock 进入容器中的示例(使该容器root访问主机)。使用MySQL,您可以尝试 -v/var/run/mysqld/mysqld.sock:/var/run/mysqld/mysql.sock ,然后连接到 localhost MySQL使用套接字转换为。

Several solutions come to mind:

  1. Move your dependencies into containers first
  2. Make your other services externally accessible and connect to them with that external IP
  3. Run your containers without network isolation
  4. Avoid connecting over the network, use a socket that is mounted as a volume instead

The reason this doesn't work out of the box is that containers run with their own network namespace by default. That means localhost (or 127.0.0.1 pointing to the loopback interface) is unique per container. Connecting to this will connect to the container itself, and not services running outside of docker or inside of a different docker container.

Option 1: If your dependency can be moved into a container, I would do this first. It makes your application stack portable as others try to run your container on their own environment. And you can still publish the port on your host where other services that have not been migrated can still reach it. You can even publish the port to the localhost interface on your docker host to avoid it being externally accessible with a syntax like: -p 127.0.0.1:3306:3306 for the published port.

Option 2: There are a variety of ways to detect the host IP address from inside of the container, but each have a limited number of scenarios where they work (e.g. requiring Docker for Mac). The most portable option is to inject your host IP into the container with something like an environment variable or configuration file, e.g.:

docker run --rm -e "HOST_IP=$(ip route get 1 | sed -n 's/^.*src \([0-9.]*\) .*$/\1/p')" ...

This does require that your service is listening on that external interface, which could be a security concern. For other methods to get the host IP address from inside of the container, see this post.

Slightly less portable is to use host.docker.internal. This works in current versions of Docker for Windows and Docker for Mac. And in 20.10, the capability has been added to Docker for Linux when you pass a special host entry with:

docker run --add-host host.docker.internal:host-gateway ...

The host-gateway is a special value added in Docker 20.10 that automatically expands to a host IP. For more details see this PR.

Option 3: Running without network isolation, i.e. running with --net host, means your application is running on the host network namespace. This is less isolation for the container, and it means you cannot access other containers over a shared docker network with DNS (instead, you need to use published ports to access other containerized applications). But for applications that need to access other services on the host that are only listening on 127.0.0.1 on the host, this can be the easiest option.

Option 4: Various services also allow access over a filesystem based socket. This socket can be mounted into the container as a bind mounted volume, allowing you to access the host service without going over the network. For access to the docker engine, you often see examples of mounting /var/run/docker.sock into the container (giving that container root access to the host). With mysql, you can try something like -v /var/run/mysqld/mysqld.sock:/var/run/mysqld/mysql.sock and then connect to localhost which mysql converts to using the socket.

从Docker容器的内部,如何连接到机器的本地主机?

清音悠歌 2025-02-06 15:32:47

您忘了将ID属性添加到视频标签中。尝试以下操作:

<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" style="mc-template-page: 
url('..\Resources\TemplatePages\Home-Page.flmsp');">
    <head>
    </head>
    <body>
        <p>
            <video id="video1" MadCap:HTML5Video="true" MadCap:Param_controls="false" MadCap:Param_loop="false" MadCap:Param_muted="false" src="../Resources/Multimedia/Aruba_Coral.webm" MadCap:Param_autoplay="true">
            </video>
            <script type="text/javascript">
                var video1 = document.getElementById('video1');
                
                video1.onended = function(e) {
                    window.location.replace('http://www.hpe.com');
                }
            </script>
        </p>
    </body>
</html>

You forgot to add the id attribute to the video tag. Try this :

<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" style="mc-template-page: 
url('..\Resources\TemplatePages\Home-Page.flmsp');">
    <head>
    </head>
    <body>
        <p>
            <video id="video1" MadCap:HTML5Video="true" MadCap:Param_controls="false" MadCap:Param_loop="false" MadCap:Param_muted="false" src="../Resources/Multimedia/Aruba_Coral.webm" MadCap:Param_autoplay="true">
            </video>
            <script type="text/javascript">
                var video1 = document.getElementById('video1');
                
                video1.onended = function(e) {
                    window.location.replace('http://www.hpe.com');
                }
            </script>
        </p>
    </body>
</html>

视频结束后重定向

清音悠歌 2025-02-06 01:02:01

它看起来像元帅。getActiveObject在基于.net Core的.NET版本中消失了。
但是我在另一个论坛上找到了一个简单的解决方案。

using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;

public static partial class MarshalForCore
{
    internal const String OLEAUT32 = "oleaut32.dll";
    internal const String OLE32 = "ole32.dll";

    [System.Security.SecurityCritical]
    public static Object GetActiveObject(String progID)
    {
        Object obj = null;
        Guid clsid;

        try
        {
            CLSIDFromProgIDEx(progID, out clsid);
        }
        catch (Exception)
        {
            CLSIDFromProgID(progID, out clsid);
        }

        GetActiveObject(ref clsid, IntPtr.Zero, out obj);
        return obj;
    }

    [DllImport(OLE32, PreserveSig = false)]
    [ResourceExposure(ResourceScope.None)]
    [SuppressUnmanagedCodeSecurity]
    [System.Security.SecurityCritical]
    private static extern void CLSIDFromProgIDEx([MarshalAs(UnmanagedType.LPWStr)] String progId, out Guid clsid);

    [DllImport(OLE32, PreserveSig = false)]
    [ResourceExposure(ResourceScope.None)]
    [SuppressUnmanagedCodeSecurity]
    [System.Security.SecurityCritical]
    private static extern void CLSIDFromProgID([MarshalAs(UnmanagedType.LPWStr)] String progId, out Guid clsid);

    [DllImport(OLEAUT32, PreserveSig = false)]
    [ResourceExposure(ResourceScope.None)]
    [SuppressUnmanagedCodeSecurity]
    [System.Security.SecurityCritical]
    private static extern void GetActiveObject(ref Guid rclsid, IntPtr reserved, [MarshalAs(UnmanagedType.Interface)] out Object ppunk);
}

可以像这样使用:

using xl = Microsoft.Office.Interop.Excel;
...
    try
    {
        var excelApp = (xl.Application)MarshalForCore.GetActiveObject("Excel.Application");
        if (excelApp != null)
        {
            var wb = excelApp.ActiveWorkbook;

            xl.Worksheet? sh = null;
            foreach (xl.Worksheet _ in wb.Worksheets) 
              if (_.Name == "MyTable") 
              { 
                sh = _; 
                break; 
              };

            if (sh == null)
            {
                sh = (xl.Worksheet)wb.Worksheets.Add();
                sh.Name = "MyTable";
            }
            sh.Cells[1, 1] = "Hello World";
        }
    }
    catch
    {
        // Excel is not running.
    }
}

It looks like Marshal.GetActiveObject is gone in newer .NET Core based .NET versions.
But I found a simple solution on another forum.

using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;

public static partial class MarshalForCore
{
    internal const String OLEAUT32 = "oleaut32.dll";
    internal const String OLE32 = "ole32.dll";

    [System.Security.SecurityCritical]
    public static Object GetActiveObject(String progID)
    {
        Object obj = null;
        Guid clsid;

        try
        {
            CLSIDFromProgIDEx(progID, out clsid);
        }
        catch (Exception)
        {
            CLSIDFromProgID(progID, out clsid);
        }

        GetActiveObject(ref clsid, IntPtr.Zero, out obj);
        return obj;
    }

    [DllImport(OLE32, PreserveSig = false)]
    [ResourceExposure(ResourceScope.None)]
    [SuppressUnmanagedCodeSecurity]
    [System.Security.SecurityCritical]
    private static extern void CLSIDFromProgIDEx([MarshalAs(UnmanagedType.LPWStr)] String progId, out Guid clsid);

    [DllImport(OLE32, PreserveSig = false)]
    [ResourceExposure(ResourceScope.None)]
    [SuppressUnmanagedCodeSecurity]
    [System.Security.SecurityCritical]
    private static extern void CLSIDFromProgID([MarshalAs(UnmanagedType.LPWStr)] String progId, out Guid clsid);

    [DllImport(OLEAUT32, PreserveSig = false)]
    [ResourceExposure(ResourceScope.None)]
    [SuppressUnmanagedCodeSecurity]
    [System.Security.SecurityCritical]
    private static extern void GetActiveObject(ref Guid rclsid, IntPtr reserved, [MarshalAs(UnmanagedType.Interface)] out Object ppunk);
}

This can be used like so:

using xl = Microsoft.Office.Interop.Excel;
...
    try
    {
        var excelApp = (xl.Application)MarshalForCore.GetActiveObject("Excel.Application");
        if (excelApp != null)
        {
            var wb = excelApp.ActiveWorkbook;

            xl.Worksheet? sh = null;
            foreach (xl.Worksheet _ in wb.Worksheets) 
              if (_.Name == "MyTable") 
              { 
                sh = _; 
                break; 
              };

            if (sh == null)
            {
                sh = (xl.Worksheet)wb.Worksheets.Add();
                sh.Name = "MyTable";
            }
            sh.Cells[1, 1] = "Hello World";
        }
    }
    catch
    {
        // Excel is not running.
    }
}

C#Excel如何使用已经打开的工作簿

清音悠歌 2025-02-05 22:33:12

您犯的错误是,您在Tojson中通过列表,但还需要将它们转换为JSON。因此,您的任务类应该是:

class Task {
  String title;
  String owner;
  DateTime time;

  List<AssignedTask> assignedTask;

  Task({
      required this.title,
      required this.owner,
      required this.time,
      required this.assignedTask});

  Map<String, dynamic> toJson() {
      return {
          'title': title,
          'owner': owner,
          'time': time,
          'assignedTask': assignedTask.map(a => a.toJson()).toList(),
      };
  };
}

The mistake you are making is, you are passing a list in toJson, but they also need to be converted to json. So your Task class should be like:

class Task {
  String title;
  String owner;
  DateTime time;

  List<AssignedTask> assignedTask;

  Task({
      required this.title,
      required this.owner,
      required this.time,
      required this.assignedTask});

  Map<String, dynamic> toJson() {
      return {
          'title': title,
          'owner': owner,
          'time': time,
          'assignedTask': assignedTask.map(a => a.toJson()).toList(),
      };
  };
}

如何在Firebase Firestore中保存对象列表

清音悠歌 2025-02-05 15:20:58

观察: 编辑是代码中的罪魁祸首。由于 iseding 是一个包含 boolean 值的全局变量。因此,在编辑时,您正在更新对所有任务影响的ISEDITION的值。

解决方案:而不是在全球范围内定义ISEDSED,您可以在任务数组的每个对象中添加ISEDITIT。这样您就可以不适合每个任务更新单击任务的值。

您的模板代码将为

<section class="TaskBox" v-if="!tasks.isEditing">

而不是

<section class="TaskBox" v-if="!isEditing">

Observation : isEditing is a culprit in your code. As isEditing is a global variable containing boolean value. Hence, On edit you are updating the value of isEditing which impact for all the tasks.

Solution : Instead of defining isEditing globally, You can add isEditing in each object of Task array. So that you can just update the value of clicked task not for every task.

Your template code will be :

<section class="TaskBox" v-if="!tasks.isEditing">

instead of

<section class="TaskBox" v-if="!isEditing">

在vue js的帮助下,我正在显示所有元素,我想从中隐藏一个元素,但所有元素都变得隐藏

清音悠歌 2025-02-05 08:08:26

时间是输入

如果您不考虑时间为输入值,请考虑到您这样做之前,这是一个重要的概念-John Carmack

安排您的设计,以便您可以检查决定要做什么的复杂逻辑>独立于实际这样做。

设计实际做的部分,以使它们“如此简单,显然没有缺陷”。偶尔或作为系统测试的一部分检查该代码 - 这些测试仍然可能是“慢”的,但它们不会阻碍(因为您找到了一种更有效的方法来减轻“决策和反馈之间的差距”)。

Time is an input

If you don't consider time an input value, think about it until you do -- it is an important concept -- John Carmack

Arrange your design so that you can check the complicated logic of deciding what to do independently from actually doing it.

Design the actually doing it parts such that they are "so simple there are obviously no deficiencies". Check that code occasionally, or as part of your system testing - those tests are still potentially going to be "slow", but they aren't going to be in the way (because you've found a more effective way to mitigate "the gap between decision and feedback").

在最短时间内执行单位测试用例的选项

清音悠歌 2025-02-05 04:11:30

请不要覆盖Python类型。给您的 str 变量另一个名称,而不是 str

也许尝试查找@google.com 喜欢这样: re.findall(r'@\ w+\。\ w+',your_string)

Please do not overwrite python types. Give your str variable another name than str.

Maybe try finding @google.com like this: re.findall(r'@\w+\.\w+', your_string)

分析字符串并在Python中打印

清音悠歌 2025-02-05 02:24:11

截至今天,似乎在运行酿造过时的 BREW UPGRADE 时,Flutter与较旧版本的比较不再发生。

It seems, as of today, Flutter's comparison with older versions is no longer happening when running brew outdated or brew upgrade.

自制 - 升级木桶时试图降级自己

清音悠歌 2025-02-04 19:48:28

尽管您是SQL的新手,但您的数据结构不过是麻烦。查询可以完成吗?是的,但是更难。我首先想提出一种替代您必须识别“组”的替代方法。创建第二个小组表,然后将所有公司与该集团相关联。您甚至可以在小组中拥有一些清晰文本的内容

CompanyGroups
CompanyGroupID  CompanyGroupName
1               Eastern Group
2               Northern Group
3               Technical Group
4               Furniture Group

Then the companies
SourceCompanyId  CompanyGroupID
4626             3
359468           3
7999             3
56167            4
11947            4

,例如每个公司和已知组有一个记录。

如果公司可能可能与多个组相关联,则您也可以每公司和替代组都有其他记录。

现在,回到定期安排的程序和您的查询。您需要拥有一个“共同”组,因此所有目标都关联,包括 该组中的基础源公司,例如您的4626是源头,而359468、7999中的其他两个则在相同的。它在另一个答案上扩展了,但迫使最左边的ID进入主要位置。

select distinct
      SourceCompanyID as GrpParent,
      SourceCompanyID as IncludedCompany
   from
      CompanyGroup cg
UNION
select
      cgParent.SourceCompanyID as GrpParent,
      cgTarget.TargetCompanyId as IncludedCompany
   from
      CompanyGroup cgParent
         JOIN CompanyGroup cgTarget
            on cgParent.SourceCompanyID = cgTarget.SourceCompanyID

请注意,即使它们与其他五个目标相关联,查询的第一部分即使它们与 source 也获得。由于复制来源,我们不想重复计数。它拥有自己的身份证,作为父母的公司,该公司将被包括在整个小组中。

第二个再次以同一父母的身份开始,但获得了 target 作为所包含的公司。因此,基于您的数据

SourceCompanyId  TargetCompanyId
4626             359468
4626             7999
56167            11947

将结果产生

GrpParent   IncludedCompany
-- first the distinct portion before union
4626        4626
56167       56167
-- now the union portion
4626        359468
4626        7999
56167       11947

,您可以看到五个总记录和4626“组”显示所有三个公司ID,包括右侧的所有三个公司ID,同样对于56167每个公司的公司右侧各自。

现在,您应该能够加入小组的数据求和,而不会引起重复的聚合。

select
      CompGrps.GrpParent,
      sum( CompSales.Sales ) as GroupTotalSales
   from
      ( select distinct
              SourceCompanyID as GrpParent,
              SourceCompanyID as IncludedCompany
           from
              CompanyGroup cg
        UNION
        select
              cgParent.SourceCompanyID as GrpParent,
              cgTarget.TargetCompanyId as IncludedCompany
           from
              CompanyGroup cgParent
                 JOIN CompanyGroup cgTarget
                    on cgParent.SourceCompanyID = cgTarget.SourceCompanyID
       ) as CompGrps
         JOIN
         ( SELECT
                 s.CompanyId,
                 SUM(s.Sales) AS Sales
              FROM
                 Sales s
             group by
                 s.CompanyId ) CompSales
            on CompGrps.IncludedCompany = CompSales.CompanyID
   group by
      CompGrps.GrpParent
   order by
      sum( CompSales.Sales ) desc

因此,请注意,第一个查询获得了不同的集团公司,并且可以从其自身的销售中进行的辅助查询可以在自身的公司ID上加入,但基于共同的小组父母的总结,因此给出了每个组的外部级别。

我还通过进行了简单的订单,以使最大的销售额排序。如您所见,现有结构有点混乱,但可以完成。

输出应该看起来像

GrpParent  GroupTotalSales
4626       2900       (4626 had 1600, 359468 had 800, and 7999 had 500)
56167      1300       (56167 had 1000, 11947 had 300)

Although you are new to SQL, your data structure as it is will be nothing but trouble. Can the query be done? Yes, but harder. I would first like to suggest an alternative to what you have to identify "groups". Create a second table of groups, then have all companies associated with said group. You could even have some clear-text content of the group such as

CompanyGroups
CompanyGroupID  CompanyGroupName
1               Eastern Group
2               Northern Group
3               Technical Group
4               Furniture Group

Then the companies
SourceCompanyId  CompanyGroupID
4626             3
359468           3
7999             3
56167            4
11947            4

So, there is one record per company and the known group associated.

If a company can possibly be associated with multiple groups, you could have additional records per company and alternate group as well.

Now, back to the regularly scheduled program and your query. You need to have one "common" group so all targets are associated, including the underlying source company in the group, such as your 4626 was the source, and the other two of 359468, 7999 are in the same. It expands on the other answer, but forces the left-most ID into a primary position.

select distinct
      SourceCompanyID as GrpParent,
      SourceCompanyID as IncludedCompany
   from
      CompanyGroup cg
UNION
select
      cgParent.SourceCompanyID as GrpParent,
      cgTarget.TargetCompanyId as IncludedCompany
   from
      CompanyGroup cgParent
         JOIN CompanyGroup cgTarget
            on cgParent.SourceCompanyID = cgTarget.SourceCompanyID

Notice the first part of the query is getting the source once even if they are associated with five other targets. We don’t want to duplicate counts because of duplicate sources. It holds its own ID as both the parent and the company to be included as part-of the group.

The second starts again with the same parent, but gets the target as the included company. So, based on your data

SourceCompanyId  TargetCompanyId
4626             359468
4626             7999
56167            11947

Would result as

GrpParent   IncludedCompany
-- first the distinct portion before union
4626        4626
56167       56167
-- now the union portion
4626        359468
4626        7999
56167       11947

And you can see the five total records and the 4626 "Group" shows all three company IDs including itself on the right-side, similarly for 56167 having two entries with each respective on the included companies right-side.

Now with this, you should be able to join the summation of data by the GROUP and not cause duplicated aggregations.

select
      CompGrps.GrpParent,
      sum( CompSales.Sales ) as GroupTotalSales
   from
      ( select distinct
              SourceCompanyID as GrpParent,
              SourceCompanyID as IncludedCompany
           from
              CompanyGroup cg
        UNION
        select
              cgParent.SourceCompanyID as GrpParent,
              cgTarget.TargetCompanyId as IncludedCompany
           from
              CompanyGroup cgParent
                 JOIN CompanyGroup cgTarget
                    on cgParent.SourceCompanyID = cgTarget.SourceCompanyID
       ) as CompGrps
         JOIN
         ( SELECT
                 s.CompanyId,
                 SUM(s.Sales) AS Sales
              FROM
                 Sales s
             group by
                 s.CompanyId ) CompSales
            on CompGrps.IncludedCompany = CompSales.CompanyID
   group by
      CompGrps.GrpParent
   order by
      sum( CompSales.Sales ) desc

So notice the first query getting distinct group companies, and the secondary querying from its own per-company sales can be joined on the company ID of itself, but summed based on the common group parent, thus giving totals the the outer level per GROUP.

I also tacked on a simple order by to get largest sales sorted at the top. As you can see, it's a bit messier with existing structure, but can be done.

The output should look something like

GrpParent  GroupTotalSales
4626       2900       (4626 had 1600, 359468 had 800, and 7999 had 500)
56167      1300       (56167 had 1000, 11947 had 300)

根据映射加入表并总和特定数据

清音悠歌 2025-02-04 19:29:47

当然,您可以使用 sys.columns 将静态列从表2返回,并将它们与表1中的动态列进行比较,并在选择第一行的选择中使用 unvivot

我发现,将所有这些包装在T-SQL块中并插入两个列表中的临时表要容易得多,然后将数据类型冲突引起的比较(可能是通过使用铸件解决)

BEGIN
  DECLARE @table1 TABLE (colname VARCHAR(MAX))
  DECLARE @table2 TABLE (colname VARCHAR(MAX))

  INSERT INTO @table1 SELECT COLNAME FROM (SELECT a, b, c FROM TABLE1 WHERE...first row condition) a UNPIVOT (COLNAME FOR COLS IN ([a],[b],[c])) a

  INSERT INTO @table2 SELECT CAST (name  AS NVARCHAR(100)) name FROM sys.columns WHERE object_id = OBJECT_ID('TABLE2')


  SELECT a.colname cols1, b.colname cols2 
    FROM @table2 a
    FULL OUTER JOIN @table1 b ON (a.colname = b.colname)
END

您可以轻松更改最终选择以返回的最终选择。你想要什么

You certainly could use sys.columns to return your static columns from Table2 and compare them to the dynamic columns in Table1 and use UNPIVOT on a select of your first row.

I have found that it was far easier to wrap this all in a T-SQL block and insert to two lists into temp tables before comparing due to data type conflicts (probably be solved by using CAST)

BEGIN
  DECLARE @table1 TABLE (colname VARCHAR(MAX))
  DECLARE @table2 TABLE (colname VARCHAR(MAX))

  INSERT INTO @table1 SELECT COLNAME FROM (SELECT a, b, c FROM TABLE1 WHERE...first row condition) a UNPIVOT (COLNAME FOR COLS IN ([a],[b],[c])) a

  INSERT INTO @table2 SELECT CAST (name  AS NVARCHAR(100)) name FROM sys.columns WHERE object_id = OBJECT_ID('TABLE2')


  SELECT a.colname cols1, b.colname cols2 
    FROM @table2 a
    FULL OUTER JOIN @table1 b ON (a.colname = b.colname)
END

You can easily change the final select to return what you want

SQL查询以将动态列标题与另一个静态表列进行比较

清音悠歌 2025-02-04 13:21:09

如果使用继承,则编译器可以将添加的成员变量放在填充中:

#include <iostream>

class A
{
  int x;
  bool y;
};

class Original : public A
{
  bool z;
};

int main() {
    std::cout << sizeof(Original) << std::endl;
}

输出:8

注意:如果您将所有成员和继承公开公开,那么原来甚至将是汇总类型。

If you use inheritance the compiler can place the added member variables in the padding:

#include <iostream>

class A
{
  int x;
  bool y;
};

class Original : public A
{
  bool z;
};

int main() {
    std::cout << sizeof(Original) << std::endl;
}

Output: 8

Note: if you make all members and inheritance public then Original will even be an aggregate type.

如何构造数据而不由于对齐而膨胀大小?

清音悠歌 2025-02-04 08:37:08

如何访问控制器中的应用程序对象?

直接回答您的问题。

  1. 将应用程序实例保存到应用程序 init 方法中的静态变量。
  2. 提供静态登录方法访问它。

这有点像单身模式,但是应用程序实例是由启动方法创建的。

public class AccessibleApp extends Application {
    private static AccessibleApp applicationInstance;

    public static AccessibleApp getApplicationInstance() {
        return applicationInstance;
    }

    @Override
    public void init() {
        applicationInstance = this;
    }

    // other app functionality ...

    public static void main(String[] args) {
        launch(args);
    }
}

然后,可以使用以下类别从任何类访问该应用程序:

AccessibleApp.getApplicationInstance()

示例代码和方法

  1. 您不应创建另一个应用程序实例。

    abougn() method的调用来创建。

    启动()方法只能为JVM进程调用一次。

  2. 在应用程序类中绝不应该有 @fxml 注释。

    @fxml 仅在控制器中使用,应用程序类也不应为控制器。

  3. 您的整体方法不正确:

    在Hellocontroller中,我想收听按钮点击,然后在HelloApplcation内部执行方法

    您不应该这样做。

    应用程序类负责应用程序生命周期。除非它是一个琐碎的独立hello世界风格应用程序,否则它不应该做其他事情。绝对不应为FXML控制器回调提供服务。

建议的方法

直接在控制器或专用服务类中执行应用程序逻辑。

  1. 编写一个具有用于计数器值和时间表的整数属性的计数类。
  2. 在班上提供开始和停止方法,请勿为此使用字符串状态。
  3. 在控制器中,创建一个计数器实例,然后在用户交互中启动并停止它。
  4. 在控制器初始化方法中,绑定显示字段文本< /a>到计数器值。

我建议您不必尝试调试和修复您的当前代码,而是建议您改用建议的方法。

要更多地了解此类方法,请参见:

How can I access the Application object in Controller?

To directly answer your question.

  1. Save the application instance to a static variable in the application init method.
  2. Provide a static accessor method to access it.

This is kind of like a singleton pattern, but the application instance is created by the launch method.

public class AccessibleApp extends Application {
    private static AccessibleApp applicationInstance;

    public static AccessibleApp getApplicationInstance() {
        return applicationInstance;
    }

    @Override
    public void init() {
        applicationInstance = this;
    }

    // other app functionality ...

    public static void main(String[] args) {
        launch(args);
    }
}

Then the application can be accessed from any class using:

AccessibleApp.getApplicationInstance()

Issues with your sample code and approach

  1. You should not create another application instance.

    The application lifecycle javadoc notes there should be only one application instance in the JVM and this will be created by the invocation of the launch() method.

    The launch() method can only be called once for the JVM process.

  2. There should never be an @FXML annotation in an Application class.

    @FXML is only used in a controller and the application class should not also be a controller.

  3. Your overall approach is incorrect:

    in HelloController I want to listen to button clicks which then execute methods inside the HelloApplcation

    You should not do this.

    The application class is responsible for the application lifecycle. Unless it is a trivial self-contained hello world style application, it should not be doing anything else. It definitely should not be servicing fxml controller callbacks.

Recommended Approach

Perform your application logic either directly in the controller or in a dedicated service class.

  1. Write a Counter class that has an integer property for the counter value and a timeline.
  2. Provide start and stop methods on the class, do not use a string status for that.
  3. In the controller create a Counter instance and start and stop it on user interaction.
  4. In the controller initialize method, bind the display field text to the counter value.

Rather than trying to debug and fix your current code, I recommend you work on implementing the suggested approach instead.

To understand such approaches more, see:

Javafx如何在控制器中访问应用程序对象?

清音悠歌 2025-02-04 01:44:04

不确定熊猫中是否有一个功能可以做到这一点。 )与OS.Walk(Directory)组合使用时应尽力而为

  • 但是,将方法os.rename ( -subdirectories in-the-the-current-directory“>获取当前目录中所有子目录的列表
  • os.rename()

Not sure there is a function in pandas to do that. However the method os.rename() should do the trick when used in combination with os.walk(directory):

使用熊猫重命名文件夹

清音悠歌 2025-02-03 18:47:20

我只会单独进行Intialize count 变量,并在循环时使用 time_machine_text.split() time_machine_text.split()。例如:

count = 0
words = time_machine_text.split()
while count < len(words):
    word = words[count]
    if "weena" in word:
        print(count)
    count += 1

编辑:这是使用find()函数的版本

count = 0
words = time_machine_text.split()
while count < len(words):
    word = words[count]
    if word.find("weena") != -1:
        print(count)
    count += 1

I would just intialize count variable separately and use while loop to iterate through time_machine_text.split(). For example:

count = 0
words = time_machine_text.split()
while count < len(words):
    word = words[count]
    if "weena" in word:
        print(count)
    count += 1

Edit: This is the version using find() function

count = 0
words = time_machine_text.split()
while count < len(words):
    word = words[count]
    if word.find("weena") != -1:
        print(count)
    count += 1

在一段时间内使用python的find()来返回字符串中的单词索引

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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