我正在阅读Bill Wagner的书" Effective C#".在第32项中,他主张开发人员创建更小,更有凝聚力的组件,可以更容易地重用.然而,在同一个项目中,他说:
...额外的安全检查也是在装配边界上完成的.来自同一程序集的所有代码具有相同的信任级别(不一定是相同的访问权限,但具有相同的真实级别).每当代码流穿过程序集边界时,CLR都会执行一些安全检查.程序流程跨越程序集边界的次数越少,效率就越高......这些性能问题都不能阻止您分解太大的程序集.性能处罚很轻微.
我的问题是,是否对Foo.dll中的每个方法调用执行了额外的安全检查,还是仅在第一次加载程序集时执行?
谢谢
我的网站是使用php文件构建的.我在这些文件中使用商业秘密算法,我的数据库的root密码也存储在这些php文件中.我的数据库用于存储许多客户的私人医疗数据.
这被认为是安全的设置; 任何人都可以从我的网络服务器下载PHP源码,因此可以访问我的root mysql密码?
我在ubuntu 8.04和mysql 5上运行apache 2.0和php 5.
谢谢.
我有两个数组,一个非常大(超过百万个条目),而另一个数组很小(少于1000个条目),在数组中查找所有条目的最大数量的最佳方法是什么?
谢谢.
我刚升级到雪豹.之前,我把一切都运行得很好,但现在当我从终端启动服务器时,我得到:
=> Booting WEBrick
=> Rails 2.3.3 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2009-08-28 23:18:19] INFO WEBrick 1.3.1
[2009-08-28 23:18:19] INFO ruby 1.8.7 (2008-08-11) [universal-darwin10.0]
[2009-08-28 23:18:19] INFO WEBrick::HTTPServer#start: pid=845 port=3000
Run Code Online (Sandbox Code Playgroud)
然后当我开始生成页面时,似乎它不能与sqlite3一起使用.我该如何解决?这是当我进入脚本化视图页面时服务器打印出来的内容:
/!\ FAILSAFE /!\ Fri Aug 28 23:18:34 -0400 2009
Status: 500 Internal Server Error
uninitialized constant SQLite3::Driver::Native::Driver::API
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:105:in `const_missing'
/Library/Ruby/Gems/1.8/gems/sqlite3-ruby-1.2.5/lib/sqlite3/driver/native/driver.rb:76:in `open'
/Library/Ruby/Gems/1.8/gems/sqlite3-ruby-1.2.5/lib/sqlite3/database.rb:76:in `initialize'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/sqlite3_adapter.rb:13:in `new'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/sqlite3_adapter.rb:13:in `sqlite3_connection'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:in `send'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:in `new_connection'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:245:in `checkout_new_connection'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:188:in `checkout'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in `loop'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in `checkout' …Run Code Online (Sandbox Code Playgroud) 最近我正在为DVR构建软件.
它将安装在插有2个或更多PCIE x4视频编码器卡的x86 pc服务器上.
我们有2个分离的过程,一个必须从这些编码器卡获取编码的视频数据,另一个必须将这些数据保存到硬盘驱动器.为什么我们有两个过程?一些历史问题.
那么,我们应该使用什么样的IPC?套接字,管道或共享内存?
目前我们正在使用socket.
我的问题是:当我编辑个人资料页面时,如何让我的个人资料控制器的编辑/更新方法停止创建新记录?
我有一个用户模型和配置文件模型.
user has_one :profile.
profile belongs_to :user.
我的routes.rb看起来像这样:map.resources:users,:has_one =>:profile
当我的应用程序的访问者创建用户并点击提交时,他们将被定向到"创建个人资料"屏幕.
以下控制器创建一个配置文件,以便创建的配置文件URL为:localhost:3000/users/[user_id]/profile
def new
@profile = `current_user.build_profile`
end
def create
@profile = current_user.build_profile(params[:profile])
if @profile.save
flash[:notice] = 'Profile was successfully created.'
redirect_to user_profile_path
else
flash[:notice] = 'Error. Something went wrong.'
render "new"
end
end
Run Code Online (Sandbox Code Playgroud)
一切正常.
编辑配置文件时出现问题.
起初看起来很好.当我转到"编辑个人资料"视图时,网址是正确的.例如,如果"显示配置文件"视图的网址是localhost:3000/users/1/profile,则"编辑配置文件"视图显示为:localhost:3000/users/1/profile/edit
非常好.
当我进行更改并单击更新按钮时,这似乎也有效.我被引导到正确的"显示配置文件"视图,我得到一个确认更改的闪存通知.
所以这是奇怪的部分.当我回到我的配置文件索引以查看应用程序中的所有配置文件时,结果表明应用程序每次更新配置文件时都创建了新的配置文件记录.原始配置文件记录仍然存在,但有新的附加记录.请记住,我的应用中的所有配置文件都与用户绑定,用户只能拥有一个配置文件.因此,如果我的应用程序中有5个用户,那么现在可能有10个不同的配置文件,每个配置文件都有一个导致已破坏页面的URL,因为数据库中不存在user_id.例如,localhost:3000/users/7/profile,users/8/profile等.
记录将保存到我的数据库中的配置文件表中,但user_id列显示NUL.
我认为问题来自(a)配置文件控制器中的编辑/更新方法,或(b)我用于在配置文件索引页面上显示配置文件的代码.
这是编辑和更新方法的配置文件控制器:
def edit
@profile = current_user.profile(params[:id])
end
def update
@profile = current_user.profile.find(params[:id])
if @profile.update_attributes(params[:profile])
flash[:notice] = 'Profile was successfully updated.'
redirect_to(@profile)
else
render "edit"
end
Run Code Online (Sandbox Code Playgroud)
结束 …
我有一个如下结构,带有一个指向名为"length"的函数的指针,该函数将返回chars成员的长度.
typedef struct pstring_t {
char * chars;
int (* length)();
} PString;
Run Code Online (Sandbox Code Playgroud)
我有一个函数来返回从指针到PString的字符长度:
int length(PString * self) {
return strlen(self->chars);
}
Run Code Online (Sandbox Code Playgroud)
我有一个函数initializeString(),它返回一个指向PString的指针:
PString * initializeString() {
PString *str;
str->length = &length;
return str;
}
Run Code Online (Sandbox Code Playgroud)
很明显,我在这里做了一些非常错误的指针,因为该str->length = &length行在我的调试器中会产生一个EXC_BAD_ACCESS信号,就像返回strlen(self-> chars)一样.有没有人对这个问题有任何见解?
我特别希望能够让initializeString()函数返回指向PString的指针,并使用指向PString的指针作为输入的长度函数.这只是在C中实现基本的面向对象系统的一个实验,但我没有很多经验处理指针的经验.感谢你给与我的帮助.
我有以下CPP代码段和相关的错误消息:
代码段
struct node{
char charVal;
bool childNode;
struct node *leftChild;
struct node *rightChild;
};
vector<std::pair<int,struct node*> > nodeCountList;
struct node *nodePtr = new struct node;
nodeCountList.push_back(1,nodePtr);
Run Code Online (Sandbox Code Playgroud)
错误信息
error: no matching function for call to ‘std::vector<std::pair<int, node*>, std::allocator<std::pair<int, node*> > >::push_back(int&, node*&)’
/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:602: note: candidates are: void std::vector<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp = std::pair<int, node*>, _Alloc = std::allocator<std::pair<int, node*> >]
Run Code Online (Sandbox Code Playgroud)
请帮我解决错误信息.
干杯