在HTML5文档中,您推荐哪种favicon格式?为什么?我希望IE7和所有现代浏览器都支持它.
另外,使用.png时,是否需要指定类型(type ="image/png")?
我想用ctrlp和vim使用ag(银色搜索器).我在.vimrc中有这个:
if executable("ag")
set grepprg=ag\ --nogroup\ --nocolor
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
endif
let g:ctrlp_show_hidden = 1
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*/.tmp/*,*/.sass-cache/*,*/node_modules/*,*.keep,*.DS_Store,*/.git/*
Run Code Online (Sandbox Code Playgroud)
我希望ctrlp包含隐藏文件但隐藏文件.如果我添加-u到ag命令它显示所有隐藏文件但不尊重wildignore或.gitignore.有可能让它尊重这些吗?
我正在使用ActiveModel :: Serializers构建API .使用params有条件地侧载数据的最佳方法是什么?
所以我可以提出如下请求GET /api/customers:
"customers": {
"first_name": "Bill",
"last_name": "Gates"
}
Run Code Online (Sandbox Code Playgroud)
和 GET /api/customers?embed=address,note
"customers": {
"first_name": "Bill",
"last_name": "Gates"
},
"address: {
"street": "abc"
},
"note": {
"body": "Banned"
}
Run Code Online (Sandbox Code Playgroud)
这样的东西取决于params.我知道ActiveModel :: Serializers有include_[ASSOCIATION]?语法,但我如何从我的控制器有效地使用它?
这是我目前的解决方案,但它并不整洁:
customer_serializer.rb:
def include_address?
!options[:embed].nil? && options[:embed].include?(:address)
end
Run Code Online (Sandbox Code Playgroud)
application_controller.rb:
def embed_resources(resources = [])
params[:embed].split(',').map { |x| resources << x.to_sym } if params[:embed]
resources
end
Run Code Online (Sandbox Code Playgroud)
customers_controller.rb:
def show
respond_with @customer, embed: embed_resources
end
Run Code Online (Sandbox Code Playgroud)
必须是一个更简单的方法?
Ember.js REST适配器期望JSON返回为:
{
"person": {
"first_name": "Barack",
"last_name": "Obama",
"is_person_of_the_year": true
}
}
Run Code Online (Sandbox Code Playgroud)
但我的API返回没有根元素的数据:
{
"first_name": "Barack",
"last_name": "Obama",
"is_person_of_the_year": true
}
Run Code Online (Sandbox Code Playgroud)
是否可以自定义REST适配器以使其接受我的JSON数据?现在它显示" 断言失败:你的服务器返回一个带有键0的哈希,但你没有映射它 "
更新: 基于Sherwin Yu的回答,这是我想出的,似乎到目前为止工作:https://gist.github.com/richardkall/5910875
我正在尝试在打字稿中使用 ses 设置电子邮件服务。我按照这个例子https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/ses/ses_sendemail.js但我得到
AWS.ses 不是构造函数。
这是我的 emailService 类
const AWS = require("aws-sdk");
const loggerService: LoggerServiceInterface = new LoggerService();
AWS.config.update({region: "us-east-1"});
export class EmailService {
sendEmail(recipient: string): Promise<boolean> {
const params = {
Destination: { /* required */
CcAddresses: [
"abcd@gmail.com",
/* more items */
],
ToAddresses: [
"abcd@gmail.com",
/* more items */
]
},
Message: { /* required */
Body: { /* required */
Html: {
Charset: "UTF-8",
Data: "HTML_FORMAT_BODY"
},
Text: {
Charset: "UTF-8",
Data: "TEXT_FORMAT_BODY"
} …Run Code Online (Sandbox Code Playgroud) 我目前正在使用wp_get_archives('type=monthly')侧边栏中显示存档链接.这是输出:
<ul>
<li><a href='http://example.com/2011/08/'>August 2011</a></li>
<li><a href='http://recently.se/2011/07/'>July 2011</a></li>
<li><a href='http://recently.se/2010/12/'>December 2010</a></li>
</ul>
Run Code Online (Sandbox Code Playgroud)
是否有可能将月份分组?像这样的东西:
<ul>
<h2>2011</h2>
<li><a href='http://example.com/2011/08/'>August 2011</a></li>
<li><a href='http://recently.se/2011/07/'>July 2011</a></li>
<h2>2010</h2>
<li><a href='http://recently.se/2010/12/'>December 2010</a></li>
</ul>
Run Code Online (Sandbox Code Playgroud) 我正在使用rails-api gem构建一个简单的JSON API.
车型/ user.rb:
class User < ActiveRecord::Base
has_secure_password
attr_accessible :email, :password, :password_confirmation
validates :email, presence: true, uniqueness: { case_sensitive: false }, format: { with: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i }
validates :password, presence: { on: :create }, length: { minimum: 6 }
end
Run Code Online (Sandbox Code Playgroud)
当我尝试在没有密码的情况下注册时,这是我获得的JSON输出:
{
"errors": {
"password_digest": [
"can't be blank"
],
"password": [
"can't be blank",
"is too short (minimum is 6 characters)"
]
}
}
Run Code Online (Sandbox Code Playgroud)
是否可以隐藏password_digest的错误消息?我正在控制器中使用respond_with返回@user对象.
我尝试了以下但没有运气(它只是重复错误"不能为空"):
validates :password_digest, presence: false
Run Code Online (Sandbox Code Playgroud) json ×3
api ×2
amazon-ses ×1
archive ×1
ctrlp ×1
email ×1
ember-data ×1
ember.js ×1
favicon ×1
html ×1
html5 ×1
ico ×1
javascript ×1
php ×1
phpmailer ×1
png ×1
rails-api ×1
typescript ×1
validation ×1
vim ×1
wordpress ×1