我正在尝试提出一种算法来查找文本正文中的URL.我目前有以下代码(这是我坐下来破解代码,我知道必须有更好的方法):
statusText.text = @"http://google.com http://www.apple.com www.joshholat.com";
NSMutableArray *urlLocations = [[NSMutableArray alloc] init];
NSRange currentLocation = NSMakeRange(0, statusText.text.length);
for (int x = 0; x < statusText.text.length; x++) {
currentLocation = [[statusText.text substringFromIndex:(x + currentLocation.location)] rangeOfString:@"http://"];
if (currentLocation.location > statusText.text.length) break;
[urlLocations addObject:[NSNumber numberWithInt:(currentLocation.location + x)]];
}
currentLocation = NSMakeRange(0, statusText.text.length);
for (int x = 0; x < statusText.text.length; x++) {
currentLocation = [[statusText.text substringFromIndex:(x + currentLocation.location)] rangeOfString:@"http://www."];
if (currentLocation.location > statusText.text.length) break;
[urlLocations addObject:[NSNumber numberWithInt:(currentLocation.location + x)]];
}
currentLocation = NSMakeRange(0, …Run Code Online (Sandbox Code Playgroud) 我正在开发一个PDF解析器/编写器,但我坚持生成交叉引用流.我的程序读取此文件,然后删除其线性化,并解压缩对象流中的所有对象.最后,它构建PDF文件并保存.
当我使用正常的交叉引用和预告片时,这非常有效,正如您在此文件中看到的那样.
当我尝试生成交叉引用流对象时(导致此文件,Adobe Reader无法查看它).
有没有人使用PDF,可以帮助我搜索问题所在?
请注意,交叉引用是文件2和文件3之间的唯一区别.前34127个字节是相同的.
如果有人需要解码参考流的内容,请下载此文件并在HEX编辑器中打开它.我一次又一次检查了这个参考表,但我找不到任何错误.但字典似乎也没问题.
非常感谢你的帮助!!!
更新
我现在已经彻底解决了这个问题.您可以在此处找到新PDF .
我使用Python 2.6作为批处理脚本替换.它将通过双击启动,因此用户将丢失/忽略对stdout的所有输出.所以,我决定添加日志记录,为了简单起见,我为此写了一个类.我的想法是,我可以Logging.Logger在我的代码中的任何地方使用,并且记录器将准备就绪.
我希望目录中的日志文件不超过10个,因此我手动清除旧的日志文件.我没有通过API找到这样的功能,而且我是偏执狂,并希望记录所有内容,事件是日志目录中有文件具有意外名称的事实.
所以,下面是我尝试这样的类,但是当我尝试测试(运行)它时出现错误:
>>> ================================ RESTART ================================
>>>
Traceback (most recent call last):
File "C:/AutomationScripts/build scripts/Deleteme.py", line 6, in <module>
class Logging:
File "C:/AutomationScripts/build scripts/Deleteme.py", line 42, in Logging
__clearOldLogs(dummySetting)
File "C:/AutomationScripts/build scripts/Deleteme.py", line 38, in __clearOldLogs
_assert(Logger, 'Logger does not exist yet! Why?')
NameError: global name '_assert' is not defined
>>>
Run Code Online (Sandbox Code Playgroud)
是的,我来自Java/C#背景.我可能不会做"Pythonic"的方式.请帮我做正确的事,请给出一个完整的答案,而不是简单地指出我的知识漏洞.我相信我提供了足够的代码示例.对不起,如果没有设置类,它就不会运行,但希望你明白了.
# This file has been tested on Python 2.6.*. For Windows only.
import logging # For actual logging
import tkMessageBox # To display an …Run Code Online (Sandbox Code Playgroud) 我正在使用SQL Server 2008,当我在Management studio中运行此Statement时,Catch Block中的Select语句按预期执行
BEGIN TRY
INSERT INTO IDontExist(ProductID)
VALUES(1)
END TRY
BEGIN CATCH
SELECT 'There was an error! ' + ERROR_MESSAGE()
END CATCH
Run Code Online (Sandbox Code Playgroud)
但是,当我运行此语句时,Catch Block中的语句永远不会执行,而错误只显示在结果选项卡中
BEGIN TRY
Select * from IDontExist
END TRY
BEGIN CATCH
SELECT 'There was an error! ' + ERROR_MESSAGE()
END CATCH
Run Code Online (Sandbox Code Playgroud)
它们都返回相同的错误号'208''无效的对象名称:IDontExist'那么为什么要处理它而另一个不处理?
我为它创建了一个ButtonCell和一个列:
ButtonCell previewButton = new ButtonCell();
Column<Auction,String> preview = new Column<Auction,String>(previewButton) {
public String getValue(Auction object) {
return "Preview";
}
};
Run Code Online (Sandbox Code Playgroud)
我现在如何为此ButtonCell添加点击处理程序(例如ClickHandler)?
git commit 给我以下信息
*
* You have some suspicious patch lines:
*
* In projects/bong/traid/apps/controller/project.php
* trailing whitespace (line 220)
projects/bong/traid/apps/controller/project.php:220:
* trailing whitespace (line 223)
Run Code Online (Sandbox Code Playgroud)
那是什么意思 ?
当我将数据保存到表中时,会在尾部的值中添加额外的空格.我观察到,当列长度为5时,如果我插入3个字符长度的值,则添加2个额外的空格.可以任何人如何解决这个问题.
我想创建一个带有固定高度标题的html页面,一个高度可变的中间部分和一个固定高度的页脚.滚动时页脚和页眉不应移动.
到目前为止没问题.
但我希望midlle部分被分割,以便右列和左列具有单独的滚动条并独立滚动.这可以通过溢出:只要零件具有固定高度就滚动.但我希望他们zu与窗口一起成长和收缩.
我没有链接帧,我想使用javascript(ajax)频繁更改2列的内容.
创建这样一个页面的最佳方法是什么?
我在学校有一点 C 编程经验,但都是 Unix。我想用 Emacs 编译一些 C,使用 Emacs 作为第二个 IDE。
这样做的最简单方法是什么?我下载了 Cygwin,但没有在 Emacs 中成功编译 helloWorld.c。即使打开 cygwin 命令提示符(shell 或其他任何名称),它也不会将 gcc 识别为命令。
错误
'make' 不是内部或外部命令,也不是可运行的程序或批处理文件。
我需要一个可以在 Windows 上运行的编译器,它是免费的(或随 Visual Studio 提供),并且可以与 Emacs 一起使用。在M-x compile命令之后在 Emacs 中输入什么也很高兴知道。我看着 MinGW,但下载它是一件苦差事。
我希望这个问题是有道理的。我经常迷失在开源世界中。
环境
Windows XP、Visual Studio 2010、Emacs 23.2.1、Windows 7.1 SDK 安装、Cygwin
作为WPF和MVVM的新手,我在努力学习一些基本功能.
让我先解释一下我的意思,然后附上一些示例代码......
我有一个显示用户列表的屏幕,我在右侧显示所选用户的详细信息,其中包含可编辑的文本框.然后我有一个Save按钮,它是DataBound,但我只想在数据实际发生变化时显示这个按钮.即 - 我需要检查"脏数据".
我有一个完整的MVVM示例,其中我有一个名为User的模型:
namespace Test.Model
{
class User
{
public string UserName { get; set; }
public string Surname { get; set; }
public string Firstname { get; set; }
}
}
Run Code Online (Sandbox Code Playgroud)
然后,ViewModel看起来像这样:
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Windows.Input;
using Test.Model;
namespace Test.ViewModel
{
class UserViewModel : ViewModelBase
{
//Private variables
private ObservableCollection<User> _users;
RelayCommand _userSave;
//Properties
public ObservableCollection<User> User
{
get
{
if (_users == null)
{
_users = new ObservableCollection<User>();
//I assume I need this …Run Code Online (Sandbox Code Playgroud)