Skip to content

Instantly share code, notes, and snippets.

@tony612
Last active December 22, 2015 08:30
Show Gist options
  • Select an option

  • Save tony612/6445601 to your computer and use it in GitHub Desktop.

Select an option

Save tony612/6445601 to your computer and use it in GitHub Desktop.
Building development env for a ruby developer from 0 on Mac.

## Xcode

> In fact, Xcode is a compiler for iOS/OS X programs.But it provides many of the necessary compilers and libraries needed for your development environment.

You can install it from Mac App Store.

For xcode below 5.0 version, you must install the Command Line Tools in Preferences > Downloads.

If you use xcode5.0, you can check if you have it in Preferences > Locations > Command Line Tools

1Password

iTerm 2

This is a better terminal(command line).(You can think it as the text-interface Operating System, comparing to the GUI interface.You can execute all commands/programs here, for example: changing directory, remoing files, opening the editor, running the command to execute the code scripts, running the command to do some server/database/... programs)

Download from http://www.iterm2.com/#/section/downloads , and drag the app to Applications.

And you may want to use the color schema http://ethanschoonover.com/solarized

Dropbox

Config file for iTerm is in dropbox.Set custom config path

Homebrew

You can use it to install and manage many program/packages or some softwares in a graceful way

http://brew.sh/

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

run $ brew doctor to check if env is ready

zsh(Optional)

It's a alternative for Bash(the shell, http://zh.wikipedia.org/wiki/Unix_shell)

$ brew install zsh

$ sudo sh -c 'echo "/usr/local/bin/zsh" >> /etc/shells' $ chsh -s /usr/local/bin/zsh

$ brew doctor

Got Warning: /usr/bin occurs before /usr/local/bin $ echo export PATH="/usr/local/bin:$PATH" >> ~/.zprofile Change PATH in ~/.zshrc to PATH="/usr/local/bin:/usr/local/sbin:$PATH"

Then you should get

$ zsh --version
$ zsh 5.0.2 (x86_64-apple-darwin12.4.0)

Git

A version-control tool(software, program) to manage your code's version. It can track all your modification to code of your project, for example, when you delete/remove/modify the code in the file. You can think it saves all the snapshoots for the project. You can push your code in a git server, so that you can do some change locally and push them to the server when you're online.For example you can use the github.com as your git server, which provide the free server to host your open source code.You can pull(sync your local code to be the same with remote server) or push(push your local changes to remote server)

You can get started in http://try.github.io/

$ brew install git

$ brew doctor

Got Warning: /usr/bin occurs before /usr/local/bin

$ echo export PATH="/usr/local/bin:$PATH" >> ~/.zshrc $ source ~/.zshrc

$ brew doctor You'd better run this often, especialy after you install something. Got Your system is ready to brew. It's OK.

ssh

It's a protocol of application layer in Computer Network, just like HTTP. But it's more safe, so you can do many things via it, such as connecting and operating a remote server, So that you can build the connection with Github with it.

Refer to this first: https://help.github.com/articles/generating-ssh-keys

Optional:

You may want to copy you old ssh file to the new mac.So use:

cp ssh/config ssh/id_rsa ssh/id_rsa.pub ~/.ssh/

And when you do some actions about git, like git clone ..., you should input the password for the old ssh key.

And you may want to change the password use ssh-keygen -p (https://help.github.com/articles/working-with-ssh-key-passphrases#adding-or-changing-a-passphrase )

rvm

Ruby Version Manager. With it, you can install many versions and switch version of ruby on your computer easily.

$ \curl -sSL https://get.rvm.io | bash -s stable

Editor

Chose one:


Below is the Ruby & Rails part

Introduction to web development

一个web应用一般有前端(client)和后端(server)组成。

以rails为例:

前端:当你在浏览器输入一个网址并敲下回车,或者点击页面的一个链接,你就向那个网址所在的服务器发送了一个HTTP请求

后端:当这个HTTP请求到达这个服务器后,rails的程序会获取到你的请求,并会根据你请求的具体路径来判断返回什么内容(也就是一个HTML文件),所以它会执行一些代码(比如操作数据库,组合数据)来拿到一些数据,然后把数据填到HTML文件中,最后把这个HTML文件通过HTTP返回给 客户端(浏览器)。

前端:浏览器接收到这个HTML文件,就会去渲染成页面,过程包括加载并执行js代码,加载并执行css代码来改变样式,加载图片。最终显示成你看到的样子。

可以参考: http://ihower.tw/rails3/intro.html

Ruby

A dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write.

Getting started: http://tryruby.org/

rvm install ruby-2.1.1

Rails

It's a web framework built with ruby. With it, you can build a website fast and easily.And with its CoC principle(convention over configuration), you can care less about the configuration.

Install it:

$ gem install rails

Use a command to create a project skeleton:

$ rails new your_app_name
$ cd your_app_name

Start the server:

rails server

Then you can visit localhost:3000 in the brower to see the web pages.

You can get started with http://railsforzombies.org/

A book for beginner: (Rails tutorial)[http://ruby.railstutorial.org/ruby-on-rails-tutorial-book]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment