mardi 26 juillet 2011

Restart Apache in Mac OS X

To restart the Apache webserver service you can run the following command in a Mac OS X Terminal window:

sudo /usr/sbin/apachectl restart

if you have the following error:

/usr/sbin/apachectl: line 73: ulimit: open files: cannot modify limit: Invalid argument


follow the instructions:


Luckily the world is a big place and someone had already fixed the problem.
Just open up /usr/sbin/apachectl and change (around line 64):

ULIMIT_MAX_FILES="ulimit -S -n `ulimit -H -n`"

to

ULIMIT_MAX_FILES=""


ref: http://www.justinball.com/2010/11/23/apachectl-stopped-working-after-mac-osx-10-6-5/

jeudi 21 juillet 2011

install wget in mac os x

wget is great command line *nix program for grabbing things from the web, but it doesn’t ship with macs. It’s also not a part of the developer tools package. Here’s the steps I used to build and install wget on my mac.

Grab the wget source code from http://ftp.gnu.org/pub/gnu/wget/wget-1.9.1.tar.gz (or get the latest here) . Open a terminal window and follow along:

tar xzf wget-1.9.1.tar.gz
cd wget-1.9.1
./configure
make
sudo make install
The wget binary should now be in your /usr/local/bin folder. Let’s also put /usr/local/bin in the shell path so we can type wget from the command line rather than the tedious /usr/local/bin/wget when we want to run the program. This is accomplished by editing ~/.bash_profile to add the following line:

PATH=$PATH:/usr/local/bin; export PATH

To get the shell to re-read this file again, type source ~/.bash_profile. Now whenever you start the terminal, /usr/local/bin will be in the path.

The other part of installing wget that needs a tweak is wget’s manual page isn’t found when running man wget from the terminal. To resolve this we need to edit the man configuration file.
 
sudo nano /usr/share/misc/man.conf

Scroll down a bit and below all the other lines beginning with MANPATH, add:
MANPATH /usr/local/man

64 bits or 32 bits?

1: how to determine the JVM that you are running is 64-bit or 32-bit?

    open the terminal and enter the following command:

    - java -d64 -version
 
    if it is a 64-bit system, you will get the following result:

        chen-macbook:~ cwang$ java -d64 -version
    Java version "1.6.0_24"
    Java(TM) SE Runtime Environment (build 1.6.0_24-b07-334-9M3326)
    Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02-334, mixed mode)


    otherwise, you will get the following result:

        chen@chen-VirtualBox:~$ java -d64 -version
    Running a 64-bit JVM is not supported on this platform.


2: how to determine your system is 64-bit or 32-bit?

    MAC OS:
        open the terminal and enter the command uname -p,
        if you get i386, that means your system is 32-bit, x86-64 otherwise.
    
 
Finished

  



 

mardi 5 juillet 2011

Emacs 学习笔记

C: ctrl;
M: alt (or apple key);
------------------


------------------
移动光标:

C-l: 光标居中;
C-v (PgDn): 下一页 ;

M-v (PgUp): 上一页;

C-p: 上一行;
C-n: 下一行;
C-b: 左移一个字符;
C-f: 右移一个字符;
M-f: 右移一个单词;
M-b: 左移一个单词;

C-a: 一行的最前端;
C-e: 一行的最后端;
M-a: 一句话的最前端;
M-e: 一句话的最后端;

M-<: 文章的头;
M->: 文章的尾;

C-u N C-f: 重复执行一个命令N次;
也可以用于输入:C-u 8 *: 输入8个*;
-------------------
文字编辑:

<Delback>: 删除光标之前的一个字符;(effacer)
C-d: 删除光标之后的一个字符;(effacer)

M-<Delback>: 删除光标之前的一个单词;(supprimer)
M-d: 删除光标之后的一个单词;(supprimer)
C-k: 删除到本行结束;(supprimer)
M-k: 删除到本句结束;(supprimer)
C-@, C-w: 删除一段文字分别标记始末;(supprimer)

effacer 和 supprimer 的区别:
supprimer 可以复原,儿effacer 不可以;
C-y: 复原命令,把最后删除的文本重新插入;(如果连续做了很多次C-k,则所有被删除的文字都要被重新插入)
通过这个方法,可以copy,用C-@,C-w标记选中的部分,然后supprimer;然后C-y 还原;再在需要的地方C-y 粘贴就行了;
C-y 只能粘贴最近一次删除的,而M-y 可以拿回所有删除的文字;
M-y: 一次——最近一次删除的;两次——之前两次删除的;以此类推;

C-x u: 撤销,undo;不过这条命令只undo 一条命令;需要undo 多个modification,使用多次命令;
同样,可以使用C-_,相同的功能但是更容易操作;(注意,使用_需要按住shift);

向前查找:C-s;(查找之后的内容)C-s,查找下一个,期间可以修改关键字,按回车,结束本次查找;
向后查找:C-r;(查找之前的内容)

-------------------
文件操作:

C-x C-f:打开一个文件;
C-x C-s:保存;
C-x C-c: 关闭当前窗口;

Tempons:
Emacs 把每个文件都保存在一个叫做“tempon” 的对象里;
C-x C-b:list of tempons;
然后想编辑哪个文件,就用命令:C-x b tempon_name 就行了;
至于每个tempon 名,在list of tempons 中看就行了;
(当然,也可以使用命令C-x C-f 打开一个文件进行编辑)
-------------------
C-g: 停止当前执行的命令;
退出一个recursive 的命令,连续按三下<ESC>;可以退出C-g 不能退出的情况;

C-x s: 保存所有可能保存的tempons,每个以此询问;

M-x repl s<Tab> X <return> Y <return>: 把光标后面的X 全部换成Y;
M-x recover file<enter>: 恢复自动保存的文件;(后面有confirmation)
-------------------
窗口:

C-x 1: 当有多个窗口的时候,只保留光标所在的窗口;
C-x 2: 分成两个窗口,同一个文件;
C-x o:切换光标到另一个窗口;

-------------------
管理操作:

M-x text mode<enter>: 进入文本编辑模式;

-------------------
帮助:

C-h C Command: 查询有关Command 的信息(C: 帮助类型);
如果不知道C 应该写什么,输入?,有一个list 将说明每个字符的不同含义;
i.e.: C-h c C-p
显示:C-p runs the command previous -line;

C-x 1: 返回一个窗口的状态;
C-u 8 *: 插入 ********;
<Delback>:    删除光标之前的字符;
C-d:   删除光标之后的字符;
M-<Delback>:  删除光标之前的单词;
M-d:删除光标之后的单词;
C-k:删除光标到本行末;
M-k:删除光标到本句末;
C-@ 或者C-SPC标记一端,C-w标记另一端,两端之间的文字会被删掉;