走过海棠暮

文章 评论 浏览 25

走过海棠暮 2024-09-01 10:36:14

除非你把事情命名得很奇怪,否则我会说错误是你试图从 ListBox 中获取 ListViewItem 。

Unless you named things weird I'd say the error is that you're trying to get a ListViewItem from a ListBox.

C# 列表框标签问题

走过海棠暮 2024-09-01 07:15:15

我无法重现该行为(使用 php 5.3.2/win32 + firefox 作为第二个示例的客户端)。

$request = '<?xml version="1.0"?> <data_root>  <data>  <info>value</info>  </data>  <action>value</action> </data_root>';
$reader = new XMLReader();
$reader->XML($request);
while($reader->read()){
  echo $reader->nodeType, " ";
}
$reader->close();

打印 1 14 1 14 1 3 15 14 15 14 1 3 15 14 15
$_REQUEST['xml'] 真的包含您期望的内容吗?

编辑:或者另一个实际

<?php
if ( isset($_REQUEST['xml']) ) {
  $request = $_REQUEST['xml'];
  $reader = new XMLReader();
  $reader->XML($request);
  while($reader->read()){
    echo $reader->nodeType, " ";
  }
  $reader->close();
  die;
}
$pre = htmlspecialchars(
'<?xml version="1.0"?>
  <data_root>
    <data> 
      <info>value</info>
    </data> 
  <action>value</action>
</data_root>');
?>
<html><head><title>....</title></head><body>
  <form method="post" action="?">
    <div>
      <textarea cols="25" rows="8" name="xml"><?php echo $pre; ?></textarea>
      <br />
      <input type="submit" />
    </div>
  </form>
</body></html>

再次使用 _REQUEST 的示例 1 14 1 14 1 3 15 14 15 14 1 3 15 14 15 在提交表单时打印。

I cannot reproduce the behavior (using php 5.3.2/win32 + firefox as the client for the second example).

$request = '<?xml version="1.0"?> <data_root>  <data>  <info>value</info>  </data>  <action>value</action> </data_root>';
$reader = new XMLReader();
$reader->XML($request);
while($reader->read()){
  echo $reader->nodeType, " ";
}
$reader->close();

prints 1 14 1 14 1 3 15 14 15 14 1 3 15 14 15.
Does $_REQUEST['xml'] really contain what you expect it to?

edit: Or another example that actually uses _REQUEST

<?php
if ( isset($_REQUEST['xml']) ) {
  $request = $_REQUEST['xml'];
  $reader = new XMLReader();
  $reader->XML($request);
  while($reader->read()){
    echo $reader->nodeType, " ";
  }
  $reader->close();
  die;
}
$pre = htmlspecialchars(
'<?xml version="1.0"?>
  <data_root>
    <data> 
      <info>value</info>
    </data> 
  <action>value</action>
</data_root>');
?>
<html><head><title>....</title></head><body>
  <form method="post" action="?">
    <div>
      <textarea cols="25" rows="8" name="xml"><?php echo $pre; ?></textarea>
      <br />
      <input type="submit" />
    </div>
  </form>
</body></html>

again 1 14 1 14 1 3 15 14 15 14 1 3 15 14 15 is printed when the form is submitted.

使用 PHP XMLReader 解析 XML

走过海棠暮 2024-09-01 06:57:53

另一个选项是:

find . -name "*.cpp" | xargs grep some_string

如果您想将搜索限制为特定的文件模式或类型。使用find,您还可以指定搜索的最大深度。

Another option is:

find . -name "*.cpp" | xargs grep some_string

if you want to restrict the search to particular file patterns or types. With find, you can also specify the maximum depth to search.

我想找到其中字符串的文件列表(在某个目录下,递归地)被写成

走过海棠暮 2024-09-01 05:03:08

是的,字符串的字典顺序格式为yyyy-mm-dd hh: ii:ss 按预期工作。您甚至可以像这样对日期进行排序。

$dts = array(
  '1000-01-01 00:00:00',
  '2010-03-16 21:22:19',
  '1000-01-01 00:00:10',
  '1976-03-27 05:55:00', 
  '1976-03-27 05:54:00',
  '1968-08-21 12:00:00',
  '2001-01-01 00:00:01'
);

sort($dts);
foreach($dts as $dt) {
  echo $dt, "\n";
}

1000-01-01 00:00:00
1000-01-01 00:00:10
1968-08-21 12:00:00
1976-03-27 05:54:00
1976-03-27 05:55:00
2001-01-01 00:00:01
2010-03-16 21:22:19

请记住,对于格式不正确的字符串,您将不会收到任何反馈。因此,如果可能存在格式错误的字符串,您最好也检查一下。如果这不是问题,则 string1>string2 就可以了。

编辑:你甚至可以让 MySQL 来做这项工作。这是否比在 php 中更好/等于/更差取决于您实际想要实现的目标。例如

$pdo = new PDO("mysql:host=localhost;dbname=test", 'localonly', 'localonly'); 
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// setting up a sample table with some values
$pdo->exec('CREATE TEMPORARY TABLE foo (id int auto_increment, d datetime NOT NULL, primary key(id))');
$pdo->exec("INSERT INTO foo (d) VALUES ('1000-01-01 00:00:00'),('2010-03-16 21:22:19'),('1000-01-01 00:00:10'),('1976-03-27 05:55:00')");


$query = "
  SELECT
    d,
    (d>'1910-03-17 12:00:00') as flag
  FROM
    foo
";

foreach ( $pdo->query($query) as $row ) {
  echo $row['flag'] ? '+ ':'- ', $row['d'], "\n";
}

印刷品

- 1000-01-01 00:00:00
+ 2010-03-16 21:22:19
- 1000-01-01 00:00:10
+ 1976-03-27 05:55:00

Yes, the lexicographical order of strings in the format yyyy-mm-dd hh:ii:ss works as intended. You could even sort dates like that.

$dts = array(
  '1000-01-01 00:00:00',
  '2010-03-16 21:22:19',
  '1000-01-01 00:00:10',
  '1976-03-27 05:55:00', 
  '1976-03-27 05:54:00',
  '1968-08-21 12:00:00',
  '2001-01-01 00:00:01'
);

sort($dts);
foreach($dts as $dt) {
  echo $dt, "\n";
}

prints

1000-01-01 00:00:00
1000-01-01 00:00:10
1968-08-21 12:00:00
1976-03-27 05:54:00
1976-03-27 05:55:00
2001-01-01 00:00:01
2010-03-16 21:22:19

But keep in mind that you will get no feedback for strings that are not in the right format. So, if it could be that there are malformed strings you'd better check that, too. If that is not a concern, string1>string2 is ok.

edit: You could even let MySQL do the work. If this is better/equal/worse to doing it in php depends on what you're actually trying to achieve. E.g.

$pdo = new PDO("mysql:host=localhost;dbname=test", 'localonly', 'localonly'); 
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// setting up a sample table with some values
$pdo->exec('CREATE TEMPORARY TABLE foo (id int auto_increment, d datetime NOT NULL, primary key(id))');
$pdo->exec("INSERT INTO foo (d) VALUES ('1000-01-01 00:00:00'),('2010-03-16 21:22:19'),('1000-01-01 00:00:10'),('1976-03-27 05:55:00')");


$query = "
  SELECT
    d,
    (d>'1910-03-17 12:00:00') as flag
  FROM
    foo
";

foreach ( $pdo->query($query) as $row ) {
  echo $row['flag'] ? '+ ':'- ', $row['d'], "\n";
}

prints

- 1000-01-01 00:00:00
+ 2010-03-16 21:22:19
- 1000-01-01 00:00:10
+ 1976-03-27 05:55:00

MySQL DATETIME 格式比较 - 是否需要 strtotime?

走过海棠暮 2024-08-31 23:29:33

我不确定您是否可以直接在通知图标上设置工具提示。这与在通知图标本身上设置文本属性是一样的。通知图标文本有一些限制。它的长度限制为 128 个字符,并且只会保留很短的时间。如果您想在更长的时间内显示更多信息,您应该查看通知图标的气球文本属性。我强烈建议您阅读 MSDN 页面,它非常有帮助。

http://msdn.microsoft.com/en-我们/library/system.windows.forms.notifyicon.aspx

I'm not sure you can set a tooltip directly on a notify icon. It's the same thing as setting the text property on the notify icon itself. There are some limitations to the notify icon text. It's limited to 128 chars and will only stay up for a short amount of time. If you want to display more info for a longer amount of time you should look at the balloon text property of the notify icon. I highly suggest reading the MSDN page it's quite helpful.

http://msdn.microsoft.com/en-us/library/system.windows.forms.notifyicon.aspx

组合 NotifyIcon 和 ToolTip

走过海棠暮 2024-08-31 22:22:14

使用 withRootName。

objectMapper.writer().withRootName(MyPojo.class.getName());

use withRootName.

objectMapper.writer().withRootName(MyPojo.class.getName());

使用类名作为 JSON Jackson 序列化的根键

走过海棠暮 2024-08-31 21:38:12

您需要将从文件中读取的对象转换为向量:

private static Vector<Countries> loadOB(String sFname) throws ClassNotFoundException, IOException {
        ObjectInputStream oStream = new ObjectInputStream(new FileInputStream(sFname));
        try{
          Object object = oStream.readObject();
          if (object instanceof Vector)
              return (Vector<Countries>) object;
          throw new IllegalArgumentException("not a Vector in "+sFname);
        }finally{
           oStream.close();
        }
     }

请注意,您无法检查它是否真的是国家向量(无法一一检查内容)。

You need to cast the object that you read from the file to Vector:

private static Vector<Countries> loadOB(String sFname) throws ClassNotFoundException, IOException {
        ObjectInputStream oStream = new ObjectInputStream(new FileInputStream(sFname));
        try{
          Object object = oStream.readObject();
          if (object instanceof Vector)
              return (Vector<Countries>) object;
          throw new IllegalArgumentException("not a Vector in "+sFname);
        }finally{
           oStream.close();
        }
     }

Note that you cannot check if it is really a Vector of Countries (short of checking the contents one by one).

如何返回 Vector java

走过海棠暮 2024-08-31 18:59:12

无论哪种方式都是完全有效且良好的(两个示例都确保使用 var 关键字声明变量),但通常最好的做法是在当前代码块的顶部声明您的变量,如第二个例子。

Either way is perfectly valid and fine (both examples ensure that the variable is declared with the var keyword), but generally it's best practice to declare your vars at the top of the current code block, as in your second example.

VS2008中变量声明警告

走过海棠暮 2024-08-31 18:54:42

如果你很优秀,为什么不出一点名呢?谁知道,如果雇用您的人没有使用/参与开源项目,您从一开始就会受到更多重视?

If you are good, why not get a little famous? Who knows, if person hiring you is not using/participating in open source project and you'll be valued more from the start?

开源身份与现实生活中的身份

走过海棠暮 2024-08-31 16:03:40

Linux系统(在Ubuntu 18.04上尝试)

安装acpi模块经过
sudo apt install acpi

运行 acpi -V 应该会为您提供大量有关系统的信息。现在我们只需要通过python获取温度值即可。

import os
os.system("acpi -V > output.txt")
battery = open("output.txt", "r")
info = battery.readline()
val = info.split()
percent4real = val[3]
percentage = int(percent4real[:-1])
print(percentage)

percentage 变量将为您提供温度。
因此,首先我们将 acpi -V 命令的输出放入文本文件中,然后读取它。由于数据都是String类型,我们需要将其转换为整数。

  • 注意:此命令在 WSL 中使用时不会显示 CPU 温度

For Linux systems(Tried on Ubuntu 18.04)

Install the acpi module by
sudo apt install acpi

Running acpi -V should give you a ton of info about your system. Now we just need to get the temperature value via python.

import os
os.system("acpi -V > output.txt")
battery = open("output.txt", "r")
info = battery.readline()
val = info.split()
percent4real = val[3]
percentage = int(percent4real[:-1])
print(percentage)

The percentage variable will give you the temperature.
So, first we take the output of the acpi -V command in a text file and then read it. We need to convert it into an integer since the data is all in String type.

  • Note: This command does not display CPU temperature when used in WSL

使用Python获取CPU温度?

走过海棠暮 2024-08-31 14:16:51

在开始阅读标准化之前,直到您对此完全没有疑问为止。如果你只在学校做过这件事,那么你可能还不够了解它,无法进行设计。

仔细收集您对每个模块的要求。您需要了解:

业务规则(特定于应用程序并且必须在数据库中强制执行,因为无论来源如何,它们都必须对所有记录强制执行),

是否存在法律或监管问题(例如 HIPAA 或 Sarbanes-Oxley 要求) )
安全性(数据需要加密吗?)

您需要存储什么数据以及为什么(这些数据在其他地方是否可用)

哪些数据只有一行数据,哪些数据需要多行?

您打算如何强制每个表中行的唯一性?您有自然键还是需要代理键(在几乎所有情况下都建议使用代理键)?

需要复制吗?

需要审核吗?

数据如何输入数据库?它是来自应用程序一次一条记录(甚至来自多个应用程序),还是其中一些来自 ETL 工具或另一个数据库的批量插入。

您是否需要知道谁输入了记录以及何时输入(这在企业系统中很可能是必要的。您

需要什么样的查找表?当您可以使用查找表并将用户限制为 ?

什么样的数据验证?

您需要知道要创建多大的测试数据

您需要 procs 或 ORM 或动态查询?

在设计中要记住一些非常基本的事情。不要在字符串字段中存储要进行数学运算的日期或数字。对于数学(零件号、邮政编码、电话号码等)作为字符串数据,因为您可能需要前导零,因此不要在字段中存储多条信息。相关表),当您发现自己在做诸如phone1、phone2、phone 3之类的事情时,请立即停止并设计一个相关表。出于数据完整性目的,请务必使用外键。

在整个设计过程中都要考虑数据完整性。没有完整性的数据是没有意义和无用的。进行性能设计,这在数据库设计中至关重要,而不是过早的优化。数据库不容易重构,因此第一次就获得性能方程中最关键的部分是很重要的。事实上,所有数据库都需要针对数据完整性、性能和安全性进行设计。

不要害怕有多个连接,正确索引这些将表现得很好。不要尝试将所有内容放入实体值类型表中。尽可能少用这些。尝试学会从处理数据集的角度思考,这将有助于您的设计。数据库经过优化可以成组执行操作。

还有更多,但这足以开始消化。

Before you start read up on normalization until you have no questions about it at all. If you only did this in school, you probably don't know enough about it to design yet.

Gather your requirements for each module carefully. You need to know:

Business rules (which are specific to applications and which must be enforced in the database because they must be enforced on all records no matter the source),

Are there legal or regulatory concerns (HIPAA for instance or Sarbanes-Oxley requirements)
security (does data need to be encrypted?)

What data do you need to store and why (is this data available anywhere else)

Which pieces of data will only have one row of data and which will need to have multiple rows?

How do you intend to enforce uniqueness of the the row in each table? Do you have a natural key or do you need a surrogate key (suggest a surrogate key in almost all cases)?

Do you need replication?

Do you need auditing?

How is the data going to be entered into the database? Will it come from the application one record at a time (or even from multiple applications)or will some of it come from bulk inserts from an ETL tool or from another database.

Do you need to know who entered the record and when (highly likely this will be necessary in an enterprise system.

What kind of lookup tables will you need? Data entry is much more accurate when you can use lookup tables and restrict the users to the values.

What kind of data validation do you need?

Roughly how many records will the system have? You need to have an idea to know how big to create your test data.

How are you going to query the data? Will you be using stored procs or an ORM or dynamic queries?

Some very basic things to remember in your design. Choose the right data type for your data. Do not store dates or numbers you intend to do math on in string fields. Do store numbers that are not candidates for math (part numbers, zip codes, phone numbers, etc) as string data as you may need leading zeros. Do not store more than one piece of information in a field. So no comma-concatenated lists (these indicate the need for a related table) and while you are at it if you find yourself doing something like phone1, phone2, phone 3, stop right away and design a related table. Do use foreign keys for data integrity purposes.

All the way through your design consider data integrity. Data that has no integrity is meaningless and useless. Do design for performance, this is critical in database design and is NOT premature optimization. Database do not refactor easily, so it is important to get the most critical parts of the performance equation right the first time. In fact all databases need to be designed for data integrity, performance and security.

Do not be afraid to have multiple joins, properly indexed these will perform just fine. Do not try to put everything into an entity value type table. Use these as sparingly as possible. Try to learn to think in terms of handling sets of data, it will help your design. Databases are optimized to do things in sets.

There's more but this is enough to start digesting.

寻找数据库设计示例的好地方 - 最佳实践

走过海棠暮 2024-08-31 13:25:22

你可以这样做:

<% #if DEBUG %>
<div id="debug"></div>
<% #else %>
<div id="release"></div>
<% #endif %>

虽然我认为它的可读性不是很好......仅在需要时才使用它!

You can do this:

<% #if DEBUG %>
<div id="debug"></div>
<% #else %>
<div id="release"></div>
<% #endif %>

Though it's not very readable in my opinion...use it only if needed!

是否可以有 ASP.NET 注释的条件编译?

走过海棠暮 2024-08-31 12:54:42

这就是我的做法:

css文件:

ul.makeMenu, ul.makeMenu ul {
    background-color:#000000;
    cursor:default;
    margin:0px 0px 0px 0px;
    padding:0px 0px 0px 0px;
    width: 180px;
}
ul.makeMenu li {
    background-image:url(../images/marker_rosu.gif);
    background-position:5px center;
    background-repeat:no-repeat;
    color:#D4020B;/*#FEBF01;*/
    list-style-type:none;
    position:relative;
    margin:0px 0px 0px 0px;
    padding:0px 5px 0px 15px;
    line-height:24px;
    text-align:left;
}
ul.makeMenu li>ul {
    display:none;
    position:absolute;
    top:0px;
    left:180px;
}
ul.makeMenu li:hover {
    background-image:url(../images/marker_negru.gif);
    background-position:5px center;
    background-repeat:no-repeat;
    background-color:#D4020B;/*#FEBF01;*/
    color:#FFFFFF;
}
ul.makeMenu {
    display:block;
}
ul.makeMenu li:hover>ul {
    display:block;
}
ul.makeMenu li a {
    color:#D4020B;/*#FEBF01;*/
    display:block;
    width:100%;
    text-decoration:none;
}
ul.makeMenu li a:hover {
    color:#000000;
}
ul.makeMenu li:hover>a {
    color:#000000;
}

产品或其他任何类别表的sql文件:

CREATE TABLE `category` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `idParrent` int(10) unsigned NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` varchar(255) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;

以及创建菜单的功能:

function getAFP ($id)
    {
        global $conx;
        $sql = sprintf("SELECT * FROM category WHERE idParrent = %d;", quote_smart($id));
        $rs = mysql_query($sql, $conx);
        $arrayResult = array();
        if (mysql_num_rows($rs)) {
            while ($row = mysql_fetch_array($rs)) {
                array_push($arrayResult, $row);
            }
            return $arrayResult;
        } else {
            return 0;
        }
    }

function makeListaCategory ($id)
    {
        $listaCategorii = array();
        $categorii = getAFP($id);
        if (! $categorii) {
            return 0;
        } else {
            foreach ($categorii as $categorie) {
                array_push($listaCategorii, $categorie[2] . "|" . $categorie[0]);
                $subcategorii = makeListaCategory($categorie[0]);
                if ($subcategorii) {
                    foreach ($subcategorii as $subcategorie) {
                        $valori = explode("|", $subcategorie);
                        array_push($listaCategorii, $categorie[2] . ">" . $valori[0] . "|" . $valori[1]);
                    }
                }
            }
        }
        return $listaCategorii;
    }

我希望这会对您有所帮助!

This is how i do:

The css file:

ul.makeMenu, ul.makeMenu ul {
    background-color:#000000;
    cursor:default;
    margin:0px 0px 0px 0px;
    padding:0px 0px 0px 0px;
    width: 180px;
}
ul.makeMenu li {
    background-image:url(../images/marker_rosu.gif);
    background-position:5px center;
    background-repeat:no-repeat;
    color:#D4020B;/*#FEBF01;*/
    list-style-type:none;
    position:relative;
    margin:0px 0px 0px 0px;
    padding:0px 5px 0px 15px;
    line-height:24px;
    text-align:left;
}
ul.makeMenu li>ul {
    display:none;
    position:absolute;
    top:0px;
    left:180px;
}
ul.makeMenu li:hover {
    background-image:url(../images/marker_negru.gif);
    background-position:5px center;
    background-repeat:no-repeat;
    background-color:#D4020B;/*#FEBF01;*/
    color:#FFFFFF;
}
ul.makeMenu {
    display:block;
}
ul.makeMenu li:hover>ul {
    display:block;
}
ul.makeMenu li a {
    color:#D4020B;/*#FEBF01;*/
    display:block;
    width:100%;
    text-decoration:none;
}
ul.makeMenu li a:hover {
    color:#000000;
}
ul.makeMenu li:hover>a {
    color:#000000;
}

the sql file for products or anything else category table:

CREATE TABLE `category` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `idParrent` int(10) unsigned NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` varchar(255) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;

and the function that create menu:

function getAFP ($id)
    {
        global $conx;
        $sql = sprintf("SELECT * FROM category WHERE idParrent = %d;", quote_smart($id));
        $rs = mysql_query($sql, $conx);
        $arrayResult = array();
        if (mysql_num_rows($rs)) {
            while ($row = mysql_fetch_array($rs)) {
                array_push($arrayResult, $row);
            }
            return $arrayResult;
        } else {
            return 0;
        }
    }

function makeListaCategory ($id)
    {
        $listaCategorii = array();
        $categorii = getAFP($id);
        if (! $categorii) {
            return 0;
        } else {
            foreach ($categorii as $categorie) {
                array_push($listaCategorii, $categorie[2] . "|" . $categorie[0]);
                $subcategorii = makeListaCategory($categorie[0]);
                if ($subcategorii) {
                    foreach ($subcategorii as $subcategorie) {
                        $valori = explode("|", $subcategorie);
                        array_push($listaCategorii, $categorie[2] . ">" . $valori[0] . "|" . $valori[1]);
                    }
                }
            }
        }
        return $listaCategorii;
    }

I hope this will help you!

如何在 php 中迭代 ul 和 li 元素?

走过海棠暮 2024-08-31 10:04:57

加载网站,但添加 no-cache 标头。类似如下:

WebBrowser web = new WebBrowser();
web.Navigate("http://yourURL.com", string.Empty, null, "Pragma: no-cache");

Load the Web site, but add a no-cache header. Something like as follows:

WebBrowser web = new WebBrowser();
web.Navigate("http://yourURL.com", string.Empty, null, "Pragma: no-cache");

将包含图像的内容获取到 Web 浏览器控件中,无需临时文件

走过海棠暮 2024-08-31 06:46:44

一种常见的度量是编辑距离,它是字符串编辑距离的一种特殊情况。它也包含在 apache string util 图书馆

One common measure is the Levenshtein distance, a special case of the string edit distance. It is also included in the apache string util library

百分比相似度分析 (Java)

更多

推荐作者

寻梦旅人

文章 0 评论 0

冰美式不加糖

文章 0 评论 0

m0_51416705

文章 0 评论 0

123456wqwqwq

文章 0 评论 0

qq_R47skh

文章 0 评论 0

hs1283

文章 0 评论 0

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