Sep 02 2010

Grepping for tabs

Category: Uncategorizedwuxicn @ 10:19 AM

在grep中无法转义\t,因此grep直接将\t认为是字母t,而不是我们希望的tab。
要想在grep中用tab,需要直接在终端输入tab,输入方法是:Ctrl+v 然后在按 tab.

Tags: , ,


Aug 18 2010

xcscope

Category: Uncategorizedwuxicn @ 2:41 PM

USAGE

;; All keybindings use the "C-c s" prefix, but are usable only while
;; editing a source file, or in the cscope results buffer:
;;      C-c s s         Find symbol.
;;      C-c s d         Find global definition.
;;      C-c s g         Find global definition (alternate binding).
;;      C-c s G         Find global definition without prompting.
;;      C-c s c         Find functions calling a function.
;;      C-c s C         Find called functions (list functions called
;;                      from a function).
;;      C-c s t         Find text string.
;;      C-c s e         Find egrep pattern.
;;      C-c s f         Find a file.
;;      C-c s i         Find files #including a file.

Continue reading “xcscope”

Tags:


Aug 13 2010

Linux下写动态链接库.so

Category: Uncategorizedwuxicn @ 9:54 PM

Linux下的动态链接库是.so文件,即:Shared Object,下面是一个简单的例子说明如何写.so以及程序如何动态载入.so中的函数和对象。

testso.h:

#ifndef _TESTSO_H
#define _TESTSO_H
extern "C" {
    int myadd(int a, int b);
    typedef int myadd_t(int, int); // myadd function type
}
#endif // _TESTSO_H

testso.cpp:

#include "testso.h"

extern "C"
int myadd(int a, int  b)
{
    return a + b;
}

编译so:

g++  -shared  -fPIC  -o testso.so testso.cpp

注意,-shared参数和-fPIC参数非常重要:
-shared 告诉gcc要生成的是动态链接库;
-fPIC 告诉gcc生成的生成的代码是非位置依赖的,方面的用于动态链接。

Continue reading “Linux下写动态链接库.so”

Tags: , , ,


Jul 24 2010

iPhone 3G的GPS不工作的修复方法

Category: Uncategorizedwuxicn @ 4:23 PM

今天早上刷完机以后,发现iPhone 3G的GPS不工作了,不管用什么软件都定位不了。在国外的论坛找到了fix的办法,非常有效,转过来:

- Go to settings, general, auto-lock, change it from 1 Minute to NEVER
- Go to settings, general, reset, reset network settings (THIS WILL REBOOT YOUR IPHONE)
- Go outside, in a clear place with NO tree’s, buildings, or anything blocking your view of the sky
- Open “MAPS”, click NO on all that wi-fi crap, then click the little gps icon, and let it sync up with the satellites (this could take a few minutes)

Tags:


Jul 05 2010

OpenSSH公钥授权方式

Category: Uncategorizedwuxicn @ 7:49 PM

用公钥授权(Public key Authentication)的方式可以实现ssh服务器与本机之间的配对,实现不用输入密码联入SSH服务器。

具体做法:

1) 在本机(ssh客户机)生成密钥文件:

client$ cd ~/.ssh
client$ ssh-keygen -q -f id_rsa -t rsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:

在提示输入密码阶段时(Enter passphrase…),直接Enter,这样以后在本机就不用输入密码了。
这样,在.ssh/目录下就会生产2个文件:id_rsaid_rsa.pub .
注意:保密好这两个文件!

2) 分发公钥文件:

将你的公钥文件 (id_rsa.pub) 分发到你的SSH服务器上:

# Step 1: 将你的id_rsa.pub文件上传到服务器上
client$ scp ~/.ssh/id_rsa.pub user@your.ssh.server:~/.ssh/

# Step 2: 在服务器上安装公钥文件
server$ chmod 700 ~/.ssh
server$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
server$ chmod 600 ~/.ssh/authorized_keys
server$ rm ~/.ssh/id_rsa.pub

注意:这个地方要用>>追加到authorized_keys文件末尾,以免冲到以前的一些公钥授权。

好了,现在大功告成了,enjoy!
PS: 以上方法只保证在OpenSSH服务器上有效,其他SSH服务器不知道。

Tags: ,


Jun 29 2010

iPhone上手动安装deb软件

Category: Uncategorizedwuxicn @ 1:12 AM

1. 下载deb软件,并通过scp或者ftp传到iphone上。

2. 安装deb:
dpkg -i /full/path/to/filename.deb
例如:在iphone上安装vim:
dpkg -i vim_7.1-3_iphoneos-arm.deb

PS: 下面是一些可以下载iphone deb软件的地方:
Cydia的saurik源: http://apt.saurik.com/cydia/debs/
saurik源下软件列表:http://apt.saurik.com/dists/tangelo-3.7/main/binary-iphoneos-arm/Packages

Tags: ,


Jun 29 2010

用SSH链接iPhone

Category: Uncategorizedwuxicn @ 12:05 AM

Step 0. 前提条件

你的iPhone是越狱过的(即你的iPhone里有Cydia软件),如果还没有,可以见这篇文章进行越狱:http://icoder.me/2010/06/24/how-to-jailbreak-and-unlock-ios-4-on-mac/

Step 1. 通过Cydia下载并安装OpenSSH

OpenSSH程序是一个后台程序,安装完后桌面没有多任何图标,我们需要继续安装其他工具来控制开启/关闭OpenSSH,见Step 2.

Step 2. OpenSSH开关工具

可以在Cydia中选择下面3个工具的任何一个(或者都选):
1. Toggle SSH (推荐)
2. SBSetting (推荐)
3. Boss Prefs

Step 3. 打开OpenSSH

开启wifi,记住你的IP。可以在下面软件中看到iphone的IP或者在wifi设置中点右边的箭头看到IP地址。
1. 在Toggle SSH中直接点”Enable SSH”开启SSH。
2. 在SBSetting中点SSH图标使其变绿即开启了SSH。
3. 略。
然后在 Settings » General » Auto Lock 中设置自动锁屏时间为 “Never”.

Step 4. 通过SSH客户端软件链接iphone

在Mac下直接在终端中输入:(将”YOUR.IPHONE.IP”替换成上面记下来的IP地址)
ssh root@YOUR.IPHONE.IP

在Win下可以通过SSH软件链接,如puTTY。

Username: root
Password: alpine

注意:在第一次链接的时候会比较慢(大概30s以上)。

Tags: ,


Jun 24 2010

iOS 4越狱+解锁教程 (Mac)

Category: Uncategorizedwuxicn @ 2:37 PM

作者:Wuxi (欢迎来我的博客: http://iCoder.me/)
============
PWNED iOS 4!

本教程介绍在Mac系统下如何越狱和解锁iOS 4,适用于iPhone 3G/3GS和iPod touch 2G(我仅在我的iPhone 3G上试过)。如果你是Win系统请找别的教程。

特别感谢iPhone Dev-Team的Hacker们为自由事业作出的贡献!
同时感谢RedmondPie网站[1]提供了非常详细的教程,喜欢看E文的同学可以直接去这个网站。
Continue reading “iOS 4越狱+解锁教程 (Mac)”

Tags: , ,


May 26 2010

Chrome + Switchy! + SSH Tunnel 自动翻墙

Category: Uncategorizedwuxicn @ 10:28 AM

感谢党、感谢国家!我们在日常上网生活中学会了很多网络技术,其中翻墙是最常用的一种。

1. 安装chrome Switchy! 插件。

2. 设置一个SSH tunnel:见我的另一篇BLOG:http://icoder.me/2010/04/21/ssh-tunnel/

3. 设置 Switchy! 的 socks 代理:
Switchy! Socks proxy setting

4. 让 Switchy! 根据被 GFW 强的网站自动翻墙:
Online Rule setting

gfwlist.txt 地址: http://autoproxy-gfwlist.googlecode.com/svn/trunk/gfwlist.txt

注意: 第一次使用的时候 “Reload Every” 设置成15分钟,当翻墙成功后可以设成3小时。

5. 最后将 Switchy! 代理设成 “Auto Switch Mode“,这样就大功告成了!以后 Switchy! 就会根据GFW列表自动启用代理了。

Tags:


May 05 2010

Install GDB cross debugger for i386 ELF on Mac OS X

Category: Uncategorizedwuxicn @ 9:31 AM

1. Download and install gettext: http://www.gnu.org/software/gettext/

2. Install i386-elf-gcc from MacPorts:

sudo port install i386-elf-gcc
sudo port -f activate i386-elf-gcc

You may need to create some symbolic links:

cd /opt/local/bin
sudo ln -s i386-elf-gcc-4.3.2 i386-elf-gcc
sudo ln -s i386-elf-g++-4.3.2 i386-elf-g++

3. Download GDB: http://www.gnu.org/software/gdb/download/

4. Configure and install GDB for i386-ELF:

./configure --prefix=/opt/local \
            --program-prefix=i386-elf- \
            --target=i386-elf \
            --with-gmp=/opt/local \
            --with-libelf=/opt/local \
            --with-build-libsubdir=/opt/local
make
sudo make install

Then the i386-ELF GDB will be installed in /opt/local with program name i386-elf-gdb.

Note: option ‘–target=i386-elf’ specifies guest(target) type ‘i386 ELF’.

Tags: , , , , ,


Next Page »