我正在寻找一个可以用来注释源代码的工具.
我有一些我需要了解的第三方源代码(JavaScript),我不想更改它(添加内联注释)以便
通常情况下,我会在上面写一个涂鸦的全部内容,但代码太长了,我需要按电子邮件分享.如果能够做到这一点,我会很高兴,包括能够在代码中的这些位置之间创建"链接",甚至可能在视觉上用线条或箭头.
我有两个链接,我想一次显示/隐藏它们,我的代码是:
<!DOCTYPE html>
<html>
<head>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">
// we will add our javascript code here
$(document).ready(function() {
$(function(){
$('#link').click(function(){
$('#colorDiv').slideToggle('slow');
return false;
});
});
});
</script>
<meta charset=utf-8 />
<title>JS Bin</title>
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
#dv {
width:100px;
height:100px;
border:1px solid;
}
</style>
</head>
<body>
<table cellspacing="2">
<tr><td><a href="#" id="link">Color</a></td><td><a href="#" id="link">Car</a></td></tr>
<tr><td><div id="colorDiv">Red</div></td><td><div id="carDiv">PRADO</div></td></tr>
</table>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
默认情况下,我应该显示第一个div.汉克斯.
(是的,我知道一台机器指令通常无关紧要.我问这个问题是因为我想了解pimpl习语,并以最好的方式使用它;而且因为有时我会关心一台机器指令.)
在下面的示例代码中,有两个类,Thing和
OtherThing.用户将包括"thing.hh".
Thing使用pimpl成语来隐藏它的实现.
OtherThing使用C样式 - 返回并获取指针的非成员函数.这种风格产生稍好的机器代码.我想知道:有没有办法使用C++风格 - 即,使函数成为成员函数 - 但仍然保存机器指令.我喜欢这种风格,因为它不会污染类外的命名空间.
注意:我只关注调用成员函数(在本例中calc).我不是在看对象分配.
下面是我的Mac上的文件,命令和机器代码.
thing.hh:
class ThingImpl;
class Thing
{
ThingImpl *impl;
public:
Thing();
int calc();
};
class OtherThing;
OtherThing *make_other();
int calc(OtherThing *);
Run Code Online (Sandbox Code Playgroud)
thing.cc:
#include "thing.hh"
struct ThingImpl
{
int x;
};
Thing::Thing()
{
impl = new ThingImpl;
impl->x = 5;
}
int Thing::calc()
{
return impl->x + 1;
}
struct OtherThing
{
int x;
};
OtherThing *make_other()
{
OtherThing *t …Run Code Online (Sandbox Code Playgroud) 当我解释问题时,请耐心等待我,我是如何解决这个问题的,最后我的问题是如何改进它.
我有一个来自离线批处理作业的100,000行csv文件,我需要将其作为正确的模型插入到数据库中.通常,如果这是一个相当直接的加载,只需将CSV文件重新设置为适合模式即可轻松加载; 但是,我不得不做一些需要查询的外部处理,使用SQLAlchemy生成我想要的数据会更方便.
我想要的数据是3个模型,它们代表数据库中3个预先存在的表,每个后续模型都依赖于以前的模型.例如:
Model C --> Foreign Key --> Model B --> Foreign Key --> Model A
Run Code Online (Sandbox Code Playgroud)
因此,模型必须按照A,B和C的顺序插入.我想出了一个生产者/消费者的方法:
- instantiate a multiprocessing.Process which contains a
threadpool of 50 persister threads that have a threadlocal
connection to a database
- read a line from the file using the csv DictReader
- enqueue the dictionary to the process, where each thread creates
the appropriate models by querying the right values and each
thread persists the models in the appropriate order
Run Code Online (Sandbox Code Playgroud)
这比非线程读取/持久化更快,但它比将文件批量加载到数据库中要慢.大约 …
我已经看到一些验证码使用javascript,php等进行解码.他们是如何做到的?
例如,非常受欢迎的megaupload网站的验证码也已被解码.
我正在为iPad开发一个Web应用程序,以便在Safari中运行.我还没有iPad可以测试.有没有人知道可用的屏幕大小 - 在Safari/ipad控件的任何空间占用之后?
使用PreApplicationStartMethod属性发生了奇怪的事情.我确实在我的最新项目中实现了它.在AssemblyInfo.cs中,我有以下行:
[assembly: PreApplicationStartMethod(typeof(MyAssembly.Initializer), "Initialize")]
Run Code Online (Sandbox Code Playgroud)
Type和方法如下所示:
namespace MyAssembly
{
public static class Initializer
{
public static void Initialize()
{
TranslationKeys.Initialize();
}
}
}
Run Code Online (Sandbox Code Playgroud)
当我重建我的应用程序并在浏览器中加载它时,我收到以下错误:
程序集"MyWebApp,Version = 0.0.1.0,Culture = neutral,PublicKeyToken = null"上的PreApplicationStartMethodAttribute指定的方法无法解析.键入:'MyAssembly.Initializer',MethodName:'Initialize'.验证类型是否为public且方法是public和static(在Visual Basic中为Shared).
我真的不知道问题是什么.
良好实践规定Fortran中的子例程参数应该都具有指定的意图(即intent(in),intent(out)或者如此问题intent(inout)所描述的):
subroutine bar (a, b)
real, intent(in) :: a
real, intent(inout) :: b
b = b + a
...
Run Code Online (Sandbox Code Playgroud)
但是,未指定intent是有效的Fortran:
subroutine bar (a, b)
real, intent(in) :: a
real :: b
b = b + a
...
Run Code Online (Sandbox Code Playgroud)
在编译时检查指定intent(inout)的参数和没有指定意图的参数之间是否存在任何真正的差异?如果我正在改进对较旧的,无意图的代码的意图,我还有什么可担心的吗?
我正在寻找一种可以监视数据库(mysql和oracle)进行更改的工具.
当有人在任何(或选择的)表格中插入或更新某些内容时,我想了解它.对于在数据库中做一些魔术的其他人来说,这可能非常有用.
我知道它可以使用触发器来完成(参见这个问题),但我对一些可以做到这一点的工具更感兴趣,这是免费的.
>>> num = 4.123456
>>> round(num, 3) # expecting 4.123
4.1230000000000002
Run Code Online (Sandbox Code Playgroud)
结果我期待4.123,我错了吗?
javascript ×2
python ×2
.net-4.0 ×1
annotations ×1
asp.net ×1
bulkinsert ×1
c# ×1
c++ ×1
database ×1
fortran ×1
fortran90 ×1
ipad ×1
jquery ×1
math ×1
mysql ×1
optimization ×1
oracle ×1
orm ×1
performance ×1
php ×1
pimpl-idiom ×1
security ×1
sql ×1
sqlalchemy ×1