2017年5月31日星期三

chmod递归分设置文件和文件夹权限

find your_path -type f -exec chmod 644 {} \;
find your_path -type d -exec chmod 755 {} \;

2017年5月25日星期四

ubuntu中使用intellij时ctrl+alt+b快捷键冲突

因为装了搜狗输入法,设置 -> 高级 -> 打开Fcitx设置,Global Config中Show Advance Option,找到Switching Vitual Keyboard,点击ctrl+alt+b,按esc取消快捷键设置,完成。

mac中brew link Error

Error: Cowardly refusing to 'sudo brew link'
You can use brew with sudo, but only if the brew executable is owned by root.
However, this is both not recommended and completely unsupported so do so at
your own risk.

ll /usr/local/bin | grep brew
-rwxr-xr-x  1 chenxiaoyu  admin   656B Mar 11  2016 brew

将brew用户改为root:
sudo chown root:admin /usr/local/bin/brew
然后运行sudo brew link xxx,解决。

lua标准库

可以参考下http://www.cnblogs.com/apexaddon/articles/1486622.html

其中有简单介绍string.gmatch,string.match,string.gsub

linux中shell变量$#,$*,$@,$?,$$的含义

参考http://c.biancheng.net/cpp/view/2739.html

$0 当前脚本的文件名
$n 传递给脚本或函数的参数。n 是一个数字,表示第几个参数。例如,第一个参数是$1,第二个参数是$2。
$# 传递给脚本或函数的参数个数。
$* 传递给脚本或函数的所有参数。
$@ 传递给脚本或函数的所有参数。被双引号(" ")包含时,与 $* 稍有不同。
$? 上个命令的退出状态,或函数的返回值。
$$ 当前Shell进程ID。对于 Shell 脚本,就是这些脚本所在的进程ID。

$* 和 $@ 的区别:
$* 和 $@ 都表示传递给函数或脚本的所有参数,不被双引号(" ")包含时,都以"$1" "$2" … "$n" 的形式输出所有参数。
但是当它们被双引号(" ")包含时,"$*" 会将所有的参数作为一个整体,以"$1 $2 … $n"的形式输出所有参数;"$@" 会将各个参数分开,以"$1" "$2" … "$n" 的形式输出所有参数。

2017年5月17日星期三

lua中pairs和ipairs的区别

pairs遍历所有元素,而ipairs只能遍历从下标1开始的元素,遇到不连续的就停止。

如果对性能有要求尽量使用ipairs

参考:
http://www.cppblog.com/wc250en007/archive/2011/12/16/162203.html
https://moonbingbing.gitbooks.io/openresty-best-practices/lua/for.html

2017年5月16日星期二

源码安装lua错误解决

参考http://www.th7.cn/system/lin/201702/200995.shtml

lua.c:82:31: fatal error: readline/readline.h: No such file or directory

说明缺少libreadline-dev依赖包,添加依赖包:
centos: yum install readline-devel
ubuntu, debian: apt-get install libreadline-dev

ubuntu中安装deb后查找安装位置

dpkg -l | grep xxx,找到软件包名,然后dpkg -L xxx

ubuntu desktop常用快捷键

系统:
锁屏 ctrl+alt+l (因为和intellij快捷键冲突,我在system settings的keyboard -> shortcuts -> system -> lock screen 中修改为了super+l)
最小化 ctrl+alt+0(小键盘),或者alt+space,n
最大化 ctrl+super+up,或者alt+space,x
还原 ctrl+super+up,或者alt+space,x
显示桌面 ctrl+super+d
关闭程序 alt+f4 / ctrl+q
打开左侧边栏程序 super+数字
复制 ctrl+c / ctrl+insert
粘贴 ctrl+v / shift+insert
同一应用中多窗口切换 alt + ~

终端:
打开终端 ctrl+alt+t
新建标签页 ctrl+shift+t
关闭标签页 ctrl+shift+w
终端中复制 ctrl+shift+c
终端中粘贴 ctrl+shift+v
全屏切换 f11
切换标签页 alt+数字
切换到上个标签 ctrl+pagedown
切换到下个标签 ctrl+pageup
光标移动到开头 ctrl+a
光标移动到结尾 ctrl+e
光标向前移动一个单词 ctrl+left
光标向后移动一个单词 ctrl+right
删除光标前所有字符 ctrl+u
删除光标后所有字符 ctrl+k
向前删除一个单词 ctrl+w
恢复之前删除的内容 ctrl+7
清楚屏幕内容 ctrl+l,或者clear

2017年5月15日星期一

ubuntu修改键位

将大写锁定Caps Lock和左Control键互换,修改~/.Xmodmap文件内容为:
remove control = Control_L
remove control = Caps_Lock
remove lock = Caps_Lock
remove lock = Control_L
keycode 66 = Control_L NoSymbol Control_L
keycode 37 = Caps_Lock NoSymbol Caps_Lock
add control = Control_L
add lock = Caps_Lock

重启即可生效。
缺点:
切换tty时会失效,锁屏后再次登陆会失效。
失效的时候可以使用命令:
xmodmap .Xmodmap
来恢复之前的设置。
参考http://forum.ubuntu.org.cn/viewtopic.php?t=463634


将Caps Lock键修改为Control键,并且Shift+CapsLock为CapsLock。修改~/.Xmodmap文件内容为:
clear lock
clear control
add control = Caps_Lock Control_L Control_R
keycode 66 = Control_L Caps_Lock NoSymbol NoSymbol
参考https://traceflight.github.io/tech/modify-caps-lock-to-ctrl.html

ubuntu16.04 desktop无法安装软件

ubuntu 16.04桌面版安装软件提示This software comes from a 3rd party and may contain non-free components,无法安装。或者用系统自带的software install无法安装。

sudo apt install gdebi
右键安装包,open with GDebi Package Installer

参考https://askubuntu.com/questions/761210/16-04-cannot-install-anything-from-ubuntu-software-center