问题列表 - 第45988页

在PHP中需要一些帮助

我在PHP中的数字有点问题,这基本上就是我想要做的:

$uni 是有问题的数字和我需要处理的数字(无论数字是多少,但它可以是数十万或只有5).

我想弄清楚"100"可以进入多少次$uni,这不是真正的问题,问题是我需要剩余的数字(小数点后)才能正确格式化.

例如:

(只需处理超过100的数字)

如果我有$uni"356",那么我需要输出"3 Credits"($credearned = 3;)和"56"($per = 56;).

此外,我需要删除某些数字,如果$per是"05",它必须只是"5".

$uni = 190;
if($uni >101){
$credearned = $uni / 100;
$per = ;
}else{
$credearned = 0;
$per = $uni;
}
Run Code Online (Sandbox Code Playgroud)

我非常感谢你的帮助,我希望我的解释不会太混乱.

谢谢.

php numbers

0
推荐指数
1
解决办法
70
查看次数

StructureMap'条件单例'用于Lucene.Net IndexReader

我有一个线程安全对象,创建起来很昂贵,需要通过我的应用程序(Lucene.Net IndexReader)提供.

该对象可能变为无效,此时我需要重新创建它(IndexReader.IsCurrent为false,需要使用IndexReader.Reopen的新实例).

我希望能够使用IoC容器(StructureMap)来管理对象的创建,但是如果可能的话,我无法解决.感觉就像某种"有条件的单身"生命周期.

StructureMap是否提供了这样的功能?还有其他建议吗?

c# structuremap singleton lucene.net ioc-container

6
推荐指数
1
解决办法
879
查看次数

Jquery可拖动和可调整大小

function makeResourceDrag(arrIndexID) {

    $('#imgA' + arrIndexID).resizable();

    $('#imgA' + arrIndexID).draggable({
        start: function(event, ui) {
            isDraggingMedia = true;
        },
        stop: function(event, ui) {
            isDraggingMedia = false;

            // Set new x and y
            resourceData[arrIndexID][4] = Math.round($('#imgA' + arrIndexID).position().left / currentScale);
            resourceData[arrIndexID][5] = Math.round($('#imgA' + arrIndexID).position().top / currentScale);

        }
    });

}
Run Code Online (Sandbox Code Playgroud)

如果可以调整可调整行,这可以正常工作,但我希望这些图像可以拖动和调整大小,如果我尝试使相同的元素具有这两个属性,我会得到有趣的行为,有没有人知道如何使这个工作?

谢谢!

jquery jquery-ui-resizable jquery-ui-draggable

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

使用 Apache Solr 检索提取的文本

我是 Apache Solr 的新手,我想用它来索引 pdf 文件。到目前为止,我设法启动并运行了它,现在我可以搜索添加的 pdf 文件。

但是,我需要能够从结果中检索搜索到的文本。

我在默认的 solrconfig.xml 中找到了一个 xml 片段,具体涉及:

<requestHandler name="/update/extract" class="org.apache.solr.handler.extraction.ExtractingRequestHandler" startup="lazy">
<lst name="defaults">
  <!-- All the main content goes into "text"... if you need to return
       the extracted text or do highlighting, use a stored field. -->
  <str name="fmap.content">text</str>
  <str name="lowernames">true</str>
  <str name="uprefix">ignored_</str>

  <!-- capture link hrefs but ignore div attributes -->
  <str name="captureAttr">true</str>
  <str name="fmap.a">links</str>
  <str name="fmap.div">ignored_</str>
</lst>
Run Code Online (Sandbox Code Playgroud)

从我从这里得到的信息(http://www.lucidimagination.com/Community/Hear-from-the-Experts/Articles/Content-Extraction-Tika),我想我必须向 schema.xml 添加一个新字段(例如“内容”)已存储=“真”和索引=“真”。但是,我不确定如何准确地完成此操作?

任何帮助表示赞赏,谢谢

apache solr cell apache-tika

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

'类'是'类型'但是像'变量'一样使用

我正在编写一个应用程序,它使用指纹识别器捕获某人指纹的图像并将其保存在数据库中.

我正忙着将vb逻辑转换为c#,但我被困在这里......

在我的主要表单中,我有2个类:fingerPrints和fingerImage.

我的问题如下:

从我的fingerPrints类,我需要引用fingerImage类.为清晰起见,这里有一些代码:

此方法派生自fingerPrint类,该类引用fingerImage类:

public byte[] getImageFromFinger(string finger)
        {
            foreach (fingerImage fi in fingerImage)
            {
                if (fi.Finger == finger)
                    return fi.Image;
            }
            return null;
        }
Run Code Online (Sandbox Code Playgroud)

我的问题是我似乎无法解决的错误... fingerImage是一个'类型'但是像'变量'一样使用.

我需要在课堂上循环10次,每个手指一次,但我做错了,我觉得它很小.任何帮助,将不胜感激.

此外,这里是我的fingerImage类的一些代码,以防万一......

public class fingerImage : frmFingerprintsMain
        {
            private byte[] _image;
            private string _finger;

            public fingerImage(byte[] image, string finger)
            {
                Image = image;
                Finger = finger;
            }

            public byte[] Image
            {
                get { return _image; }
                set { _image = value; }
            }

            public string Finger
            {
                get { return _finger; …
Run Code Online (Sandbox Code Playgroud)

c#

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

是否有某个Py3k专用库的索引?

我很好奇是否有重要的库只支持Python 3,因为看起来许多支持它的库也恰好支持Python 2.

python python-3.x

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

键入代码示例时谷歌的预测文本 - 没有自动建议下拉菜单

谷歌的新预测文本通过显示浅灰色字体的下一个字符来预测框中的"当您键入"时的搜索.有谁知道这样做的任何代码?我知道典型的建议下拉菜单,但我正在寻找在搜索框中执行所有操作的示例代码 - 没有自动建议下拉菜单.

javascript php autocomplete autosuggest

5
推荐指数
1
解决办法
4002
查看次数

Google Guice:带参数的提供商

我有一个依赖于类A和B的构造函数.我这样定义它:

@Inject TestClass(A a, B b)
Run Code Online (Sandbox Code Playgroud)

在Guice中有一种方法可以手动注入一个构造函数参数吗?

问题是,类的对象A无法构建,因为它取决于用户输入.我只是想知道Guice是否支持接受参数的提供者.例如,目前可以创建一个对象provider.get(),Guice是否有一个支持provider.get(a)

java dependency-injection guice

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

返回JSON或XML的ExceptionHandler无法在spring mvc 3中运行

代码是这样的:

   @Controller
    public class TestController {

        @RequestMapping(value = "/testerror", method = RequestMethod.GET)
        public @ResponseBody ErrorTO testerror(HttpServletRequest request,HttpServletResponse response) {
           throw new ABCException("serious error!");
        }


        @ExceptionHandler(ABCException.class)
        public  @ResponseBody ErrorTO handleException(ABCException ex,
                HttpServletRequest request, HttpServletResponse response) {
            response.setStatus(response.SC_BAD_REQUEST);
            return new ErrorTO(ex.getMessage());
        }


     @RequestMapping(value = "/test", method = RequestMethod.GET)
    public @ResponseBody ErrorTO test(HttpServletRequest request, 
                                      HttpServletResponse response) {
        ErrorTO error = new ErrorTO();
        error.setCode(-12345);
        error.setMessage("this is a test error.");
        return error;
    }

}
Run Code Online (Sandbox Code Playgroud)

当我尝试卷曲-H"接受:application/json"-v"http://localhost.com:8080/testerror"我收到此错误:org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerExceptionResolver - 找不到HttpMessageConverter,支持返回类型[类com.kibboko.poprocks.appservices.dtos.ErrorTO]和[application/json]

但如果我尝试卷曲-H"接受:application/json"-v"http://localhost.com:8080/test",工作并返回json响应."application/xml"也有效.

我需要处理的异常处理程序有什么特别之处,以便它可以与json或xml一起使用吗?谢谢!

exception-handling spring-mvc

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

PHP - 获取bool以在false时回显false

以下代码不打印任何内容:

$bool_val = (bool)false;
echo $bool_val;
Run Code Online (Sandbox Code Playgroud)

但是下面的代码打印出来1:

$bool_val = (bool)true;
echo $bool_val;
Run Code Online (Sandbox Code Playgroud)

有没有更好的方式来打印0false$bool_valfalse不是增加一个if声明?

php boolean

160
推荐指数
10
解决办法
14万
查看次数