GUIDE

The road ahead will be long and our climb will be steep

Functional Test in Ubuntu Server Use Rails

| Comments

  • install xfvb in ubuntu server
1
2
sudo apt-get install xvfb
sudo apt-get install xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic
  • run rspec
1
xvfb-run -a -n 99 bundle exec rspec spec

Bundle Install or Exec Another Project in This Project

| Comments

rspec.rake

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
repo_path = 'another project absolute path'

Bundler.with_clean_env do
  Dir.chdir repo_path do
    %x{bundle install}
  end
end

...

Bundler.with_clean_env do
  Dir.chdir repo_path do
    %x{rspec spec --format html --out rspec_results.html --format documentation --out rspec_results.txt}
  end
end

Set Prompt String in Shell on Mac

| Comments

PS1

Custom Path
1
2
3
4
# echo $PS1
# \h:\W \u\$

export PS1='$(whoami)@$(hostname):$(pwd)'
Full Folder Path
1
export PS1='$(pwd): '
Current Folder Path
1
export PS1='${PWD##*/}: '
Recommend Settings
1
2
3
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\W\[\033[m\]\$ "

How to Use Chmod in Unix/linux

| Comments

File permission modify command: chmod

  • Usage: chmod XXX file   
# XXX: owner/group(users in owner's group)/otherUsers

x = 4: 'read' permission
x = 2: 'write' permission
x = 1: 'exec' permission
  • Example:
sudo chmod 600 file (only owner has read, write permission)
sudo chmod 644 file (owner has read and write permission, group users and other users has only read permission)

sudo chmod 700 file (only owner has read, write and exec permission)
sudo chmod 666 file (everyone has read, write permission)
sudo chmod 777 file (everyone has read, write and exec permission)

sudo chmod go-x file (cancel the exec permission of group and other users)

Install Ruby on Ubuntu

| Comments

  • 一些依赖包:
sudo apt-get install -y build-essential openssl libreadline6 libreadline6-dev curl zlib1g zlib1g-dev libyaml libxml2 libxslt autoconf libc6-dev ncurses-dev automake libtool bison pkg-config git-core subversion

git-core和subversion可选

gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3
\curl -L get.rvm.io | bash -s stable
  • 为rvm命令配置快捷方式
source ~/.rvm/scripts/rvm
  • 安装ruby
rvm list known
rvm install 2.0.0
  • 如果服务器是在国内,可选择将gem源换为taobao域名
gem source -r https://rubygems.org/
gem source --add http://ruby.taobao.org/
gem source -l # 查看gems源