Install GDB on Mac OS

2013年10月03日 13:30

First install Homebrew using command: [1]

ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"

Then using brew to install gdb using command: [2]

brew install https://raw.github.com/Homebrew/homebrew-dupes/master/gdb.rb

[1]http://brew.sh/index_zh-cn.html

[2] http://stackoverflow.com/questions/8336433/gdb-on-macosx-lion

评论(11) 阅读(5094)

3.二维数组中的查找

2013年9月30日 17:43

给一个有规律的整数矩阵,每行元素从左到右递增,第列元素从上到下递增。

要求完成一个查找函数,输入为满足以上条件的一个二维数组以及一个整数,判断数组中是否包含此整数。

如:

[tex] \begin{bmatrix}  1 & 2 & 8 & 9 \\ 2 & 4& 9& 12\\ 4 & 7 & 10&13 \\ 6 & 8 & 11& 15\end{bmatrix}[/tex]

查找7应当返回true,查找5应当返回false.

Tags: c++
评论(9) 阅读(2621)

Configure git bash prompt on Mac OS Lion

2013年9月29日 09:59

Create a ~/.bash_profile and enable colors using:

export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$"
export CLICOLOR=1
# light theme, white background
export LSCOLORS=ExFxBxDxCxegedabagacad

alias ls='ls -GFh'

In the ~/ folder, create subfolder .bash and drop gitprompt.sh and gitstatus.py files there (bash.zip)

In the ~/.bash_profile file, add ``source ~/.bash/gitprompt.s'' so the file becomes:

export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$"
export CLICOLOR=1
# light theme, white background
export LSCOLORS=ExFxBxDxCxegedabagacad

alias ls='ls -GFh'

#enable git bash prompt
source ~/.bash/gitprompt.sh

Restart terminal, and see the new look :

References

  1. http://osxdaily.com/2013/02/05/improve-terminal-appearance-mac-os-x/
  2. http://jimmylarkin.net/post/2013/04/18/The-ultimate-git-bash-prompt.aspx

 

Tags: Git mac os
评论(6) 阅读(4046)

1.赋值运算符函数

2013年9月28日 16:43

程序来自何海涛《剑指OFFER》一书

方法1:手动分配内存,调用strcpy

Tags: c++
评论(6) 阅读(2427)

Ubuntu 13.04 + Emacs 24.3 + W3M

2013年9月26日 08:05

1. 下载安装w3m

$ apt-get install w3m
$ cvs -d :pserver:anonymous@cvs.namazu.org:/storage/cvsroot co emacs-w3m

下载完成后,将源码拷贝到/usr/local/src目录下

$ sudo cp -r emacs-w3m /usr/local/src/
$ cd /usr/local/src/emacs-w3m/
$ sudo autoconf
$ sudo ./configure
$ sudo make
$ sudo make install

2. Emacs 24.3,在~/.emacs.d/init.el 文件里添加如下设置

;; set emacs-w3m
;;设置emacs-w3m浏览器
(add-to-list 'load-path "/usr/local/src/emacs-w3m/")
(require 'w3m)
(require 'w3m-load)
;(require 'mime-w3m)
 
;; 设置w3m主页
(setq w3m-home-page "http://www.google.com")
 
;; 默认显示图片
(setq w3m-default-display-inline-images t)
(setq w3m-default-toggle-inline-images t)
 
;; 使用cookies
(setq w3m-command-arguments '("-cookie" "-F"))
(setq w3m-use-cookies t)
(setq browse-url-browser-function 'w3m-browse-url)
(setq w3m-view-this-url-new-session-in-background t)

3. 在Emacs中开启w3m:

M-x w3m


为图方便,大部分内容转载自阿戴网http://www.adaiw.com/?p=804

 

Tags: emacs ubuntu
评论(16) 阅读(6273)