小编mrt*_*181的帖子

如何在.tmux.conf中编写if语句为不同的tmux版本设置不同的选项?

我有一个.tmux.conf,我在安装了不同tmux版本的不同机器上使用.

我想根据tmux版本设置不同的鼠标选项.在一台机器上我有2.0另一个版本2.1.

我没有把他的意思弄清楚

if "[[(( $(tmux -V | cut -c 6-) < 2.1 ))]]" \
  "set -g mode-mouse on;" \
  "set -g mouse-resize-pane on;" \
  "set -g select-pane on;" \
  "set -g select-window on" "set -g mouse on"
Run Code Online (Sandbox Code Playgroud)

当我获取文件时

$ tmux source-file .tmux.conf

我收到这条消息

.tmux.conf:12: unknown command: set -g mouse-resize-pane on

我运行它的机器有版本2.1所以它不应该设置四个选项.

我想在运行tmux 2.0或更少时设置四个选项,或者在运行tmux 2.1时设置一个选项.

这个bash语句有效

$ tmux -V
tmux 2.1
$ if [[(( $(tmux -V | cut -c 6-) < 2.1 ))]];then echo …
Run Code Online (Sandbox Code Playgroud)

bash shell scripting if-statement tmux

33
推荐指数
6
解决办法
2万
查看次数

计算两点之间的距离

我需要创建一个计算两点之间距离的类.我被困了,我是一个初学者.这是我的课程:

package org.totalbeginner.tutorial;

public class Point {

    public double x;
    public double y;

    Point(double xcoord, double ycoord){
        this.x = xcoord;
        this.y = ycoord;
    }

    public double getX() {
        return x;
    }

    public double getY() {
        return y;
    }    
}
Run Code Online (Sandbox Code Playgroud)

第二节课.

package org.totalbeginner.tutorial;

public class Line {

    double x;
    double y;

    Point p1 = new Point(2.0,2.0);
    Point p2 = new Point(4.0,4.0);
    Point mp = new Point(x,y);

    public void midpoint() {
        x = (p1.getX() + p2.getX()) / 2;
        y = (p1.getY() + …
Run Code Online (Sandbox Code Playgroud)

java

20
推荐指数
4
解决办法
9万
查看次数

当我运行带参数的查询或命令时,为什么Dapper会抛出OracleException?

我是评价精致但我已经遇到了一些问题.

我想这样做

using (IDbConnection connection = GetConnection())
{
    connection.Open();
    var result = connection.Query(
        "select * from myTable where ID_PK = @a;", new { a = 1 });
}
Run Code Online (Sandbox Code Playgroud)

它在SqlMapper.cs的第393行抛出ORA-00936:缺少表达式OracleException

using (var reader = cmd.ExecuteReader())
Run Code Online (Sandbox Code Playgroud)

当我删除参数时,我将整个表放入结果变量中.

查询在sqldeveloper中没有问题.我正在使用Oracle.DataAccess Assembly 2.112.2.0

oracle orm exception oracle11g dapper

15
推荐指数
2
解决办法
3751
查看次数

如何配置Resharper 5.1的Test Runner接受网络共享?

我有一个位于网络共享上的项目.测试运行器尝试运行测试但失败并显示错误消息.

单元测试亚军未能加载程序集:JetBrains.ReSahrper.TaskRunnerFramework.TaskException:无法加载文件或assembl '文件://\myshare的\ Visual Studio 2010的\项目\ MyPorject\TestMyProject\BIN \发布\ TestMyProject.dll' 或一个它的依赖关系.

测试使用MSTest运行.我在Visual Studio 2010 Pro上的devenv.exe.config中启用了选项loadFromRemoteSources,并且可以部署Testproject.

问题是Test runner尝试读取程序集的位置(file:// \)

当我从C:\启动项目时它起作用.

我能做什么?

c# resharper unit-testing visual-studio-2010

11
推荐指数
1
解决办法
2086
查看次数

如何实现通用的IEnumerable或IDictionary来避免CA1006?

出于好奇,我想知道如何最好地实现一个可用于避免CA1006警告的类

CA1006:Microsoft.Design:考虑一种设计,其中'IReader.Query(String,String)'不嵌套泛型类型'IList(Of IDictionary(Of String,Object))'.

这是返回泛型类型的方法

public virtual IList<IDictionary<string, object>> Query(
    string fullFileName, 
    string sheetName)
{
    using (var connection = new OdbcConnection(
        this.GetOdbcConnectionString(fullFileName)))
    {
        connection.Open();
        return connection
            .Query(string.Format(
                CultureInfo.InvariantCulture,
                SystemResources.ExcelReader_Query_select_top_128___from__0_,
                sheetName))
            .Cast<IDictionary<string, object>>()
            .ToList();
    }
}
Run Code Online (Sandbox Code Playgroud)

就像是

SourceData<T, U> Query(string fullFileName, string sheetName)
SourceData Query(string fullFileName, string sheetName)
Run Code Online (Sandbox Code Playgroud)

编辑:

根据Marc的建议,我在这个类中封装了嵌套泛型

public class QueryRow : List<KeyValuePair<string, object>>
{
    protected internal QueryRow(IEnumerable<KeyValuePair<string, object>> dictionary)
    {
        this.AddRange(dictionary.Select(kvp => kvp));
    }
}
Run Code Online (Sandbox Code Playgroud)

c# generics ienumerable fxcop dapper

9
推荐指数
1
解决办法
2899
查看次数

当我从CF6.1迁移到CF8或Railo3.1时会有什么陷阱等待我?

谷歌并没有提供太多内容(或者我的查询很糟糕).有人做过切换并可以分享经验吗?

migration coldfusion middleware railo cfml

8
推荐指数
1
解决办法
460
查看次数

RestTemplate接收html内容类型而不是json

我正在尝试访问以这种方式返回json字符串的rest webservice:

HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<String> entity = new HttpEntity<String>(request.getRequest(RequestFormat.JSON),headers);
MyBean response = template.postForObject(endpoint.toURI(), entity,MyBean.class);
Run Code Online (Sandbox Code Playgroud)

我收到了这条消息:

Could not extract response: no suitable HttpMessageConverter found for response type 
mypackage.MyBean and content type [text/html;charset=utf-8]
Run Code Online (Sandbox Code Playgroud)

那是因为我正在联系的webservice不会返回带有application/json内容类型但带有text/html的响应.

所以我试图以这种方式将媒体类型添加到RestTemplate:

@Bean
    public RestTemplate restTemplate() {
        RestTemplate template = new RestTemplate(clientHttpRequestFactory());
        List<HttpMessageConverter<?>> converters = template.getMessageConverters();
        for(HttpMessageConverter<?> converter : converters){
            if(converter instanceof MappingJackson2HttpMessageConverter){
                try{
                converter.getSupportedMediaTypes().add(MediaType.TEXT_HTML);
                }catch(Exception e){
                    e.printStackTrace();
                }
            }
        }
        return template;
    }
Run Code Online (Sandbox Code Playgroud)

但它给了我这个例外:

java.lang.UnsupportedOperationException
    at java.util.Collections$UnmodifiableCollection.add(Collections.java:1075)
    at mypackage.Application.restTemplate(Application.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) …
Run Code Online (Sandbox Code Playgroud)

html spring json

8
推荐指数
1
解决办法
8159
查看次数

如何通过COM Interop在Excel中获取特定范围?

我有以下问题.我必须通过COM interop读取excel文件.我是COM interop编程的新手.

我用这个搜索一个特定的字符串:

this.sheet = (Excel.Worksheet)this.excelApp.Workbook.Sheets.Item[this.sheetname];
            this.sheet.Activate();
            Excel.Range firstRow = this.sheet.Range["A1", "XFD1"];
            Excel.Range foundRange = firstRow.Find(
                this.StringISearch,
                Type.Missing,
                Type.Missing,
                Excel.XlLookAt.xlWhole,
                Excel.XlSearchOrder.xlByColumns,
                Excel.XlSearchDirection.xlNext,
                false,
                false,
                Type.Missing);
Run Code Online (Sandbox Code Playgroud)

不,我想使用foundRange作为获得另一个范围的起点.

像这样的东西

Excel.Range MyRange = this.sheet.Range[foundRange + 2 rows, + 1 column & lastRow];
Run Code Online (Sandbox Code Playgroud)

我没有办法做到这一点.有吗?

c# excel range com-interop

7
推荐指数
1
解决办法
2万
查看次数

这个git涂抹/清洁过滤器有什么问题?

我想在我的git存储库中应用此过滤器,以在结帐时从解决方案文件中删除一个部分,并在提交期间添加此部分.

这是我要删除或添加的部分:

GlobalSection(SubversionScc) = preSolution
    Svn-Managed = True
    Manager = AnkhSVN - Subversion Support for Visual Studio
EndGlobalSection
Run Code Online (Sandbox Code Playgroud)

我在.git/info/attributes中设置了这个过滤器

*.sln filter = SourceControlProvider

我已将这些命令添加到我的配置中

$ git config filter.SourceControlProvider.smudge "sed -e '/GlobalSection(SubversionScc)/,/EndGlobalSection/d' %"
$ git config filter.SourceControlProvider.clean "sed -n -e '/^Global$/ r ankhsvnsection ' < %"
Run Code Online (Sandbox Code Playgroud)

好吧,它不起作用.我做错了什么?

ankhsvnsection是一个文本文件,与*.sln文件位于同一目录中

git sed filter gitattributes

7
推荐指数
1
解决办法
5815
查看次数

如何使用PowerShell将多个文件压缩成一个zip文件?

我想将多个文件压缩成一个zip.

我现在坚持这个:

Get-ChildItem -path C:\logs -Recurse | Where {$_.Extension -eq ".csv" -and $_.LastWriteTime -lt (Get-Date).AddDays(-7)} | write-zip -level 9 -append ($_.LastWriteTime).zip | move-item -Force -Destination {
    $dir = "C:\backup\archive"
    $null = mkdir $dir -Force
    "$dir\"
}
Run Code Online (Sandbox Code Playgroud)

我得到了这个例外

Write-Zip:无法将参数绑定到参数'Path',因为它为null.

这部分是问题:

write-zip -level 9 -append ($_.LastWriteTime).zip
Run Code Online (Sandbox Code Playgroud)

我之前从未使用过PowerShell,但我必须提供脚本,我无法提供ac#解决方案.

powershell zip pipe

7
推荐指数
1
解决办法
1万
查看次数