我试图看看是否foo
包含"非活动"或用户是否尝试键入"非活动"一词的部分.
有没有更简单的方法来实现这一目标?
if (foo.equals("inactive") || foo.equals("inactiv")
|| foo.equals("inacti") || foo.equals("inact")
|| foo.equals("inac") || fofoo.equals("ina")
|| foo.equals("in") || foo.equals("nactive")
|| foo.equals("nactiv") || foo.equals("nacti")
|| foo.equals("nact") || foo.equals("nac")
|| foo.equals("na") || foo.equals("n")) {
Run Code Online (Sandbox Code Playgroud) 我有一个类使用颜色矩阵在ImageView上添加图像效果.我有几种颜色矩阵用于对比度,曝光,温度和饱和度.例如:
public static Bitmap changeContrast(Bitmap bmp, float contrast)
{
ColorMatrix cm = new ColorMatrix(new float[]
{
contrast, 0, 0, 0, 0,
0, contrast, 0, 0, 0,
0, 0, contrast, 0, 0,
0, 0, 0, 1, 0
});
return getBitmapFromColorMatrix(cm, bmp);
}
Run Code Online (Sandbox Code Playgroud)
现在我的问题是,图像的锐化.这些似乎没有颜色矩阵.请帮忙.
我尝试使用此处的代码锐化图像,但处理时间太长,我不知道应该将哪些有效值传递给方法的权重参数sharpenImage(Bitmap src, double weight)
.
我有一个表,其中一列显示日期时间值.我正在使用angularjs ngtable模块.
<div ng-controller="TestCtrl" class="container">
<table ng-table="tableParams" class="table table-bordered">
<thead>
<tr>
<th>name</th>
<th>date</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="test in $data">
<td data-title="'name'" >
{{test.name}}
</td>
<td data-title="'remarks'">
{{test.date}}
</td>
</tr>
</tbody>
</table>
</div>
Run Code Online (Sandbox Code Playgroud)
{{test.date}}
看起来像一个例子2015-12-08T16:00:00.000Z
.我想把它转换成Dec08 16:00:00
.怎么能在angularjs中完成?
我有一个有趣的情况.当我在Microsoft SQL Server Management Studio中的远程SQL服务器上运行查询时,它运行速度很快(12秒),但是当我使用DbContext.Database.SqlQuery<EntityType>(script)
它在Entity Framework中运行相同的查询时需要48秒.
我尝试过设置set arithabort on
.设置已应用,但未改变性能.我无法提供查询执行计划,因为我对SQL服务器的权限有限.但我可以100%表示这不是查询问题.
考虑这个查询:
declare @t table (...)
insert into @t
select <long query>
select top 1 * from @t
Run Code Online (Sandbox Code Playgroud)
该@t
变量包含大约35k行.EF和SSMS的执行时间非常相似.但当我删除top 1
然后奇怪的事情开始发生.在SSMS中,我得到10秒,但在EF约40秒.
我想这个小实验可以排除SQL Server选择错误的执行计划和减慢速度的可能性.
另一个兴趣点是EF完成的实体实现.我认为这也不是瓶颈,因为当我在本地SQL Express上运行类似大小的结果集的类似查询时 - 我几乎立即得到结果.
所以我的下一个猜测是网络问题.我安装了Microsoft Network Monitor 3.4并监控SSMS和EF的网络流量.我发现的interestig事情是由于某种原因有很多较小的数据包和EF版本的一些TLS数据包.在SSMS版本中,数据包大小更稳定,并且没有TLS数据包.
所以问题是:是否可以加速EF版本?什么是TLS数据包,是否有可能摆脱它们?
更新
实体框架v6.1.3
.NET v4.5.1
SQL Server v10.50.2550.0
本地SQLExpress v12.0.4213.0
Windows 7 Pro
更新
using (var connection = new SqlConnection(DbContext.Database.Connection.ConnectionString))
using (var cmd = new SqlCommand(script, connection))
{
connection.Open();
cmd.CommandType = CommandType.Text;
using (SqlDataReader …
Run Code Online (Sandbox Code Playgroud) 有没有办法通过UILabel添加一条简单的线.我有一个40px高的UILabel,只想在中间水平画一条黑线(20px).有没有办法在不创建图像并将其设置为背景的情况下执行此操作?
我目前正在测试VS2015以了解它对我们的解决方案的反应.我有一些麻烦,因为VS2015带来C#6,我不能还使用(因为我的同事没有这个,因为我们的构建机器也不会个月前拥有它).
我看到我应该能够为每个项目语言指定版本到C#5.我为我们所有的项目(其中270个)做了这个.现在,当我使用C#6功能进行编译时,我发现了一个错误,这很好.
但是,resharper一直试图让我使用Expression body进行属性,字符串插值,......
有没有办法让Resharper不提出这种改变?
在模块警告(https://docs.python.org/3.5/library/warnings.html)中,可以发出似乎来自堆栈中某个位置的警告:
warnings.warn('This is a test', stacklevel=2)
Run Code Online (Sandbox Code Playgroud)
是否存在引发错误的等价物?我知道我可以使用备用回溯引发错误,但我无法在模块中创建该回溯,因为它需要来自之前的版本.我想象的是:
tb = magic_create_traceback_right_here()
raise ValueError('This is a test').with_traceback(tb.tb_next)
Run Code Online (Sandbox Code Playgroud)
原因是我正在开发一个具有一个函数的模块,module.check_raise
我想引发一个看起来源于函数调用位置的错误.如果我在module.check_raise
函数内引发错误,它似乎来自内部module.check_raise
,这是不希望的.
此外,我尝试了一些技巧,比如提出一个虚拟异常,捕获它,然后传递回溯,但不知怎的,tb_next变成了None
.我没有想法.
编辑:
我想要这个最小例子的输出(称为tb2.py):
import check_raise
check_raise.raise_if_string_is_true('True')
Run Code Online (Sandbox Code Playgroud)
只有这个:
Traceback (most recent call last):
File "tb2.py", line 10, in <module>
check_raise.raise_if_string_is_true(string)
RuntimeError: An exception was raised.
Run Code Online (Sandbox Code Playgroud) 有了这个任务:
gulp.task("es6", function () {
return browserify({entries: 'src/main/es6/main.js', extensions: ['.js'], debug: true})
.transform(babelify)
.bundle()
.pipe(source('superpos.js'))
.pipe(streamify(uglify()))
.pipe(gulp.dest('src/main/webapp'));
});
Run Code Online (Sandbox Code Playgroud)
我得到这种错误日志:
它很清晰漂亮,我喜欢它.
但是为了让我的手表保持运行,我需要处理错误而不是让它通过,比如说
...
.transform(babelify)
.bundle()
.on('error', function(error){
// pretty error print
this.emit('end');
})
...
Run Code Online (Sandbox Code Playgroud)
如何在此处重现相同的错误日志?
我宁愿通过组合chalk,gutil和读取错误文件来避免痛苦地再现它,但是以某种方式使用相同的函数.
我在使用Spring和angular的应用程序上遇到了一个我不理解的行为.http请求中存在异常.我在下面做了测试.
@RequestMapping(value = "/contract/upload/excel", method = RequestMethod.POST)
public String uploadContractExcel(HttpServletRequest request, ModelMap model) {
if(true) {
throw new RuntimeException("my code is broken");
}
...
Run Code Online (Sandbox Code Playgroud)
在$ http函数的JavaScript中,而不是进入错误块,它返回到状态代码为200的成功块 - 确定.所以我无法处理任何异常.
$http({
method : 'POST',
url : resolveAjax,
data : formData
}).then(
function successCallback(response) {
var data = response.data;
if (data.upload_error === "true") {
$scope.busy = false;
$scope.upload_error_message = data.upload_error_message;
} else {
$scope.contractSummary = angular
.fromJson(data.reference_excel_resolved);
$scope.busy = false;
$scope.tabindex = $scope.tabindex * 1 + 1;
}
},
function errorCallback(response) {
$scope.upload_error_message …
Run Code Online (Sandbox Code Playgroud) 我目前的Chrome版本是 Version 47.0.2526.73 (64-bit)
我注意到了这个错误
Uncaught (in promise) TypeError: Request scheme 'chrome-extension' is unsupported
Run Code Online (Sandbox Code Playgroud)
仅在我更新Chrome后才会出现.
我不知道聚合物有什么问题,或Chrome错误?
截图:
angularjs ×2
java ×2
javascript ×2
android ×1
babeljs ×1
build ×1
c# ×1
c#-6.0 ×1
colormatrix ×1
datetime ×1
gulp ×1
ios ×1
matrix ×1
networking ×1
node.js ×1
polymer-1.0 ×1
python ×1
python-3.5 ×1
python-3.x ×1
resharper ×1
spring ×1
sql-server ×1
swift ×1
uilabel ×1