小编You*_*bit的帖子

如何将命令行参数传递给PowerShell ps1文件

多年来,我一直使用cmd/DOS/Windowsshell并将命令行参数传递给批处理文件.例如,我有一个文件,zuzu.bat并在其中,我访问%1,%2等等.现在,我想,当我叫做同样的PowerShell脚本when I am in a Cmd.exe shell.我有一个脚本,xuxu.ps1(我已经将PS1添加到我的PATHEXT变量和与PowerShell关联的PS1文件).但无论我做什么,我似乎都无法从$args变量中得到任何东西.它的长度始终为0.

如果我在PowerShellshell中,而不是cmd.exe,它可以工作(当然).但我还不够舒服,无法全时在PowerShell环境中生活.我不想打字powershell.exe -command xuxu.ps1 p1 p2 p3 p4.我想打字xuxu p1 p2 p3 p4.

这是可能的,如果是的话,怎么样?

我无法工作的样本很简单,foo.ps1:

Write-Host "Num Args:" $args.Length;
foreach ($arg in $args) {
    Write-Host "Arg: $arg";
}
Run Code Online (Sandbox Code Playgroud)

结果总是如下:

C:\temp> foo
Num Args: 0
C:\temp> foo a b c d
Num Args: 0
c:\temp>
Run Code Online (Sandbox Code Playgroud)

powershell command-line arguments

82
推荐指数
5
解决办法
25万
查看次数

如何使用PDFBox居中文本

我的问题非常简单:如何使用PDF将文本置于PDF中心PDFBox

我事先不知道字符串,我找不到中间的试用版.字符串并不总是具有相同的宽度.

我需要:

  • 一种可以使文本居中的方法,例如 addCenteredString(myString)
  • 一种方法,可以给我字符串的宽度,以像素为单位.然后我可以计算中心,因为我知道PDF的尺寸.

欢迎任何帮助!

java text-alignment pdfbox

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

找不到jmap命令

我正在尝试jmap在我的CentOS服务器上使用该命令,但它一直告诉我即使我安装了JDK也找不到该命令.

这是命令的输出java -version:

java version "1.7.0_25"
OpenJDK Runtime Environment (rhel-2.3.10.4.el6_4-x86_64)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?

java linux centos

16
推荐指数
4
解决办法
3万
查看次数

Apache Spark与Apache Spark 2

与Apache Spark相比,Apache Spark2带来了哪些改进?

  1. 从架构角度来看
  2. 从应用的角度来看
  3. 或者更多

apache-spark apache-spark-2.0

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

无法检测到有效的hadoop主目录

我已经设置了Hadoop 2.2.0单节点并启动了它.我能够浏览FS http://localhost:50070/ 然后我尝试使用以下代码编写一个虚拟文件.

public class Test {
public void write(File file) throws IOException{
    FileSystem fs = FileSystem.get(new Configuration());
    Path outFile = new Path("test.jpg");       
    FSDataOutputStream out = fs.create(outFile);        

}    
Run Code Online (Sandbox Code Playgroud)

我得到以下异常

INFO:   DEBUG - field org.apache.hadoop.metrics2.lib.MutableRate org.apache.hadoop.security.UserGroupInformation$UgiMetrics.loginSuccess with annotation @org.apache.hadoop.metrics2.annotation.Metric(valueName=Time, value=[Rate of successful kerberos logins and latency (milliseconds)], about=, type=DEFAULT, always=false, sampleName=Ops)
    INFO:   DEBUG - field org.apache.hadoop.metrics2.lib.MutableRate org.apache.hadoop.security.UserGroupInformation$UgiMetrics.loginFailure with annotation @org.apache.hadoop.metrics2.annotation.Metric(valueName=Time, value=[Rate of failed kerberos logins and latency (milliseconds)], about=, type=DEFAULT, always=false, sampleName=Ops)
    INFO:   DEBUG - UgiMetrics, User and group related …
Run Code Online (Sandbox Code Playgroud)

hadoop hdfs

11
推荐指数
2
解决办法
3万
查看次数

具有多个有效负载的Solr建议

我们正在使用Solr建议功能进行businessName查找.当用户输入查询以及匹配的名称时,我们希望solr从id,地址,城市,州,国家等字段中发送其他属性.

我尝试使用payloadField标记在solr suggester中配置多个字段,但它只返回第一个字段.我试过用逗号分隔的方式把它们放进去,但没有运气.这是solrconfig.xml文件的当前配置.

<searchComponent name="suggest" class="solr.SuggestComponent">
    <lst name="suggester">
        <str name="name">suggest</str>
        <str name="lookupImpl">AnalyzingLookupFactory</str>
        <str name="storeDir">suggester_fuzzy_dir</str>
        <str name="dictionaryImpl">DocumentDictionaryFactory</str>
        <str name="field">businessName</str>
        <str name="payloadField">profileId</str> 
        <str name="payloadField">email</str>
        <str name="payloadField">city</str>
        <str name="payloadField">state</str>
        <str name="payloadField">postalCode</str>
        <str name="payloadField">phoneNumber</str>
        <str name="weightField">businessName</str>
        <str name="suggestAnalyzerFieldType">text_general</str>
        <str name="buildOnStartup">true</str>
        <str name="buildOnCommit">true</str>
        <str name="preserveSep">false</str>
    </lst>
</searchComponent>
Run Code Online (Sandbox Code Playgroud)

在结果中发送多个有效负载需要什么配置?谢谢.


编辑:
这是solr建议者的当前输出.

    {
        "suggest": {
            "suggest": {
                "Rock": {
                    "numFound": 1,
                    "suggestions": [
                        {
                            "term": "Rockview Properties",
                            "weight": 0,
                            "payload": "123456789"
                        }
                    ]
                }
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

我的期望:
建议者有效负载包含多个字段的方式.有效载荷字段还包含哪些数据属于哪个字段的信息.我不是要使用 …

solr solrcloud

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

如何将mysql数据实时迁移到ElasticSearch

我有一个带有几个表的mysql数据库,我想将mysql数据迁移到ElasticSearch.通过批处理作业将整个数据库迁移到ES很容易.但是我应该如何从mysql实时更新ES.即如果在mysql中有更新操作,那么我应该在ES中执行相同的操作.我研究了mysql binLog,它可以反映mysql的任何变化.但我必须将binLog解析为ES语法,我认为这真的很痛苦.谢谢!(与Solr相同的情况)

mysql lucene solr search-engine elasticsearch

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

Solr不一致的结果计数

我有四个节点solrcloud安装版本4.10和我的集合有4个分片,2个副本.我的应用程序提供实时数据摄取的搜索功能,数据摄取和搜索过程并行运行.

每天数据加载大约2~3MM记录(插入/更新操作),总文件数为80MM +.

我们面临的问题是solr在数据摄取的高峰时间内返回非常不一致的记录计数.

示例查询:

for i in `seq 1 50`;
do
       curl 'http://localhost:8888/solr/OPTUM/select?q=*:*&wt=json&indent=true'|grep numFound|rev|cut -d'{' -f1 |rev
done
Run Code Online (Sandbox Code Playgroud)

响应numfound变量显示有时非常少的文档计数然后实际存在于solr中.

请建议我是否需要进行任何配置更改以获得一致的计数.

lucene solr

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

@relay的目的(pattern:true)

新的表达@relay(pattern: true)是在推出更改日志中relay.js 0.5.

但是无法从描述中找出来,也不能测试它究竟是做什么以及什么时候我应该在写作时使用它fatQueries.

一些例子会非常有帮助.

relayjs

10
推荐指数
1
解决办法
1981
查看次数

Laravel 5.1中VerifyCsrfToken.php第53行中的TokenMismatchException

当我尝试登录时显示令牌错误.我在视图中检查了令牌是正确的,当评论时\App\Http\Middleware\VerifyCsrfToken::class,Kernel.php它使我登录但在重定向到我的仪表板后我没有登录.我在Mac上使用MAMP.

<div>
    <h1>Login</h1>
    <div>
        {!! Form::open(['url'=>'user/login','class' => '']) !!}
        <input type="hidden" name="_token" value="{{ csrf_token() }}">
        <ul>
          <li><label>Customer Code</label>{!!Form::Text('customer_code',Input::old('customer_code'),['class'=>''])!!}</li>
          <li><label>Password</label>{!!Form::Password('password','',['class'=>''])!!}</li>
          <li>{!! Form::submit('Submit',array('class' => 'btn')) !!}</li>
        </ul> 
        {!!Form::close()!!}
    </div>
    <div><a href="{!!URL::to('user/forget_password')!!}">Forget Password</a></div>
</div>
Run Code Online (Sandbox Code Playgroud)

同时我Sentry Package用于登录.

    /**
     * post_login
     */
    public function post_login()
    { 
        try
        {
            $rules  = [ 
                    'customer_code'         => 'required',
                    'password'              => 'required',
                ] ;                    
            $message = [ 
                    'customer_code.required'             => 'erorrr1',
                    'password.required'                =>'error2'    
                             ];                            
            $validator = Validator::make(Input::all(), $rules,$message);
            if ($validator->fails())
            {            
                return Redirect::back()->withErrors($validator)->withInput();        
            } // …
Run Code Online (Sandbox Code Playgroud)

php session csrf session-cookies laravel-5

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