我刚安装了Emmet VIM插件,看起来非常有趣.用于激活Emmet插件功能的"触发器组合键"并不是最好的.因此我试图在我的vimrc文件中重新映射它.我已成功完成重新映射Escape键,如下所示:
inoremap ;; <ESC>
Run Code Online (Sandbox Code Playgroud)
这允许我输入分号字符";" 快速连续退出插入模式并进入正常模式.但是,当我尝试重新映射Emmet触发键时,它不起作用,即(读作Control键和"y"键,后跟","键).我尝试了以下组合:
inoremap hh <C-y> ,
inoremap hh <C-y>,
inoremap hh <C-y,>
Run Code Online (Sandbox Code Playgroud)
如上所示,我正在尝试将"hh"键组合映射到Emmet VIM的触发键.
在此先感谢您的时间.
巴拉特
我尝试使用自制软件和macports在我的rvm ruby 2.0.0-p353上安装nokogiri,按照nokogiri安装页面上的说明进行操作:
http://nokogiri.org/tutorials/installing_nokogiri.html
在两者中,我得到完全相同的错误文件描述符错误消息,如下所示:
? sudo gem install nokogiri
Fetching: mini_portile-0.5.2.gem (100%)
Successfully installed mini_portile-0.5.2
Fetching: nokogiri-1.6.1.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/Users/Bharat/.rvm/rubies/ruby-2.0.0-p353/bin/ruby extconf.rb
/Users/Bharat/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:292:in `initialize_copy': Bad file descriptor (Errno::EBADF)
from /Users/Bharat/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:292:in `initialize_dup'
from /Users/Bharat/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:292:in `dup'
from /Users/Bharat/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:292:in `<module:Logging>'
from /Users/Bharat/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:289:in `<module:MakeMakefile>'
from /Users/Bharat/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:47:in `<top (required)>'
from /Users/Bharat/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/Bharat/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from extconf.rb:5:in `<main>'
extconf failed, exit code 1
Run Code Online (Sandbox Code Playgroud)
搜索此错误会导致与jRuby相关的信息非常少,但我使用的是MRI.
我正在使用 jQuery/javascript 在 haml 模板上显示 Highcharts 图。这是一个片段,显示了 HighCharts 站点中演示代码中的独立图表:
:javascript
$(document).ready(function() {
$("#tabs").tabs();
new Highcharts.Chart({
chart: {
renderTo: 'volume_chart'
},
title: {
text: 'Logarithmic axis demo'
},
xAxis: {
tickInterval: 1
},
yAxis: {
type: 'logarithmic',
minorTickInterval: 0.1
},
tooltip: {
headerFormat: '<b>{series.name}</b><br />',
pointFormat: 'x = {point.x}, y = {point.y}'
},
series: [{
data: [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],
pointStart: 1
}]
});
});
Run Code Online (Sandbox Code Playgroud)
这工作正常。现在我试图从 show.html.haml 文件中的 ruby/rails 数组中设置系列数据,如下所示:
...
- data_array = [1, …Run Code Online (Sandbox Code Playgroud) 这是 github 上 Allen Downey 的 Think Bayes 书中的一段代码:
def ReadData(filename='showcases.2011.csv'):
"""Reads a CSV file of data.
Args:
filename: string filename
Returns: sequence of (price1 price2 bid1 bid2 diff1 diff2) tuples
"""
fp = open(filename)
reader = csv.reader(fp)
res = []
for t in reader:
_heading = t[0]
data = t[1:]
try:
data = [int(x) for x in data]
# print heading, data[0], len(data)
res.append(data)
except ValueError:
pass
fp.close()
return zip(*res)
Run Code Online (Sandbox Code Playgroud)
整个文件可以在这个 URL上看到:Github 上这个文件的链接。
我想弄清楚 zip(*res) 在最后一行代码中是什么意思?具体来说: …
我需要在Seaborn distplot上绘制与某些X值相对应的点,以使它们落在密度曲线上或密度曲线下方。这是来自以下URL的distplot: 从Seaborn网站-distplot示例
这是带有代码的图像:
因此,例如,在上面显示的曲线图中,我需要以编程方式确定与落在密度曲线上的X值0对应的Y轴值是多少。从图中看来,它大约在0.37左右。如何在我的程序中得到它?
假设可以做到,那么我如何在所示的图中显示它,即,哪一行代码可以显示出来。我正在将一组R可视化转换为Python。R中的以下图显示了我要实现的目标:
看到曲线上显示的点了吗?有许多要绘制的点值,但是如果您帮助我绘制一个点值,我可以尝试进行其余操作。我是Matplotlib和Seaborn软件包的初学者。
我正在 David Beazly 的优秀 Python Cookbook 文本中研究如何在 Python 中使用生成器。以下代码配方非常优雅地使用生成器定义了深度优先树遍历:
# example.py
#
# Example of depth-first search using a generator
class Node:
def __init__(self, value):
self._value = value
self._children = []
def __repr__(self):
return 'Node({!r})'.format(self._value)
def add_child(self, node):
self._children.append(node)
def __iter__(self):
return iter(self._children)
def depth_first(self):
yield self
for c in self:
yield from c.depth_first()
# Example
if __name__ == '__main__':
root = Node(0)
child1 = Node(1)
child2 = Node(2)
root.add_child(child1)
root.add_child(child2)
child1.add_child(Node(3))
child1.add_child(Node(4))
child2.add_child(Node(5))
for ch in root.depth_first():
print(ch)
# …Run Code Online (Sandbox Code Playgroud) 我正在尝试从Rails 3.2.16应用程序升级到Rails 4.0.2并遇到以下问题.
我有一个名为BaseDataTable的类,如下面的代码片段所示:
class BaseDatatable
delegate :h, :link_to, to: :@view
...
end
Run Code Online (Sandbox Code Playgroud)
然后我从继承自BaseDatatable的类中调用上面委托的h方法(除了link_to),如下所示:
class TypeWellsDatatable < BaseDatatable
private
def row(type_well)
ret_array = []
...
ret_array << h(phases)
...
end
...
end
Run Code Online (Sandbox Code Playgroud)
这在Rails 3.2.16中工作正常,但在Rails 4.0.2中抛出以下错误:
NoMethodError - private method `h' called for #<#<Class:0x00000107c8d2c0>:0x00000100ed8310>:
app/datatables/base_datatable.rb:2:in `h'
app/datatables/type_wells_datatable.rb:22:in `row'
app/datatables/base_datatable.rb:13:in `block in as_json'
activerecord (4.0.2) lib/active_record/relation/delegation.rb:13:in `map'
app/datatables/base_datatable.rb:13:in `as_json'
activesupport (4.0.2) lib/active_support/json/encoding.rb:50:in `block in encode'
activesupport (4.0.2) lib/active_support/json/encoding.rb:81:in `check_for_circular_references'
activesupport (4.0.2) lib/active_support/json/encoding.rb:49:in `encode'
Run Code Online (Sandbox Code Playgroud)
似乎ActiveSupport gem在Rails 4.0.2中将此方法设为私有,这对我来说没有任何意义(或者我只是不明白).我的问题是:绕过这个问题的侵入性最小的方法是什么?还有许多其他类继承自BaseDatatble类并使用相同的技术.
python ×2
emmet ×1
function ×1
gem ×1
generator ×1
javascript ×1
jquery ×1
macos ×1
map ×1
matplotlib ×1
nokogiri ×1
plot ×1
point ×1
python-3.x ×1
ruby ×1
ruby-2.0 ×1
seaborn ×1
vim ×1
yield-from ×1
zip ×1