走过海棠暮

文章 0 评论 0 浏览 24

走过海棠暮 2024-10-16 22:35:08

我认为将语法从 3.1 设置为 2.5 是一个坏主意。只需下载较旧的 python 2.5 版本并使用编译器和库即可。在主要版本之间,API 签名会发生变化,并且会添加新功能。您无法在 pydev 中进行高版本开发并在不遇到问题的情况下编译另一个版本。此外,Python 3.1 向后不兼容 Python 2.x(例如 print 是一个函数),因此如果需要的话,最好下载并使用 Python 2.5。

I think it is a bad idea to set the grammar to 2.5 from 3.1. Just download the older python 2.5 version and use the compiler and the libraries with it. Between major versions changes happen to the API signatures and new features get added. You cannot afford to develop in high version in pydev and compile for another without encountering problem. Moreover Python 3.1 is backwards incompatible with Python 2.x (print is a function for e.g), so it is better you download and use Python 2.5 if that is the requirement.

Python 的版本

走过海棠暮 2024-10-16 01:45:34

经过多次尝试和错误我想通了。如果其他人有同样的问题,我会分享。我编写的这段代码根据产品 ID 从数据库中获取 sku 编号。然后,它通过 xml-rpc 根据 sku 向供应商请求库存水平,获取响应,然后更新数据库中产品 ID 的当前库存水平。

                                //Grab the stock level of the item from supplier server
                $query = sprintf("SELECT prodcode FROM [|PREFIX|]products where productid='%d'",
                $GLOBALS['ISC_CLASS_DB']->Quote($prodId));
        $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
                             $product_sku = mysql_fetch_row($result);
                             $product_sku2 = $product_sku[0];

 $server_url = "http://m.com/fvg/webservices/index.php";

 $request = xmlrpc_encode_request("catalog.getStockQuantity", array($product_sku2));
 $context = stream_context_create(array('http' => array(
 'method' => "POST",
 'header' => "Content-Type: text/xml",
 'content' => $request
 )));
 $file = file_get_contents($server_url, false, $context);
 $response = xmlrpc_decode($file);

                            $query = sprintf("UPDATE [|PREFIX|]products SET prodcurrentinv='$response' where productid='%d'", $GLOBALS['ISC_CLASS_DB']->Quote($prodId)); 
$result = $GLOBALS['ISC_CLASS_DB']->Query($query);

I figured it out after much trial and error. I'll share in case others have the same question. This bit of code I worked out grabs the sku number from the database based on the product ID. Then it requests the stock level from the supplier based on the sku via xml-rpc, gets the response back and then updates the current inventory level in the database for the product id.

                                //Grab the stock level of the item from supplier server
                $query = sprintf("SELECT prodcode FROM [|PREFIX|]products where productid='%d'",
                $GLOBALS['ISC_CLASS_DB']->Quote($prodId));
        $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
                             $product_sku = mysql_fetch_row($result);
                             $product_sku2 = $product_sku[0];

 $server_url = "http://m.com/fvg/webservices/index.php";

 $request = xmlrpc_encode_request("catalog.getStockQuantity", array($product_sku2));
 $context = stream_context_create(array('http' => array(
 'method' => "POST",
 'header' => "Content-Type: text/xml",
 'content' => $request
 )));
 $file = file_get_contents($server_url, false, $context);
 $response = xmlrpc_decode($file);

                            $query = sprintf("UPDATE [|PREFIX|]products SET prodcurrentinv='$response' where productid='%d'", $GLOBALS['ISC_CLASS_DB']->Quote($prodId)); 
$result = $GLOBALS['ISC_CLASS_DB']->Query($query);

如何使用 xml-rpc 中的数据更新数据库表?

走过海棠暮 2024-10-16 01:08:52

假设您确实有权访问头文件或具有标识函数及其参数的文档 - 这是它的样子

假设函数如下
int Func1 (int i1, int i2);
无效 Func2(无效);

现在下面是示例代码

#include windows.h  
#include stdio.h  
// use either dumpbin or http://www.dependencywalker.com/ to confirm the functions  
//Let us assume it has two functions with their prototypes known - Func1 & Func2  
int Func1 (int i1, int i2);  
void Func2(void);  
typedef int (*FUNC1_PTR) (int, int);  
typedef void (*FUNC2_PTR) (void);  
const char NONAME_DLL[] = "some.dll";  
int main(int argc, char *argv[]) {  
    FUNC1_PTR f1;  
    //FUNC2_PTR F2;  
    int i= 1, j = 2;  
    HMODULE hMod = LoadLibrary(NONAME_DLL);  
    if (!hMod) {  
        printf("LoadLibrary fails with error code %d \n", GetLastError());  
        return 1;  
    }  
    f1 = (FUNC1_PTR) GetProcAddress(hMod, "Func1");  
    if (f1) {  
        int ret = (*f1)(i, j);  
    }  
    FreeLibrary (hMod);  
    return 0;  
}  

如果您无权访问头文件或不知道函数签名 - 可能没有什么方法可以继续
- 运行一个使用此函数的程序,并在调用此函数时使用调试器中断并查看它的作用。
- 使用交互式反汇编程序(例如IDA Pro),它可以显示签名元素,例如向函数传递了多少参数。
- 反汇编函数以分析其序言和尾声。耗时且不是一项微不足道的任务,更重要的是因为不同的编译器、不同的调用约定、优化的代码加壳器等等。
- 我听人们说他们使用过 winedump - 你可以在这里查看 http://www. winehq.org/docs/winedump - 但我从未使用过它。 Nirsoft.net 的 DLL Export Viewer 或许是另一个工具。
- 这也是另一个工具 - Visual dumpbin 使用 UnDecorateSymbolName,该工具可在 http://code.entersources.com/f/Visual-Dumpbin-AC--Visual-GUI-for-Dumpbin_2_1671_0.aspx。 DLL 必须由 MS 编译器构建。检查此链接可能会给您更多线索,...

Assuming that you do have access to a header file or have documentation that identifies the function and their parameters - here is what it looks like

Assume that the functions are as follows
int Func1 (int i1, int i2);
void Func2(void);

Now what follows is the example code

#include windows.h  
#include stdio.h  
// use either dumpbin or http://www.dependencywalker.com/ to confirm the functions  
//Let us assume it has two functions with their prototypes known - Func1 & Func2  
int Func1 (int i1, int i2);  
void Func2(void);  
typedef int (*FUNC1_PTR) (int, int);  
typedef void (*FUNC2_PTR) (void);  
const char NONAME_DLL[] = "some.dll";  
int main(int argc, char *argv[]) {  
    FUNC1_PTR f1;  
    //FUNC2_PTR F2;  
    int i= 1, j = 2;  
    HMODULE hMod = LoadLibrary(NONAME_DLL);  
    if (!hMod) {  
        printf("LoadLibrary fails with error code %d \n", GetLastError());  
        return 1;  
    }  
    f1 = (FUNC1_PTR) GetProcAddress(hMod, "Func1");  
    if (f1) {  
        int ret = (*f1)(i, j);  
    }  
    FreeLibrary (hMod);  
    return 0;  
}  

If you do not have access to the header file or know the functions signature - there are perhaps few ways to proceed
- Run a program which uses this function and break with a debugger when this function is called and see what it does.
- Use interactive disassembler (for example, IDA Pro), it can show the signature elements such as how many parameters are passed into a function.
- Disassembling the function to analyze its prologue and epilogue. Time consuming and not a trivial task, more so because of the different compilers, different calling conventions, optimized code packers, and so on.
- I have heard people say that they have used winedump - you can check it out here http://www.winehq.org/docs/winedump - I have never used it though. Nirsoft.net's DLL Export Viewer is perhaps another tool.
- Also this is another tool- Visual dumpbin that uses UnDecorateSymbolName, the tool is available at http://code.entersources.com/f/Visual-Dumpbin-A-C--Visual-GUI-for-Dumpbin_2_1671_0.aspx. The DLL must be built by MS compiler. Check this link might give you some more clues, ...

如何在 C++ 中使用非托管 DLL win32应用程序?

走过海棠暮 2024-10-15 16:57:04

您至少可以在Windows下尝试NETLink

In[1]:= Needs["NETLink`"]
matlab = CreateCOMObject["matlab.application"]

Out[2]= «NETObject[COMInterface[MLApp.DIMLApp]]»

然后您可以调用Matlab函数:

In[4]:= matlab@Execute["version"]

Out[4]= "
ans =

7.9.0.529 (R2009b)

"

In[5]:= matlab@Execute["a=2"]

matlab@Execute["a*2"]

Out[5]= "
a =

     2

"

Out[6]= "
ans =

     4

"

HTH

You can try NETLink for this at least under Windows:

In[1]:= Needs["NETLink`"]
matlab = CreateCOMObject["matlab.application"]

Out[2]= «NETObject[COMInterface[MLApp.DIMLApp]]»

And then you can invoke Matlab functions:

In[4]:= matlab@Execute["version"]

Out[4]= "
ans =

7.9.0.529 (R2009b)

"

In[5]:= matlab@Execute["a=2"]

matlab@Execute["a*2"]

Out[5]= "
a =

     2

"

Out[6]= "
ans =

     4

"

HTH

如何从mathematica调用matlab函数?

走过海棠暮 2024-10-15 13:11:11

MoveFile 功能确实是你想要的。从文档中:

MoveFile函数将在同一目录中或跨目录移动(重命名)文件或目录(包括其子目录)。

如果源位置和目标位置位于同一卷上,则执行原子重命名操作。如果它们位于不同的卷上,则改为执行复制/删除操作(这是您能做的最好的操作)。

The MoveFile function is indeed what you want. From the documentation:

The MoveFile function will move (rename) either a file or a directory (including its children) either in the same directory or across directories.

If the source and destination locations are both on the same volume, then an atomic rename operation is performed. If they're on different volumes, then a copy/delete operation is done instead (this is the best you can do).

用于在 C 中重命名文件的 Win32 API

走过海棠暮 2024-10-15 10:19:04

尝试使用以下正则表达式“^\d+$”

try to use following regExp "^\d+$"

验证文本框仅包含数字

走过海棠暮 2024-10-15 09:47:57

如果您使用的是 JQuery...(此处安装说明: http://jquery.com/

$(document).ready(function(){ 
    if( window == window.top) { $('form#myform').hide(); }
});

这只是隐藏了如果窗口不是最顶层的窗口,则表单的 ID 为“myform”。

If you are using JQuery... (installation instructions here: http://jquery.com/ )

$(document).ready(function(){ 
    if( window == window.top) { $('form#myform').hide(); }
});

Which just hides the form with id "myform" if the window is not the topmost window.

检测这是 iframe 加载还是直接加载

走过海棠暮 2024-10-15 09:21:19

经过很多努力我已经解决了这个问题。绑定 DataGridView 当数据源中有一些数据时,它可能是列表或数据表。

After lots of effort i have solved this issue. Bind your DataGridView When you have some data in the Data Source either it would be a list or DataTable.

Windows窗体应用程序异常

走过海棠暮 2024-10-15 07:48:08

作为黑客,我创建了一个 1 像素高、8.5 英寸宽的白色图像并将其嵌入到我的报告中。这迫使报表宽度为 8.5 英寸,但没有解释如何让渲染引擎使报表自动展开。

As a hack, I've created a 1 px tall, 8.5 inch wide white image and embedded it in my report. This forces the report to 8.5 inches wide, but doesn't explain how to get the rendering engine to make the report expand automatically.

SSRS 2005 - 订阅电子邮件被压缩到左侧

走过海棠暮 2024-10-15 06:08:47

使用 Perl 而不是 Python。该程序(SinFP)是用 Perl 编写的,您可以修改代码以满足您的需要。

Use Perl instead of Python. The program (SinFP) is written in Perl, you can modify the code to suite your needs.

使用外部工具、subprocess.Popen 和线程进行多端口扫描

走过海棠暮 2024-10-15 03:05:32

你可以先从指定的url下载php脚本文档,然后给出http-client链接来下载本地存储的文件。或将文档内容放入输出流:

 $cont = file_get_contents($_GET['url']);
  header('Content-Type: application/octet-stream');
  header("Content-Transfer-Encoding: binary ");
  header('Accept-Ranges: bytes');
  header('Content-disposition: attachment; filename=' . $new_file_name));
  echo($cont);

you can first download from php script document from specified url, then give http-client link to download locally stored file. or put document content to output stream:

 $cont = file_get_contents($_GET['url']);
  header('Content-Type: application/octet-stream');
  header("Content-Transfer-Encoding: binary ");
  header('Accept-Ranges: bytes');
  header('Content-disposition: attachment; filename=' . $new_file_name));
  echo($cont);

是否可以将图像从网络复制到硬盘?

走过海棠暮 2024-10-14 23:51:17

有多种方法可以阻止方法对作为参数传递的对象进行更改:

  • 制作对象的副本,然后传递该副本。复制对象的方法有很多种。复制构造函数和静态工厂方法可能比实现 clone() 更好。
  • 为对象的类创建一个只读包装类,实例化它并传递它。只读包装器要么不提供更新方法,要么实现它们不执行任何操作,或者引发异常。
  • 重构对象的 API,使其具有只读接口和读写接口,并将其作为前者的实例传递。 (当然,调用者可以尝试将其强制转换为后者...)
  • 使用 Java 安全性来防止不需要的更新。 (这是昂贵且复杂的......)

当然,如果您试图“保护”的对象具有您想要防止更改的深层结构,那么您需要确保处理这个问题;例如,通过深度复制、通过返回组件对象的副本或返回它们的包装等等。

上述大多数方法都会增加复杂性和运行时成本,因此我的建议是避免您需要执行此类操作的设计。如果可行,只需记录该对象应被视为只读,并将其留给编写该方法的人员的常识来执行正确的操作。

例如,众所周知的事实是,您不应更改用作 Map 中的键的对象的状态,以免其值发生变化。然而,通常不采取任何措施来尝试“强制”这一点;即使用可变对象作为键......并且只是不更改它们。

There are a number of approaches to stopping a method making changes to an object passed as a parameter:

  • Make a copy of the object, and pass the copy. There are a variety of ways of copying objects. Copy constructors and static factory methods are probably better than implementing clone().
  • Create a read-only wrapper class for the object's class, instantiate it and pass it. The read-only wrapper either doesn't provide the update methods, or implements them to do nothing, or throw exceptions.
  • Refactor the object's API so that it has an read-only interface and a read-write interface, and pass it as an instance of the former. (Of course, the caller can try to cast it to the latter ...)
  • Use Java security to prevent unwanted updates. (This is expensive and complicated ...)

Of course, if the object that you are trying to "protect" has deep structure that you want to prevent changes to, then you need to make sure that you deal with this; e.g. by deep copying, by returning copies of component objects or returning them wrapped, and so on.

Most of the approaches above add complexity and runtime cost, so my advice is to avoid designs where you need to do this kind of thing. If feasible, simply document that the object should be treated as read-only, and leave it to the common sense of the person who codes the method to do the right thing.

For example, it is a well known fact that you should not change the state of an object used as a key in a Map in such a way that its value changes. However, it is common to do nothing to try to "enforce" this; i.e. to use mutable objects as keys ... and just not change them.

java:传递引用数组?

走过海棠暮 2024-10-14 16:57:29

正如已经提到的,使用 == 是不正确的。为了便于阅读,请尝试:

field.getText().isEmpty()

field.getText().trim().isEmpty()

As has been mentioned, using == is not correct. For readability, try:

field.getText().isEmpty()

or

field.getText().trim().isEmpty()

关于Java中JTextField的一个问题

走过海棠暮 2024-10-14 15:40:45

如果有人仍在寻找答案,计算距离很简单(精确获取方向很难计算,如果有人知道简单的答案,请添加)

所以检查您的经纬度值之间的差异,将十进制度更改为 0.001 意味着 111m 距离。检查纬度和经度到十进制的变化最大 0.001 将在您的点周围绘制一个半径为 111m 的圆。

前任。您的起点是 A(Lat1,Lng1)。您想要测试的点 B(LatB,LngB) 、 C(LatC,LngC) .....

if: (Lat1 - 0.001) <纬度B (Lat1 + 0.001) && (Lng1-0.001)< LngB < (Lng1 + 0.001) == True // B 点半径为 100m。

如果:(Lat1 - 0.001) <纬度C < (Lat1 + 0.001) && (Lng1-0.001)<液化天然气碳< (Lng1 + 0.001) == False // C 点不在 100m 半径内。

十进制度参考 https://en.wikipedia.org/wiki/Decimal_ Degrees

十进制距离
01.0111公里
10.111.1公里
20.011.11公里
30.001111 m
40.000111.1 m
50.000011.11 m
60.0000010.111 m
70.00000011.11 cm
80.000000011.11毫米

if someone still looking for answer, calculating distance is simple ( getting direction precisely is hard to calculate, if someone knows simple answer for that please do add)

So check difference between your lat-long values, change in decimal degrees to 0.001 means 111m distance. checking both latitude and longitude to decimal degrees change max 0.001 will draw a 111m radius circle around your point.

Ex. your starting point is A(Lat1,Lng1). points you want to test B(LatB,LngB) , C(LatC,LngC) .....

if: (Lat1 - 0.001) < LatB < (Lat1 + 0.001) && (Lng1 - 0.001) < LngB < (Lng1 + 0.001) == True // point B is in 100m radious.

if: (Lat1 - 0.001) < LatC < (Lat1 + 0.001) && (Lng1 - 0.001) < LngC < (Lng1 + 0.001) == False // point C is Not in 100m radious.

Decimal degrees reference https://en.wikipedia.org/wiki/Decimal_degrees

decimaldegreesdistance
01.0111 km
10.111.1 km
20.011.11 km
30.001111 m
40.000111.1 m
50.000011.11 m
60.0000010.111 m
70.00000011.11 cm
80.000000011.11 mm

当经纬度已知点时计算100米距离

走过海棠暮 2024-10-14 14:37:50

每当有多个线程访问相同的资源时,您就必须担心线程安全,并且这些资源不是一成不变的。

You have to worry about thread safety whenever you have more than one thread accessing the same resources, and those resources are not immutable.

什么时候需要担心线程安全?

更多

推荐作者

泪是无色的血

文章 0 评论 0

yriii2

文章 0 评论 0

1649543945

文章 0 评论 0

g红火

文章 0 评论 0

嘿哥们儿

文章 0 评论 0

旧城烟雨

文章 0 评论 0

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