This file contains hidden or 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
Grape::Entity.format_with :utc do |date| | |
date.strftime('%Y年%m月%d日 %H:%M') if date | |
end | |
Grape::Entity.format_with :date do |date| | |
date.strftime('%Y年%m月%d日') if date | |
end | |
Grape::Entity.format_with :datetime do |date| | |
date.strftime('%Y年%m月%d日 %H:%M:%S') if date | |
end |
This file contains hidden or 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
module Entities::Admin | |
class OptionType < Grape::Entity | |
expose :id, documentation: {type: String, desc: 'ID'} | |
expose :name, documentation: {type: String, desc: '商品属性名称'} | |
expose :group_name, documentation: {type: String, desc: '属性群名称'} | |
expose :required, documentation: {type: Boolean, desc: '是否必填'} | |
expose :position, documentation: {type: Boolean, desc: '排序号'} | |
expose :phone_category_id, documentation: {type: String, desc: '商品类别ID'}, if: { type: :full } | |
expose :values, documentation: {type: String, desc: '商品属性值'}, if: { type: :full } | |
expose :category_names, documentation: {type: String, desc: '商品属性值'}, if: { type: :full } |
This file contains hidden or 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
class String | |
def black; "\e[30m#{self}\e[0m" end | |
def red; "\e[31m#{self}\e[0m" end | |
def green; "\e[32m#{self}\e[0m" end | |
def brown; "\e[33m#{self}\e[0m" end | |
def blue; "\e[34m#{self}\e[0m" end | |
def magenta;"\e[35m#{self}\e[0m" end | |
def cyan; "\e[36m#{self}\e[0m" end | |
def gray; "\e[37m#{self}\e[0m" end | |
end |
This file contains hidden or 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
def longest_common_substr(strings) | |
shortest = strings.min_by &:length | |
maxlen = shortest.length | |
maxlen.downto(0) do |len| | |
0.upto(maxlen - len) do |start| | |
substr = shortest[start,len] | |
return substr if strings.all?{|str| str.include? substr } | |
end | |
end | |
end |
This file contains hidden or 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
if has("mac") | |
let g:ctrlp_user_command = 'gfind %s -type f' | |
" Sane Ignore For ctrlp | |
endif | |
if exists("g:ctrlp_user_command") | |
unlet g:ctrlp_user_command | |
endif | |
set wildignore+=*\\vendor\\** | |
set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux | |
set wildignore+=*\\tmp\\*,*.swp,*.zip,*.exe " Windows |
This file contains hidden or 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
# You can enable this feature by: LOGGER=crazy rails s | |
# File : config/initializers/logger.rb | |
if ENV["LOGGER"] == "crazy" | |
class ActiveSupport::Logger::SimpleFormatter | |
def call(severity, time, progname, msg) | |
"#{severity} #{time}: #{progname} #{caller.grep(/phoenix/)} -- : #{msg}\n" | |
end | |
end | |
end |
NewerOlder