我安装了jekyll,但令人惊讶的是osx不知道它的安装.
$ sudo gem install jekyll
Password:
Successfully installed jekyll-1.2.1
Parsing documentation for jekyll-1.2.1
Done installing documentation for jekyll after 1 seconds
1 gem installed
$ jekyll
-bash: jekyll: command not found
gem environment ( - INSTALLATION DIRECTORY: /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/gems/2.0.0 )
$ cd /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/gems/2.0.0/gems/
Run Code Online (Sandbox Code Playgroud)

echo $PATH
/usr/local/bin:/usr/local/sbin:~/bin:/usr/local/bin:/usr/local/sbin:~/bin:/Users/TheSpiritMolecule/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/TheSpiritMolecule/.rvm/bin
Run Code Online (Sandbox Code Playgroud) 此正则表达式将每个小写字词转换为大写字母.我有一个全名输入字段.我希望用户看到他/她按下的每个单词的第一个字母在输入字段中转换为大写.
我不知道如何正确替换当前输入字段中的选定字符.
$('input').on('keypress', function(event) {
var $this = $(this),
val = $this.val(),
regex = /\b[a-z]/g;
val = val.toLowerCase().replace(regex, function(letter) {
return letter.toUpperCase();
});
// I want this value to be in the input field.
console.log(val);
});
Run Code Online (Sandbox Code Playgroud) 我有一个文章架构,其中有一个子文档comments,其中包含我为此特定文章所获得的所有注释.
我想要做的是按ID选择一篇文章,填写其作者字段以及评论中的作者字段.然后按日期对注释子文档进行排序.
文章架构:
var articleSchema = new Schema({
title: { type: String, default: '', trim: true },
body: { type: String, default: '', trim: true },
author: { type: Schema.ObjectId, ref: 'User' },
comments: [{
body: { type: String, default: '' },
author: { type: Schema.ObjectId, ref: 'User' },
created_at: { type : Date, default : Date.now, get: getCreatedAtDate }
}],
tags: { type: [], get: getTags, set: setTags },
image: {
cdnUri: String,
files: []
},
created_at: …Run Code Online (Sandbox Code Playgroud) 问题:想要显示从左侧指向元素(referenceEl)的工具提示.referenceEl位于宽度有限(60px)且overflow: hidden应用了css道具的容器内.工具提示会在其引用元素后附加,因此它们在DOM中共享相同的容器.这导致工具提示部分显示.
Bootstrap 4 Tooltip api提供了一个container选项,可以指定'body'作为追加点的替代容器:http://getbootstrap.com/docs/4.0/components/tooltips/#options
如何在反应中实现此功能material-ui@beta?
material-ui使用的版本:1.0.0-beta.31
工具提示参考:https://material-ui-next.com/api/tooltip/#tooltip
tooltip演示页面:https://material-ui-next.com/demos/tooltips/#tooltips
bootstrap工具提示实现部分:https://github.com/twbs/bootstrap/blob/v4-dev/js/src/tooltip.js#L277-L283
mui工具提示渲染部分:https://github.com/mui-org/material-ui/blob/v1-beta/src/Tooltip/Tooltip.js#L305-L360
示例代码:
<Tooltip id="contacts-tooltip"
title={'contacts'}
placement={'right'}
enterDelay={300} leaveDelay={300}>
<ListItem button
component={NavLink}
to={'/contacts'}
onClick={toggleDrawer(false)}
className={classes._listItem}
activeClassName={classes._activeListItem}
>
<ListItemIcon>
<People classes={{root: classes.iconRoot}}/>
</ListItemIcon>
<ListItemText primary={'Contacts'}/>
</ListItem>
</Tooltip>
Run Code Online (Sandbox Code Playgroud) 我最近在我的终端上安装了Mathias的dotfiles,我主要有两个关于这个回购的问题.
第一:我不能让我的自定义别名/函数开始工作.我将它们写在Mathias的dotfiles的默认位置,在.aliases/中.functions.我.bash_profile添加并保存代码后重新加载.
第二:我如何自动更新更新,同时我.aliases / .functions在Mathias的repo的默认位置设置了自定义别名和功能.(/Users/TheSpiritMolecule/dotfiles)
可以说我有一个注释架构。评论可以有多个回复。我如何创建一个虚拟属性来created_at像这样转换每个回复的日期?moment(this.replies.[currentReplyIndex].created_at).format('lll')
const Comment = new mongoose.Schema({ // sort: new to old by created_at
body: String,
replies: [{
body: String,
created_at: {
type: Date,
default: Date.now
}
}]
});
Run Code Online (Sandbox Code Playgroud)
我不知道如何使用对象子文档结构数组来执行此操作。
我怎样才能Music成为'音乐?
{
id: 4
name: "playlist 1"
created_at: "2015-04-21T21:43:07.000Z"
updated_at: "2015-04-23T20:44:50.000Z"
Music: [
{
id: 12
name: "Deorro - Five Hours (Static Video) [LE7ELS]"
video_id: "K_yBUfMGvzc"
thumbnail: "https://i.ytimg.com/vi/K_yBUfMGvzc/default.jpg"
created_at: "2015-04-22T21:46:21.000Z"
updated_at: "2015-04-22T21:46:21.000Z"
playlist_id: 4
}
]
}
Run Code Online (Sandbox Code Playgroud)
我的查询看起来像:
.get(function (req, res) {
db.Playlist.findAll({
include: [db.Music]
}).then(function (playlists) {
if(!playlists) {
res.status(404).json({message: 'No playlist found!'});
return;
}
res.json(playlists)
})
})
Run Code Online (Sandbox Code Playgroud)
播放列表模型:
module.exports = function(sequelize, DataType) {
var Playlist = sequelize.define('Playlist', {
name: DataType.STRING
}, {
classMethods: {
associate: function(models) …Run Code Online (Sandbox Code Playgroud) 我无法在grunt中使用很多contrib-sass功能.我前一天潜入咕噜声,发现它真的很棒.
链接到contrib-sass repo,其中说源图应该正常工作:https: //github.com/gruntjs/grunt-contrib-sass/commit/e85ee70ccb8839867172b57ca1378293291f8037
注意:我有sass流血的边缘,如果我使用此功能可以正常工作:sass --watch --scss --sourcemap --no-cache使用谷歌Chrome金丝雀源图和Sass样式表调试
这是我的Gruntfile.js:
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd hh:mm:ss") %> */\n',
concat: {
options: {
separator: '\n// New file\n',
banner: '<%= banner %>'
},
develop: {
files: [
{ src: ['js/develop/plugins.js', 'js/develop/main.js'], dest: 'js/concDev.js' }
]
},
vendor: {
files: [
{ src: ['js/vendor/*.js', '!js/vendor/jquery-1.9.1.min.js', '!js/vendor/modernizr-2.6.2.min.js'], dest: 'js/concVend.js' }
]
}
},
uglify: {
options: {
banner: '<%= banner …Run Code Online (Sandbox Code Playgroud) 文档说我不能同时使用这两个功能https://angular.io/docs/ts/latest/guide/router.html#!#canload-blocks-preload
我要实现的是如果用户被授权访问路由,则可以延迟加载路由。
javascript ×2
mongodb ×2
mongoose ×2
node.js ×2
terminal ×2
angular ×1
dotfiles ×1
gruntjs ×1
jekyll ×1
jquery ×1
material-ui ×1
no-cache ×1
reactjs ×1
routing ×1
sass ×1
sequelize.js ×1
source-maps ×1
watch ×1