我有两个函数,但其中一个函数只从另一个函数调用,所以我想内联辅助函数.我的代码看起来像这样:
data PoS = N | V | Adj | Adv | Phr
posEntity :: Parser PoS
posEntity =
do pos <- string "N." <|>
string "V." <|>
string "Adj." <|>
string "Adv." <|>
string "Phr."
return (posToPoS pos)
<?> "part of speech"
posToPoS pos
| pos == "N." = N
| pos == "V." = V
| pos == "Adj." = Adj
| pos == "Adv." = Adv
| pos == "Phr." = Phr
Run Code Online (Sandbox Code Playgroud)
显然posToPoS应该内联,但我不确定做这样的事情所需的语法.
谢谢!
我正在写一个宝石,我的目标是Ruby,JRuby和Rubinius.我正在使用Travis CI来构建我的库.当我定位Ruby和JRuby时,我的gem正确构建,但是当针对Rubinius时,它不起作用.这是错误:
Run Code Online (Sandbox Code Playgroud)Using worker: worker-linux-2-2.bb.travis-ci.org:travis-linux-13 git.1 $ git clone --depth=50 --branch=master git://github.com/maxgale/actor.git maxgale/actor Cloning into 'maxgale/actor'... remote: Counting objects: 74, done. remote: Compressing objects: 100% (48/48), done. remote: Total 74 (delta 29), reused 64 (delta 22) Receiving objects: 100% (74/74), 12.06 KiB | 0 bytes/s, done. Resolving deltas: 100% (29/29), done. Checking connectivity... done. $ cd maxgale/actor git.3 $ git checkout -qf f83f26d85f69e9c2965a4faa2065dd37ac789c36 $ rvm use rbx --install --binary --fuzzy rbx is not installed - installing. Searching for binary rubies, …
我有一个包含目录的 GCS 存储桶my-bucket-name/my-temp-dir-name
。该目录包含许多子文件。我想执行复制命令,例如gsutil cp gs://my-bucket-name/my-temp-dir-name gs://my-bucket-name/my-dir-name
。
此操作是否有任何原子保证?是否有可能在my-dir-name
所有文件可用之前就可以访问某些文件?如果my-dir-name
已经存在怎么办?
我正在尝试创建一个表单,用作控制器上的destroy方法的确认.在我的路线中,我有:
resources :leagues do
get 'delete', :on => :member
end
Run Code Online (Sandbox Code Playgroud)
在我的delete.html.erb中,我有以下内容:
<% form_for current_league, :html => {:method => :delete} do |form| %>
<%= form.submit 'Yes' %>
<%= form.submit 'No', :name => 'cancel' %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
current_league是一个由以下定义的辅助函数:
def current_league
@current_league ||= League.find_by_id(params[:id])
end
Run Code Online (Sandbox Code Playgroud)
所以问题在于生成的表单只编辑联盟模型,如form method ="post"所示.
<form accept-charset="UTF-8" action="/leagues/1" class="edit_league" id="edit_league_1" method="post">
<div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓" />
<input name="_method" type="hidden" value="delete" />
<input name="authenticity_token" type="hidden" value="abcdefg" />
</div>
<input id="league_submit" name="commit" type="submit" value="Yes" />
<input id="league_submit" name="cancel" type="submit" value="No" …
Run Code Online (Sandbox Code Playgroud) 我想做这样的事情,但我不确定是否有可能.我在Google上找不到任何信息.
template <typename T>
class Container {
public:
T *ptr;
};
class Other {
private:
Container *container_ref;
}
Run Code Online (Sandbox Code Playgroud)
谢谢您的帮助.
我安装了Nginx和phusion乘客,但我无法访问服务器.我正在使用默认配置文件,但当我尝试访问浏览器中的IP地址时,我从未收到服务器的响应.在我的服务器上我可以做到:
curl 127.0.0.1
Run Code Online (Sandbox Code Playgroud)
要获得响应,但访问浏览器中的IP地址总是超时.我确保端口80通过执行打开sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
,但没有任何改变.我正在使用Ubuntu.
Authlogic需要许多Active Record功能,这些功能在Active Model中不可用,因此在Mongoid中不可用.Authlogic如何与Mongoid一起使用?
我正在尝试使用此处的Vector类型实现光线数据类型:http://www.haskell.org/haskellwiki/Numeric_Haskell:_A_Vector_Tutorial # Importing_the_library
Vector只会保存双打,所以我想使用Vector类型的Unboxed版本.
这是我试图编译的代码:
module Main where
import qualified Data.Vector.Unboxed as Vector
data Ray = Ray Data.Vector.Unboxed Data.Vector.Unboxed
Run Code Online (Sandbox Code Playgroud)
我得到的错误是
Not in scope: type constructor or class `Data.Vector.Unboxed'
Failed, modules loaded: none.
Run Code Online (Sandbox Code Playgroud) 当我执行时,rvm install ruby-1.9.3-head
我收到此错误:
? ~ rvm install ruby-1.9.3-head
Installing Ruby from source to: /Users/max/.rvm/rubies/ruby-1.9.3-head, this may take a while depending on your cpu(s)...
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any …
Run Code Online (Sandbox Code Playgroud) 当我尝试访问运行在nginx和乘客之上的rails应用程序时,我得到403.以下是日志文件中的错误:
2013/05/09 13:52:34 [error] 27787#0: *1 directory index of "/var/www/Tread-Forth/current/public/" is forbidden, client: 192.249.16.60, server: treadforth.com, request: "GET / \
HTTP/1.1", host: "www.treadforth.com"
Run Code Online (Sandbox Code Playgroud)
即使我以root身份运行nginx,也会出现此问题,因此我认为这不是权限问题.我认为问题是我的nginx.conf文件中没有passenger_ruby
或没有passenger_root
定义.问题是,我不知道这些值在配置文件中的位置,我不知道它们的值应该是什么.任何帮助都会很棒.这是我的conf文件供参考:
worker_processes 1;
events {
worker_connections 1024;
}
http {
#passenger_root /usr/local/bin/passenger;
#passenger_ruby /usr/local/bin/ruby;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name .treadforth.com;
root /var/www/Tread-Forth/current/public;
passenger_enabled on;
}
}
Run Code Online (Sandbox Code Playgroud)
您可以看到我尝试过的乘客注释和passenger_ruby的注释版本.当我取消注释这些时,nginx无法启动但不会产生任何错误消息.