<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>iCoder.ME</title>
	<atom:link href="http://icoder.me/feed/" rel="self" type="application/rss+xml" />
	<link>http://icoder.me</link>
	<description>C/C++, Python, ... Data structures and Algorithms</description>
	<lastBuildDate>Thu, 02 Sep 2010 02:19:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Grepping for tabs</title>
		<link>http://icoder.me/2010/09/02/grepping-for-tabs/</link>
		<comments>http://icoder.me/2010/09/02/grepping-for-tabs/#comments</comments>
		<pubDate>Thu, 02 Sep 2010 02:19:53 +0000</pubDate>
		<dc:creator>wuxicn</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://icoder.me/?p=594</guid>
		<description><![CDATA[在grep中无法转义\t，因此grep直接将\t认为是字母t，而不是我们希望的tab。 要想在grep中用tab，需要直接在终端输入tab，输入方法是：Ctrl+v 然后在按 tab.]]></description>
			<content:encoded><![CDATA[<p>在grep中无法转义\t，因此grep直接将\t认为是字母t，而不是我们希望的tab。<br />
要想在grep中用tab，需要直接在终端输入tab，输入方法是：<span class="bgy">Ctrl+v 然后在按 tab.</b></p>
]]></content:encoded>
			<wfw:commentRss>http://icoder.me/2010/09/02/grepping-for-tabs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>xcscope</title>
		<link>http://icoder.me/2010/08/18/xcscope/</link>
		<comments>http://icoder.me/2010/08/18/xcscope/#comments</comments>
		<pubDate>Wed, 18 Aug 2010 06:41:09 +0000</pubDate>
		<dc:creator>wuxicn</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Emacs]]></category>

		<guid isPermaLink="false">http://icoder.me/?p=591</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<h2 class="red">USAGE</h2>
<pre class="mycode">;; 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.
</pre>
<p><span id="more-591"></span></p>
<pre class="mycode">;; These pertain to navigation through the search results:
;;
;;      C-c s b         Display *cscope* buffer.
;;      C-c s B         Auto display *cscope* buffer toggle.
;;      C-c s n         Next symbol.
;;      C-c s N         Next file.
;;      C-c s p         Previous symbol.
;;      C-c s P         Previous file.
;;      C-c s u         Pop mark.
;;
;; These pertain to setting and unsetting the variable,
;; `cscope-initial-directory', (location searched for the cscope database
;;  directory):
;;
;;      C-c s a         Set initial directory.
;;      C-c s A         Unset initial directory.
;;
;; These pertain to cscope database maintenance:
;;
;;      C-c s L         Create list of files to index.
;;      C-c s I         Create list and index.
;;      C-c s E         Edit list of files to index.
;;      C-c s W         Locate this buffer's cscope directory
;;                      ("W" --> "where").
;;      C-c s S         Locate this buffer's cscope directory.
;;                      (alternate binding: "S" --> "show").
;;      C-c s T         Locate this buffer's cscope directory.
;;                      (alternate binding: "T" --> "tell").
;;      C-c s D         Dired this buffer's directory.
</pre>
<h2 class="red">INSTALLATION</h2>
<pre class="mycode">;; * NOTE: this interface currently runs under Unix only.
;;
;; This module needs a shell script called "cscope-indexer", which
;; should have been supplied along with this emacs-lisp file.  The
;; purpose of "cscope-indexer" is to create and optionally maintain
;; the cscope databases.  If all of your source files are in one
;; directory, you don't need this script; it's very nice to have,
;; though, as it handles recursive subdirectory indexing, and can be
;; used in a nightly or weekly cron job to index very large source
;; repositories.  See the beginning of the file, "cscope-indexer", for
;; usage information.
;;
;; Installation steps:
;;
;; 0. (It is, of course, assumed that cscope is already properly
;;    installed on the current system.)
;;
;; 1. Install the "cscope-indexer" script into some convenient
;;    directory in $PATH.  The only real constraint is that (X)Emacs
;;    must be able to find and execute it.  You may also have to edit
;;    the value of PATH in the script, although this is unlikely; the
;;    majority of people should be able to use the script, "as-is".
;;
;; 2. Make sure that the "cscope-indexer" script is executable.  In
;;    particular, if you had to ftp this file, it is probably no
;;    longer executable.
;;
;; 3. Put this emacs-lisp file somewhere where (X)Emacs can find it.  It
;;    basically has to be in some directory listed in "load-path".
;;
;; 4. Edit your ~/.emacs file to add the line:
;;
;;      (require 'xcscope)
;;
;; 5. If you intend to use xcscope.el often you can optionally edit your
;;    ~/.emacs file to add keybindings that reduce the number of keystrokes
;;    required.  For example, the following will add "C-f#" keybindings, which
;;    are easier to type than the usual "C-c s" prefixed keybindings.  Note
;;    that specifying "global-map" instead of "cscope:map" makes the
;;    keybindings available in all buffers:
;;
;;	(define-key global-map [(control f3)]  'cscope-set-initial-directory)
;;	(define-key global-map [(control f4)]  'cscope-unset-initial-directory)
;;	(define-key global-map [(control f5)]  'cscope-find-this-symbol)
;;	(define-key global-map [(control f6)]  'cscope-find-global-definition)
;;	(define-key global-map [(control f7)]
;;	  'cscope-find-global-definition-no-prompting)
;;	(define-key global-map [(control f8)]  'cscope-pop-mark)
;;	(define-key global-map [(control f9)]  'cscope-next-symbol)
;;	(define-key global-map [(control f10)] 'cscope-next-file)
;;	(define-key global-map [(control f11)] 'cscope-prev-symbol)
;;	(define-key global-map [(control f12)] 'cscope-prev-file)
;;      (define-key global-map [(meta f9)]  'cscope-display-buffer)
;;      (defin-ekey global-map [(meta f10)] 'cscope-display-buffer-toggle)
;;
;; 6. Restart (X)Emacs.  That's it.
</pre>
<p>more info see: xcscope.el.</p>
]]></content:encoded>
			<wfw:commentRss>http://icoder.me/2010/08/18/xcscope/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux下写动态链接库.so</title>
		<link>http://icoder.me/2010/08/13/write-so-on-linux/</link>
		<comments>http://icoder.me/2010/08/13/write-so-on-linux/#comments</comments>
		<pubDate>Fri, 13 Aug 2010 13:54:07 +0000</pubDate>
		<dc:creator>wuxicn</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[Cpp]]></category>
		<category><![CDATA[Gcc]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://icoder.me/?p=584</guid>
		<description><![CDATA[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生成的生成的代码是非位置依赖的，方面的用于动态链接。 [...]]]></description>
			<content:encoded><![CDATA[<p>Linux下的动态链接库是.so文件，即：Shared Object，下面是一个简单的例子说明如何写.so以及程序如何动态载入.so中的函数和对象。</p>
<p>testso.h:</p>
<pre class="mycode">#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
</pre>
<p>testso.cpp:</p>
<pre class="mycode">
#include "testso.h"

extern "C"
int myadd(int a, int  b)
{
    return a + b;
}
</pre>
<p>编译so：</p>
<pre class="mycode">g++  -shared  -fPIC  -o testso.so testso.cpp</pre>
<p>注意，<b class="red">-shared</b>参数和<b class="red">-fPIC</b>参数非常重要：<br />
-shared 告诉gcc要生成的是动态链接库；<br />
-fPIC 告诉gcc生成的生成的代码是非位置依赖的，方面的用于动态链接。</p>
<p><span id="more-584"></span></p>
<p>在主程序里调用这个动态链接库：<br />
main.cpp:</p>
<pre class="mycode">#include <stdio.h>
#include
<dlfcn.h> // for dynamic library函数

#include "testso.h"

void print_usage(void)
{
    printf("Usage: main SO_PATH\n");
}

int main(int argc, char *argv[])
{
    if (2 != argc) {
        print_usage();
        exit(0);
    }

    const char *soname = argv[1];

    void *so_handle = dlopen(soname, RTLD_LAZY); // 载入.so文件
    if (!so_handle) {
        fprintf(stderr, "Error: load so `%s' failed.\n", soname);
        exit(-1);
    }

    dlerror(); // 清空错误信息
    myadd_t *fn = (myadd_t*)dlsym(so_handle, "myadd"); // 载入函数
    char *err = dlerror();
    if (NULL != err) {
        fprintf(stderr, "%s\n", err);
        exit(-1);
    }

    printf("myadd 57 + 3 = %d\n", fn(57, 3)); // 调用函数

    dlclose(so_handle); // 关闭so句柄
    return 0;
}
</pre>
<p>编译主程序：<br />
g++ main.cpp -o main -ldl</p>
<p>注意：要加上-ldl</p>
<p>好了，上面就是如何写和调用动态库中的C函数。<br />
对于C++中的类，不能直接导出，需要通过继承的方式才能从动态链接库中导出：</p>
<p>=====================</p>
<p>testso.h: </p>
<pre class="mycode">#ifndef _TESTSO_H
#define _TESTSO_H

// 只能通过基类调用，因此需要先定义一个基类，然后在create中生成真正需要生成的对象。
class Base
{
public:
    int a, b;

    virtual int add(void)
    {
        return -1;
    }
};

class A : public Base
{
public:
    int add(void);
};

extern "C" {
        Base* create(void);
        void destroy(Base *p);

        typedef Base* create_t(void);  // create factory
        typedef void destory_t(Base*); // destory
}

#endif // _TESTSO_H
</pre>
<p>testso.cpp:</p>
<pre class="mycode">#include "testso.h"

int A::add(void)
{
    return a + b;
}

extern "C"
{
    Base* create(void) // 注意：create函数必须返回Base的对象，不能直接返回A的
                       //      对象，否则后面调用A::add()的时候会提示错误。
    {
        return new A;
    }

    void destory(Base *p)
    {
        if (p) delete p;
    }
}
</pre>
<p>main.cpp: // 这里需要注意</p>
<pre class="mycode">#include
<dlfcn.h>
#include <stdlib.h>
#include <stdio.h>
#include "testso.h"

void print_usage(void)
{
    printf("Usage: myso SO_PATH\n");
}

int main(int argc, char *argv[])
{
    if (2 != argc) {
        print_usage();
        exit(0);
    }   

    const char *soname = argv[1];

    void *so_handle = dlopen(soname, RTLD_LAZY);
    if (!so_handle) {
        fprintf(stderr, "Error: load so `%s' failed.\n", soname);
        exit(-1);
    }   

    dlerror();
    create_t *create = (create_t*) dlsym(so_handle, "create");
    if (NULL != err) {
        fprintf(stderr, "%s\n", err);
        exit(-1);
    }
    Base *pa = create();

    pa->a = 57;
    pa->b = 3;
    printf("A.add(57, 3)=%d\n", pa->add()); // 注意，这里通过虚函数实现了
                                            // 对A::add()的调用。

    destory_t *destory = (destory_t*) dlsym(so_handle, "destory");
    if (NULL != err) {
        fprintf(stderr, "%s\n", err);
        exit(-1);
    }
    destory(pa);
    pa = NULL;

    dlclose(so_handle);

    printf("DONE!\n");
    return 0;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://icoder.me/2010/08/13/write-so-on-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPhone 3G的GPS不工作的修复方法</title>
		<link>http://icoder.me/2010/07/24/fix-gps-on-iphone-3g/</link>
		<comments>http://icoder.me/2010/07/24/fix-gps-on-iphone-3g/#comments</comments>
		<pubDate>Sat, 24 Jul 2010 08:23:15 +0000</pubDate>
		<dc:creator>wuxicn</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://icoder.me/?p=579</guid>
		<description><![CDATA[今天早上刷完机以后，发现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&#8217;s, buildings, or anything blocking your view of the sky - Open &#8220;MAPS&#8221;, click NO on all [...]]]></description>
			<content:encoded><![CDATA[<p>今天早上刷完机以后，发现iPhone 3G的GPS不工作了，不管用什么软件都定位不了。在国外的论坛找到了fix的办法，非常有效，转过来：</p>
<p>- Go to settings, general, auto-lock, change it from 1 Minute to NEVER<br />
- Go to settings, general, reset, reset network settings (THIS WILL REBOOT YOUR IPHONE)<br />
- Go outside, in a clear place with NO tree&#8217;s, buildings, or anything blocking your view of the sky<br />
- Open &#8220;MAPS&#8221;, 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)</p>
]]></content:encoded>
			<wfw:commentRss>http://icoder.me/2010/07/24/fix-gps-on-iphone-3g/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenSSH公钥授权方式</title>
		<link>http://icoder.me/2010/07/05/openssh-public-key-authentication/</link>
		<comments>http://icoder.me/2010/07/05/openssh-public-key-authentication/#comments</comments>
		<pubDate>Mon, 05 Jul 2010 11:49:11 +0000</pubDate>
		<dc:creator>wuxicn</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[SSH]]></category>

		<guid isPermaLink="false">http://icoder.me/?p=574</guid>
		<description><![CDATA[用公钥授权（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&#8230;)，直接Enter，这样以后在本机就不用输入密码了。 这样，在.ssh/目录下就会生产2个文件：id_rsa 和 id_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$ [...]]]></description>
			<content:encoded><![CDATA[<p>用公钥授权（Public key Authentication）的方式可以实现ssh服务器与本机之间的配对，实现不用输入密码联入SSH服务器。</p>
<p>具体做法：</p>
<h3>1) 在本机（ssh客户机）生成密钥文件：</h3>
<pre class="mycode">client$ cd ~/.ssh
client$ ssh-keygen -q -f id_rsa -t rsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
</pre>
<p>在提示输入密码阶段时(Enter passphrase&#8230;)，直接Enter，这样以后在本机就不用输入密码了。<br />
这样，在.ssh/目录下就会生产2个文件：<b class="red">id_rsa</b> 和 <b class="red">id_rsa.pub</b> .<br />
<b class="red">注意：保密好这两个文件！</b></p>
<h3>2) 分发公钥文件：</h3>
<p>将你的公钥文件 (<i>id_rsa.pub</i>) 分发到你的SSH服务器上：</p>
<pre class="mycode"># 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 &gt;&gt; ~/.ssh/authorized_keys
server$ chmod 600 ~/.ssh/authorized_keys
server$ rm ~/.ssh/id_rsa.pub</pre>
<p><b class="red">注意：这个地方要用&gt;&gt;追加到authorized_keys文件末尾，以免冲到以前的一些公钥授权。</b></p>
<p>好了，现在大功告成了，enjoy!<br />
PS： 以上方法只保证在OpenSSH服务器上有效，其他SSH服务器不知道。</p>
]]></content:encoded>
			<wfw:commentRss>http://icoder.me/2010/07/05/openssh-public-key-authentication/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>iPhone上手动安装deb软件</title>
		<link>http://icoder.me/2010/06/29/install-deb-on-iphone/</link>
		<comments>http://icoder.me/2010/06/29/install-deb-on-iphone/#comments</comments>
		<pubDate>Mon, 28 Jun 2010 17:12:40 +0000</pubDate>
		<dc:creator>wuxicn</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Hack]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://icoder.me/?p=571</guid>
		<description><![CDATA[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]]></description>
			<content:encoded><![CDATA[<p>1. 下载deb软件，并通过scp或者ftp传到iphone上。</p>
<p>2. 安装deb：<br />
<span class="bgy">dpkg -i /full/path/to/filename.deb</span><br />
例如：在iphone上安装vim：<br />
<span class="bgy">dpkg -i vim_7.1-3_iphoneos-arm.deb</span></p>
<p>PS: 下面是一些可以下载iphone deb软件的地方：<br />
Cydia的saurik源： <a href="http://apt.saurik.com/cydia/debs/">http://apt.saurik.com/cydia/debs/</a><br />
saurik源下软件列表：<a href="http://apt.saurik.com/dists/tangelo-3.7/main/binary-iphoneos-arm/Packages">http://apt.saurik.com/dists/tangelo-3.7/main/binary-iphoneos-arm/Packages</a></p>
]]></content:encoded>
			<wfw:commentRss>http://icoder.me/2010/06/29/install-deb-on-iphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>用SSH链接iPhone</title>
		<link>http://icoder.me/2010/06/29/connect-iphone-via-ssh/</link>
		<comments>http://icoder.me/2010/06/29/connect-iphone-via-ssh/#comments</comments>
		<pubDate>Mon, 28 Jun 2010 16:05:51 +0000</pubDate>
		<dc:creator>wuxicn</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Hack]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://icoder.me/?p=568</guid>
		<description><![CDATA[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中直接点&#8221;Enable SSH&#8221;开启SSH。 2. 在SBSetting中点SSH图标使其变绿即开启了SSH。 3. 略。 然后在 Settings &#187; General &#187; Auto Lock 中设置自动锁屏时间为 &#8220;Never&#8221;. Step 4. 通过SSH客户端软件链接iphone 在Mac下直接在终端中输入：（将&#8221;YOUR.IPHONE.IP&#8221;替换成上面记下来的IP地址） ssh root@YOUR.IPHONE.IP 在Win下可以通过SSH软件链接，如puTTY。 Username: root Password: alpine [...]]]></description>
			<content:encoded><![CDATA[<h3>Step 0. 前提条件</h3>
<p>你的iPhone是越狱过的(即你的iPhone里有Cydia软件)，如果还没有，可以见这篇文章进行越狱：<a href="http://icoder.me/2010/06/24/how-to-jailbreak-and-unlock-ios-4-on-mac/">http://icoder.me/2010/06/24/how-to-jailbreak-and-unlock-ios-4-on-mac/</a></p>
<h3>Step 1. 通过Cydia下载并安装OpenSSH</h3>
<p>OpenSSH程序是一个后台程序，安装完后桌面没有多任何图标，我们需要继续安装其他工具来控制开启/关闭OpenSSH，见Step 2.</p>
<h3>Step 2. OpenSSH开关工具</h3>
<p>可以在Cydia中选择下面3个工具的任何一个（或者都选）：<br />
1. <b>Toggle SSH <span class="red">(推荐)</span></b><br />
2. <b>SBSetting <span class="red">(推荐)</span></b><br />
3. <b>Boss Prefs</b></p>
<h3>Step 3. 打开OpenSSH</h3>
<p>开启wifi，记住你的IP。可以在下面软件中看到iphone的IP或者在wifi设置中点右边的箭头看到IP地址。<br />
1. 在Toggle SSH中直接点&#8221;Enable SSH&#8221;开启SSH。<br />
2. 在SBSetting中点SSH图标使其变绿即开启了SSH。<br />
3. 略。<br />
然后在 Settings &raquo; General &raquo; Auto Lock 中设置自动锁屏时间为 &#8220;Never&#8221;.</p>
<h3>Step 4. 通过SSH客户端软件链接iphone</h3>
<p>在Mac下直接在终端中输入：（将&#8221;YOUR.IPHONE.IP&#8221;替换成上面记下来的IP地址）<br />
<span class="bgy">ssh root@<i>YOUR.IPHONE.IP</i></span></p>
<p>在Win下可以通过SSH软件链接，如puTTY。</p>
<p><b class="red">Username:</b> <i class="bgy">root</i><br />
<b class="red">Password:</b> <i class="bgy">alpine</i></p>
<p>注意：在第一次链接的时候会比较慢（大概30s以上）。</p>
]]></content:encoded>
			<wfw:commentRss>http://icoder.me/2010/06/29/connect-iphone-via-ssh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iOS 4越狱+解锁教程 (Mac)</title>
		<link>http://icoder.me/2010/06/24/how-to-jailbreak-and-unlock-ios-4-on-mac/</link>
		<comments>http://icoder.me/2010/06/24/how-to-jailbreak-and-unlock-ios-4-on-mac/#comments</comments>
		<pubDate>Thu, 24 Jun 2010 06:37:55 +0000</pubDate>
		<dc:creator>wuxicn</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Hack]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Mac]]></category>

		<guid isPermaLink="false">http://icoder.me/?p=553</guid>
		<description><![CDATA[作者：Wuxi (欢迎来我的博客： http://iCoder.me/) ============ 本教程介绍在Mac系统下如何越狱和解锁iOS 4，适用于iPhone 3G/3GS和iPod touch 2G（我仅在我的iPhone 3G上试过）。如果你是Win系统请找别的教程。 特别感谢iPhone Dev-Team的Hacker们为自由事业作出的贡献！ 同时感谢RedmondPie网站[1]提供了非常详细的教程，喜欢看E文的同学可以直接去这个网站。 一、越狱iOS 4 iPhone Dev-Team在他们的博客里宣布更新了PwnageTool 4.01[2]，可以定制和越狱iOS 4官方版（非之前的4.0GM版）。不管你是已经越狱解锁过的iphone还是没有甚至没有激活的iphone(我的3G就是处于未激活状态），通过PwnageTool 4.01定制完的iOS 4都能越狱。 Step 1 下载并安装最新的iTunes. Step 2 下载iOS 4正式版，下载地址： 苹果官网的正式版iOS 4下载地址： iPhone 3G iOS 4下载地址 http://appldnld.apple.com.edgesuite.net/content.info.apple.com/iPhone4/061-7436.20100621.58Yt4/iPhone1,2_4.0_8A293_Restore.ipsw iPhone 3GS iOS 4下载地址 http://appldnld.apple.com.edgesuite.net/content.info.apple.com/iPhone4/061-7437.20100621.5urG8/iPhone2,1_4.0_8A293_Restore.ipsw iPhone 4 iOS 4下载地址 http://appldnld.apple.com.edgesuite.net/content.info.apple.com/iPhone4/061-7380.20100621,Vfgb5/iPhone3,1_4.0_8A293_Restore.ipsw iPod Touch 2代 iOS 4下载地址 http://appldnld.apple.com.edgesuite.net/content.info.apple.com/iPhone4/061-7435.20100621.tr49t/iPod2,1_4.0_8A293_Restore.ipsw iPod Touch 3代 iOS [...]]]></description>
			<content:encoded><![CDATA[<p>作者：Wuxi (欢迎来我的博客： <a href="http://iCoder.me/">http://iCoder.me/</a>)<br />
============<br />
<a href="http://icoder.me/wp-content/uploads/2010/06/pic-0.jpeg"><img src="http://icoder.me/wp-content/uploads/2010/06/pic-0.jpeg" alt="PWNED iOS 4!" title="PWNED iOS4" width="500" height="556" class="alignnone size-full wp-image-556" /></a></p>
<p>本教程介绍在Mac系统下如何越狱和解锁iOS 4，适用于iPhone 3G/3GS和iPod touch 2G（我仅在我的iPhone 3G上试过）。如果你是Win系统请找别的教程。</p>
<p>特别感谢iPhone Dev-Team的Hacker们为自由事业作出的贡献！<br />
同时感谢RedmondPie网站<sup>[1]</sup>提供了非常详细的教程，喜欢看E文的同学可以直接去这个网站。<br />
<span id="more-553"></span></p>
<h2>一、越狱iOS 4</h2>
<p>iPhone Dev-Team在他们的博客里宣布更新了PwnageTool 4.01<sup>[2]</sup>，可以定制和越狱iOS 4官方版（非之前的4.0GM版）。不管你是已经越狱解锁过的iphone还是没有甚至没有激活的iphone(我的3G就是处于未激活状态），通过PwnageTool 4.01定制完的iOS 4都能越狱。</p>
<h3>Step 1</h3>
<p>下载并安装最新的iTunes.</p>
<h3>Step 2</h3>
<p>下载iOS 4正式版，下载地址： </p>
<p>苹果官网的正式版iOS 4下载地址：<br />
<b class="red">iPhone 3G iOS 4下载地址</b> <a href="http://appldnld.apple.com.edgesuite.net/content.info.apple.com/iPhone4/061-7436.20100621.58Yt4/iPhone1,2_4.0_8A293_Restore.ipsw">http://appldnld.apple.com.edgesuite.net/content.info.apple.com/iPhone4/061-7436.20100621.58Yt4/iPhone1,2_4.0_8A293_Restore.ipsw</a></p>
<p><b class="red">iPhone 3GS iOS 4下载地址</b> <a href="http://appldnld.apple.com.edgesuite.net/content.info.apple.com/iPhone4/061-7437.20100621.5urG8/iPhone2,1_4.0_8A293_Restore.ipsw">http://appldnld.apple.com.edgesuite.net/content.info.apple.com/iPhone4/061-7437.20100621.5urG8/iPhone2,1_4.0_8A293_Restore.ipsw</a></p>
<p><b class="red">iPhone 4 iOS 4下载地址</b> <a href="http://appldnld.apple.com.edgesuite.net/content.info.apple.com/iPhone4/061-7380.20100621,Vfgb5/iPhone3,1_4.0_8A293_Restore.ipsw">http://appldnld.apple.com.edgesuite.net/content.info.apple.com/iPhone4/061-7380.20100621,Vfgb5/iPhone3,1_4.0_8A293_Restore.ipsw</a></p>
<p><b class="red">iPod Touch 2代 iOS 4下载地址</b> <a href="http://appldnld.apple.com.edgesuite.net/content.info.apple.com/iPhone4/061-7435.20100621.tr49t/iPod2,1_4.0_8A293_Restore.ipsw">http://appldnld.apple.com.edgesuite.net/content.info.apple.com/iPhone4/061-7435.20100621.tr49t/iPod2,1_4.0_8A293_Restore.ipsw</a></p>
<p><b class="red">iPod Touch 3代 iOS 4下载地址</b> <a href="http://appldnld.apple.com.edgesuite.net/content.info.apple.com/iPhone4/061-7381.20100621.AzSP9/iPod3,1_4.0_8A293_Restore.ipsw">http://appldnld.apple.com.edgesuite.net/content.info.apple.com/iPhone4/061-7381.20100621.AzSP9/iPod3,1_4.0_8A293_Restore.ipsw</a></p>
<h3>Step 3</h3>
<p>然后下载PwnageTool 4.01，下载地址： <a href="http://torrents.thepiratebay.org/5645662/PwnageTool_4.01.dmg.5645662.TPB.torrent">http://torrents.thepiratebay.org/5645662/PwnageTool_4.01.dmg.5645662.TPB.torrent</a> 这个是一个BT种子文件，然后通过BT下载PwnageTool 4.01程序。</p>
<h3>Step 4</h3>
<p>运行PwnageTool 4.01定制越狱的iOS 4：</p>
<p>1. 选择左上角的&#8221;Simple mode&#8221;，然后选择你的设备，如iPhone 3G(S)。然后点右下角的蓝色“下一步”按钮。<br />
<a href="http://icoder.me/wp-content/uploads/2010/06/pic-1.png"><img src="http://icoder.me/wp-content/uploads/2010/06/pic-1.png" alt="Step 4.1" title="Step 4.1" width="520" height="465" class="alignnone size-full wp-image-555" /></a><br />
图1</p>
<p>2. PwnageTool 4.01提问：&#8221;Do you have an iPhone 3G(S) contract that would active normally through iTunes?&#8221; 时，如果你的iphone是水货需要解锁选择&#8221;No&#8221;，如果是联通行货选择&#8221;Yes&#8221;. 然后点下一步。<br />
<a href="http://icoder.me/wp-content/uploads/2010/06/pic-2.png"><img src="http://icoder.me/wp-content/uploads/2010/06/pic-2.png" alt="Step 4.2" title="Step 4.2" width="448" height="399" class="alignnone size-full wp-image-557" /></a><br />
图2</p>
<p>3. 等待PwnageTool创建定制的iOS 4（时间比较长，耐心等待）。<br />
<a href="http://icoder.me/wp-content/uploads/2010/06/pic-3.jpeg"><img src="http://icoder.me/wp-content/uploads/2010/06/pic-3.jpeg" alt="Step 4.3" title="Step 4.3" width="448" height="398" class="alignnone size-full wp-image-558" /></a><br />
图3</p>
<p>PwnageTool创建完成后会出现下图的的画面。<br />
<a href="http://icoder.me/wp-content/uploads/2010/06/pic-4.jpeg"><img src="http://icoder.me/wp-content/uploads/2010/06/pic-4.jpeg" alt="Step 4.3-2" title="Step 4.3-2" width="448" height="398" class="alignnone size-full wp-image-559" /></a><br />
图4</p>
<p>4. 上面过程完成后，就可以关闭PwnageTool了。（进入DFU模式的方法在后面介绍）</p>
<h3>Step 5</h3>
<p>将iphone与Mac链接，等待iTunes识别出iPhone。<br />
然后按照下面操作进入DFU模式：<br />
1. 同时按下iPhone的Home和 电源键，保持10秒；<br />
2. 在不释放Home键的情况下松开 电源键，再保持10秒。<br />
这时iTunes会提示进入恢复模式（DFU）了。</p>
<h3>Step 6</h3>
<p>注意：按住Mac左边的&#8221;alt/option&#8221;键，然后选&#8221;Restore&#8221;（恢复），这时会弹出一个文件选择框，然后选刚才我们定制好的iOS 4恢复文件。等待iTunes恢复（安装）iOS 4.</p>
<p>=====================<br />
<i class="red">上面这些是用PwnageTool越狱的过程，下面介绍如何解锁。</i></p>
<h2>二、解锁iOS 4</h2>
<h3>Step 7</h3>
<p>首先在iphone里设置好wifi。</p>
<h3>Step 8</h3>
<p>1. 在iPhone里运行Cydia程序，在Cydia下面选择&#8221;Manage&#8221;，然后选择&#8221;Sources&#8221;菜单。<br />
<a href="http://icoder.me/wp-content/uploads/2010/06/pic-5.jpeg"><img src="http://icoder.me/wp-content/uploads/2010/06/pic-5.jpeg" alt="Step 8" title="Step 8" width="260" height="390" class="alignnone size-full wp-image-560" /></a><br />
图5</p>
<p>2. 按右上角的&#8221;Edit&#8221;</p>
<p>3. 按左上角的&#8221;Add&#8221;</p>
<p>4. 输入 <span class="bgy">http://repo666.ultrasn0w.com</span> <b class="red">注意，这里是数字0不是字母o</b>. 然后点&#8221;Add Source&#8221;. 按照提示，完成操作点&#8221;Done&#8221;.</p>
<p>5. 选择&#8221;repo666.ultrasn0w.com&#8221;，进入以后选&#8221;ultrasn0w&#8221;，然后点Install开始安装。</p>
<p>&#8212;&#8212;&#8212;&#8212;<br />
<b class="red">注意：如果安装过程中错现关于&#8221;apt.saurik.com&#8221;的错误，解决办法：</b><br />
在wifi中这是代理：（这个方法我试过有效）<br />
119.70.40.101<br />
8080</p>
<p>或者（这个方法没试过）<br />
解决办法：<br />
所幸的是，apt.saurik.com提供了另一个可以替代cache.saurik.com的源：apt.saurik.com/cydia<br />
只要修改一下apt的source list即可解决问题。</p>
<p>打开iphone的/etc/apt/souces.list.d/saurik.list<br />
编辑：<br />
deb http://apt.saurik.com/ tangelo-3.7 main</p>
<p>改为：<br />
deb http://apt.saurik.com/cydia/ tangelo-3.7 main<br />
&#8212;&#8212;&#8212;&#8212;</p>
<h3>Step 9</h3>
<p>安装完成后会出现下图，然后点&#8221;Reboot Device&#8221;重启机器，解锁就完成了！<br />
<a href="http://icoder.me/wp-content/uploads/2010/06/pic-8.jpeg"><img src="http://icoder.me/wp-content/uploads/2010/06/pic-8.jpeg" alt="Step 9" title="Step 9" width="320" height="480" class="alignnone size-full wp-image-561" /></a><br />
图8</p>
<p>放入你的SIM卡打个电话试试把！</p>
<p>Enjoy!</p>
<h3>References</h3>
<p>[1] RedmondPie: <a href="http://www.redmondpie.com/">http://www.redmondpie.com/</a><br />
[2] PwnageTool 4.01 Release Info (需要翻。墙访问): <a href="http://blog.iphone-dev.org/post/726179754/foursome-news">http://blog.iphone-dev.org/post/726179754/foursome-news</a></p>
]]></content:encoded>
			<wfw:commentRss>http://icoder.me/2010/06/24/how-to-jailbreak-and-unlock-ios-4-on-mac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>1. “Hello world” ── 引导程序(Boot loader)</title>
		<link>http://icoder.me/2010/06/10/bootloader/</link>
		<comments>http://icoder.me/2010/06/10/bootloader/#comments</comments>
		<pubDate>Thu, 10 Jun 2010 01:23:38 +0000</pubDate>
		<dc:creator>wuxicn</dc:creator>
				<category><![CDATA[OSDev]]></category>
		<category><![CDATA[Assembly]]></category>

		<guid isPermaLink="false">http://icoder.me/?p=536</guid>
		<description><![CDATA[table.quicknav { width:100%; border:none; } table.quicknav td.prev { width:40%; text-align:left;} table.quicknav td.next { width:40%; text-align:right; } table.quicknav td.top { text-align:center; } &#171; Previous TOP &#187; Next ====== 1. “Hello world” ── 引导程序(Boot loader) 做好了准备工作，现在可以开始写操作系统了。一般学习编程的第一个程序都是“hello world”，因此我们的操作系统也不例外。下面看看用10分钟的时间如何写一个可以在裸机（虚拟机）上直接运行的“操作系统”。 我们的 &#8220;Hello world&#8221; 操作系统 ;; File : t1.asm ;; Author : wuxi ;; Date : 2010.6.9 ;; Tutorial: http://icoder.me/osdev-tutorial/ ;; [...]]]></description>
			<content:encoded><![CDATA[<style>
table.quicknav { width:100%; border:none; }
table.quicknav td.prev { width:40%; text-align:left;}
table.quicknav td.next { width:40%; text-align:right; }
table.quicknav td.top { text-align:center; }
</style>
<table class="quicknav">
<tr>
<td class="prev"><a href="http://icoder.me/2010/05/10/preparations-for-writing-an-os/">&laquo; Previous</a></td>
<td class="top"><a href="http://icoder.me/osdev-tutorial/">TOP</a></td>
<td class="next">&raquo; Next</a></td>
</tr>
</table>
<p>======</p>
<h2>1. “Hello world” ── 引导程序(Boot loader)</h2>
<p>做好了<a href="http://icoder.me/2010/05/10/preparations-for-writing-an-os/">准备工作</a>，现在可以开始写操作系统了。一般学习编程的第一个程序都是“hello world”，因此我们的操作系统也不例外。下面看看用10分钟的时间如何写一个可以在裸机（虚拟机）上直接运行的“操作系统”。</p>
<h3>我们的 &#8220;Hello world&#8221; 操作系统</h3>
<p><span id="more-536"></span></p>
<pre class="mycode">
;; File    : t1.asm
;; Author  : wuxi
;; Date    : 2010.6.9
;; Tutorial: http://icoder.me/osdev-tutorial/
;; Project : http://code.google.com/p/myminios
;;
    org 0x7c00  ; BIOS自检完后将转到内存绝对地址7c00处继续执行
    jmp _start

_start:
    xor ax, ax  ; make it zero
    mov ds, ax
    mov es, ax

;; 设置BIOS输出的属性（其实位置、颜色）
    xor dx, dx
    mov bx, 0x000e

;; 通过BIOS的INT 10H中断输出文字
    mov bp, msg
    mov cx, msglen
    mov al, 1
    mov ah, 0x13
    int 0x10

;; 挂起
    jmp $

;; 文字常量:
msg db "Hello OS world!", 0
msglen equ $ - msg   ; 文字串的长度

;; 引导程序标记：以 0x55 0xaa 结尾
    times 510 - ($ - $$) db 0
    db 0x55
    db 0xaa
</pre>
<p>上面这段代码可以在http://code.google.com/p/myminios里下载到，在其目录下输入：&#8221;<span class="bgy">make t1</span>&#8221; 就会编译并生产a.img文件，然后直接在虚拟机里将a.img作为磁盘镜像启动就能看到在屏幕的第一行显示一串黄色的“<span style="color:yellow">Hello OS world!</span>”文字。</p>
<p>手工进行编译可以这样做：<span class="bgy">nasm -o t1.bin t1.asm</span></p>
<p>其实这不是一个真正意义上的操作系统，这只是一个引导程序。但是无论如何，这个程序不需要任何系统，直接在裸机上运行，我们的操作系统就可以在这个基础上逐渐扩展而来。</p>
<h3>&#8220;Hello world&#8221; 的解释</h3>
<p>当BIOS自检完后，他将会把启动盘的第一个扇区（0面、0磁道、1扇区）的这512字节内容加载到内存的<b class="red">0x7c00</b>位置，然后跳转到0x7c00位置，将执行权交给这个位置的程序。因此，我们程序的第一条命令 &#8220;<span class="bgy">org 0x7c00</span>&#8221; 就是告诉汇编编译器（nasm）这个程序将被加载到内存0x7c00位置。</p>
<p>并且，此时不管你是32位机器还是64位机器，现在都是运行在16位实模式(real mode)<sup>[1]</sup>下。因此，寻址范围只有1M Byte.</p>
<p>接下来，我们通过调用BIOS提供的INT 10H服务<sup>[2]</sup>将msg（也就是&#8221;Hello OS world!&#8221;字符串输）出到了屏幕上。<br />
调用方法很简单，将参数值存入对应寄存器（如字符串起始地址存入寄存器BP），然后通过命令 &#8220;<span class="bgy">int 0&#215;10</span>&#8221; 让BIOS帮我们输出字符串。具体各个参数的意义可以参见文献[2].</p>
<p><b class="red">好了，现在一个可以在裸机上独立运行的引导程序雏形已经有了，接下来教程中我们将在它的基础上进行扩展，逐步将它扩展成我们的操作系统。</b></p>
<h3>References</h3>
<p>[1] Real Mode. <a href="http://www.deinmeister.de/x86modes.htm#pa">http://www.deinmeister.de/x86modes.htm#pa</a></p>
<p>[2] INT 10 : BIOS Video services. <a href="http://www.uv.tietgen.dk/staff/mlha/pc/Prog/asm/int/INT10.htm">http://www.uv.tietgen.dk/staff/mlha/pc/Prog/asm/int/INT10.htm</a></p>
<p>======</p>
<table class="quicknav">
<tr>
<td class="prev"><a href="http://icoder.me/2010/05/10/preparations-for-writing-an-os/">&laquo; Previous</a></td>
<td class="top"><a href="http://icoder.me/osdev-tutorial/">TOP</a></td>
<td class="next">&raquo; Next</a></td>
</tr>
</table>
]]></content:encoded>
			<wfw:commentRss>http://icoder.me/2010/06/10/bootloader/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Chrome + Switchy! + SSH Tunnel 自动翻墙</title>
		<link>http://icoder.me/2010/05/26/chrome-switchy-ssh-tunnel/</link>
		<comments>http://icoder.me/2010/05/26/chrome-switchy-ssh-tunnel/#comments</comments>
		<pubDate>Wed, 26 May 2010 02:28:19 +0000</pubDate>
		<dc:creator>wuxicn</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Chrome]]></category>

		<guid isPermaLink="false">http://icoder.me/?p=530</guid>
		<description><![CDATA[感谢党、感谢国家！我们在日常上网生活中学会了很多网络技术，其中翻墙是最常用的一种。 1. 安装chrome Switchy! 插件。 2. 设置一个SSH tunnel：见我的另一篇BLOG：http://icoder.me/2010/04/21/ssh-tunnel/ 3. 设置 Switchy! 的 socks 代理： 4. 让 Switchy! 根据被 GFW 强的网站自动翻墙： gfwlist.txt 地址： http://autoproxy-gfwlist.googlecode.com/svn/trunk/gfwlist.txt 注意： 第一次使用的时候 &#8220;Reload Every&#8221; 设置成15分钟，当翻墙成功后可以设成3小时。 5. 最后将 Switchy! 代理设成 &#8220;Auto Switch Mode&#8220;，这样就大功告成了！以后 Switchy! 就会根据GFW列表自动启用代理了。]]></description>
			<content:encoded><![CDATA[<p>感谢党、感谢国家！我们在日常上网生活中学会了很多网络技术，其中翻墙是最常用的一种。</p>
<p>1. 安装chrome Switchy! 插件。</p>
<p>2. 设置一个SSH tunnel：见我的另一篇BLOG：<a href="http://icoder.me/2010/04/21/ssh-tunnel/">http://icoder.me/2010/04/21/ssh-tunnel/</a></p>
<p>3. 设置 Switchy! 的 socks 代理：<br />
<a href="http://icoder.me/wp-content/uploads/2010/05/1.png"><img src="http://icoder.me/wp-content/uploads/2010/05/1.png" alt="Switchy! Socks proxy setting" title="Switchy! Socks proxy setting" width="760" height="630" class="alignnone size-full wp-image-531" /></a></p>
<p>4. 让 Switchy! 根据被 GFW 强的网站自动翻墙：<br />
<a href="http://icoder.me/wp-content/uploads/2010/05/2.png"><img src="http://icoder.me/wp-content/uploads/2010/05/2.png" alt="Online Rule setting" title="Online Rule setting" width="760" height="630" class="alignnone size-full wp-image-532" /></a></p>
<p><b class="red">gfwlist.txt 地址：</b> http://autoproxy-gfwlist.googlecode.com/svn/trunk/gfwlist.txt</p>
<p><b class="red">注意：</b> 第一次使用的时候 &#8220;<b>Reload Every</b>&#8221; 设置成15分钟，当翻墙成功后可以设成3小时。</p>
<p>5. 最后将 Switchy! 代理设成 &#8220;<b>Auto Switch Mode</b>&#8220;，这样就大功告成了！以后 Switchy! 就会根据GFW列表自动启用代理了。</p>
]]></content:encoded>
			<wfw:commentRss>http://icoder.me/2010/05/26/chrome-switchy-ssh-tunnel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
