我刚刚开始学习线程安全性.这让我的代码更具防御性,也许过于防守.
使用像Erlang这样的函数式语言会让我完全摆脱这种担忧吗?
我想不出一个合适的头衔.我有一些数据像 -
$data = <<<EOD
<strong>
HHHHH
<strong>
TTTTT
<strong>
RRRRRRR
<strong>
EOD;
Run Code Online (Sandbox Code Playgroud)
基本上只有一个例子.实际上,数据就像 -
<strong>Some Title</strong>
DATA
<strong>Some other Title</strong>
OTHER DATA
Run Code Online (Sandbox Code Playgroud)
示例:http://pastebin.com/cxzZWDZ8
现在我应用以下RegEx.
preg_match_all("%<strong>(.*?)<strong>%s", $data, $all);
Run Code Online (Sandbox Code Playgroud)
这符合,HHHHH并且RRRRRRR但是我想匹配TTTTT.我怎样才能做到这一点?
import java.net.URL;
import java.net.URLConnection;
import java.sql.*;
public class searchlink{
public static void main(String args[]) throws Exception {
//String link="http://hosted.ap.org";
Connection con=null;
Statement stmt=null;
Statement stmtR=null;
if(con==null){
SQLConnection.setURL("jdbc:sqlserver://192.168.2.53\\SQL2005;user=sa;password=365media;DatabaseName=LN_ADWEEK");
con=SQLConnection.getNewConnection();
stmt=con.createStatement();
stmtR=con.createStatement();
}
ResultSet rs;
rs=stmt.executeQuery("select url from urls where url='http://www.topix.com/rty/elyria-oh'");
while(rs.next()){
String mem=rs.getString(1);
System.out.println("Result is "+mem);}
}
}
Run Code Online (Sandbox Code Playgroud)
如果查询返回一行,上面的程序将打印输出.如果查询未返回任何内容,程序将停止而不打印任何内容.
而不是在没有打印任何东西的情况下停止它,我希望程序识别出查询没有返回任何内容并打印输出,如下所示"SQL查询执行后没有返回任何内容".
如何识别使用某些方法或变量来执行查询而不返回任何行?
我在这里造成内存泄漏还是可以这样做?我应该使用智能指针成员而不是引用吗?
class A
{
public:
A() : b_(*(new B))
{}
private:
B& b_;
};
int main()
{
A a;
return 0;
}
Run Code Online (Sandbox Code Playgroud) 最近我开始开发Android软键盘并且在偏好方面遇到了一些问题.
如何在Android设置应用中添加首选项?我搜索了AnySoftKeyboard的几乎所有源代码,但没有找到任何将它们添加到Settings应用程序的内容.
我正在放置一个链接来显示我的意思:http://code.google.com/p/softkeyboard/wiki/Settings
(从头开始的第一张照片)
谢谢
PS抱歉我的英文不好..
假设我正在设计一个应用程序,我需要使用全局计时系统(这是一个跨领域的问题).我需要从我的应用程序的任何地方访问来自该全球计时系统的数据,并且我不能看到"应用程序的这部分需要它而另一部分不需要".
我的问题是..我应该将其设计为一种环境语境(在这种情况下,是Singleton),还是应该尝试设计其他方式来适应这种情况?
我当然不认为让我的所有类必须通过构造函数注入将这个全局计时类传递给它们是正确的.很多时候我必须将参考文件真正传递到链中,直到某些类最终需要它.另一方面,从阅读的角度来看,它会使一切变得更加清晰(它清楚地说明了我的类的依赖性).
人们通常如何处理这个问题?有没有其他技术可以帮助解决这个问题?AOP可能吗?
PS:全球计时系统只是我从一本我正在阅读的书中获取的一个想法.日志系统将是这类问题的另一个很好的例子.
谢谢
我正在尝试启动并运行,但每当我启动服务器时,我都会看到"未初始化的常量ExceptionNotifier".
http://github.com/rails/exception_notification
在我的Gemfile中我有
gem"exception_notification",:git =>" http://github.com/rails/exception_notification.git " ,: branch =>"master"
我已经尝试将配置如config/application.rb,config/environment.rb和config.ru中的github readme所示.我用我的应用程序名称替换了"Whatever".
exception-handling ruby-on-rails ruby-on-rails-plugins ruby-on-rails-3
我们正在将现有的 Windows 代码移植到 Linux。我们使用 ACE 作为抽象层。我们使用 Windows 命名管道与多个客户端进行通信并执行重叠操作。
在 linux 中与此等效的是什么。我检查了 linux 命名管道(FIFO),但它们似乎只支持一个客户端和一个服务器,并且不支持重叠 IO。
你能指导我吗?
我有一个应用程序需要扫描条形码才能获得代码才能继续.
我使用此代码开始扫描活动:
finish = (Button) findViewById(R.id.finishButton);
finish.setOnClickListener(new OnClickListener() {
public void onClick(View viewParam) {
/*Prompt the user to scan the barcode */
new AlertDialog.Builder(Visit.this)
.setMessage("Please Scan the clients barcode to complete the visit")
.setPositiveButton("Scan Barcode", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//Start the scan application
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
startActivityForResult(intent, 0);
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//Execute some method call
Toast.makeText(Visit.this, "Scan declined...", Toast.LENGTH_SHORT).show();
} …Run Code Online (Sandbox Code Playgroud)