它说,我正在关注生成SSH密钥
sudo apt-get install xclip
#下载并安装xclip.如果没有
apt-get,可能需要使用其他安装程序(如yum)xclip -sel clip <〜/ .ssh/id_rsa.pub
#将id_rsa.pub文件的内容复制到剪贴板
但是在我跑完之后xclip -sel clip < ~/.ssh/id_rsa.pub我得到了Error: Can't open display: (null)
什么问题?我用Google搜索,但一无所获
我想对POST request我的本地开发者这样做:
HTTParty.post('http://localhost:3000/fetch_heroku',
:body => {:type => 'product'},)
Run Code Online (Sandbox Code Playgroud)
但是,它从服务器控制台报告
Started POST "/fetch_heroku" for 127.0.0.1 at 2016-02-03 23:33:39 +0800
ActiveRecord::SchemaMigration Load (0.0ms) SELECT "schema_migrations".* FROM "schema_migrations"
Processing by AdminController#fetch_heroku as */*
Parameters: {"type"=>"product"}
Can't verify CSRF token authenticity
Completed 422 Unprocessable Entity in 1ms
Run Code Online (Sandbox Code Playgroud)
这是我的控制器和路线设置,非常简单.
def fetch_heroku
if params[:type] == 'product'
flash[:alert] = 'Fetch Product From Heroku'
Heroku.get_product
end
end
post 'fetch_heroku' => 'admin#fetch_heroku'
Run Code Online (Sandbox Code Playgroud)
我不确定我需要做什么?关闭CSRF肯定会起作用,但我认为在创建这样的API时应该是我的错误.
我还需要做其他设置吗?
我使用Jupyter Notebook来分析数据集.笔记本中有很多情节,其中一些是3d图.
我想知道是否有可能使3d绘图具有交互性,所以我可以稍后再详细介绍它?
也许我们可以在上面添加一个按钮?点击它可以弹出一个3d图,人们可以缩放,平移,旋转等.
我的思想:
这不适合我的情况,因为我需要在3d情节之后继续绘图.%qt会影响以后的情节.
mpld3在我的情况下几乎是理想的,不需要重写任何东西,与matplotlib兼容.但是,它只支持2D绘图.我没有看到任何有关3D的计划(https://github.com/mpld3/mpld3/issues/223).
没有在bokeh图库中找到3d绘图的任何实际示例.我只找到使用的https://demo.bokehplots.com/apps/surface3dvisjs.
因为我需要的只是直线和外观,是否可以使用浏览器中的js将数据传递给js plot以使其具有交互性?(然后我们可能还需要添加3d轴.)这可能类似于visjs,和mpld3.
我正在关注#335部署到VPS,并且在剧集结束时,我们需要运行ssh-add以授予服务器访问github repo的权限.
问题是如何在Windows中运行它?需要安装什么?
我知道要运行ssh以访问远程服务器,我可以使用Putty.但是这个命令需要在本地运行,我知道如何使用它Putty来执行此操作.
我试图用一个属性选择对象uniq @videos.uniq{|p| p.author}
time = Time.new(2014, 12)
start_time = time.beginning_of_month
end_time = time.end_of_month
videos = Video.where("created_at > ? AND created_at < ?", start_time, end_time).where("likes > ?", 15)
selected_videos = videos.uniq{|p| p.author}
puts videos.count, videos.class, selected_videos.count
#=> 23, Video::ActiveRecord_Relation, 23
videos_first = videos.first(23)
selected_videos = videos_first.uniq{|p| p.author}
puts videos_first.count, videos_first.class, selected_videos.count
#=> 23, array, 10
Run Code Online (Sandbox Code Playgroud)
.uniq不适合ActiveRecord_Relation.问题是查询返回一个Video::ActiveRecord_Relation,但我需要array.
当然,这可以通过使用来实现to_a,但这是优雅吗?
.uniq的activerecord:relation?在我的笔记本中,我有一个返回临时计算结果的单元格.它有点长,所以在它运行后,我想隐藏它,并在需要时显示它.
要手动完成,我可以双击输出的左侧,以隐藏它
但有什么方法可以通过代码来做到这一点?例如,
单元格的最后一行,使用类似的命令%%hide output,输出将在完成运行后隐藏.
另外,我可以在输出HTML中获得此功能吗?
我正在使用Ipython Notebook进行研究.随着我的文件越来越大,我不断提取代码,比如绘图方法,拟合方法等.
我想我需要一种方法来组织这个.有什么好办法吗?
目前,我这样做:
data/
helpers/
my_notebook.ipynb
import_file.py
Run Code Online (Sandbox Code Playgroud)
我在存储数据data/,并提取helper method到helpers/,并分成像文件plot_helper.py,app_helper.py等等.
我总结了进口import_file.py,
from IPython.display import display
import numpy as np
import scipy as sp
import pandas as pd
import matplotlib as mpl
from matplotlib import pyplot as plt
import sklearn
import re
Run Code Online (Sandbox Code Playgroud)
然后我可以.ipynb在顶部单元格中导入我需要的所有内容
该结构可以在https://github.com/cqcn1991/Wind-Speed-Analysis看到
我现在遇到的一个问题是我有太多的子模块helpers/,而且很难想出应该将哪个方法放入哪个文件中.
我认为,一个可行的办法是组织中pre-processing,processing,post-processing.
更新:
我的大型jupyter研究笔记本:https://cdn.rawgit.com/cqcn1991/Wind-Speed-Analysis/master/output_HTML/marham.html
顶部单元格是standard import+ magic+extentions …
基本上,我想创建一个像Facebook和Stackoverflow的通知.具体来说,在帖子评论系统中,当帖子得到评论时,所涉及的每个人(创建帖子的人和创建评论的人,除了新的评论者)都会收到一条通知消息,说明此帖子已被评论.当人们阅读通知时,通知就会被驳回.
我曾尝试使用mailboxer gem来实现它,但遗憾的是没有使用其相关方法的可用示例,包括social_stream本身.
还有其他方法来创建通知系统吗?
当我尝试从头开始创建它时,我遇到了几个问题:
Model Notification
topic_id: integer
user_id: integer
checked: boolean #so we can tell whether the notification is read or not
Run Code Online (Sandbox Code Playgroud)
我认为我们只需要在用户访问通知索引后将每个通知消息的"已检查"属性设置为true.(在NotificationsController中)
def index
@notifications=current_user.notication.all
@notification.each do |notification|
notification.checked = true
end
@notification.save!
end
Run Code Online (Sandbox Code Playgroud)
2.选择要通知的用户(并排除用户发表新评论)
我只是不知道如何查询......
3.创建通知
我认为这应该是这样的
#in CommentController
def create
#after creating comments, creat notifications
@users.each do |user|
Notification.create(topic_id:@topic, user_id: user.id)
end
end
Run Code Online (Sandbox Code Playgroud)
但我认为这真的很难看
没有必要解决上面的3个问题,任何简单的通知系统解决方案都是可取的,谢谢......
在进行拟合时,我总是遇到类似的代码
clf = svm.SVC(kernel='linear', C=1).fit(X_train, y_train)
Run Code Online (Sandbox Code Playgroud)
(来自http://scikit-learn.org/stable/modules/cross_validation.html#k-fold)
什么clf代表什么?我用Google搜索,但没有发现任何线索.
我有一个数据框,其中包含有关电影的信息.它有一个名为的列genre,其中包含它所属的类型列表.例如:
df['genre']
## returns
0 ['comedy', 'sci-fi']
1 ['action', 'romance', 'comedy']
2 ['documentary']
3 ['crime','horror']
...
Run Code Online (Sandbox Code Playgroud)
我想知道如何查询数据帧,所以它返回属于cerain类型的电影?
例如,某些东西可能会df['genre'].contains('comedy')返回0或1.
我知道列表,我可以这样做:
'comedy' in ['comedy', 'sci-fi']
Run Code Online (Sandbox Code Playgroud)
但是,在大熊猫中,我没有找到类似的东西,我唯一知道的是df['genre'].str.contains(),但它对列表类型不起作用.
python ×4
ssh ×2
activerecord ×1
gem ×1
ipython ×1
jupyter ×1
linux ×1
matplotlib ×1
pandas ×1
scikit-learn ×1
windows ×1