This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
有时由于一些原因需要限制url链接中传过来的参数符合我们定制的规则,对参数的限制在路由配置时使用**constraints**关键定。 | |
例如限制参数id的值以A开头,应该这样写: | |
~~~~ ruby | |
get 'photos/:id', to: 'photos#show', constraints: { id: /[A-Z]\d{5}/ } | |
#等同于 | |
get 'photos/:id', to: 'photos#show', id: /[A-Z]\d{5}/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
使用rails搭建个人网站,功能杂,一不小心router代码就写的杂乱无章,想要优化router代码就要好好学习rails的router. | |
## 简单路由 | |
网址url是如何指向到我们想让它去的代码块中,router就是用来干这个的,比如router中这样写: | |
~~~~ ruby | |
get '/members/:id', to: 'members#show' | |
~~~~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# encoding: utf-8 | |
require 'qiniu-rs' | |
AK = "access_key" | |
SK = "secret_key " | |
bucket_name = "七牛空间名称" | |
backup_file = "待上传文件(绝对路径)" | |
Qiniu::RS.establish_connection!({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
初级 | |
i: insert模式,按esc返回normal模式 | |
x: 删除当前光标所在的一个字符 | |
s: 删除当前光标所在的一个字符并且变成insert模式 | |
:w: 保存 | |
:q: 退出 | |
hjkl: 光标上下左右的移动 | |
dd: 删除当前行 | |
yy: 复制当前行 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set guifont=menlo:h13 | |
set bsdir=buffer | |
set enc=utf-8 | |
set fenc=utf-8 | |
set fencs=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936 | |
syntax on | |
set number | |
set hlsearch | |
set history=200 | |
set tabstop=2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Browser: firefox | |
<img id=“blah” src=“#” /><br> <%= file_field_tag ‘image’, :onchange => “readURL(this)” %> | |
<script type=“text/javascript”> | |
function readURL(input) { | |
if (input.files && input.files[0]) { | |
var reader = new FileReader(); | |
reader.onload = function (e) { |
NewerOlder