我正在尝试在sublime Text 3中打开一个目录.
我可以使用subl命令从命令行启动sublime .
帮助文本显示以下内容:
Sublime Text build 3059
Usage: subl [arguments] [files] edit the given files
or: subl [arguments] [directories] open the given directories
or: subl [arguments] - edit stdin
Arguments:
--project <project>: Load the given project
--command <command>: Run the given command
-n or --new-window: Open a new window
-a or --add: Add folders to the current window
-w or --wait: Wait for the files to be closed before returning
-b or --background: Don't activate …Run Code Online (Sandbox Code Playgroud) 我制作了一个示例脚本.这是我正在运行的示例脚本:
def array_generator
signalp_array = Array.new(11){ Array.new(11,0) }
signalp = Hash.new
file = File.readlines("./sample.txt")
file.each_with_index do |line, idx|
row = line.gsub(/\s+/m, ' ').chomp.split(" ") # split the line into a array based on white space.
signalp_array[idx][0..row.length - 1] = row # Merge into existing array
end
signalp_array.each do |g|
seq_id = g[0]
cut_off = g[4]
d_value = g[8]
signalp[seq_id] = [:cut_off => cut_off, :d_value => d_value]
end
return signalp
end
signalp = array_generator
puts signalp
signalp.each do |id, neww|
puts …Run Code Online (Sandbox Code Playgroud) 我想从最小到最高排序一系列数字(科学记数法).
这是我试过的(徒劳):
require 'bigdecimal'
s = ['1.8e-101','1.3e-116', '0', '1.5e-5']
s.sort { |n| BigDecimal.new(n) }.reverse
# Results Obtained
# => [ "1.3e-116", "1.8e-101", "0", "1.5e-5" ]
# Expected Results
# => [ "0", "1.3e-116", "1.8e-101", "1.5e-5"]
Run Code Online (Sandbox Code Playgroud) 我试图从多维数组中获取最长的字符串,但由于某种原因它不起作用.
这就是我所拥有的:
a =
["MAKKGKPRPDHRPPAHNPHYAHDPPPYSQQQPPLQQQNYAQQMNRQHARPRPSPPSEVSDCVKYSLFLYNCIFWVSMHSS"],
["MHHGGGGGNRQHARPRPSPPSEVSDCVKYSLFLYNCIFWVSMHSS"], ["MTYINLGVTRTGDLMIGRHRP"],
["MRIYNRVCFQTAGCYLQNLVTTSIQPARVWTY"], ["MAACGLGRVFSAFKVDEMD"],
["MPSGFVGKRSGFCQFCCSHI"], ["MTYSTAKEGAYPFRNFN"]]
p a.max_by{|v|v}[0] # => "MTYSTAKEGAYPFRNFN"
Run Code Online (Sandbox Code Playgroud)
有人可以让我知道我做错了什么吗?
我想创建一个基本的ruby脚本,将Slim模板呈现为html(这最终将成为更大项目的一部分).理想情况下,我想使用脚本中生成的HTML.
我知道这可以使用TILT(如SLIM README中所示),其中说明如下:
Slim使用Tilt编译生成的代码.如果要直接使用Slim模板,可以使用Tilt界面.
Tilt.new['template.slim'].render(scope)
Slim::Template.new('template.slim', optional_option_hash).render(scope)
Slim::Template.new(optional_option_hash) { source }.render(scope)
Run Code Online (Sandbox Code Playgroud)
可选的选项哈希可以包含上面部分中记录的选项.范围是执行模板代码的对象.
但是,我仍然无法成功运行它.因此,我想知道是否有人可以通过制作一个有效的例子来帮助我.
编辑(最近进一步编辑):
我已经玩了很多代码但我继续得到以下错误:
undefined local variable or method `source' for main:Object (NameError)
Run Code Online (Sandbox Code Playgroud)
这就是我正在运行的:
require 'slim'
# I'm not sure about the next two lines...
optional_option_hash = {}
scope = Object.new
Tilt.new('template.slim').render(scope)
Slim::Template.new('template.slim', optional_option_hash).render(scope)
Slim::Template.new(optional_option_hash) { source }.render(scope)
Run Code Online (Sandbox Code Playgroud)
非常感谢您的帮助.
我正在尝试使用Travis.ci进行自动化测试.但是,目前构建在尝试执行时仍然失败bundle exec rake.这就是我所看到的......
$ bundle exec rake
rake aborted!
Don't know how to build task 'default'
/home/travis/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `eval'
/home/travis/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `<main>'
(See full trace by running task with --trace)
The command "bundle exec rake" exited with 1.
Done. Your build exited with 1.
Run Code Online (Sandbox Code Playgroud)
我的单元测试位于主目录的test文件夹中,名为test_np_search.rb.我知道我不知何故应该将travis指向这个位置以运行单元测试,但我不知道如何做到这一点.
我已经多次阅读过travis.ci上的ruby相关文档并且已经在线查看了教程,但是我无法让它工作.
有问题的整个github存储库在这里:https://github.com/IsmailM/NeuroPeptideSearch
Travis.CI链接在这里:https://travis-ci.org/IsmailM/NeuroPeptideSearch
我一直试图让这个分类一个多星期,现在取得了任何成功,所以如果有人能帮助我,我将非常感激.
多谢
当服务器上出现错误(例如IOError或ArgumentError)时,我试图使sinatra应用程序显示自定义错误页面。
当前,我正在使用AJAX将结果加载到某个#resultsdiv中,但是如果并且在服务器上出现错误时,我希望在新页面上打开错误页面。
当前,服务器上显示IOError并在控制台中看到错误(服务器响应状态为500(内部服务器错误))。除此之外,什么也没有发生。
我认为我必须使用Javascript(以及Sinatra :: Base类),但是我花了整个整个昨天和今天的早晨。
我将非常感谢您的帮助。我为应用创建了一个过于简化的版本,如下所示...
Sinatra_app.rb
require 'sinatra/base'
require9 'sinatra'
require 'slim'
# A helper module
module GVhelpers
def create_results(name)
# raise IOError, "There's a problem..."
return "<p>The Server Says 'Hey #{name}'</p>"
end
end
class GVapp < Sinatra::Base
helpers GVhelpers
set :root, File.dirname(__FILE__)
error do
@error = env['sinatra.error']
slim :"500", :locals => {:error => error}
end
get '/' do
slim :index
end
post '/form' do
name = params[:personName]
create_results(name)
end
end
GVapp.run!
Run Code Online (Sandbox Code Playgroud)
index.slim(在views文件夹中)
script src="/jquery.min.js" …Run Code Online (Sandbox Code Playgroud) ruby ×6
sorting ×2
arrays ×1
command-line ×1
fish ×1
hash ×1
sinatra ×1
slim-lang ×1
sublimetext3 ×1
travis-ci ×1
unit-testing ×1