-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcmdlog.txt
184 lines (139 loc) · 6.36 KB
/
cmdlog.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
set HTTP_PROXY=http://172.30.4.63:3128
$ rails generate scaffold Post name:string title:string content:text
rails new novelpool
git init
git add .
git commit -am "init"
# github.com create new repotery
git remote add origin https://brookzhang@github.com/brookzhang/novelpool.git
git push -u origin master
rails g migration initdatabase
rake db:migrate
rails g controller Pages
rails destroy controller Pages
rails g controller Pages home toplist about help
# edit routes
git config branch.master.remote origin
git config branch.master.merge refs/heads/master
git branch -m master development
git branch -m published master
git push origin master
#insert test data
rails g model User
rails c
user = User.new
user.email="brook@brook.com"
......
user.save
reload! #when model class modified ,reload them in console
rails g migration AlterAuthorOfBook
rails g controller maintain/Sections index show new edit
rake routes # show all routes
sudo gem sources -r http://rubygems.org/ #terminal ,remove source
sudo gem sources -a http://ruby.taobao.org #add source
#============================operation============================
# 创建一个表及相关的mvc
$ rails generate model User name:string email:string #User , not Users ,created a migrate in /db/migrate/, edit if needs.
$ rake db:migrate
$ rails generate controller Users show #Users ,not User
$ rails generate controller maintian/Users show #Users ,not User
$ rails generate migration some_action_name_as_a_tag_only_needs_fullfil
$ rails generate migration AddPartNumberToProducts
$ rails generate migration AddPartNumberToProducts part_number:string
$ rails generate migration RemovePartNumberFromProducts part_number:string
$ rails generate migration AddDetailsToProducts part_number:string price:decimal
#============================rails:============================
$ rails new sample_app -T #without testing code
$ rails server #rails s,quit: ctrl+c
$ rails server --environment production
$ rails console # rails c ,quit ctrl+d
$ rails console --sandbox #no changes
$ rails console test
$ first_user = User.first =User.find(1) User.all
$ tail -f log/development.log #show database log
# ============================gem: ============================
$ set HTTP_PROXY=http://172.30.4.63:3128 #set proxy=http://172.30.4.63:3128
$ gem install rails # -p --http-proxy http://172.30.4.63:3128
# ============================rake: ruby make============================
$ rake db:create
$ rake db:test:prepare
$ rake db:reset #clear database
$ rake db:populate # lib/tasks/sample_data.rake task :populate =>:environment
$ rake db:rollback #回滚到最近的一次migration执行的状态
$ rake db:rollback STEP=3 #回滚最近的3次的迁移任务
$ rake db:migrate:redo #重做迁移
# ============================git:============================
$ git config --global user.name "name"
$ git config --global user.email "mail"
$ git config --global http.proxy http://172.30.4.63:3128
$ git config --global alias.co checkout
$ git config --global co.editor "vim -f"
$ git config --global core.autocrlf false
$ git config --global github.user username #connected with https
$ git config --global github.token tokencode #https security code
$ git init #init repository for a new folder
$ git checkout -b modify-readme #new branch
$ git status
$ git branch
$ git branch -d some-branch / git branch -D modify-readme #delte branch,-d needs merged all changes ,-D not care about changes.
$ git merge modify-readme
$ git add . #add all include new file
$ git commit -m "message" #commit modified one file
$ git commit -a #commit all changes ,not include new files
$ git commit -am "message" #short write
$ git mv README README.markdown #rename file
$ git log
$ git rm public/index.html #tell git that a file should be removed
$ git add . / git commit -am "massage" / git checkout master / git merge other-branch / git push # merge a branch
$ git checkout master / git checkout -b new-branch #make a new branch, and leave on new-branch
# ============================github:============================
Global setup:
Set up git
git config --global user.name "Brook"
git config --global user.email brook_realize@126.com
Next steps:
git init
git add .
git commit -m 'first commit'
git remote add origin https://brookzhang@github.com/brookzhang/hybook.git
git push -u origin master
$ git remote add origin https://brookzhang@github.com/brookzhang/fat_free_crm.git
$ git push origin master
$ git push origin master:master
$ git push
$ git clone https://brookzhang@github.com/brookzhang/first_app.git
$ git pull
$ git fetch
$ git push heroku master
$ git remote rm heroku
$ git remote add heroku git@heroku.com:brook.git
# ============================rspec:============================
$ rails generate rspec:install
$ rails generate integration_test layout_links
$ rspec spec/
$ bundle exec rspec spec/
$ time rspec spec/
$ rspec spec/models/user_spec.rb -e "should have an encrypted password attribute"
# ============================heroku:============================
$ sudo gem install heroku
$ heroku keys:add #follow steps ,add ssh public key
$ heroku create
$ heroku rake db:migrate
$ [sudo] gem install taps
$ heroku db:push #push data to heroku
$ heroku console #same as rails console on heroku
# ============================vim:============================
$ :w #write = save
$ :q #quit
$ d #delete
# ============================ubuntu:============================
$ cd #change directory
$ ls #list
$ mv #move
$ cp #copy
$ rm #remove file or directory
$ rm rf #remove recursive force
$ rm -rf spec/views
$ ps -e | grep apt #show apt* process
$ sudo killall apt #kill process
$ sudo killall apt-get