走过海棠暮

文章 0 评论 0 浏览 24

走过海棠暮 2024-10-25 14:35:12

您还可以使用 Unix 文本编辑器 ed:

echo '
pattern1
garbage
pattern2
' > test.txt

cat <<-'EOF' | sed -e 's/^ *//' -e 's/ *$//' | ed -s test.txt &>/dev/null
  H
  /pattern1/+1,/pattern2/-1d
  wq
EOF

有关详细信息,请参阅:使用 ed 文本编辑文件脚本编辑器

You may also use the Unix text editor ed:

echo '
pattern1
garbage
pattern2
' > test.txt

cat <<-'EOF' | sed -e 's/^ *//' -e 's/ *$//' | ed -s test.txt &>/dev/null
  H
  /pattern1/+1,/pattern2/-1d
  wq
EOF

For more information see: Editing files with the ed text editor from scripts

使用 sed 删除两个模式之间的行(不包含)

走过海棠暮 2024-10-25 11:34:58

使用 Document#getElementById() 获取现有锚点元素,而不是 RootPanel#get()

Anchor searchLink = Anchor.wrap(Document.get().getElementById("search"));
searchLink.setHref(Window.Location.createUrlBuilder().
  setPath("search.html").buildString());

Use Document#getElementById() to get the existing anchor Element instead of RootPanel#get():

Anchor searchLink = Anchor.wrap(Document.get().getElementById("search"));
searchLink.setHref(Window.Location.createUrlBuilder().
  setPath("search.html").buildString());

使用 GWT 更新现有 HTML 链接?

走过海棠暮 2024-10-25 06:09:09

我没有使用过 Kinect 控制器,但您可以尝试以下实现的快速模板匹配算法:
https://github.com/dajuric/accord-net-extensions

发挥你的深度图像而不是标准灰度图像。样品已包含在内。

聚苯乙烯
该库还提供其他跟踪算法,例如卡尔曼滤波、粒子滤波、JPDAF、Camshift、Mean-shift(包含示例)。

I have not worked with the Kinect controller, but you can try fast template matching algorithm implemented in:
https://github.com/dajuric/accord-net-extensions

Just use your depth image instead standard grayscale image. The samples are included.

P.S.
This library also provides other tracking algorithms such as Kalman filtering, particle filtering, JPDAF, Camshift, Mean-shift (samples included).

滤波检测后的形状跟踪

走过海棠暮 2024-10-25 04:00:12

我有同样的错误消息 - 对我来说,问题是我指定了错误的 jar 依赖项(从另一个源复制)。您可以在此处查看可用的工件:

http://search.maven.org/#search% 7Cga%7C1%7Cclojure

我希望这对某人有帮助

I had the same error message - what was broken for me was I specified the wrong jar dependency (copied from another source). You can view available artefacts here:

http://search.maven.org/#search%7Cga%7C1%7Cclojure

I hope this helps someone

Lein deps 命令找不到工件

走过海棠暮 2024-10-24 21:12:33

您应该再次通读 jquery 文档,尤其是涵盖 数据的部分dataType 参数。 data 必须是键/值对象,即:

data: { 'userid': userid }

...对于 dataType,允许的值为 xml、html、text、json 和 jsonp。如果您的 PHP 脚本发送合适的 Content-type 标头(例如 header('Content-type: text/json');,那么您只需将此参数保留在默认(“智能猜测”)。jQuery 将从其内容类型标头推断响应类型,否则,服务器可能会假设您正在发送 HTML 并添加 HTML 内容类型标头本身。然后就窒息了。
设置 内部编码 和 < a href="http://www.php.net/manual/en/function.mb-http-output.php" rel="nofollow">输出编码 在 PHP 脚本中,以便它理解正确请求并发送格式正确的 UTF-8 响应。

为了进一步调试,您可能需要:

  • 在 PHP 中添加一些日志记录代码,例如,转储 $_POST 数组以及发送到服务器上文本文件的响应
  • 发布测试请求使用像curl或wget这样的东西到你的PHP脚本,看看响应是否是你所期望的,
  • 让你的javascript发布到一个虚拟脚本,除了记录请求并发送一个空响应之外什么也不做; 查看是否可以
  • 使用脚本调试器(例如 Firefox 上的 Firebug,或者 Chrom[e|ium] 中内置的东西) 单步调试您的 javascript;在成功处理程序中设置一个断点,看看是否命中,如果命中,响应包含什么内容

You should read through the jquery documentation once more, especially the part that covers the data and dataType parameters. data must be a key/value object, i.e.:

data: { 'userid': userid }

...and for dataType, allowed values are xml, html, text, json, and jsonp. If your PHP script sends a suitable Content-type header (e.g. header('Content-type: text/json');, then you can simply leave this parameter at the default ('Intelligent guess'). jQuery will infer the response type from its content type header. You should send the header anyway because otherwise, the server will probably assume you're sending HTML and add a HTML content type header itself, which jQuery then chokes on.
It's probably also a good idea to set the internal encoding and output encoding in your PHP script, so that it understands the request correctly and sends a well-formed UTF-8 response.

For further debugging, you might want to:

  • add some logging code to your PHP, for example, dump the $_POST array and the response you're sending to a text file on the server
  • post a test request to your PHP script using something like curl or wget, and see if the response is what you expect
  • have your javascript post to a dummy script that does nothing but log the request and send an empty response; see if that works
  • step through your javascript using a script debugger (e.g. Firebug on Firefox, or the thing that's built into Chrom[e|ium]); set a breakpoint inside the success handler and see if it's hit, and if so, what the response contains

当内容类型设置为 JSON UTF-8 时,jQuery AJAX 帖子为空

走过海棠暮 2024-10-24 16:30:56

mailo 看起来几乎是正确的,但该命令将是 ssh 命令的第二个参数,如下所示:

ssh username@server 'echo "* * * * * /path/to/script/" >> /etc/crontab'

或者,如果您的系统不会自动加载 /etc/crontab,您应该能够通过管道传输到 crontab 命令,如下所示:

ssh username@server 'echo "* * * * * myscript" | /usr/bin/crontab'

mailo seemed almost right, but the command would be the second argument to the ssh command, like this:

ssh username@server 'echo "* * * * * /path/to/script/" >> /etc/crontab'

Or if your system doesn't automatically load /etc/crontab you should be able to pipe to the crontab command like this:

ssh username@server 'echo "* * * * * myscript" | /usr/bin/crontab'

在 shell 脚本中使用 ssh 登录在服务器上创建 cron 条目

走过海棠暮 2024-10-24 15:54:01

我们在本机 IBM JDK/JRE 上运行没有问题。我们在使用 Sun 特定类(com.sun.org.apache.xerces.internal.parsers.SAXParserSunX509 等一些外部工具时遇到了一些问题)。

我们还使用 Tomcat 和其他一些 apache 产品,没有出现任何重大问题。 IBM 的 JRE 对我们来说非常快速且强大。

We run on the native IBM JDK/JRE without issue. We've had a couple issues with external tools using Sun specific classes (com.sun.org.apache.xerces.internal.parsers.SAXParser, SunX509, a couple others).

We also use Tomcat and some of the other apache products without any major issues. IBM's JRE has been very fast and robust for us.

需要将 Java 应用程序从 Solaris 10 迁移到 AIX。 AIX 平台有可用的 Oracle 或 OpenJDK 吗?

走过海棠暮 2024-10-24 10:11:45

第一个与第二个不一样。

在这种特定情况下,它们可能会产生相同的结果。 但是,Point可以轻松地为new Point实现赋值运算符并做一些“不同”的事情(我没有这本书,所以我不知道每一个细节)。同样,赋值运算符应该做你所期望的......但是,thePoint可能是一个容器(例如,智能指针),它可以(由于某些奇怪的原因) ) 使用初始化(Point)默认初始化后赋值 时的行为有所不同。

在这种情况下,这些细节可能并不重要,但它们确实会影响初始化顺序和执行。当您的程序增长时,这种差异将变得很重要。那时,初始化需要时间,并且您需要确保对象正确初始化:它们被正确构造(第一次)并且它们以正确的顺序构造。最明显的情况:当默认构造函数的行为与带参数的构造函数不同时,特别是当构造函数产生分配或具有其他耗时(或行为不同)的副作用时,它将产生影响。

而且,由于我们是在构造函数中执行此操作,因此为 int x 和 int y 分配的值是多少?

这完全取决于 Point 的构造函数。

我们应该在 new Point(x,y) 中写入 x 和 y 的值吗?或者说,这样是正确的吗?

首选方法(对于大多数团队来说)是尽可能使用初始化列表和正式构造函数,并编写类型以支持正确的初始化。当代码库增长时,会出现很多微妙之处。此构造函数使用初始化列表:

HeapPoint::HeapPoint(int x, int y): thePoint(new Point(x,y)) { }

如果您愿意,在假设的情况下可能需要正确的初始化像这样声明 thePoint:

const Point* const thePoint;

第一个 const 意味着您不能修改 Point(例如,Point.xPoint.y)。第二个 const 意味着您不能为该变量分配新的分配。 OP 中的示例是简单的示例,但随着程序的增长绝对有帮助。

the first is not the same as the second.

in this specific case, they will probably produce the same result. however, Point could easily implement an assignment operator for new Point and do something 'different' (i don't have the book, so i don't know every detail). as well, the assignment operator should do what you'd expect... however, thePoint could be a container (e.g., smart pointer) which could (for some odd reason) behave differently when using initialization(Point) vs default initialization followed by assignment.

these details likely won't matter in this case, but they do affect initialization order, and the execution. the difference will be important when your programs grow. at that time, initialization will take time, and you will want to ensure that the objects are initialized correctly: that they are constructed properly (the first time) and that they are constructed in the right order. most obvious case: it will make a difference when a default constructor behaves different from one with parameters, especially when the constructor produces allocations or has other time-consuming (or behaviorally different) side effects.

And, since we are doing this in a constructor, what are the values assigned for int x and int y?

that depends entirely on Point's constructor.

Should we write values insted of x and y in new Point(x,y)? Or, it is correct that way?

the preferred way (for most teams) is to use the initialization list and formal constructors wherever possible, and to write your types to support correct initialization. there are a lot of subtleties that come out when codebases grow. this constructor uses the initialization list:

HeapPoint::HeapPoint(int x, int y): thePoint(new Point(x,y)) { }

proper initialization could in a hypothetical case be required if you want to declare thePoint like so:

const Point* const thePoint;

the first const means that you cannot modify the Point (e.g., Point.x or Point.y). the second const means that you cannot assign a new allocation to the variable. trivial examples for the example in the OP, but definitely helpful as your programs grow.

C++构造函数问题

走过海棠暮 2024-10-24 08:55:17

命令如下:

drush user-password someuser --password="New Password-of yours"

您可以通过 Drsuh term 进行更改

The Command goes like this:

drush user-password someuser --password="New Password-of yours"

You can change through Drsuh term

是否可以使用 Drush 更改用户的 Drupal 密码?

走过海棠暮 2024-10-24 06:17:45

在这里您可以找到 NSMutableArray 的洗牌类别:

洗牌 NSMutableArray 的最佳方法是什么?

Here you can find a Shuffling Category for NSMutableArray:

What's the Best Way to Shuffle an NSMutableArray?

随机打乱数字序列

走过海棠暮 2024-10-24 00:58:43

构建广播系统的方法有很多种,但您必须要么放弃可靠性(即,某些消息必须丢失),要么使用适当的订阅系统。

如果您愿意放弃可靠性,您可以创建一个共享内存段并命名为手动重置事件对象。当新消息到达时,将其写入共享内存段,向事件对象发出信号,然后关闭事件对象并创建一个具有不同名称的新消息(该名称应该位于 shmem 段中的某处)。客户端打开 shmem 段,找到当前事件对象,等待它收到信号,然后读取消息和新事件段。

在此选项中,您必须小心处理在 shmem 段正确更新的同时客户端读取的情况。实现此目的的一种方法是在 shmem 段中有两个序列号字段 - 一个在写入新消息之前更新,一个在写入之后更新。客户端在读取消息之前读取第二序列号,然后重新读取这两个序列号,并检查它们是否全部相等(并丢弃消息并在之后重试)如果不是,则延迟)。请务必在对这些序列号的访问周围放置内存屏障,以确保编译器不会对它们重新排序!

当然,这一切都有点毛茸茸的。 命名管道要简单得多,但需要订阅(某种形式)。服务器调用 CreateNamedPipe ,然后接受与 ConnectNamedPipe。客户端使用 CreateFile< /a> 连接到服务器的管道。然后,服务器循环将数据(使用WriteFile)发送到所有客户端。请注意,每次接受连接时,您都需要使用 CreateNamedPipe 创建管道的附加实例。可以在此处找到命名管道服务器的示例: http://msdn.microsoft.com/en-us/library/aa365588(v=vs.85).aspx

There are a number of ways to do a broadcast system, but you'll have to either give up reliability (ie, some messages must be lost) or use a proper subscription system.

If you're willing to give up reliability, you can create a shared memory segment and named manual-reset event object. When a new message arrives, write it to the shared memory segment, signal the event object, then close the event object and create a new one with a different name (the name should be in the shmem segment somewhere). Clients open the shmem segment, find the current event object, wait for it to be signaled, then read off the message and new event segment.

In this option, you must be careful to deal with the case of a client reading at the same time as the shmem segment is updated properly. One way to do this is to have two sequence number fields in the shmem segment - one is updated before the new message is written, one after. Clients read the second sequence number prior to reading the message, then re-read both sequence numbers after, and check that they are all equal (and discard the message and retry after a delay if they are not). Be sure to place memory barriers around accesses to these sequence numbers to ensure the compiler does not reorder them!

Of course, this is all a bit hairy. Named pipes are a lot simpler, but a subscription (of a sort) is required. The server calls CreateNamedPipe, then accepts connections with ConnectNamedPipe. Clients use CreateFile to connect to the server's pipe. The server then just loops to send data (using WriteFile) to all of its clients. Note that you will need to create addititonal instance of the pipe using CreateNamedPipe each time you accept a connection. An example of a named pipe server can be found here: http://msdn.microsoft.com/en-us/library/aa365588(v=vs.85).aspx

服务间单向通信的选项

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

答案可能已过时 - 三星开发者网站上有一个开发者论坛,看起来三星人提供了实际的帮助。

Answer may be obsolete - there is a developer forum on Samsung devs website and it looks like Samsung people provide actual help.

在哪里向三星报告设备特定的错误?

走过海棠暮 2024-10-23 09:28:47

您必须将 NSView 设置为第一响应者

- (BOOL)acceptsFirstResponder {
返回是;
}

You have to set your NSView to be first responder

- (BOOL)acceptsFirstResponder {
return YES;
}

键盘事件 Objective C

走过海棠暮 2024-10-23 04:45:03

我总是尝试使用 TDD 进行开发。这意味着我创建一个单元测试项目,并使用单元测试来测试我的服务。

I always try to develop using TDD. This implies that I create a unit test project, and use unit tests to test my services.

测试 WCF 服务

走过海棠暮 2024-10-23 04:31:36

当您说“设置属性”时,我假设您的意思是这是表上的另一列。如果是这样,这应该可行:

if self.value1 > self.value2
    update_attribute :status, "foo"
else
    update_attribute :status, "bar"
end

在实例化对象或更新多个属性时(self.update_attributes :动物=>“小猫”,:声音=>“咆哮!”)。这是 Hash 使用的表示法。

您也可以只使用 status = "foo",但这会设置属性而不保存,因此您还必须调用 self.saveupdate_attribute 在一个简洁的包中完成这两项任务。

When you say "sets an attribute", I assume that you mean this is another column on the table. If so, this should work:

if self.value1 > self.value2
    update_attribute :status, "foo"
else
    update_attribute :status, "bar"
end

The "rocket" notation (:this => "that") is used when instantiating an object, or when updating more than one attribute (self.update_attributes :animal => "kitten", :sound => "Roar!"). It's the notation that a Hash uses.

You could also just use status = "foo", but that will set the attribute without saving, so you'd also have to call self.save. update_attribute does both in one neat package.

在模型中设置属性

更多

推荐作者

爱人如己

文章 0 评论 0

萧瑟寒风

文章 0 评论 0

云雾

文章 0 评论 0

倒带

文章 0 评论 0

浮世清欢

文章 0 评论 0

撩起发的微风

文章 0 评论 0

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