安固途径

知识来源于感觉和经验

利用 gulp-pug 自动编译出错停止监听的解决办法

2017-02-21, 星期二|
前端

用 gulp-pug 编译 pug 文件很方便,不过也会出现因 pug 文件中语法出错而编译出错的情况,这时 gulp.watch 就停止了,需要手动重新启动非常的不方便。利用插件 gulp-notify 可以很方便的解决这个问题。

var gulp = require('gulp'),
    pug = require('gulp-pug'),
    notify = require('gulp-notify');

gulp.task('pug', function(){
    return gulp.src('pug/*/*.pug')
        // .pipe(plumber())
        .pipe( pug({ pretty: true }).on('error', notify.onError( (error) => { return `pug went wrong, ${error}`; } )) )
        .pipe(gulp.dest('page'));
});

这样,gulp.watch 进程就不会停止了,还会继续监听 pu

...
阅读全文

自定义终端提示文字

2017-02-10, 星期五|
linux系统设置

可以利用修改环境变量 PS1 来修改终端提示文字,例如

$ export PS1="\u@\h:\W$ "

将上述命令增加到 ~/.bashrc 文件中。

变量 PS1 中的变量及其的具体含义如下

  • \d – Current date
  • \t – Current time
  • \h – Host name
  • # – Command number
  • \u – User name
  • \W – Current working directory (ie: Desktop/)
  • \w – Current working directory with full path (ie: /Users/Admin/Desktop/)
...
阅读全文

Visual Box ubuntu 共享文件夹没有权限的问题

2017-02-10, 星期五|
linux

虚拟机中安装的是 ubuntu, 和主机共享文件夹后,非 root 的普通用户不能进入这个共享文件夹。如果想要让普通用户进入,需要将该用户加入 vboxsf 组,假设用户名为 foo, 共享文件夹名为 sf_uShare,那么将用户 foo 加入 vboxsf 组的命令是

# usermod -aG vboxsf foo

可以使用 groups 查看 foo 是否已经加入 vboxsf 组

$ groups foo

重启虚拟机后,用户 foo 现在可以进入 /media/sf_uShare 目录了。

更多参考 stackexchange

...
阅读全文

修复 ios safari hover 无效问题

2017-02-06, 星期一|
前端

在 ios safari 上用伪元素 hover ,点击不会起作用,这时可以为任意用 hover 的元素增加一个 onclick 属性来解决这个问题。

<div onclick="">Click Me!</div>

参考 stackoverflow

...
阅读全文

Terminal 中的花括号

2017-01-13, 星期五|
linux

在 Linux {} 中可以用来讲多条路径用一条命令来表示,例如:

$ mkdir -p dist/t
$ cp -r t/{css,img,js,fonts,*.html} dist/t

非常重要的一点是 {} 尽管是用括号表示,但是括号之间不能有空格,有则必须转义,否则就会出现错误。

...
阅读全文