刚刚在过去一小时内下载并安装了elasticsearch 1.3.2
打开IP表到端口9200和9300:9400
在/ etc/hosts中设置我的计算机名称和IP
头部模块和护理人员安装并顺利运行
curhost on localhost工作完美无缺
将所有jar从下载复制到eclipse中,因此版本客户端相同
--Java--
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.index.query.QueryBuilders;
public class Test{
public static void main(String[] args) {
Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name", "elastictest").build();
TransportClient transportClient = new TransportClient(settings);
Client client = transportClient.addTransportAddress(new InetSocketTransportAddress("143.79.236.xxx",9300));//just masking ip with xxx for SO Question
try{
SearchResponse response = client.prepareSearch().setQuery(QueryBuilders.matchQuery("url", "twitter")).setSize(5).execute().actionGet();//bunch of urls indexed
String output = response.toString();
System.out.println(output);
}catch(Exception e){
e.printStackTrace();
}
client.close();
}
}
Run Code Online (Sandbox Code Playgroud)
--Output--
log4j:WARN No …Run Code Online (Sandbox Code Playgroud) 我试图用PhantomJS截取一个网页的截图.具体地讲,我使用捕获的示例espn.com从这个例子.我的代码看起来像这样:
var page = new WebPage();
page.open('http://www.espn.com', function (status) {
page.render('fb.png');
phantom.exit();
});
Run Code Online (Sandbox Code Playgroud)
然后我使用我的终端或命令提示符转到我的PhantomJS目录并运行:
phantomjs shotty.js
Run Code Online (Sandbox Code Playgroud)
一切都运行良好,但完成输出图像需要6-8秒.这是正常的吗?有没有更快的方法来实现这一点,以便它在一秒或更短的时间内完成?
我使用的是CentOS和Windows 7.两个盒子都有8GB的RAM,3.2 GHz的CPU,我在speedtest.net上的速度下降了22Mbp/s,速度达到了1Mbp/s
我想知道是否有一个行业标准可以更好地保护移动设备上的ajax呼叫.
我的移动应用程序由我的网站的html,js和css文件组成 - 但是在移动设备上本地安装它们以提高性能.移动设备的本地index.html然后调用我的Web服务器获取数据(在本例中为Tomcat).
我发现这个工作的唯一方法是在我的servlet中启用CORS:
response.setContentType("text/html");
response.addHeader("Access-Control-Allow-Origin", "*");
response.addHeader("Access-Control-Allow-Methods", "GET, PUT, POST, OPTIONS, DELETE");
response.addHeader("Access-Control-Allow-Headers", "Content-Type");
response.addHeader("Access-Control-Max-Age", "86400");
Run Code Online (Sandbox Code Playgroud)
但老实说,我出于各种原因不喜欢它,但主要是 - 现在任何东西都可以从任何领域查询我的网络服务器并获得回复......
如何从使用CORS的移动设备实现对我的网络服务器的相同ajax调用 - 但是以更安全的方式,以便只允许我的应用程序访问?
**或者**在这种移动设备的情况下,CORS是否完全错误,并且有更标准/更理想的解决方案?
我正在使用Selenium WebDriver截取网页截图.它运行得很好.但是,从我在eclipse中运行的时间到我本地驱动器中显示的屏幕截图是7-10秒.大多数延迟似乎都在推出Firefox.
码:
WebDriver driver = new FirefoxDriver();
driver.get("http://www.cnn.com");
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File("c:\\test\\screenshot.png"));
Run Code Online (Sandbox Code Playgroud)
我怎样才能加快这个过程?有没有办法可以使用已经打开的Firefox浏览器来保存开新的浏览器?这段代码有点沉重吗?
详细信息:使用eclipse在CentOS盒和Win7盒上尝试.myspeedtest.net显示22Mbps下行和1 Mbps上行.
我正在使用OpenNLP的NameFinder API示例文档.初始化名称查找器后,文档使用以下代码作为输入文本:
for (String document[][] : documents) {
for (String[] sentence : document) {
Span nameSpans[] = nameFinder.find(sentence);
// do something with the names
}
nameFinder.clearAdaptiveData()
}
Run Code Online (Sandbox Code Playgroud)
然而,当我把它带入eclipse时,'documents'(而不是'document')变量给我一个错误,说变量文件无法解析.使用'documents'数组变量引用的文档是什么?我是否需要初始化一个名为'documents'的数组,该数组包含txt文件以便此错误消失?
谢谢您的帮助.
我试图通过Eclipse中的solrj查询solr.我尝试过最新的solrj wiki示例:
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.params.ModifiableSolrParams;
import java.net.MalformedURLException;
public class SolrQuery2 {
public static void main(String[] args) throws MalformedURLException, SolrServerException {
SolrServer solr = new CommonsHttpSolrServer("http://localhost:8080/solr");
// http://localhost:8080/solr/select/?q=outside
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("qt", "/select");
params.set("q", "outside");
QueryResponse response = solr.query(params);
System.out.println("response = " + response);
}
}
Run Code Online (Sandbox Code Playgroud)
但是,无论我做什么,我都无法克服这个错误:
Exception in thread "main" java.lang.NoSuchMethodError:
org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
Run Code Online (Sandbox Code Playgroud)
接下来,我尝试了食谱示例:
import java.util.Iterator;
import org.apache.solr.client.solrj.SolrQuery; //Error: The import org.apache.solr.client.solrj.SolrQuery conflicts with a type defined in the same …Run Code Online (Sandbox Code Playgroud) 我正在使用html2canvas来获取网页的屏幕截图并将其渲染为缩略图(好吧,400x300,不完全是缩略图).
基于截图控制台代码,除缩略图部分外,一切都很好.
如何将图像大小设置为400x300?在firebug中,我将属性定位为:<canvas style="width: 973px; height: 2184px;" width="973" height="2184"></canvas>.但是,我无法弄清楚我的代码(下面)或html2canvas.js在哪里硬编码400x300参数.
screenshot.html:
<html>
<head>
<title>Screenshot</title>
<!--[if lt IE 9]>
<script src="//html5shim.googlecode.com/svn/trunk/html5.js">
</script>
<![endif]-->
</head>
<body>
<div class=container> </div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="js/html2canvas.js"></script>
<script type="text/javascript">
var date=new Date();
var message,timeoutTimer,timer;
var proxyUrl="http://html2canvas.appspot.com";
function addRow(a,c,d){var b=$("<tr />").appendTo($(a));b.append($("<td />").css("font-weight","bold").text(c)).append($("<td />").text(d))}function throwMessage(b,a){window.clearTimeout(timeoutTimer);timeoutTimer=window.setTimeout(function(){message.fadeOut(function(){message.remove()})},a||2000);$(message).remove();message=$("<div />").html(b).css({margin:0,padding:10,background:"#000",opacity:0.7,position:"fixed",top:10,right:10,fontFamily:"Tahoma",color:"#fff",fontSize:12,borderRadius:12,width:"auto",height:"auto",textAlign:"center",textDecoration:"none"}).hide().fadeIn().appendTo("body")}$(function(){$("#recommended a").click(function(c){c.preventDefault();$("#url").val(this.href);$("button").click()});var a,b;$('input[type="button"]').click(function(){$(a.contentWindow).unbind("load");$(a).contents().find("body").html2canvas({canvasHeight:b.body.scrollHeight,canvasWidth:b.body.scrollWidth,logging:true})});$("#getscreenshot").click(function(d){d.preventDefault();$(this).prop("disabled",true);var c=$("#url").val();$("#content").append($("<img />").attr("src","loading.gif").css("margin-top",40));var f=document.createElement("a");f.href=c;$.ajax({data:{xhr2:false,url:f.href},url:proxyUrl,dataType:"jsonp",success:function(e){a=document.createElement("iframe");$(a).css({visibility:"hidden"}).width($(window).width()/2).height($(window).height()/2);$("#content").append(a);b=a.contentWindow.document;b.open();$(a.contentWindow).load(function(){var g=$(a).contents().find("body"),h={onrendered:function(j){$("#content").empty().append(j);$("#getscreenshot").prop("disabled",false);$("base").attr("href","")},allowTaint:true,taintTest:false,flashcanvas:"src/flashcanvas.min.js"},i=html2canvas(g,h)});$("base").attr("href",f.protocol+"//"+f.hostname+"/"+f.pathname);e=e.replace("<head>","<head><base href='"+f.protocol+"//"+f.hostname+"/"+f.pathname+"' />");if($("#disablejs").prop("checked")){e=e.replace(/\<script/gi,"<!--<script");e=e.replace(/\<\/script\>/gi,"<\/script>-->")}b.write(e);b.close()}})})});
</script>
<form class="well form-search">
<label for=url>Website URL:</label>
<input type=url id=url value="http://www.yahoo.com" class="input-medium search-query"/>
<button class=btn id=getscreenshot>Get screenshot!</button>
</form>
<div id=content></div> …Run Code Online (Sandbox Code Playgroud) 背景:
我创建了一个名为AvailableDomains的Schema(简单策略,1个节点).
在该密钥空间中,我创建了1个表/列系列,称为带有列的域(id,urn,timestamp,flag).除时间戳之外的所有类型文本都是类型时间戳.
我启动cassandra,
启动cqlsh -3,
使用AvailableDomains,
然后发出以下命令来引入csv:
COPY domains (id, urn, timestamp, flag) from 'test.csv' where HEADER= TRUE;
Run Code Online (Sandbox Code Playgroud)
我收到一条错误说:不正确的COPY命令
问题:我做错了什么?
细节:
CSV-
id,url,timestamp,flag
1,google.com,1375891081,1
2,facebook.com,1375891081,1
3,youtube.com,1375891081,1
4,yahoo.com,1375891081,1
5,baidu.com,1375891081,1
6,wikipedia.org,1375891081,1
7,amazon.com,1375891081,1
8,qq.com,1375891081,1
9,live.com,1375891081,1
10,linkedin.com,1375891081,1
Run Code Online (Sandbox Code Playgroud)
csv的位置在cassandra/bin(cqlsh所在的dir).
操作系统: Centos 6.4 64位
我有一个请求调用一堆图像,如下所示:
<a href='www.domain1.com'><img src='../image/img1.png' onerror='imgError(this);'/></a>
<a href='www.domain2.com'><img src='../image/img2.png' onerror='imgError(this);'/></a>
Run Code Online (Sandbox Code Playgroud)
问题是当进行调用时,一些图像(~20%)还没有准备好.他们需要另一秒钟.
所以在js或jquery中我想做的是在出错时获取失败的图像,等待1秒,然后再尝试加载那些失败的图像.如果他们在第二次尝试失败 - 哦,我很好.但我没有正确地这样做...我不应该在js中的另一个方法中调用超时吗?
function imgError(image) {
image.onerror = "";
image.src = image;
setTimeout(function () {
return true;
}, 1000);
}
Run Code Online (Sandbox Code Playgroud) 我有一个图像列表,其中每个图像都包裹在li中:
<li><a href='http://www.so.com'><img src='http://www.so.com/1.jpg'></a></li>
Run Code Online (Sandbox Code Playgroud)
如果图像1.jpg被打破就好像它从未存在于DOM中,我怎么能隐藏整个li?
我找到了一些关于如何隐藏图像并从我想要的另一个SO帖子中学到的好js ,display:none所以我没有创建一个空行.但是我把这些放在一起很麻烦.
javascript ×4
java ×3
html ×2
jquery ×2
screenshot ×2
ajax ×1
apache ×1
canvas ×1
cassandra ×1
cors ×1
css ×1
data-mining ×1
html2canvas ×1
lucene ×1
nlp ×1
opennlp ×1
phantomjs ×1
security ×1
selenium ×1
solr ×1
solrj ×1
web-services ×1
webdriver ×1