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

2017年4月21日星期五

protobuf中set_allocate_和mutable_

都可以用于嵌套的消息使用,mutable_返回对应消息的指针,set_allocate_中传的指针必须是new出来的堆内存而不能是栈内存。