我在bash脚本文件中有以下代码:
#! /bin/sh
#
# Usage:
#
# f.sh <start_directory> <destination_directory> <prepare_directory> <remote_host_for_copy> <remote_user>
#
print_correct_syntax() {
echo "f.sh <start_directory> <destination_directory> <prepare_directory> <remote_host_for_copy> <remote_user>"
echo ""
echo '<start_directory> needs to be a full path, <destination_directory> needs to be full path, <prepare_directory> has to be relative to start_directory path'
echo ""
}
# ---- end of function definition ----
# check number of run-time arguments given to script
if [ $# != 5 ]
then
echo Wrong Syntax! $(print_correct_syntax)
exit;
fi …
Run Code Online (Sandbox Code Playgroud) 我想了解Sunspot在标准模式下是否在全文搜索中搜索字符或字符序列以及如何搜索序列.
例如,我有以下设置:
class User < ActiveRecord::Base
searchable do
text :email
end
end
Run Code Online (Sandbox Code Playgroud)
一个User
与电子邮件"panayotis@matsinopoulos.gr"
以下查询:
search = User.search do
fulltext 'matsinopoulos'
end
Run Code Online (Sandbox Code Playgroud)
没有带来任何结果,而:
search = User.search do
fulltext 'panayotis@matsinopoulos.gr'
end
Run Code Online (Sandbox Code Playgroud)
带来的.
是否有任何配置设置太阳黑子匹配字符序列而不是单词?
或者,我做错了什么?
我有一个简单的网页,其中 CSS 样式规则不适用于表单按钮,如果我使用的是 Chrome 或 Safari(Mac OS X、Yosemite)。它确实适用于 Firefox。如果我使用 background-color 属性,它确实适用于 Chrome 和 Safari。
看下面的例子。该save
按钮没有Roboto Mono
字体,它应该是。仅当您在 Chrome 或 Safari 上打开页面时才会出现此问题。它在 Firefox 上运行完美。
最重要的是,如果我background-color
在按钮上应用类似的样式,那么字体会Roboto Mono
突然按预期工作,并且它也应用在按钮上。
这是我使用的代码。
http://jsbin.com/foqiso/edit?html,css,output
任何线索为什么按钮不采用指定的字体,但前提是
?
更新:还有另一种解决方法。<input type="submit" value="Save">
如果我使用<button type=submit>Save</button>
,而不是使用,则使用button
我期望的字体进行样式设置。
我有字符串"abigword"
,我想采取数组["ab", "ig", "wo", "rd"]
.为了概括,给定一个字符串,我想把它的组成字符数组一对一地配对.
什么是最优雅的Ruby方式呢?
我在用 Rails 3.2.X
我有Controllers继承案例如下:
class ApplicationController < ActionController::Base
before_filter :do_something
protected
def do_something
end
end
Run Code Online (Sandbox Code Playgroud)
和
class ChildController < ApplicationController
before_filter :do_something_else
protected
def do_something_else
end
end
Run Code Online (Sandbox Code Playgroud)
在调用动作时ChildController
我看到do_something_else
之前被调用do_something
.这是预期的行为吗?
即使我这样做:
append_before_filter :do_something_else
Run Code Online (Sandbox Code Playgroud)
将do_something_else
始终首先调用,这是不是我的预期.
如何before_filters
在子控制器上before_filters
定义其父控制器上定义的子控制器之后执行.
[更新]请注意,问题更为笼统.我需要一个答案,它将涵盖任何数量的过滤器ApplicationController
和子控制器上的任何数量的过滤器以及更长的继承树上的子控制器的子控制器.
要使此更新更加清晰:
class ApplicationController < ActionController::Base
before_filter :do_something1
before_filter :do_something2
end
class ChildController < ApplicationController
before_filter :do_something3
before_filter :do_somethign4
end
class Child2Controller < ChildController
before_filter :do_something5
before_filter :do_somethign6
end
Run Code Online (Sandbox Code Playgroud)
呼叫操作Child2Controller
应该被称为:1)do_something1 …
在使用 Rails 3.2 进行日志记录时,我想记录日志条目所在的文件名和行号。
因此,如果在我的在线 ruby 脚本中customer.rb
我23
有一个类似以下的日志:
Rails.logger.debug "Debug message"
Run Code Online (Sandbox Code Playgroud)
我希望日志记录如下内容:
[customer.rb:23] Debug message
Run Code Online (Sandbox Code Playgroud)
那可能吗?
我可以写一个简短的例子来验证内部to_a
的Enumerable
调用each
.这里是:
class MyFooClass
include Enumerable
def initialize
@members = [1, 2, 3]
end
def each
puts "each is now called"
@members.each{ |m| yield(m) }
end
end
a = MyFooClass.new
puts "let us convert to array"
g = a.to_a
Run Code Online (Sandbox Code Playgroud)
输出是:
let us convert to array
each is now called
Run Code Online (Sandbox Code Playgroud)
请注意,each
它不是成员Enumerable
,但是to_a
.此外,如果我each
从我的类中删除定义,然后代码崩溃与以下消息:
in `to_a': undefined method `each' for #<MyFooClass:0x997c1ac @members=[1, 2, 3]> (NoMethodError)
Run Code Online (Sandbox Code Playgroud)
我想知道是否有关于此的Ruby官方文档,这将记录to_a
(在其成员中Enumerable
)通过each …
我试图n
使用Ruby枚举器获取下一个数量的元素,使用:
a = [1, 2, 3, 4, 5, 6]
enum = a.each
enum.next(2) # expecting [1, 2]
enum.next(2) # expecting [3, 4]
Run Code Online (Sandbox Code Playgroud)
但#next
不支持这一点.还有另一种方法可以做到吗?或者我该怎么办?
什么是正确的Ruby方法呢?
有谁知道如何在纯HAML中写下以下内容?请注意,我想显示两个完全相邻的选择框,旁边是一个按钮,中间没有任何空格:
<%= f.select :state, State.all.order(:name).map {|s| [s.name, s.id]} -%>
<%= f.select :subject, Subject.all.order(:name).map {|s| [s.name, s.id]} -%>
<%= f.button "Search", class: "input-lg" -%>
Run Code Online (Sandbox Code Playgroud)
编辑包含在以下内容中:
= form_for @tutors_search_form, url: "/tutors/search", method: :get do |f|
.container
.row.text-center
:erb
<%= f.text_field :subject, class: "input-lg input-no-border-radius", placeholder: "What Subject do you want to learn?", required: true, id: 'home-page-search-bar-subject-input' -%>
<%= f.text_field :state, class: "input-lg input-no-border-radius", placeholder: "Which State are you in?", required: true, id: 'home-page-search-bar-state-input' -%>
<%= f.button "Search", class: "btn btn-primary-wouaou btn-lg …
Run Code Online (Sandbox Code Playgroud)