小编jon*_*ock的帖子

更改iPython笔记本服务器/ Jupyter的默认端口

我试图在防火墙后面的机器上运行ipython notebook/jupyter服务器.唯一打开的端口是端口80.所以我想知道如何将默认端口从8890更改为80?

我运行了以下命令ipython profile create来创建配置文件.

然后编辑ipython_notebook_config.py并编辑它以包含以下内容:

c = get_config()
c.NotebookApp.port = 80
Run Code Online (Sandbox Code Playgroud)

当我尝试运行python笔记本时.我收到以下错误:

ERROR: the notebook server could not be started because no available port could be found.


但是,似乎没有其他东西使用端口80.Apache不会在启动时启动并被禁用.我甚至使用netstat来查看每个端口的使用情况.

$ sudo netstat -lnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address                 State       PID/Program name
tcp        0      0 0.0.0.0:21              0.0.0.0:*               LISTEN      1226/vsftpd     
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1532/sshd       
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      3433/cupsd      
tcp        0      0 127.0.0.1:5984          0.0.0.0:*               LISTEN      1410/beam.smp …
Run Code Online (Sandbox Code Playgroud)

port ipython ipython-notebook anaconda jupyter

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

检查来自Alamofire和Swift的多个异步响应

我正在编写一个依赖于来自各种站点/服务的数据的应用程序,并且涉及基于来自这些不同来源的数据执行计算以生成最终产品.

我编写了一个带有两个函数的示例类,它们收集来自两个源的数据.我选择使函数不同,因为有时我们根据源应用不同的身份验证方法,但在这个例子中我只是将它们剥离到最简单的形式.这两个函数都使用Alamofire来触发和处理请求.

然后我有一个初始化函数,它说如果我们成功地从两个源收集数据,然后加载另一个nib文件,否则等待几秒钟,如果没有返回响应,则加载服务器错误nib文件.

我试图让这个例子尽可能简单.实质上.这是我想要遵循的那种逻辑.不幸的是,这似乎目前在其当前实施中不起作用.

import Foundation

class GrabData{
    var data_source_1:String?
    var data_source_2:String?

    init(){    
        // get data from source 1
        get_data_1{ data_source_1 in
            println("\(data_source_1)")
        }

        // get data from source 2
        get_data_2{ data_source_1 in
            println("\(data_source_1)")
        }

        var timer = 0;
        while(timer<5){
            if((data_source_1 == nil) && (data_source_2 == nil)){
                // do nothing unless 4 seconds has elapsed
                if (timer == 4){
                    // load server error nib
                }
            }else{
                // load another nib, and start manipulating data
            }
            // sleep for 1 second …
Run Code Online (Sandbox Code Playgroud)

asynchronous ios data-synchronization swift alamofire

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

如何在使用Twitter Stream给出的流示例上暂停,终止,停止或关闭PycURL请求

我目前正在使用twitter API流(http://stream.twitter.com/1/statuses/sample.json),因此我不断收到数据.我希望一旦我从中检索到X个对象就停止cURLing流(在示例中,我将10作为任意数字).

您可以在下面的代码中查看我是如何尝试关闭连接的.curling.perform()下面的代码永远不会执行,因为它是一个连续的数据流.所以我试图在body_callback中关闭流,但是因为perform()当前正在运行,所以我无法调用close().

任何帮助,将不胜感激.

码:

# Imports
import pycurl # Used for doing cURL request
import base64 # Used to encode username and API Key
import json # Used to break down the json objects

# Settings to access stream and API
userName = 'twitter_username' # My username
password = 'twitter_password' # My API Key
apiURL = 'http://stream.twitter.com/1/statuses/sample.json' # the twitter api
tweets = [] # An array of Tweets

# Methods to do with the tweets array
def how_many_tweets(): …
Run Code Online (Sandbox Code Playgroud)

python curl kill stream pycurl

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

Google Chart API线图上的日期错误

因此,我尝试使用Google的Chart API在线图上绘制Tide次数.但是,图表上绘制的点与正确的日期和时间值不对应.

数据的形式为日期时间(x轴)和潮汐高度(y轴).我不确定我是否正确创建了日期时间值,或者API只是做了一些奇怪的事情.

例如,tideTimes数组中的最后一个日期是11月1日,但图表显示12月的数据点,您可以在下面的图片中看到此行为.我添加了下面的代码,以便您重新创建这些错误.

如果有人能告诉我我做错了什么,我将不胜感激. 在谷歌图表api上显示错误的数据点

    <html>
      <head>
        <script type="text/javascript" src="https://www.google.com/jsapi"></script>
        <script type="text/javascript">

        google.load("visualization", "1", {packages:["corechart"]});
          google.setOnLoadCallback(drawWeekChart);
          function drawWeekChart() {

            var data = new google.visualization.DataTable();
            data.addColumn('datetime', 'Date');
            data.addColumn('number', 'Wave Height (Meters)');
            var tideTimes = [
                [new Date(2012, 10, 29, 05, 44, 00, 00), 9.12],
                [new Date(2012, 10, 29, 11, 47, 00, 00), 1.62],
                [new Date(2012, 10, 29, 18, 01, 00, 00), 9.23],
                [new Date(2012, 10, 30, 00, 01, 00, 00), 1.55],
                [new Date(2012, 10, 30, 06, 16, 00, 00), 9.20],
                [new …
Run Code Online (Sandbox Code Playgroud)

javascript datetime google-visualization

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

使用终端记录/保存数据流

我希望能够使用curl命令保存我返回的数据流.我已经尝试使用cat命令,并使用curl命令管道,但是我做错了.我目前使用的代码是:

cat > file.txt | curl http://datastream.com/data
Run Code Online (Sandbox Code Playgroud)

任何帮助,将不胜感激.

bash save data-stream

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