2016年1月12日星期二

iTerm2 快捷键

进入Preferences,Keys,left option改为+Esc

修改option+left:action改为Send Escape Sequence,Esc+为B
修改opton+right:action改为Send Escape Sequence,Esc+为F
增加cmd+left:action改为Send Escape Sequence,Esc+为[H
增加cmd+right:action改为Send Escape Sequence,Esc+为[F

这样option+left、right就是左右移动单词,cmd+left、right就是移动到行首行尾


转自:

https://ruby-china.org/topics/681

2015年2月12日星期四

git中清除的没有引用的对象

鉴于天朝奇葩的网络状态,用repo来下载Android的源代码是一件很痛苦的事,经常会发生网络中断的现象。而不知道是repo还是git的问题,会导致git库重新下载,并且以前下载的部分仍然会保存在文件系统中(我就是眼睁睁地看着Android的代码在中断几次后,从30多G膨胀到50多G,还没有下载完╮(╯﹏╰)╭)。
那么如何解决这个问题呢?我检查了.repo目录,发现在XXX.git/objects/pack下有很多tmp_pack_xxx的文件。这就是下载的临时文件。可以用下面的方法来删除:

repo forall -c “git prune"

2013年6月10日星期一

联想Y500安装Unbuntu12.04



新买了一台联想Y500,预装了Windows8。为了安装Unbuntu和Windows8双系统,折腾了一天。

安装步骤:
1. 分区
Y500预装的Windows8有个盘,C盘和D盘。从D盘划分出部分空间给Ubuntu
1)win键+x,弹出菜单中选择“磁盘管理”
2)选择D盘,右键点击弹出的菜单中选择“压缩卷”
3)输入要划分的空间。

2. 制作LiveUSB安装U盘
1)从ubuntu官网下载Ubuntu12.04.2的iso镜像文件,这个版本开始支持UEFI和SecureBoot。但我后来还是把SecureBoot关掉了(原因见下面第6点)。
2)从另一台Ubuntu机器通过“启动盘创建器”,创建启动U盘。
3)修改U盘下/boot/grub/grub.cfg文件:
   "gfxmode=auto"改为"gfxmode=1920*1080"(改成其他分辨率应该也可以,但我没有试验)
   所有的"quiet splash"改为"nomodeset=1"。
如果不修改,无法进入grub菜单的选项。

3. 安装Ubuntu
修改BIOS从usb启动,安装Ubuntu。安装选项我选择的是“Install Ubuntu alongside them”。
安装时就可以配置网络,最好是把网络配置好。否则安装完后要在命令行下配置网络又是件头疼的事。

4. 修改新安装的Ubuntu的grub.cfg文件
1) 安装完再次通过usb启动,选择"try Ubuntu"
2) 执行以下命令mount新安装的Ubuntu分区
   sudo mkdir /mnt/newinstall
   sudo mount /dev/sda8 /mnt/newinstall (sda8是我机器上Ubuntu的分区)
3) sudo vi /mnt/newinstall/boot/grub/grub.conf,修改上面2.3)的选项

5. 安装GT750M显卡驱动
现在可以启动Ubuntu了。但因为没有显卡驱动,启动Ubuntu只能进入shell。驱动可以从Nvidia官网下载。现在最新版的下载地址是
http://us.download.nvidia.com/XFree86/Linux-x86_64/319.23/NVIDIA-Linux-x86_64-319.23.run

执行以下命令:
wget http://us.download.nvidia.com/XFree86/Linux-x86_64/319.23/NVIDIA-Linux-x86_64-319.23.run
sudo chmod +x NVIDIA-Linux-x86_64-319.23.run
sudo ./NVIDIA-Linux-x86_64-319.23.run

驱动安装完成后,再次启动就可以进入图形界面。

6. boot-repair修复Windows8
从Dash或terminal启动boot-repair,选择"Recommended repair",然后按照指示操作即可。
注意:boot-repair会要求关闭SecureBoot,虽然12.04.2(*参考1)支持SecureBoot,但为了安全起见,我还是把SecureBoot关闭了。

7. 选择正确的grub选项启动Windows8
boot-repair修复之后grub会生成很多选项,包括联想的一键恢复(下面第3个选项)都会显示出来。
下面列举几个我机器上的grub选项:
Ubuntu, Linux 3.5.0-32-generic
Windows Boot UEFI recovery
Windows Boot UEFI recovery bkpbootx64.efi
Windows 8 (loader) (on /dev/sda5)

这里就有个很坑爹的问题。启动Windows8不是选第4个!导致我以为boot-repair没有成功,重试了好几次。万般无奈之下,我无聊地一个个去试,发现第2个"Windows Boot UEFI recovery"居然进去了。。。
原来此recovery(boot-repair之后成功修复的recovey)非彼recovery(恢复模式),我一直理解成类似Android的recovery模式了orz

好了,终于双系统都可以正常启动了。

参考
1. https://help.ubuntu.com/community/UEFI
2. http://askubuntu.com/questions/272570/unable-to-install-ubuntu-on-lenovo-y500
3. http://askubuntu.com/questions/221835/installing-ubuntu-on-a-pre-installed-uefi-supported-windows-8-system

2012年10月29日星期一

backtrace显示调用栈层次

代码摘自man backtrace
#include <execinfo.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

void
       myfunc3(void)
       {
           int j, nptrs;
       #define SIZE 100
           void *buffer[100];
           char **strings;

           nptrs = backtrace(buffer, SIZE);
           printf("backtrace() returned %d addresses\n", nptrs);

           /* The call backtrace_symbols_fd(buffer, nptrs, STDOUT_FILENO)
              would produce similar output to the following: */

           strings = backtrace_symbols(buffer, nptrs);
           if (strings == NULL) {
               perror("backtrace_symbols");
               exit(EXIT_FAILURE);
           }

           for (j = 0; j < nptrs; j++)
               printf("%s\n", strings[j]);

           free(strings);
       }

       static void   /* "static" means don't export the symbol... */
       myfunc2(void)
       {
           myfunc3();
       }

static void   /* "static" means don't export the symbol... */
       myfunc2(void)
       {
           myfunc3();
       }

       void
       myfunc(int ncalls)
       {
           if (ncalls > 1)
               myfunc(ncalls - 1);
           else
               myfunc2();
       }

       int
       main(int argc, char *argv[])
       {
           if (argc != 2) {
               fprintf(stderr, "%s num-calls\n", argv[0]);
               exit(EXIT_FAILURE);
           }

           myfunc(atoi(argv[1]));
           exit(EXIT_SUCCESS);
       }

2012年7月8日星期日

电话相关缩略语

AAA
Authentication, Authorization and Accounting 认证 授权和计费
AN-AAA 
Access Network AAA 接入网络认证的AAA
AT 
Access Terminal 接入终端
CAVE
Cellular Authentication and Voice Encryption algorithm 蜂窝鉴权和语音加密算法
CHAP 
Challenge Handshake Authentication Protocol 查询握手认证协议
IMSI 
International Mobile Subscriber Identity 国际移动用户识别码
IOS 
Inter-Operability Specification 互操作规范
MEI 
Mobility Event Indicator 移动性事件指示
MS 
Mobility Station 移动台,本文指双模手机
SIP 
Session Initiation Protocol 会话初始化协议
UDP 
User Datagram Protocol 用户数据报协议
UIM 
User Identity Model 用户识别模块
WAG 
WLAN Access Gateway WLAN 接入网关
WLAN 
Wireless Local Area Network 无线局域网
wPDIF 
WiFi Packet Data Interworking Function WiFi 分组数据互联网关

2012年7月5日星期四

Android模拟器命令行使用

telnet localhost <port>
然后就可以执行相关命令。
例如gsm call 1234