问题列表 - 第34377页

纯css悬停显示另一个元素可能吗?

<a href="">
  text here always show
 <div  style="display:none;">
   hide text here
 </div>
</a>


a:hover{

//when hover show 'hide text here' ; when not hover, hide it again 
}
Run Code Online (Sandbox Code Playgroud)

可以用纯css来做这个效果吗?

html css

25
推荐指数
1
解决办法
2万
查看次数

有没有理由使用运行时断言而不是编译时断言?

在查看Visual C++代码库时,我发现了以下奇怪的事情.在编译时可以评估条件的情况下,使用运行时断言(检查条件并在违反条件时抛出异常):

assert( sizeof( SomeType ) == sizeof( SomeOtherType ) );
Run Code Online (Sandbox Code Playgroud)

很明显,编译器将评估条件并替换有效的代码

assert( true );
Run Code Online (Sandbox Code Playgroud)

什么都不做或

assert( false );
Run Code Online (Sandbox Code Playgroud)

每次控件通过该行时都会抛出异常.

IMO应该使用编译时断言,原因如下:

  • 它会在编译时更早地暴露条件违规 - 和
  • 它会让清洁(因此更快,更小)的机器代码被发出

看起来像编译时断言是唯一正确的事情.有没有可能的理由在这里更喜欢运行时断言?

c++ assert error-checking visual-c++

5
推荐指数
1
解决办法
4582
查看次数

在Rails中调用jQuery ajax?

我想执行一个简单的事情.当用户单击链接时,jQuery需要生成一个Ajax请求,该请求将链接项的id发送到控制器中的方法.基本上,当用户单击删除链接时,我想要一个漂亮的模态对话框窗口.该窗口需要包含有关已删除项目的各种信息.例如 <%= link_to "Delete", item, :id => "delete" %>

我可以用jquery选择这个链接,甚至在用户点击它时打开一个弹出对话框.通过application.js但我真正需要的是jQuery在单击链接时调用我的方法,在我的方法中我将通过format.js回答.在js文件中,我放置代码以显示带有所需参数的模态对话框.所有这些行为都是通过ajax of course进行的.我无法为控制器中的方法生成ajax请求.不知道如何处理jQuery.ajax方法,特别是如何强制jQuery将url参数传递给rails方法.我观看了railscast并用.post研究了这个例子,但我不需要提交任何表格.任何建议表示赞赏.谢谢

jquery jquery-ui ruby-on-rails

2
推荐指数
1
解决办法
2792
查看次数

(Co)列表中的差异与Scala中的Stacks不同吗?

当我编写这段代码时,我在Scala中遇到了编译错误

var s: Stack[_ <: Number] = new Stack[Integer]; 
s.push(new Integer(1)); //compile-error: type mismatch; found :Integer required: _$bqjyh where type _$bqjyh <: Number
s.push(null); //compile-error: type mismatch; found   : Null(null) required: _$2 where type _$2 <: Objects.Vehicle
Run Code Online (Sandbox Code Playgroud)

由于通配符,这相当于Java中的协变集合; 它确切的类型在未知,所以我们不能添加东西到堆栈.

但是对于列表,我不会得到同样的错误:

   var list: List[_ <: Number] = Nil;
   var intList : List[Integer] = new Integer(1) :: Nil;
   list = intList ; //no error
   list = new Float(2) :: vehicles;  //even float allowed
Run Code Online (Sandbox Code Playgroud)

现在,我可以添加甚至float,但事实上我相信listListIntegers,所以不会 …

java generics scala covariance

3
推荐指数
1
解决办法
243
查看次数

Mysql:将日期从'dd/mm/yyyy'转换为'yyyymmdd'

我正在研究一个在varchar(10)mysql字段中存储日期的数据库(太可悲了).

我无法改变数据库结构(即构建一个小插件),但我必须查询数据库,查找此数据字段在接下来的10天之间的行.

例:

| fid | fdate      |
|  1  | 10/09/2010 |
|  2  | 17/09/2010 |
|  3  | 19/09/2010 |
Run Code Online (Sandbox Code Playgroud)

我必须得到fid 1和2的行,因为日期是<=现在+ 10天.

通常我做这种查询:

SELECT fid FROM table WHERE fdate <= DATE_ADD(NOW(), INTERVAL 10 DAY);
Run Code Online (Sandbox Code Playgroud)

或者,如果日期的格式为"yyyymmdd":

SELECT fid FROM table WHERE fdate <= DATE_FORMAT(NOW(), '%Y%m%d');
Run Code Online (Sandbox Code Playgroud)

但它们对格式没用dd/mm/yyyy.

我已经想通了

SELECT fid, CONCAT(SUBSTRING(fdate, 7, 4), SUBSTRING(fdate, 4, 2), SUBSTRING(fdate, 1, 2)) AS mydate FROM table HAVING mydate <= DATE_ADD(NOW(), INTERVAL 10 DAY);
Run Code Online (Sandbox Code Playgroud)

但我想用concat和substring重建日期格式有点过分,并且该having子句不会帮助查询速度.

任何的想法? …

mysql date

6
推荐指数
1
解决办法
1万
查看次数

如何正确调整播放器精灵速度?(基本上是一个数学问题?)

背景:我有一个鸟瞰的JavaScript游戏,玩家通过触摸圆圈来控制太空飞船 - 例如触摸圆心的左侧,船将向左移动,触摸右上方,它将移动到顶部正确等等......离伪陀螺的圆心越远,朝这个方向的速度越快.但是,我不是直接调整船的速度,而是设置targetSpeed.x和targetSpeed.y值,然后船将使用以下内容调整其速度:

if (this.speed.x < this.targetSpeed.x) {
    this.speed.x += this.speedStep;
}
else if (this.speed.x > this.targetSpeed.x) {
    this.speed.x -= this.speedStep;
}
Run Code Online (Sandbox Code Playgroud)

...和y速度相同,而速度步长是一个很小的值,使其更平滑而且不会太突然(船不应该从快速向左方向转向直接快速向右方向).

我的问题:使用上面的代码,我相信速度将在对角线方向上更快调整,而在水平/垂直线上调整速度更慢.如何纠正此问题以获得相同的目标速度?

非常感谢您的帮助!

math vector angle

2
推荐指数
1
解决办法
241
查看次数

紧凑框架中的透明度

我需要在.NETCF中创建一个透明背景的图像,我使用洋红色作为我希望透明的背景.我尝试这样做的方法是覆盖onPaint().但我无法让背景透明化?这就是我所拥有的:

protected override void OnPaint(PaintEventArgs e)
{
    Graphics g = e.Graphics;

    ImageAttributes imageAttributs = new ImageAttributes();
    imageAttributs.SetColorKey(Color.FromArgb(255, 0, 255), 
        Color.FromArgb(255, 0, 255));
    g.DrawImage(cross, crossRect, 200, 10, cross.Width, cross.Height,
        GraphicsUnit.Pixel, imageAttributs);

    base.OnPaint(e);
}
Run Code Online (Sandbox Code Playgroud)

但是当我尝试包含ImageAttributes时,我的图像根本没有被绘制?

.net c# compact-framework windows-mobile

6
推荐指数
1
解决办法
6363
查看次数

marshal_as,字符串和字段与属性

包括"stdafx.h"

#include <string>
#include <msclr/marshal_cppstd.h>

ref class Test {
    System::String^ text;
    void Method() {
        std::string f = msclr::interop::marshal_as<std::string>(text); // line 8
    }
};
Run Code Online (Sandbox Code Playgroud)

使用VS2008编译时此代码给出:

.\test.cpp(8) : error C2665: 'msclr::interop::marshal_as' : none of the 3 overloads could convert all the argument types
        f:\programy\vs9\vc\include\msclr\marshal.h(153): could be '_To_Type msclr::interop::marshal_as<std::string>(const char [])'
        with
        [
            _To_Type=std::string
        ]
        f:\programy\vs9\vc\include\msclr\marshal.h(160): or       '_To_Type msclr::interop::marshal_as<std::string>(const wchar_t [])'
        with
        [
            _To_Type=std::string
        ]
        f:\Programy\VS9\VC\include\msclr/marshal_cppstd.h(35): or       'std::string msclr::interop::marshal_as<std::string,System::String^>(System::String ^const &)'
        while trying to match the argument list '(System::String ^)'
Run Code Online (Sandbox Code Playgroud)

但是当我将字段更改为属性时:

    property System::String^ …
Run Code Online (Sandbox Code Playgroud)

c++-cli marshalling visual-studio-2008

5
推荐指数
2
解决办法
1677
查看次数

比较和交换vs测试和设置

有人可以向我解释多线程中上述操作的工作和差异吗?

c++ atomicity thread-synchronization

22
推荐指数
2
解决办法
1万
查看次数

确定一个数字是否为素数的好算法?

可能重复:
更有效地检查int是否为素数

我需要测试一些非常大的整数来看它是否是素数.你能提供一些好的算法或库例程吗?

编辑:C/C++就行了.

谢谢.

algorithm primes

0
推荐指数
1
解决办法
702
查看次数