我正在尝试在Jekyll重建一个博客,我已经找到了一个简单的任务.
如果我有以下模板集:
default.html中:
{{ head }}
{{ content }}
Run Code Online (Sandbox Code Playgroud)
frontpage.html:
---
layout: default
---
{% capture head %}
Frontpage
{% end %}
{{ content }}
Run Code Online (Sandbox Code Playgroud)
index.html的:
---
layout: frontpage
---
Other stuff
Run Code Online (Sandbox Code Playgroud)
我当时希望{% capture head %}将变量传递给布局.但似乎只有Front Matter的变量实际上被传递为page.variable_name.
有没有办法将capture-d var 传递给Jekyll的布局?
猜猜我可以制作2种不同的布局frontpage,normal_page这将取代布局中的整个{{head}}{{content}}块.但这就像html的两倍,所以capture如果可能的话我宁愿解决它.
我在Lion上使用Homebrew安装了Imagemagick,一切都很好,除了它从php调用时根本不起作用.安慰:
$ convert -version
Version: ImageMagick 6.7.1-1 2011-07-29 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP
$ which convert
/usr/local/bin/convert
Run Code Online (Sandbox Code Playgroud)
PHP:
echo exec ('convert -version');
Run Code Online (Sandbox Code Playgroud)
或者exec('convert -version',$ output); 的var_dump($输出);
什么都不产生(或空数组).
exec ('/usr/local/bin/convert') // works, but
exec ('which convert') // doesn't
Run Code Online (Sandbox Code Playgroud)
我需要在本地测试它,以确保我可以检测生产环境中的转换.但我无法正确测试它.PATH已设置,它可以在终端中运行,但不能在PHP中运行.
解决:
事实证明,对于php应该工作convert,/usr/bin/所以这解决了它:
ln -s /usr/local/bin/convert /usr/bin/convert
Run Code Online (Sandbox Code Playgroud)
更新
这是因为MAMP,这是修复:http://firedevcom.tumblr.com/post/22791937644/fix-for-homebrew-imagemagick-and-mamp
打开/ Applications/MAMP/Library/bin/envvars
并注释掉以下几行:
DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"
export DYLD_LIBRARY_PATH
Run Code Online (Sandbox Code Playgroud)
完成.
git 1.8的另一个问题:
$ git push
error: dst ref refs/heads/master receives from more than one src.
error: failed to push some refs to 'gitosis@xxx.xx:xxx.git'
Run Code Online (Sandbox Code Playgroud)
建议?它在升级到1.8之前正在工作.
$ git remote -v
origin gitosis@xxx.xx:xxx.git (fetch)
origin gitosis@xxx.xx:xxx.git (push)
Run Code Online (Sandbox Code Playgroud)
谷歌搜索后我首先尝试了这个:
$ git push origin :refs/heads/refs/heads/master
remote: warning: Allowing deletion of corrupt ref.
To gitosis@xxx.xx:xxx.git
- [deleted] refs/heads/master
Run Code Online (Sandbox Code Playgroud)
不知道那是什么,为什么它是腐败的.
$ git pull
Already up-to-date.
$ git push
error: dst ref refs/heads/master receives from more than one src.
error: failed to push some refs to 'gitosis@xxx.xx:xxx.git'
Run Code Online (Sandbox Code Playgroud)
仍然没有工作,但 …
我对apache有这个奇怪的问题:
$ apachectl configtest
Syntax OK
Run Code Online (Sandbox Code Playgroud)
配置是可以的,它实际上是在一分钟前工作,然后关闭它.
$ sudo apachectl start
org.apache.httpd: Already loaded
Run Code Online (Sandbox Code Playgroud)
不,这不对:
$ ps ax | grep httpd
58204 s000 R+ 0:00.00 grep httpd
Run Code Online (Sandbox Code Playgroud)
我们试着阻止它:
$ sudo apachectl stop
Run Code Online (Sandbox Code Playgroud)
看起来好像停了吧?让我们再试一次:
$ sudo apachectl start
$ sudo apachectl start
org.apache.httpd: Already loaded
Run Code Online (Sandbox Code Playgroud)
所以它必须运行,但它不在ps ax,它根本不起作用.
$ sudo apachectl stop
$ sudo apachectl stop
launchctl: Error unloading: org.apache.httpd
Run Code Online (Sandbox Code Playgroud)
试图从自动启动中删除它:
$ sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
$ sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
launchctl: Error unloading: org.apache.httpd
Run Code Online (Sandbox Code Playgroud)
但是当我尝试启动它时,它是相同的,它假装它启动但它没有.错误日志中也没有任何内容.救命!
OS X …
window.scrollTo(0,1); 不起作用.更糟糕的是,地址栏只会移动一点,有时会被卡住一半.
每当我尝试通过Pow打开本地应用程序时,我都会遇到以下错误(*=数字):
Error: timeout: waiting for /tmp/nack.*.*.sock
at null._onTimeout (/Users/pain/Library/Application Support/Pow/Versions/0.4.1/node_modules/nack/lib/process.js:416:29)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
Run Code Online (Sandbox Code Playgroud)
刷新几次后,应用程序启动并正常工作.但是,在离开一段时间之后,每次都做起来很烦人.
这是预期的行为吗?有没有办法增加超时?
更新:
$ time rails runner "puts 1"
4.72s user 1.32s system 28% cpu 21.198 total # first time after reboot
3.73s user 0.68s system 99% cpu 4.424 total # after that
Run Code Online (Sandbox Code Playgroud)
更新:
事实上同样的事情适用于Sinatra应用程序,它本身很快就开始了.并且几乎立即显示超时消息,看起来根本没有实际的超时.然后在第二页刷新它工作正常.
更新:
只需要启动一个半静态的Sinatra应用程序,比如它出现之前的5或6次.是什么赋予了?该应用程序几乎是即时的.
我已经安装了RasPi Raspbian,现在我无法执行ssh或git clone,只看到本地主机名正在解析.然而ping工作:
pi ~ $ ssh test.com
ssh: Could not resolve hostname test.com: Name or service not known
pi ~ $ git clone gitosis@test.com:test.git
Cloning into 'test'...
ssh: Could not resolve hostname test.com: Name or service not known
fatal: The remote end hung up unexpectedly
pi ~ $ ping test.com
PING test.com (174.36.85.72) 56(84) bytes of data.
Run Code Online (Sandbox Code Playgroud)
我通过使用http://github.com代替来解决github的问题git://github.com,但这不正常,我想指出问题所在.
谷歌搜索类似的问题,但提供的解决方案是拼写错误纠正,或添加域到主机文件.
有没有可靠的方法来tmux 2.5使用macOS剪贴板?
升级到2.5后,一切都走下坡路.我已经尝试了我找到的所有解决方案,没有任何效果.有人可以提供一份工作样本tmux.conf,以使其有效吗?
我可以从neovim内部复制tmux就好了.我无法使用tmux自己复制文本.
这是我所拥有的.tmux.conf:
setw -g mode-keys vi
bind-key -T copy-mode-vi 'v' begin-selection
bind-key -T copy-mode-vi 'y' copy-pipe-and-cancel "reattach-to-user-namespace pbcopy" \; display-message "copied to system clipboard"
Run Code Online (Sandbox Code Playgroud)
这些是每次会话启动时出现的错误:
.tmux.conf:95: unknown command: begin-selection
.tmux.conf:96: unknown command: copy-pipe-and-cancel
Run Code Online (Sandbox Code Playgroud)
我尝试过以下方法:
set-window-option -g mode-keys vi
bind-key -Tcopy-mode-vi 'v' send -X begin-selection
bind-key -Tcopy-mode-vi 'y' send -X copy-pipe-and-cancel pbcopy
Run Code Online (Sandbox Code Playgroud)
我也尝试过:
bind-key -Tcopy-mode-vi 'y' send -X copy-pipe-and-cancel
Run Code Online (Sandbox Code Playgroud)
没有.
我用Guard用Rspec; 我用focus: true它来强制它只运行我正在进行的测试.但有时我会忘记删除focus: true,这会让我未来的自我和与之合作的人分心.
我想创建一个git钩子来检查spec文件夹,以确保focus: true除了测试文件之外没有,spec/rails_helper.rb并将其保存在Repository中.
我已经阅读了这个答案将git钩子放入存储库,猜测它必须有点尴尬.
如何使用钩子来阻止基于文件内容的提交?
更新
这是我现在拥有的,但它不起作用,即使没有匹配,git拒绝提交.
FILES_PATTERN='\.rb(\..+)?$'
FORBIDDEN="(\, focus: true|binding\.pry)"
git diff --cached --name-only | egrep "$FILES_PATTERN" | xargs egrep --with-filename -n "$FORBIDDEN" && echo "Commit reject, found $FORBIDDEN reference, please remove" && exit 1
exit 0
Run Code Online (Sandbox Code Playgroud) 我正在移植一个使用Carrierwave到Rails 4的应用程序,但我遇到了强大的params问题.我有一个模特
accepts_nested_attributes_for :photos
Run Code Online (Sandbox Code Playgroud)
以下是上传图片的传递方式:
{
# ...
"model"=>
{
# ...
"photos_attributes"=>
{
"1362752177921"=>
{
"image"=>"test.jpg",
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是,我似乎无法弄清楚如何编写将接受的参数photos_attributes.
我试过.permit(photos_attributes: [])但它只是跳过它们,当我使用时permit!,uuid在保存之前创建的不会出现在SQL中,这是第二个问题:
photos.uuid may not be NULL: INSERT INTO "photos" ("created_at", "model_id", "image", "title", "updated_at") VALUES (?, ?, ?, ?, ?)
Run Code Online (Sandbox Code Playgroud)
这里缺乏强参数的文档,我甚至不确定如何继续.
更新 这适用于嵌套属性:
params.permit( ..., :photos_attributes => ['id', 'title', 'image', '_destroy'])
Run Code Online (Sandbox Code Playgroud)
但是看起来像Carrierwave或Nested Form应该先为Rails 4更新.它只是试图一直保存一个空图像.相同的代码(没有strong_params)在Rails 3中有效.
file-upload nested-forms carrierwave strong-parameters ruby-on-rails-4
git ×2
macos ×2
address-bar ×1
apache ×1
carrierwave ×1
file-upload ×1
homebrew ×1
imagemagick ×1
ios ×1
ios5 ×1
iphone ×1
jekyll ×1
liquid ×1
macos-sierra ×1
mamp ×1
nested-forms ×1
networking ×1
osx-lion ×1
php ×1
rack ×1
rack-pow ×1
sinatra ×1
tmux ×1