我有以下代码:
$('a.confirm').click(function(e) {
e.preventDefault();
var answer = confirm("Are you sure?")
if (answer){
// do the default action
}
});
Run Code Online (Sandbox Code Playgroud)
如果用户确认,我必须输入什么代码才能执行默认操作?
我在类中找到了这行代码,我必须修改它:
::Configuration * tmpCo = m_configurationDB;//pointer to current db
Run Code Online (Sandbox Code Playgroud)
而且我不知道究竟是什么意思是双重冒号前面的类名.没有它我会读:声明tmpCo作为指向类的对象的指针Configuration...但前面的双冒号混淆了我.
我还发现:
typedef ::config::set ConfigSet;
Run Code Online (Sandbox Code Playgroud) 嗨,我有一个问题,在下面的代码中我们需要写n--;吗?
int n = pointList.size();
for(int i=pointList.size()-1;i>=0;i--){
for(int j=0;j<list.size();j++){
if(pointList.get(i).equals(list.get(j))){
pointList.remove(i);
n--;
}
}
}
Run Code Online (Sandbox Code Playgroud)
list也是一个arrayList.谢谢.
我的MVC2应用程序使用一个组件,使后续的AJAX调用回到相同的操作,这会导致服务器上的各种不必要的数据访问和处理.组件供应商建议我将这些后续请求重新路由到不同的操作.后续请求的不同之处在于它们具有特定的查询字符串,我想知道是否可以在路由表中对查询字符串设置约束.
例如,初始请求带有一个URL,如http:// localhost/document/display/1.这可以通过默认路由处理.我想写一个自定义路由来处理像http:// localhost/document/display/1这样的URL ?vendorParam1 = blah1&script = blah.js和http:// localhost/document/display/1?vendorParam2 = blah2&script = blah.js通过检测URL中的"供应商".
我试过以下,但它抛出一个System.ArgumentException: The route URL cannot start with a '/' or '~' character and it cannot contain a '?' character.:
routes.MapRoute(
null,
"Document/Display/{id}?{args}",
new { controller = "OtherController", action = "OtherAction" },
new RouteValueDictionary { { "args", "vendor" } });
Run Code Online (Sandbox Code Playgroud)
我可以编写一条考虑查询字符串的路由吗?如果没有,你还有其他想法吗?
更新:简单地说,我可以编写路由约束,使http:// localhost/document/display/1路由到DocumentController.Display操作但是http:// localhost/document/display/1?vendorParam1 = blah1&script = blah.js被路由在VendorController.Display行动?最后,我希望任何查询字符串包含"vendor"的URL都被路由到该VendorController.Display …
当我试图找到数字的立方根时发生奇怪的事情.
以下代码返回undefined.在cmd:-1.#IND
cout<<pow(( double )(20.0*(-3.2) + 30.0),( double )1/3)
Run Code Online (Sandbox Code Playgroud)
虽然这个非常好.在cmd:4.93242414866094
cout<<pow(( double )(20.0*4.5 + 30.0),( double )1/3)
Run Code Online (Sandbox Code Playgroud)
从数学方面来说它必须起作用,因为我们可以从负数中得到立方根.Pow来自Visual C++ 2010 math.h库.有任何想法吗?
每次我ConfigurationManager.GetSection("registeredPlugIns")为这个自定义部分做一个我收到此错误:
为registeredPlugIns创建配置节处理程序时发生错误:
无法从程序集'System.Configuration,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'加载类型'Engine.PlugInArch.PlugInConfigurationSection'.
为什么要尝试加载类型System.Configuration而不是我要求的组件?
这是我的部分代码:
namespace Engine.PlugInArch
{
public class PlugInConfigurationSection : ConfigurationSection
{
[ConfigurationProperty("plugIns", IsDefaultCollection = false),
ConfigurationCollection(typeof(PlugInCollection), AddItemName = "addPlugin")]
public PlugInCollection PlugIns
{
get { return this["plugIns"] as PlugInCollection; }
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的app.config
<configuration>
<configSections>
<section name="registeredPlugIns" type="Engine.PlugInArch.PlugInConfigurationSection, Engine"/>
</configSections>
...
<registeredPlugIns>
<plugIns>
<addPlugIn DllName="ProcessorPlugin.dll"/>
</plugIns>
</registeredPlugIns>
</configuration>
Run Code Online (Sandbox Code Playgroud) 我试图在pyglet中混合使用opengl中的2d和3d,即绘制一个3d场景,然后切换到正交投影并在顶部绘制内容.我绘制3d东西,将投影矩阵推到堆栈,做一个glOrtho投影矩阵,绘制2d的东西,然后从堆栈中弹出前一个矩阵.3d的东西很好,但由于某种原因,2d部分根本没有绘制,即使是单独的.这是代码:
class Window(pyglet.window.Window):
# resolution
width, height = 1024, 786
def __init__(self, width, height):
# initialise window
super(Window, self).__init__(width, height)
# set title
self.set_caption("OpenGL Doss")
# call update() at 30fps
pyglet.clock.schedule_interval(self.update, 1 / 30.0)
glEnable(GL_TEXTURE_2D) # enable textures
glShadeModel(GL_SMOOTH) # smooth shading of polygons
glClearColor(0.0, 0.0, 0.0, 0.0)
glClearDepth(1.0)
glDepthFunc(GL_LEQUAL)
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST) # make stuff look nice
self.world = World() # initialise world
self.label = pyglet.text.Label('Hello, world',
font_name='Times New Roman',
font_size=20,
width=10, height=10)
def on_resize(self, width, height):
print 'on resize' …Run Code Online (Sandbox Code Playgroud) 这是我的MD5问题的另一个问题.我知道问题是ASCII字符©(0xa9,169).要么是我将字符插入字符串的方式,要么是高字节和低字节问题.
如果我
NSString *source = [NSString stringWithFormat:@"%c", 0xa9];
NSData *data = [source dataUsingEncoding:NSASCIIStringEncoding];
NSLog(@"\n\n ############### source %@ \ndata desc %@", source, [data description]);
CC_MD5([data bytes], [data length], result);
return [NSString stringWithFormat:
@"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
result[0], result[1], result[2], result[3],
result[4], result[5], result[6], result[7],
result[8], result[9], result[10], result[11],
result[12], result[13], result[14], result[15]
];
Run Code Online (Sandbox Code Playgroud)
结果:
######### source©[数据描述] =(null)
md5:d41d8cd98f00b204e9800998ecf8427e
值:int 169 char©
当我将编码更改为
NSData *data = [NSData dataWithBytes:[source UTF8String] length:[source length]];
Run Code Online (Sandbox Code Playgroud)
结果是
######### source©[数据描述] ="<"c2>
md5:6465dad1d31752be3f3283e8f70feef7
当我将编码更改为
NSData *data = [NSData dataWithBytes:[source UTF8String] …Run Code Online (Sandbox Code Playgroud) 我正在寻找C或C++中的这个问题的解决方案.
编辑:澄清.这是在Linux系统上.特定于Linux的解决方案绝对没问题.跨平台不是一个问题.
我有一个在自己的线程中运行的服务.这个服务是一个有几个方法的类,其中一些方法需要在自己服务的线程中而不是在调用者的线程中运行.
目前我正在使用包装器方法创建具有输入和输出参数的结构,将结构插入队列并返回(如果"命令"是异步的)或等待其执行(如果"命令"是同步的).
在线程方面,服务唤醒,从队列中弹出一个结构,找出要执行的内容并调用适当的方法.
这个实现有效,但添加新方法非常麻烦:定义包装器,带参数的结构和处理程序.我想知道是否有一种更简单的方法来编写这种模型:一种类方法,它在类自己的线程上执行,而不是在调用者的线程中执行.
编辑 - 一种结论:
似乎没有事实上的方法来实现我所要求的,不涉及额外的编码工作.
我会坚持我提出的方法,它确保类型安全,最小化锁定,允许同步和异步调用以及相当适度的开销.
另一方面,它需要一些额外的编码,并且随着方法数量的增加,调度机制可能变得臃肿.在构造上注册调度方法,或者让包装器执行该工作似乎可以解决问题,消除一些开销并删除一些代码.
c++ ×3
.net ×1
arraylist ×1
c ×1
c# ×1
class-design ×1
cocoa ×1
cocoa-touch ×1
components ×1
ios ×1
java ×1
jquery ×1
math.h ×1
namespaces ×1
nsdata ×1
nsdate ×1
objective-c ×1
opengl ×1
pow ×1
pyglet ×1
python ×1
routing ×1
syntax ×1