我有数百万对相同长度的字符串我想比较并找到它不匹配的位置.
例如每个对于$str1和$str2我们要找到匹配的位置$str_source:
$str_source = "ATTCCGGG";
$str1 = "ATTGCGGG"; # 1 mismatch with Str1 at position 3 (0-based)
$str2 = "ATACCGGC"; # 2 mismatches with source at position 2 and 7
Run Code Online (Sandbox Code Playgroud)
有没有快速的方法来做到这一点.目前我有C风格方法,我使用'substr'函数循环两个字符串中的每个位置.但这种方法非常缓慢.
my @mism_pos;
for $i (0 .. length($str_source)) {
$source_base = substr($str_source,$i,1);
$str_base = substr($str2,$i,$1);
if ($source_base ne $str_base) {
push @mism_pos,$i;
}
}
Run Code Online (Sandbox Code Playgroud) <div id="DateAndTime" style="clear:left; width:100%" class="Frame">
<h2>Date & Time Criteria</h2>
<h3>Permitted Days of the Week</h3>
<p class="DataForm" style="float:left">
<asp:CheckBox id="chkMonday" runat="server" Text="Monday"/><br />
<asp:CheckBox id="chkTuesday" runat="server" Text="Tuesday"/><br />
<asp:CheckBox id="chkWednesday" runat="server" Text="Wednesday"/><br />
<asp:CheckBox id="chkThursday" runat="server" Text="Thursday"/><br />
<asp:CheckBox id="chkFriday" runat="server" Text="Friday"/><br />
<asp:CheckBox id="chkSaturday" runat="server" Text="Saturday"/><br />
<asp:CheckBox id="chkSunday" runat="server" Text="Sunday"/><br />
</p>
<p class="DataForm" style="float:left">
<asp:CheckBox id="CheckBox1" runat="server" Text="Monday"/><br />
<asp:CheckBox id="CheckBox2" runat="server" Text="Tuesday"/><br />
<asp:CheckBox id="CheckBox3" runat="server" Text="Wednesday"/><br />
<asp:CheckBox id="CheckBox4" runat="server" Text="Thursday"/><br />
<asp:CheckBox id="CheckBox5" runat="server" Text="Friday"/><br …Run Code Online (Sandbox Code Playgroud) 嘿那里,想知道是否有人可以帮助SQL和Python的新手.我以为自己对它有了相当不错的把握,但最近发生了一些奇怪的事情.
以下是从较大部分剪切的以下代码:
try:
self.db.query("SELECT * FROM account WHERE email = '{0}' AND pass = '{1}'".format(self.mail.strip(self.bchars),self.pw.strip(self.bchars)))
except MySQLdb.Error, e:
print "Error %d: %s" % (e.args[0], e.args[1])
exists = self.db.store_result().fetch_row()
print "EXISTS",exists
Run Code Online (Sandbox Code Playgroud)
它用来打印这个:
EXISTS ((2, 'test@test.com', '1234', 1, 0, 2161, '192.168.1.47', 0),)
Run Code Online (Sandbox Code Playgroud)
现在,它打印出来:它用来打印这个:
EXISTS ((2L, 'test@test.com', '1234', 1L, 0L, 2161, '192.168.1.47', 0L),)
Run Code Online (Sandbox Code Playgroud)
我不知道这些L's来自哪里.我检查了SQL数据库,甚至重新加载它以确保.我已经恢复了最后一天的所有代码(所有代码都在运行),但仍无法找到解决方案.我也尝试过搜索,但我甚至不确定这个问题是什么,所以很难搜索.感谢任何人提供的任何帮助或信息.
今天我遇到了一个基于php的应用程序的非常奇怪的行为.在系统的某个部分,有一个UI利用AJAX调用来填充列表框,其中包含来自后端的内容.
现在,AJAX侦听器对所有传入请求执行安全检查,确保只有有效的客户端IP才能获得响应.有效的IP也存储在后端.
为了获得客户端的IP,我使用了普通的旧版本
$_SERVER['REMOTE_ADDR']
Run Code Online (Sandbox Code Playgroud)
这适用于大多数客户.今天我遇到了一个安装,其中remote_addr包含一个网络适配器的IP,它不是为我的应用程序执行实际通信的那个.
谷歌浏览我的Roshan的博客条目:
function getRealIpAddr()
{
if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet
{
$ip=$_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))//check ip is pass from prxy
{
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
$ip=$_SERVER['REMOTE_ADDR'];
}
return $ip;
}
Run Code Online (Sandbox Code Playgroud)
可悲的是,问题仍然存在.
有没有人偶然发现这类问题(实际上我不认为我发现了一个完全新问题^^)并且有一个想法让我如何解决这个问题?
编辑:
我上线了
通过常规LAN卡进行通信.现在,actuall客户端有更多设备.VMNet适配器等.
我想知道客户端配置如何"打扰"Web服务器那么多......
TIA
ķ
我有一系列日期格式为:
26/03/1992
12/06/2010
13/01/1995
等......它在DD/MM/YYYY.我需要找到像"星期二","星期一"等那样的日子.
我知道我需要解析日期或其他事情,但我不确定如何解决这个问题.
我的表设计的一部分是包括一个IsDeleted BIT列,每当用户删除一条记录时,该列设置为1.因此,所有SELECTS都不可避免地伴随着WHERE IsDeleted = 0条件.
我在之前的一个问题(我不能因为上帝的爱重新找到那篇文章并参考它)中读到这可能不是最好的设计而且"审计追踪"表可能更好.
你们是怎么处理这个问题的?
更新 我在SQL Server上.其他DB的解决方案是受欢迎的,虽然对我没有用,但也许对其他人有用.
Update2 只是为了封装到目前为止所说的每个人.似乎基本上有3种方法可以解决这个问题.
在以下代码中:
import java.io.*;
public class MyClass1
{
MyClass1()
{
System.out.println("base class");
}
public void print()
{
System.out.println("base print");
}
}
class ChildClass extends MyClass1
{
public ChildClass()
{
System.out.println("child class");
}
public void print()
{
System.out.println("child print");
}
}
Run Code Online (Sandbox Code Playgroud)
为什么当我创建ChildClass类型的实例时,基类的构造函数也会被执行?
use LWP::Simple;
use Parallel::ForkManager;
@links=(
["http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-2.1-windows.exe","SweetHome3D-2.1-windows.exe"],
["http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-2.1-macosx.dmg","SweetHome3D-2.1-macosx.dmg"],
["http://prdownloads.sourceforge.net/sweethome3d/SweetHome3DViewer-2.1.zip","SweetHome3DViewer-2.1.zip"],
);
# Max 30 processes for parallel download
my $pm = new Parallel::ForkManager(30);
foreach my $linkarray (@links) {
my $pid = $pm->start and next; # do the fork
my ($link,$fn) = @$linkarray;
warn "Cannot get $fn from $link"
if getstore($link,$fn) != RC_OK;
print "$pid = $link is done ";
$pm->finish; # do the exit in the child process
}
$pm->wait_all_children;
Run Code Online (Sandbox Code Playgroud)
执行完毕后,我要去pid是零
0 = http://prdownloads.sourceforge.net/sweethome3d/SweetHome3DViewer-2.1.zip is done 0 = http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-2.1-macosx.dmg is done 0 …
我想在<br />一个特定的课上追加一个.使用:after伪类只显示<br />为文本.
有没有办法让这项工作?
它是IE8的内部,所以浏览器问题不是问题.如果我做
<span class="linebreakclass">cats are</span> brilliant
Run Code Online (Sandbox Code Playgroud)
我希望"辉煌"出现在新的一条线上.
我有2个基本接口,IViewBase(所有视图都将实现)和IPresenterBase(所有演示者都将实现):
public interface IViewBase { }
public interface IPresenterBase
{
IViewBase View { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
然后我创建了一个新的接口ILogPresenter,它派生自IPresenterBase和ILogView派生自IViewBase:
public interface ILogPresenter : IPresenterBase { }
public interface ILogView : IViewBase{ }
Run Code Online (Sandbox Code Playgroud)
当我创建一个实现ILogPresenter的类时,
public class LogPresenter: ILogPresenter
{
public ILogView View { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:
'LogPresenter'没有实现接口成员'IPresenterBase.View'.'LogPresenter.View'无法实现'IPresenterBase.View',因为它没有匹配的返回类型'Views.IViewBase'.
我不能将LogPresenter.View的返回类型设置为从IViewBase派生的ILogView?我想用不同的IView实现ILogPresenter,它来自IViewBase.