走过海棠暮

文章 0 评论 0 浏览 24

走过海棠暮 2024-12-20 11:11:09

基本上有两种方法可以做到这一点:

  1. 如果该对象在某种程度上与另一个视图或编辑器的选择相关,那么您可以使用编写一个 SelectionListener 来获取当前选择,然后使用以下方法设置正确的对象方法: getViewSite().getPage().addSelectionListener(mySelectionListener)

  2. 否则,定义一个您的代码和视图都可以访问的对象 (例如,使用静态属性、OSGi 服务或 Eclipse 扩展),并且您可以使用该对象来传递信息。您的数据源更新此对象,并且您可以定义视图可以将自己注册到的更改侦听器/回调。

There are basically two ways to do this:

  1. If the object is somehow related to the selection of another view or an editor, then you could use write a SelectionListener that gets the current selection, and then sets the correct object using the following method: getViewSite().getPage().addSelectionListener(mySelectionListener)

  2. Otherwise, define an object that both your code and the view can reach (e.g. using a static attribute, an OSGi service or an Eclipse extension), and you can use that object to pass information. Your data source updates this object, and you can define a change listener/callback that the view can register himself to.

将对象传递给 rcp 视图

走过海棠暮 2024-12-20 11:07:55

也许这个工具可以帮助你,一个全交互管理器,帮助 Three.js 轻松绑定交互事件

更多细节参见 三.交互

import { Scene, PerspectiveCamera, WebGLRenderer, Mesh, BoxGeometry, MeshBasicMaterial } from 'three';
import { Interaction } from 'three.interaction';

const renderer = new WebGLRenderer({ canvas: canvasElement });
const scene = new Scene();
const camera = new PerspectiveCamera(60, width / height, 0.1, 100);

// new a interaction, then you can add interaction-event with your free style
const interaction = new Interaction(renderer, scene, camera);

const cube = new Mesh(
  new BoxGeometry(1, 1, 1),
  new MeshBasicMaterial({ color: 0xffffff }),
);
scene.add(cube);
cube.cursor = 'pointer';
cube.on('click', function(ev) {});
cube.on('touchstart', function(ev) {});
cube.on('touchcancel', function(ev) {});
cube.on('touchmove', function(ev) {});
cube.on('touchend', function(ev) {});
cube.on('mousedown', function(ev) {});
cube.on('mouseout', function(ev) {});
cube.on('mouseover', function(ev) {});
cube.on('mousemove', function(ev) {});
cube.on('mouseup', function(ev) {});
// and so on ...

/**
 * you can also listen at parent or any display-tree node,
 * source event will bubble up along with display-tree.
 */
scene.on('touchstart', ev => {
  console.log(ev);
})
scene.on('touchmove', ev => {
  console.log(ev);
})

maybe this tool can help you, a full-interaction manager, help three.js easy to binding interaction event

more detial see three.interaction

import { Scene, PerspectiveCamera, WebGLRenderer, Mesh, BoxGeometry, MeshBasicMaterial } from 'three';
import { Interaction } from 'three.interaction';

const renderer = new WebGLRenderer({ canvas: canvasElement });
const scene = new Scene();
const camera = new PerspectiveCamera(60, width / height, 0.1, 100);

// new a interaction, then you can add interaction-event with your free style
const interaction = new Interaction(renderer, scene, camera);

const cube = new Mesh(
  new BoxGeometry(1, 1, 1),
  new MeshBasicMaterial({ color: 0xffffff }),
);
scene.add(cube);
cube.cursor = 'pointer';
cube.on('click', function(ev) {});
cube.on('touchstart', function(ev) {});
cube.on('touchcancel', function(ev) {});
cube.on('touchmove', function(ev) {});
cube.on('touchend', function(ev) {});
cube.on('mousedown', function(ev) {});
cube.on('mouseout', function(ev) {});
cube.on('mouseover', function(ev) {});
cube.on('mousemove', function(ev) {});
cube.on('mouseup', function(ev) {});
// and so on ...

/**
 * you can also listen at parent or any display-tree node,
 * source event will bubble up along with display-tree.
 */
scene.on('touchstart', ev => {
  console.log(ev);
})
scene.on('touchmove', ev => {
  console.log(ev);
})

如何在 THREE.js 中获取被点击的元素

走过海棠暮 2024-12-20 08:33:23

试试这个——

SELECT n.*, c2.* FROM country c
  JOIN country_news cn
    ON cn.country_id = c.id
  JOIN news n
    ON cn.news_id = n.id
  LEFT JOIN country_news cn2
    ON cn2.news_id = n.id
  LEFT JOIN country c2
    ON cn2.country_id = c2.id
WHERE c.id = 1

Try this one -

SELECT n.*, c2.* FROM country c
  JOIN country_news cn
    ON cn.country_id = c.id
  JOIN news n
    ON cn.news_id = n.id
  LEFT JOIN country_news cn2
    ON cn2.news_id = n.id
  LEFT JOIN country c2
    ON cn2.country_id = c2.id
WHERE c.id = 1

在一个查询中提取两个多对多

走过海棠暮 2024-12-20 06:04:06

记录卡在这里了
您认为您想要一个树视图,其中包含经过的时间、调用计数等,
但您需要的是通过找到可以修复的内容来优化应用程序,以消除不必要的挂钟时间。
这是一个最有效的示例,在我的 。

某些事情很容易花费大量时间,因为它不一定局限于特定的例程、特定的代码行或程序中的特定路径 调用树。
无论它在哪里,该方法都能找到它。
更重要的是,它不会费心去衡量超出发现问题所需的最低限度的问题。
但是,如果您确实觉得需要购买或安装某些东西,那么它对您没有帮助。

Stuck record here.
You think you want a tree view, with elapsed time, call count, etc.,
but what you need is to optimize the app by finding what you can fix to eliminate wall-clock time being spent unnecessarily.
Here's an example of what works best, in my experience.

It is very easy for something to be taking a large fraction of time, where it is not necessarily localized to particular routines, particular lines of code, or particular paths in the call tree.
That method finds it no matter where it is.
What more, it doesn't bother measuring the problem beyond the minimum needed to find it.
However, if you really feel the need to buy or install something, it doesn't help you there.

分析 WPF 应用程序 - 所有方法的概述

走过海棠暮 2024-12-20 04:17:15

据我所知,这很难做到。 Unix 信号是原始的。

默认情况下,信号被传递到随机线程。为了解决这个问题,通常采用的技巧是阻止除一个线程之外的所有线程中的信号。最简单的方法是使用 pthread_sigmask 阻止 main 中的所有信号,然后创建线程(它将继承信号掩码),然后使用一个单独的线程来执行 sigwait /sigwaitinfo 阻止信号。这会强制将信号传递到该线程。

在信号捕获线程中消耗信号后,您需要使用 main 的线程 id 和捕获的信号编号执行 pthread_kill 以将信号转发到 main。问题是 main 会被阻塞。

在转发信号之前,您无法真正解除阻塞 main 并阻塞信号捕获线程,因为这是一种竞争条件 - 没有什么可以阻止第二个信号进入,并且信号捕获线程看不到它。这一切的努力都白费了。

您可以让信号线程通过某种其他形式的 IPC(管道或其他形式)向 main 发送一条消息,说“捕获 XX,采取适当的操作”。也许这就足够了?

也许有人有一些聪明的想法,但我怀疑底线是这不是 UNIX 中通常的做法。

As far as I know this would be tricky to do. Unix signals are primitive.

Signals get delivered to a random thread by default. To get around this the trick usually employed is to block signals in all the threads except one. The easiest way to do this is to block all the signals in main with pthread_sigmask, then create the threads (which will inherit the signal mask), and then have a separate thread that does a sigwait/sigwaitinfo on the blocked signals. This forces the signals to be delivered to that thread.

After consuming the signal in the signal-catching thread you would need to do a pthread_kill with main's thread id and the caught signal number to forward the signal to main. The problem is that main would have it blocked.

You can't really unblock main and block the signal-catching thread before forwarding the signal because it is a race condition - there is nothing stopping a second signal from coming in and the signal-catching thread not seeing it. That defeats the whole effort.

You could have the signal-thread send a message to main through some other form of IPC (pipe or whatever) saying "caught XX, take appropriate action". Maybe that is sufficient?

Maybe someone has some clever idea but I suspect the bottom line is that this just isn't how it is normally done in unix.

Windows Hooks 的 Linux 等效项

走过海棠暮 2024-12-20 03:14:45

这可行:

/^[a-z][a-z0-9_]{0,7}$/i

例如,

/^[a-z][a-z0-9_]{0,7}$/i.test('a1234567'); // true
/^[a-z][a-z0-9_]{0,7}$/i.test('01234567'); // false

This would work:

/^[a-z][a-z0-9_]{0,7}$/i

For example,

/^[a-z][a-z0-9_]{0,7}$/i.test('a1234567'); // true
/^[a-z][a-z0-9_]{0,7}$/i.test('01234567'); // false

我需要字符串的正则表达式

走过海棠暮 2024-12-19 22:35:28

如果你打算在 2011 年学习 PHP,那就好好学吧。

首先,不推荐使用 mysql_query 或 mysql_ Anything 代码。不要再使用它了。

别担心 - 我建议的内容非常适用于 mysql 数据库,但它也适用于任何数据库:

  • PDO 是 PHP 社区不断添加功能的内容,所以我会使用它。
  • PDO 也更强大,并且使以后切换数据库变得更容易。
  • MYSQLi(i 代表改进)取代了已弃用的基于 mysql_ 的查询,但我肯定会直接使用 PDO。
  • 您还可以轻松创建一个数组
    稍后对象的一行更改!

其次,Phil 提到了 fetchAll()。这是最终目标。其他方式只需一次一行地移动即可。这使用推土机而不是铲子。注意:这不是选择大量数据的最佳方法,因为它会耗尽内存。否则的话,也没关系。

为此,请使用准备好的过程来保护您的代码免受 SQL 注入攻击。

<?php
/* Execute a prepared statement by binding PHP variables */
$calories = 150;
$colour = 'red';
$sth = $dbh->prepare('SELECT name, colour, calories
    FROM fruit
    WHERE calories < :calories AND colour = :colour');
$sth->bindParam(':calories', $calories, PDO::PARAM_INT);
$sth->bindParam(':colour', $colour, PDO::PARAM_STR, 12);
$sth->execute();

/* Fetch all of the rows into an array */
print("Fetch all of the remaining rows in the result set:\n");
$result = $sth->fetchAll();
print_r($result);

?>

If you are going to learn PHP in 2011, let's do it right.

First off, mysql_query or mysql_ anything code is deprecated. Don't use it anymore.

Don't worry - what I am suggesting works great with mysql databases, but it will also work great with any database:

  • PDO is what the PHP community continues to add features to, so I would use that.
  • PDO is also way more powerful, and makes it easier to switch databases later.
  • MYSQLi (the i stands for improved) replaces deprecated mysql_ based queries, but I would definitely go straight to using PDO.
  • You could also easily create an array
    of objects later with one line change!

Secondly, Phil mentioned fetchAll(). This is the end goal. The other ways simply move thru it one row at a time. This uses a bulldozer instead of a shovel. Note: not the best way of selecting really large amounts of data, as it will use up memory. Otherwise, it is fine.

To get there, use prepared procedures to protect your code from SQL injection attacks.

<?php
/* Execute a prepared statement by binding PHP variables */
$calories = 150;
$colour = 'red';
$sth = $dbh->prepare('SELECT name, colour, calories
    FROM fruit
    WHERE calories < :calories AND colour = :colour');
$sth->bindParam(':calories', $calories, PDO::PARAM_INT);
$sth->bindParam(':colour', $colour, PDO::PARAM_STR, 12);
$sth->execute();

/* Fetch all of the rows into an array */
print("Fetch all of the remaining rows in the result set:\n");
$result = $sth->fetchAll();
print_r($result);

?>

在 PHP 中以数组形式获取 MySQL 查询结果的最佳方法是什么?

走过海棠暮 2024-12-19 18:01:40

基于@Sajid回复

if (preg_match_all('/(?:SB.+?EB(?:[\r\n]+|$))/', $string, $result))
{
    for ($i=0; $i<count($result[0]); $i++)
    {
        $single_item = $result[0][$i];
        $single_item = str_replace("SB","",$single_item);
        $single_item = str_replace("EB","",$single_item);
        if (preg_match('/(\d{3}\.\d{3}\.\d{2})/', $single_item))
        {
            $id = $single_item;
            $qty = $result[0][$i-2];
            $name = $result[0][$i-1];
            $price = $result[0][$i+1];
            $total = $result[0][$i+2];
        }
    }
}

有点乱,但它有效! :)

Based on @Sajid reply:

if (preg_match_all('/(?:SB.+?EB(?:[\r\n]+|$))/', $string, $result))
{
    for ($i=0; $i<count($result[0]); $i++)
    {
        $single_item = $result[0][$i];
        $single_item = str_replace("SB","",$single_item);
        $single_item = str_replace("EB","",$single_item);
        if (preg_match('/(\d{3}\.\d{3}\.\d{2})/', $single_item))
        {
            $id = $single_item;
            $qty = $result[0][$i-2];
            $name = $result[0][$i-1];
            $price = $result[0][$i+1];
            $total = $result[0][$i+2];
        }
    }
}

It's a bit messy, but it works! :)

提取字符串匹配模式的一部分 - 正则表达式,关闭但没有雪茄

走过海棠暮 2024-12-19 14:36:31

某些字符,例如带重音的字母(例如 é)可以用两种方式表示 - 单个代码点 U+00E9 或纯字母后跟组合重音符号U+0065 U+0301。普通标准化将选择其中之一来始终表示它(NFC 的单个代码点,NFD 的组合形式)。

对于可以由多个基本字符序列和组合标记表示的字符(例如,“s,下面的点,上面的点”与将点放在上面然后将点放在下面或使用已经具有其中一个点的基本字符),NFD 将也选择其中一个(下面是第一个,因为它发生了)

兼容性分解包括许多“不应该真正”是字符的字符,但它们是因为它们被用于遗留编码中。普通规范化不会统一这些(为了保持往返完整性 - 这对于组合形式来说不是问题,因为没有遗留编码[除了少数越南编码]同时使用这两种编码),但兼容性规范化会统一。想想一些东亚编码中出现的“kg”公斤符号(或半角/全角片假名和字母表),或者 MacRoman 中的“fi”连字。

有关更多详细信息,请参阅 http://unicode.org/reports/tr15/

Some characters, for example a letter with an accent (say, é) can be represented in two ways - a single code point U+00E9 or the plain letter followed by a combining accent mark U+0065 U+0301. Ordinary normalization will choose one of these to always represent it (the single code point for NFC, the combining form for NFD).

For characters that could be represented by multiple sequences of base characters and combining marks (say, "s, dot below, dot above" vs putting dot above then dot below or using a base character that already has one of the dots), NFD will also pick one of these (below goes first, as it happens)

The compatibility decompositions include a number of characters that "shouldn't really" be characters but are because they were used in legacy encodings. Ordinary normalization won't unify these (to preserve round-trip integrity - this isn't an issue for the combining forms because no legacy encoding [except a handful of vietnamese encodings] used both), but compatibility normalization will. Think like the "kg" kilogram sign that appears in some East Asian encodings (or the halfwidth/fullwidth katakana and alphabet), or the "fi" ligature in MacRoman.

See http://unicode.org/reports/tr15/ for more details.

标准化 UTF-8 到底是什么?

走过海棠暮 2024-12-19 14:05:13

两种可能性。
1)退出模拟器,然后运行你想运行的应用程序
2)只需停止使用模拟器的应用程序并运行您想要运行的应用程序

Two Possibilities.
1)just quit the simulator,and run the application you want to run
2)just stop the application that using the simulator and run the application you want to run

iPhone模拟器无法启动?

走过海棠暮 2024-12-19 13:20:03

正如您所说,+0.5f 是四舍五入到最接近的数字。理想情况下,当 ldpi 的数字按比例缩小时,值 1 变为 0.75,当转换为 int 时,该值表示为小于 1 或 ~=0。通过添加舍入数字,该数字提高到 1.25,当转换为 int 时,会产生 <2 或 ~=1。这样,您的精灵应该以最小移动 1 进行绘制。以不同速度移动的精灵会以相同的速度移动的唯一原因是,如果它们太接近,以至于在舍入时,使用比例尺它们最终会具有相同的大小你给了。总而言之,你的方程与我见过的其他方程非常相似。我正在为我工​​作的公司制作一款使用 SurfaceView 的游戏,虽然我无法详细说明代码,但你的问题是我一段时间以来一直困扰的问题。我不确定你的物理如何更新,但也许这是你应该检查的事情,特别是它如何计算游戏计时器的滴答声。您的应用程序可能会读取其刻度,因为它们之间的距离太近,无法达到在转换为 int 后移动 1.25 或 1 的点,因此您的精灵看起来不会移动。我短暂地遇到了这个问题,首先查看我的速度,直到我发现错误出在计时器中。我注意到的另一件事是你的算法收集密度。在 mdpi 设备上,返回 1 还是 160?这可能会产生很大的影响,但我不确定,因为我使用的方程不同。您找到的另一个方程是 android.developer.com 开发指南中列出的方程的释义,用于描述操作系统如何将像素转换为倾角。人们倾向于引用的原因是提供参考,以帮助其他人构建自己的算法,以适合其应用程序的需求。希望这会有所帮助,因为这确实是我目前能给出的最佳答案。抱歉,有任何打字错误,我是通过手机发送的

The +0.5f is to round up to the nearest nukber, as you said. Ideally, when the number is scaled down for ldpi, a value of 1 becomes 0.75, which, when cast to an int is expressed as less than 1 or ~=0. By adding the rounding figure, this number is raised to 1.25 which, when cast as an int yields <2 or ~=1. This way, your sprite should be drawn with a minimum movement of 1. The only reason sprites that move at different speeds would move the same speeds is if they are so close that, when rounded, they wind up being the same size using the scale you gave. Altogether, your equation is very similar to others ive seen. Im making a game that uses surfaceview for the company i work for as well, and while i cant go into details on the code, your issue is one that i struggled with for sone time. Im not sure how your physics updates, but perhaps thats something you should check into, specifically, how it counts ticks for your game timer. It may be that your application is reading its ticks as being too close together to reach the point where it would hit the point of moving the 1.25 or 1 after casting to int, and therefore your sprite appears not to move. I briefly experienced that problem and at first was looking at my velocity until i found that the error was in the timer. One other thing i noticed is that your algorithm collects the density. On a mdpi device, does this return 1 or 160? That could make a big difference, but im not sure, as the equation i used was different. The other equation you found is a paraphrase of the equation listed in the development guide at android.developer.com to describe how the os converts pixels into dip. The reson people tend to quote that is to provide a reference to help others build their own algorithm for scaling appropriate for the jeeds of their app. Hopefully that helps, as its really the best answer i can give at this time. Sorry for any typing errors, im sending this from my phone

了解精灵运动/速度的 DIP

走过海棠暮 2024-12-19 12:41:50

当您使用批量加载器批量加载数据时,不会加载或使用您的模型定义 - 数据会使用低级 API 直接加载到数据存储中。因此,您的模型代码也不会被调用。你的“非常肮脏的解决方案”是解决这个问题的正确方法。

When you bulkload data with the bulkloader, your model definitions are not loaded or used - data is loaded directly into the datastore using the low-level API. As a result, none of your model code is called either. Your 'very dirty solution' is the right way to go about this.

当我批量加载数据时,Google 应用引擎会忽略我的自定义数据库属性吗?

走过海棠暮 2024-12-19 10:08:52

该术语是相对于 theta 0导数

  • theta 标记为 X 轴上的坐标(假设为 A)
  • 在 Y 轴上找到相应的坐标(假设为 B),因此该点属于函数 J
  • 在点 (A, B)
  • 的导数就是这条切线的斜率。

在此处输入图像描述

导数用于控制成本函数(J 函数)最小化的两个方面:

  • 方向 - 符号斜率告诉您应该沿着 X 轴向哪个方向移动以收敛 J
  • 速率 - 斜率的大小告诉您应该移动多快

The term is a derivative with respect to the theta 0.

  • Mark theta as coordinate on X-axis (let it be A)
  • Find corresponding coordinate on Y-axis (let it be B) so the point belongs to the function J
  • Draw tangent line to that function at the point (A, B)
  • The derivative is the slope of this tangent line.

enter image description here

The derivative is used to control two aspects of the cost function (J function) minimization:

  • direction - sign of the slope tells you in which direction you should move along the X-axis in order to converge J
  • rate - magnitude of the slope tells you how fast you should move

梯度下降算法中的delta到底是什么意思?

走过海棠暮 2024-12-18 22:11:47

如果您想在文本末尾插入 Drawable,Drawable 会隐藏文本的最后一个字符,以避免在文本末尾添加另一个字符并从该字符开始绘制。

val myText = "Your text"    

val span: Spannable = SpannableString(myText+"-")
val android: Drawable = ContextCompat.getDrawable(this, R.drawable.yourDrawable)!!
android.setBounds(0, 0, 30, 30)
val image = ImageSpan(android, ImageSpan.ALIGN_BOTTOM)
span.setSpan(image, span.indexOf("-"), span.indexOf("-")+1, Spannable.SPAN_INCLUSIVE_EXCLUSIVE)

If you want to insert Drawable at the end of the text, Drawable is hiding the last character of the text to avoid that add another character at the end of the text and start the drawable at that character.

val myText = "Your text"    

val span: Spannable = SpannableString(myText+"-")
val android: Drawable = ContextCompat.getDrawable(this, R.drawable.yourDrawable)!!
android.setBounds(0, 0, 30, 30)
val image = ImageSpan(android, ImageSpan.ALIGN_BOTTOM)
span.setSpan(image, span.indexOf("-"), span.indexOf("-")+1, Spannable.SPAN_INCLUSIVE_EXCLUSIVE)

如何在多行TextView的末尾插入ImageView?

走过海棠暮 2024-12-18 20:46:22

我不认为这会按照议程通常的方式进行,即按时间顺序,所以我认为没有什么方法可以做到这一点。不过,我想到的是用标签定义批次(在议程中设置标签的,例如前20个),然后按标签过滤(/SPC 过滤当前行的标签)。

我的第一个想法与优先级基本相同:S- 在议程中设置它们,但随后描述了按优先级过滤在邮件列表上,但似乎并不那么容易。

I don't see this going the same way as the agenda usually goes, i.e. chronology, so I don't think there are meant-to-be ways to do that. What comes to my mind, though, is defining your batches with tags (: in the agenda to set tags, say on the first 20), then filtering by tags (/ SPC to filter on tags of the current line).

The first idea I had was basically the same with priorities : S-<up> in the agenda to set them, but then filtering by priority is described here on the mailing list, but doesn't seem that easy.

组织模式:按 20 个项目的块划分议程

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