我刚刚在Node.js应用程序中使用Log4js启用了日志记录.我使用了https://github.com/nomiddlename/log4js-node中的配置选项,它运行正常.
它将日志写入日志文件以及控制台中.我不希望在控制台中打印它. 无法弄清楚如何配置它.非常抱歉问这个愚蠢的问题.
以下代码中的println有效(带或不带toInt)
println("retweets : ", e.getOrElse("retweets", 0).toInt)
top10Tweets(""+e.get("text").get, e.getOrElse("retweets", 0).toInt)
Run Code Online (Sandbox Code Playgroud)
但是当我将它作为函数的参数传递时(如上所述),它不起作用.它说"价值toInt不是Any的成员"
当我删除toInt时,它说,
type mismatch;
[error] found : Any
[error] required: Int
Run Code Online (Sandbox Code Playgroud)
e是地图,如下所示,
def tweetDetails(obj: twitter4j.Status) = {
Map(
"id" -> obj.getUser().getId(),
"screenName" -> obj.getUser().getScreenName(),
"text" -> obj.getText(),
"retweets" -> obj.getRetweetCount(),
"mentions" -> obj.getUserMentionEntities().length)
}
Run Code Online (Sandbox Code Playgroud)
top10Tweets的签名,
def top10Tweets(tweets: String, retweet_c: Int, mention_c: Int) = {
}
Run Code Online (Sandbox Code Playgroud) 我在我的网络应用程序中使用Apache Commons Email,它工作正常.
现在我需要通过附件发送文档,我遇到了一些问题.我需要从数据库中获取文件(作为BLOB)并将其添加为附件.看起来Commons Email不支持流附件,它只从路径中获取文件.
我需要知道这里的最佳做法是什么?
我打算使用cloudfoundry paas服务(来自VMWare)来托管我的node.js应用程序.我已经看到它在服务层和node.js框架中支持mongo和redis.到现在为止还挺好.
现在我需要将我的媒体文件(用户上传的图像)存储到文件系统中.我有存储在Mongo中的元数据.
我一直在搜索互联网,但还没有得到很好的信息.
我的csv文件包含6Million记录,我试图通过使用skiprows将其拆分为多个较小的文件..我的Pandas版本是'0.12.0',代码是
pd.read_csv(TRAIN_FILE, chunksize=50000, header=None, skiprows=999999, nrows=100000)
Run Code Online (Sandbox Code Playgroud)
它只要小于900000就可以工作.任何想法是否是预期的?如果我不使用短语,我的小数可以达到5万条记录.还没有尝试过.也会尝试这个.
尝试过csv splitter,但它对第一个条目不起作用,可能是因为每个单元格由多行代码组成等.
编辑:我可以通过使用pandas read_csv读取整个7GB文件并将部分写入多个csv文件将其拆分为csv.
我正在尝试按照https://github.com/LearnBoost/socket.io/wiki/Configuring-Socket.IO设置socket.io的配置
io.set('log level', 1);
Run Code Online (Sandbox Code Playgroud)
但我得到的是TypeError:对象#没有方法'设置'......出了什么问题?我有io = require("socket.io")
也尝试过,
io.configure('production', function(){
io.set('log level', 1);
});
Run Code Online (Sandbox Code Playgroud)
但没有运气.怎么了 ?
编辑:
require.paths.push('/cygdrive/c/Personal/software/nodejs/NODE/node_modules');
var express = require("express"),
fs = require("fs"),
form = require('connect-form'),
app = express.createServer(
form({ keepExtensions: true })
),
sys = require("sys"),
RentModel = require("./rent_schema"),
UserModel = require("./track_schema"),
io = require("socket.io"),
fb = require('facebook-js'),
Twitter = require('./Twitter_Analysis'),
Foursquare = require('./Foursquare_Analysis'),
YQL = require("yql"),
settings = require("./settings");
socket = io.listen(app);
:::::::::::::::::
app.listen(9999);
Run Code Online (Sandbox Code Playgroud)
这工作正常..但如果我将其更改为io = require("socket.io").listen(8080)它给我错误,找不到listen方法.
我试图用新的纬度,经度帮助更新PrimeFaces的谷歌地图p:ajax,但它不起作用......我正在使用JSF 2.0.我p:ajax早先以类似的方式使用它,它工作得很漂亮.知道为什么这不起作用吗?以下是代码,contForm是表单的id.
<h:outputText value="Latitude :"/>
<h:inputText value="#{confirmBrandRegistration.newBrand.mapLatitude}" size="10">
<p:ajax event="blur" update="contForm:gMapID"/>
</h:inputText>
<h:outputText value=" Longitude :"/>
<h:inputText value="#{confirmBrandRegistration.newBrand.mapLongitude}" size="10" >
<p:ajax event="blur" update="contForm:gMapID"/>
</h:inputText>
<h:outputText value=" Marker :"/>
<h:inputText value="#{confirmBrandRegistration.newBrand.mapMarker}" size="20" >
<p:ajax event="blur" update="contForm:gMapID"
listener="#{confirmBrandRegistration.updateMarker}"/>
</h:inputText>
</h:panelGrid>
<p:outputPanel id="gMapID">
<f:view contentType="text/html">
<p:gmap center="#{confirmBrandRegistration.newBrand.mapLatitude}, #{confirmBrandRegistration.newBrand.mapLongitude}"
zoom="16" type="HYBRID" streetView="true"
model="#{confirmBrandRegistration.simpleModel}"
style="width:500px;height:400px" />
</f:view>
</p:outputPanel>
Run Code Online (Sandbox Code Playgroud) 我的socket.io版本是socket.io@0.8.7和redis@0.7.1.我在Windows上.
在某些地方,我看到问题已经解决了.我想我使用的是最新的socket.io版本.什么是emitter.setMaxListeners(),我在哪里可以设置它?
(node) warning: possible EventEmitter memory leak detected. 11 listeners added.
Use emitter.setMaxListeners() to increase limit.
Trace:
at RedisClient.<anonymous> (events.js:133:17)
at Socket.<anonymous> (c:\HTML5\LIKEPREF\test\server\server.js:576:18)
at Socket.$emit (events.js:67:17)
at SocketNamespace.handlePacket (C:\Personal\software\nodejs\NODE\node_modul
es\socket.io\lib\namespace.js:335:22)
at Manager.onClientMessage (C:\Personal\software\nodejs\NODE\node_modules\so
cket.io\lib\manager.js:459:38)
at WebSocket.onMessage (C:\Personal\software\nodejs\NODE\node_modules\socket
.io\lib\transport.js:387:20)
at Parser.<anonymous> (C:\Personal\software\nodejs\NODE\node_modules\socket.
io\lib\transports\websocket\hybi-16.js:40:10)
at Parser.emit (events.js:67:17)
at C:\Personal\software\nodejs\NODE\node_modules\socket.io\lib\transports\we
bsocket\hybi-16.js:286:16
at Parser.expectHandler (C:\Personal\software\nodejs\NODE\node_modules\socke
t.io\lib\transports\websocket\hybi-16.js:297:15)
Run Code Online (Sandbox Code Playgroud)
我正在使用redis pubsub,当我订阅redis时,它会抛出这个警告.
我使用了没有 nginx 的本地设置来为我的 node.js 应用程序提供服务,我使用的是 socket.io 并且性能非常好。
现在,我使用 nginx 来代理我的请求,我发现socket.io 的响应时间很长,这意味着我的页面渲染速度很快,但 socket.io 渲染的数据比以前慢了一个数量级。
我正在使用 NGINX 1.1.16,这是配置,
gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
access_log logs/host.access.log main;
location / {
proxy_pass http://localhost:9999;
root html;
index index.html index.htm;
}
Run Code Online (Sandbox Code Playgroud)
尽管一切正常,但我有两个问题,
socket.io 响应比以前慢。使用 NGINX 时,响应时间约为 12-15 秒,不使用 NGINX 时,响应时间几乎不到 300 毫秒。用 apache benchmark 尝试过这个。
我在控制台中看到这条消息,在使用 NGINX 之前是不存在的,
[2012-03-08 09:50:58.889] [INFO] console - warn - 'websocket connection invalid'
Run Code Online (Sandbox Code Playgroud)我beieveSGDClassifier()与loss='log'支持多标记分类,我没有使用OneVsRestClassifier。检查这个
现在,我的数据集非常大,我正在使用HashingVectorizer并将结果作为输入传递给SGDClassifier. 我的目标有 42048 个特征。
当我运行它时,如下所示:
clf.partial_fit(X_train_batch, y)
Run Code Online (Sandbox Code Playgroud)
我得到:ValueError: bad input shape (300000, 42048)。
我也使用类作为参数如下,但仍然是同样的问题。
clf.partial_fit(X_train_batch, y, classes=np.arange(42048))
Run Code Online (Sandbox Code Playgroud)
在 SGDClassifier 的文档中,它说 y : numpy array of shape [n_samples]
classification machine-learning stochastic-process scikit-learn