安固途径

知识来源于感觉和经验

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

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

...
阅读全文

让 express 传入给 pug 的变量非编码

2017-01-12, 星期四|
前端开发

由 express 传入模板 pug 的变量有编码为

#{ cntent }

非编码为

!{ content }

这样变量中就可以包含 HTML

...
阅读全文

find 命令不包含某文件夹的选项

2017-01-09, 星期一|
linux

输入

$ tree

输出

.
├── dist
├── index.css
├── index.html
├── index.js
└── node_modules

2 directories, 3 files

假设目录下存在index.html, index.css, index.js, node_modules 等文件或目录。

利用 find 命令找出当前目录下不包含node_moduels的文件或文件夹

输入

$ find . -maxdepth 1 -not -name node_moduels

输出

./dist
./index.css
./index.html
./index.js

利用 find 命令将目录下非node_modules的文件或目录复制到dist目录。

$ find . -maxdepth1 -not -name node_modules -not -name dist|xargs -J % cp -r % dist

查看结果

$ ls dist

输出

index.css   index.html  index.js
...
阅读全文