-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.xml
482 lines (475 loc) · 34 KB
/
search.xml
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
<?xml version="1.0" encoding="utf-8"?>
<search>
<entry>
<title>证书文件格式互转(cer/crt/jks/bks/keystore/pem...)</title>
<url>/2020/01/11/%E8%AF%81%E4%B9%A6%E6%96%87%E4%BB%B6%E6%A0%BC%E5%BC%8F%E4%BA%92%E8%BD%AC/</url>
<content><![CDATA[<table>
<thead>
<tr>
<th>序号</th>
<th>源证书文件格式</th>
<th>目标证书文件格式</th>
<th>所需命令</th>
</tr>
</thead>
<tbody><tr>
<td>1</td>
<td>keystore</td>
<td>p12</td>
<td>keytool -importkeystore -srckeystore xxxx.keystore -srcstoretype JKS -deststoretype PKCS12 -destkeystore xxx.p12</td>
</tr>
<tr>
<td>2</td>
<td>p12</td>
<td>jks</td>
<td>keytool -importkeystore -srckeystore xxx.p12 -srcstoretype PKCS12 -deststoretype JKS -destkeystore xxx.jks</td>
</tr>
<tr>
<td>3</td>
<td>pk8</td>
<td>pem</td>
<td>openssl pkcs8 -inform DER -nocrypt -in xxx.pk8 -out xxx.pem</td>
</tr>
<tr>
<td>4</td>
<td>pem</td>
<td>pks12</td>
<td>openssl pkcs12 -export -in xxx.x509.pem -inkey platform.pem -out xxx.pkcs12</td>
</tr>
<tr>
<td>5</td>
<td>pks12</td>
<td>jks</td>
<td>keytool -importkeystore -srckeystore xxx.pkcs12 -srcstoretype pkcs12 -srcstorepass android -destkeystore xxx.jks -deststoretype jks -deststorepass android</td>
</tr>
<tr>
<td>6</td>
<td>jks</td>
<td>p12</td>
<td>keytool -importkeystore -srckeystore xxx.jks -destkeystore xxx.p12 -srcstoretype JKS -deststoretype PKCS12 -srcstorepass android -deststorepass android -srcalias platform -destalias platform -srckeypass android -destkeypass android -noprompt</td>
</tr>
<tr>
<td>7</td>
<td>p12</td>
<td>x509.pem</td>
<td>openssl pkcs12 -in xxx.p12 -nodes -nokeys -out xxx.x509.pem -password pass:android</td>
</tr>
<tr>
<td>8</td>
<td>p12</td>
<td>rsa.pem</td>
<td>openssl pkcs12 -in xxx.p12 -nodes -cacerts -out xxx.rsa.pem -password pass:android</td>
</tr>
<tr>
<td>9</td>
<td>rsa.pem</td>
<td>pk8</td>
<td>openssl pkcs8 -topk8 -outform DER -in xxx.rsa.pem -inform PEM -out xxx.pk8 -nocrypt</td>
</tr>
<tr>
<td>10</td>
<td>cer</td>
<td>jks</td>
<td>keytool -import -file xxx.cer -keystore xxx.jks</td>
</tr>
<tr>
<td>11</td>
<td>cer</td>
<td>bks</td>
<td>keytool -importcert -v -trustcacerts -alias xx -file xxx.cer -keystore xxx.bks -storetype BKS -storepass ‘123456’</td>
</tr>
<tr>
<td>12</td>
<td>bks</td>
<td>cer</td>
<td>keytool -export -alias xx -file xxx.cer -keystore xxx.bks -storetype BKS -provider org.bouncycastle.jce.provider.BouncyCastleProvider -storepass ‘123456’</td>
</tr>
<tr>
<td>13</td>
<td>cer</td>
<td>crt</td>
<td>openssl x509 -inform DER -in xxx.cer -out xxx.crt</td>
</tr>
<tr>
<td>14</td>
<td>pem</td>
<td>crt</td>
<td>openssl x509 -outform der -in xxx.pem -out xxx.crt</td>
</tr>
<tr>
<td>15</td>
<td>pem</td>
<td>cer</td>
<td>openssl x509 -inform pem -in xxx.pem -outform der -out xxx.cer</td>
</tr>
</tbody></table>
<p>另外:<br>查看 bks 文件中包含的证书<br>keytool -list -rfc -keystore xxx.bks -storetype BKS</p>
<p>查看 jks 文件中包含的证书<br>keytool -list -rfc -keystore xxx.jks -storetype JKS</p>
]]></content>
<categories>
<category>Android</category>
</categories>
<tags>
<tag>HTTPS</tag>
</tags>
</entry>
<entry>
<title>[Ynaqdh]到底是什么意思(what’s the meaning of [Ynadqh])</title>
<url>/2019/01/05/%5BYnaqdh%5D%E5%88%B0%E5%BA%95%E6%98%AF%E4%BB%80%E4%B9%88%E6%84%8F%E6%80%9D(what%E2%80%99s%20the%20meaning%20of%20%5BYnadqh%5D)/</url>
<content><![CDATA[<p><img src="http://p16vszsby.bkt.clouddn.com/ynaqdh.png?attname=&e=1514196708&token=NYX5b6QaVFGMB5vzHSgy0lp2jGcBlHXbg7YIca07:u-odOyrV96PHiZXnu5TU2z-3_q4" alt="image"></p>
<p>使用Mac终端时经常会碰见上图中的提醒 ++<strong>[ynaqdh]</strong>++ ,下面简单说明一下:</p>
<ul>
<li>Y - yes, overwrite</li>
<li>n - no, do not overwrite</li>
<li>a - all, overwrite this and all others</li>
<li>q - quit, abort</li>
<li>d - diff, show the differences between the old and the new</li>
<li>h - help, show this help</li>
</ul>
]]></content>
</entry>
<entry>
<title>第一行代码总结</title>
<url>/2018/12/12/%E7%AC%AC%E4%B8%80%E8%A1%8C%E4%BB%A3%E7%A0%81%E6%80%BB%E7%BB%93/</url>
<content><![CDATA[<ol>
<li>Android系统架构</li>
<li>为什么使用Log而不是System.out +</li>
<li>Activity的基本用法</li>
<li>Activity中如何使用Menu</li>
<li>Intent的使用(显示和隐式)</li>
<li>向下(上)一个Activity传递数据</li>
<li>Activity的四种状态,7个方法,3种生存期</li>
<li>Activity被回收了如何保存和恢复数据</li>
<li>Activity的四种启动模式</li>
<li>Activity的实践: 如何知晓当前Activity名称,如何随时退出程序,启动活动的最佳写法</li>
<li>常用系统控件: AlertDialog+构建,ProgressBar的构建</li>
<li>四种基本布局</li>
<li>引入布局,创建自定义控件</li>
<li>提升ListView性能,ListView点击事件</li>
<li>RecyclerView的基本用法(Adapter的编写),实现横向滚动和瀑布式布局</li>
<li>RecyclerView点击事件</li>
<li>Fragment的基本用法: 动态添加fragment(限定符的使用), 模拟返回栈, fragment与Activity之间通信</li>
<li>fragment的生命周期,4种状态,比Activity多了5个回调方法</li>
<li>广播机制简介(标准广播和有序广播)</li>
<li>如何接收广播(动态注册&静态注册)</li>
<li>如何发送广播(标准&有序) 如何使用本地广播</li>
<li>广播实践: 实现强制下线</li>
<li>数据持久化技术<br>1) 如何将数据写入文件中(以及读取)<br>2) 如何将数据存储到SharedPreferences(以及读取)<br>3) SQLite的使用(增删改查)<br>4) LitePal的使用(增删改查)</li>
<li>在程序运行时申请权限</li>
<li>ContentResolver 的基本用法(读取系统联系人)</li>
<li>创建自己的内容提供器ContentProvider</li>
<li>Notification 的使用,添加PendingIntent,点击之后消失的功能</li>
<li>Notification 进阶使用: 设置震动,提示音,呼吸灯,大文本,大图,优先级</li>
<li>调用摄像头拍照</li>
<li>从相册中选取照片</li>
<li>播放音频 播放视频</li>
<li>WebView的用法</li>
<li>HttpURLConnection的基本使用</li>
<li>OKHttp的基本使用</li>
<li>解析XML格式数据(PULL解析&SAX解析)</li>
<li>解析JSON格式数据(JSonObjective&Gson)</li>
<li>子线程中更新UI</li>
<li>异步消息处理机制分析</li>
<li>AsyncTask 的基本用法</li>
<li>服务的基本用法,启动和停止服务</li>
<li>活动和服务进行通信</li>
<li>Service 小技巧: 前台服务, IntentService</li>
<li>LBS(Location Based Serveice)基本位置的服务<br>1) 确定自己的位置<br>2) 实时更新当前的位置<br>3) 选择定位模式<br>4) 添加省市县位置信息<br>5) 让地图显示出来<br>6) 移动到我的位置<br>7) 让我显示出来</li>
<li>Material Design简介<br>Toolbar的基本用法(添加Menu,点击事件,最左加入一个导航按钮)<br>DrawerLayout 的基本用法(侧滑显示菜单)<br>NavigationView(侧滑菜单,Menu和headerLayout)<br>FloatingActionBar(悬浮按钮)<br>Snackbar(增加Undo按钮)<br>CoordinateLayout(加强版FrameLayout,自动帮助我们做出最为合理的响应)<br>CardView(卡片式布局)<br>APPBarLayout(防止滑动RecyclerView时遮挡Toolbar,该控件必须是CoordinateLayout的子布局)<br>SwipeRefreshLayout(下拉刷新)<br>CollapsingToolbarLayout(可折叠式标题,仅能作为APPBarLayout直接子布局使用)</li>
<li>充分利用系统状态栏</li>
<li>全局获取Context</li>
<li>使用Intent传递对象(Serializable方式和Parcelable方式)</li>
<li>创建定时任务,Alarm机制</li>
<li>Doze模式,多窗口模式</li>
<li>Lambda表达式</li>
</ol>
]]></content>
<categories>
<category>Android</category>
</categories>
<tags>
<tag>Android</tag>
</tags>
</entry>
<entry>
<title>如何在Mac上卸载Java</title>
<url>/2018/02/27/%E5%A6%82%E4%BD%95%E5%9C%A8Mac%E4%B8%8A%E5%8D%B8%E8%BD%BDJava/</url>
<content><![CDATA[<p>在“终端”窗口中,复制和粘贴命令:</p>
<p>sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin</p>
<p>sudo rm -fr /Library/PreferencesPanes/JavaControlPanel.prefPane</p>
<p>sudo rm -fr ~/Library/Application\ Support/Java</p>
]]></content>
<categories>
<category>Mac</category>
</categories>
<tags>
<tag>Mac</tag>
</tags>
</entry>
<entry>
<title>配置开机自启rails以及chromium</title>
<url>/2018/02/06/%E9%85%8D%E7%BD%AE%E5%BC%80%E6%9C%BA%E8%87%AA%E5%90%AFrails%E4%BB%A5%E5%8F%8Achromium/</url>
<content><![CDATA[<p><img src="http://p16vszsby.bkt.clouddn.com/stories_logo.svg?attname=&e=1517555769&token=NYX5b6QaVFGMB5vzHSgy0lp2jGcBlHXbg7YIca07:dVrK4uzv6s1E5ukGOGGRYGc4zqM" alt="image"></p>
<h1 id="Stories-Dashboard"><a href="#Stories-Dashboard" class="headerlink" title="Stories Dashboard"></a>Stories Dashboard</h1><p>To startup rails and chromium when the raspberry PI startup. </p>
<p><img src="https://img.shields.io/badge/rails-5.1.4-red.svg" alt="rails"> <img src="https://img.shields.io/badge/ruby-2.5.0-blue.svg" alt="ruby"> <img src="https://img.shields.io/badge/created-Jan%202018-brightgreen.svg" alt="created"></p>
<ol>
<li><strong>Clone repo</strong>, open Terminal enter this code</li>
</ol>
<blockquote>
<figure class="highlight plain"><figcaption><span>clone [email protected]:namiwang/stories-dashboard.git```</span></figcaption><table><tr><td class="code"><pre><span class="line"></span><br><span class="line"></span><br><span class="line">2. **Install gems**, run this lines of codes separately</span><br><span class="line"></span><br><span class="line">```cd stories-dashboard``` </span><br><span class="line">```bundle </span><br></pre></td></tr></table></figure>
</blockquote>
<ol start="3">
<li><strong>Change path</strong>, if the path you choose don’t like this <code>/home/pi/workspace/stories-dashboard</code>, you must edit two files in stories-dashboard/app/bin </li>
</ol>
<ul>
<li><p>startup</p>
<p> change<br> <del><code>cd /home/pi/workspace/stories-dashboard</code></del><br> into </p>
<figure class="highlight plain"><figcaption><span>/yourpath/stories-dashboard```</span></figcaption><table><tr><td class="code"><pre><span class="line"></span><br><span class="line">- rc.local</span><br><span class="line"></span><br><span class="line"> change </span><br><span class="line"> ~~```su pi -c "exec /home/pi/workspace/stories-dashboard/bin/startup"```~~ </span><br><span class="line"> into </span><br><span class="line"> ```su pi -c "exec /yourpath/stories-dashboard/bin/startup"</span><br></pre></td></tr></table></figure>
<ol start="4">
<li><blockquote>
<p><code>reboot</code> </p>
</blockquote>
</li>
</ol>
</li>
</ul>
<h2 id="Prohibited-raspberry-PI-sleeping"><a href="#Prohibited-raspberry-PI-sleeping" class="headerlink" title="Prohibited raspberry PI sleeping"></a>Prohibited raspberry PI sleeping</h2><ol>
<li>Open Terminal enter this command<blockquote>
<figure class="highlight plain"><figcaption><span>nano</span><a href="/etc/lightdm/lightdm.conf```">link</a></figcaption><table><tr><td class="code"><pre><span class="line"></span><br><span class="line">2. Press **"Ctrl + w"** to find ==[Seat:*]==, after this few lines you will see </span><br><span class="line">```# xserver-command=X``` </span><br><span class="line"></span><br><span class="line">change it into </span><br><span class="line"></span><br><span class="line">```xserver-command = X -s 0 -dpms``` </span><br><span class="line"></span><br><span class="line">it means to Close the screen saver and Display Power Management Signaling.</span><br><span class="line"></span><br><span class="line">3. > ```reboot </span><br></pre></td></tr></table></figure>
</blockquote>
</li>
</ol>
]]></content>
<categories>
<category>Raspberry Pi</category>
</categories>
<tags>
<tag>Rails</tag>
<tag>Raspberry Pi</tag>
</tags>
</entry>
<entry>
<title>树莓派禁止休眠</title>
<url>/2018/02/03/%E6%A0%91%E8%8E%93%E6%B4%BE%E7%A6%81%E6%AD%A2%E4%BC%91%E7%9C%A0/</url>
<content><![CDATA[<h2 id="Prohibited-raspberry-PI-sleeping"><a href="#Prohibited-raspberry-PI-sleeping" class="headerlink" title="Prohibited raspberry PI sleeping"></a>Prohibited raspberry PI sleeping</h2><ol>
<li>Open Terminal enter this command<blockquote>
<figure class="highlight plain"><figcaption><span>nano</span><a href="/etc/lightdm/lightdm.conf```">link</a></figcaption><table><tr><td class="code"><pre><span class="line"></span><br><span class="line">2. Press **"Ctrl + w"** find ==[Seat:*]==, after this few lines you will see </span><br><span class="line">```# xserver-command=X``` </span><br><span class="line"></span><br><span class="line">change it into </span><br><span class="line"></span><br><span class="line">```xserver-command = X -s 0 -dpms``` </span><br><span class="line"></span><br><span class="line">it means to Close the screen saver and Display Power Management Signaling.</span><br><span class="line">3. > ```reboot </span><br></pre></td></tr></table></figure>
</blockquote>
</li>
</ol>
]]></content>
<categories>
<category>Raspberry Pi</category>
</categories>
<tags>
<tag>Raspberry Pi</tag>
</tags>
</entry>
<entry>
<title>树莓派开启启动自定义脚本</title>
<url>/2018/02/01/%E6%A0%91%E8%8E%93%E6%B4%BE%E5%BC%80%E5%90%AF%E5%90%AF%E5%8A%A8/</url>
<content><![CDATA[<ol>
<li><p>nano /etc/rc.local 修改开机启动文件</p>
<p> 在 exit 0 这行代码之前添加</p>
<blockquote>
<p> su pi -c “exec /home/pi/stories.sh”</p>
</blockquote>
</li>
</ol>
<ol start="2">
<li>编辑启动rails server 和 Chromium 的脚本</li>
</ol>
<blockquote>
<p> #!/bin/sh</p>
<p>cd /home/pi/Documents/stories_dashboard</p>
<p>source ~/.profile</p>
<p>rails s &</p>
<p>sleep 15</p>
<p>DISPLAY=:0 chromium-browser -kiosk <a href="http://localhost:3000" target="_blank" rel="noopener">http://localhost:3000</a></p>
</blockquote>
<p>3.不要忘了修改stories.sh的权限</p>
<blockquote>
<pre><code>chmod 777 stories.sh</code></pre></blockquote>
]]></content>
<categories>
<category>Raspberry Pi</category>
</categories>
<tags>
<tag>Rails</tag>
<tag>Raspberry Pi</tag>
</tags>
</entry>
<entry>
<title>ror教程(ruby on rails)3</title>
<url>/2017/12/28/ror%E6%95%99%E7%A8%8B%EF%BC%88ruby-on-rails%EF%BC%893/</url>
<content><![CDATA[<p>Hash.new 可接受一个参数指明元素的默认值,即当键不存在时返回的值</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">>> h = Hash.new</span><br><span class="line">=> {}</span><br><span class="line">>> h[:foo] # 试图获取不存在的键 :foo 对应的值</span><br><span class="line">=> nil</span><br><span class="line">>> h = Hash.new(0) # 让不存在的键返回 0 而不是 nil</span><br><span class="line">=> {}</span><br><span class="line">>> h[:foo]</span><br><span class="line">=> 0</span><br></pre></td></tr></table></figure>
<p>在类中调用方法或访问属性时可以不用 self.(赋值例外)</p>
<h2 id="Confuse"><a href="#Confuse" class="headerlink" title="Confuse"></a>Confuse</h2><h1 id="不理解-yield"><a href="#不理解-yield" class="headerlink" title="不理解 yield"></a>不理解 yield</h1><p>pbcopy ~/.ssh/id_rsa.pub</p>
<p> .card-img-overlay<br> .d-flex.pt-5.pb-3.px-2<br> .card-text.text-white.pl-2= post.summary</p>
<pre><code>tag颜色,动态加载,搜索,排行。
react,flutter。</code></pre>]]></content>
<categories>
<category>Rails</category>
</categories>
<tags>
<tag>Rails</tag>
</tags>
</entry>
<entry>
<title>Rails 提示 Looks like your apps bin rails is a stub that was generated by Bund</title>
<url>/2017/12/28/Rails-%E6%8F%90%E7%A4%BA-Looks-like-your-apps-bin-rails-is-a-stub-that-was-generated-by-Bund/</url>
<content><![CDATA[<p>Rails 提示 Looks like your app’s ./bin/rails is a stub that was generated by Bundler.</p>
<p><img src="http://p16vszsby.bkt.clouddn.com/rails_issue_tips.png?attname=&e=1514445128&token=NYX5b6QaVFGMB5vzHSgy0lp2jGcBlHXbg7YIca07:LyVSwgYzyFIGDFLy6dUX_8sIWi8" alt="image"></p>
<h6 id="无缘无故的输入rails相关指令出现了一大堆tips,目前还没有影响运行,但是看着很不爽。"><a href="#无缘无故的输入rails相关指令出现了一大堆tips,目前还没有影响运行,但是看着很不爽。" class="headerlink" title="无缘无故的输入rails相关指令出现了一大堆tips,目前还没有影响运行,但是看着很不爽。"></a>无缘无故的输入rails相关指令出现了一大堆tips,目前还没有影响运行,但是看着很不爽。</h6><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">Looks like your app's ./bin/rails is a stub that was generated by Bundler.</span><br><span class="line"></span><br><span class="line">In Rails 5, your app's bin/ directory contains executables that are versioned</span><br><span class="line">like any other source code, rather than stubs that are generated on demand.</span><br><span class="line"></span><br><span class="line">Here's how to upgrade:</span><br><span class="line"></span><br><span class="line"> bundle config --delete bin # Turn off Bundler's stub generator</span><br><span class="line"> rails app:update:bin # Use the new Rails 5 executables</span><br><span class="line"> git add bin # Add bin/ to source control</span><br><span class="line"></span><br><span class="line">You may need to remove bin/ from your .gitignore as well.</span><br></pre></td></tr></table></figure>
<h6 id="尝试按照其中的提示解决这个问题"><a href="#尝试按照其中的提示解决这个问题" class="headerlink" title="尝试按照其中的提示解决这个问题"></a>尝试按照其中的提示解决这个问题</h6><p>输入如下指令</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">rails app:update:bin</span><br></pre></td></tr></table></figure>
<p><img src="http://p16vszsby.bkt.clouddn.com/rails_issue_solution.png?attname=&e=1514445128&token=NYX5b6QaVFGMB5vzHSgy0lp2jGcBlHXbg7YIca07:gMnRViHhqWh6oDmB1qK7LGj-dqY" alt="image"></p>
<p>问题完美解决了。</p>
<p><img src="http://p16vszsby.bkt.clouddn.com/rails_issue_result.png?attname=&e=1514445128&token=NYX5b6QaVFGMB5vzHSgy0lp2jGcBlHXbg7YIca07:Qhu1XGU8QnHi4hoLXLFXD7XyjGA" alt="image"></p>
]]></content>
<categories>
<category>Rails</category>
</categories>
<tags>
<tag>Rails</tag>
</tags>
</entry>
<entry>
<title>rails 提示没有匹配的路由(no route matches)</title>
<url>/2017/12/27/rails-%E6%8F%90%E7%A4%BA%E6%B2%A1%E6%9C%89%E5%8C%B9%E9%85%8D%E7%9A%84%E8%B7%AF%E7%94%B1-no-route-matches/</url>
<content><![CDATA[<h1 id="No-route-matches"><a href="#No-route-matches" class="headerlink" title="No route matches"></a>No route matches</h1><p><img src="http://p16vszsby.bkt.clouddn.com/no_route_matches.png?attname=&e=1514442700&token=NYX5b6QaVFGMB5vzHSgy0lp2jGcBlHXbg7YIca07:ZqqhszZqoE67WXLDgRgK12iS8MM" alt="image"></p>
<p>今天在跟着做 Ruby on Rails 教程第五章的例子时,遇到了一个问题 No route maches</p>
<p>代码如下</p>
<p><img src="http://p16vszsby.bkt.clouddn.com/no_route_maches_code.png?attname=&e=1514442795&token=NYX5b6QaVFGMB5vzHSgy0lp2jGcBlHXbg7YIca07:wX1LfWieeycOo_hyS5VuzqLwlI0" alt="image"></p>
<p>最后发现是在path那里多加了单引号导致的,删掉之后完美运行。</p>
<p><img src="http://p16vszsby.bkt.clouddn.com/no_route_maches_right.png?attname=&e=1514443115&token=NYX5b6QaVFGMB5vzHSgy0lp2jGcBlHXbg7YIca07:gfnTqUBePUl5Rt75RasB0MOzqbQ" alt="image"></p>
]]></content>
<categories>
<category>Rails</category>
</categories>
<tags>
<tag>Rails</tag>
</tags>
</entry>
<entry>
<title>rails 提示没有匹配的路由(no route matches)</title>
<url>/2017/12/27/rails-%E6%8F%90%E7%A4%BA%E6%B2%A1%E6%9C%89%E5%8C%B9%E9%85%8D%E7%9A%84%E8%B7%AF%E7%94%B1-no-route-matches-1/</url>
<content><![CDATA[<h1 id="No-route-matches"><a href="#No-route-matches" class="headerlink" title="No route matches"></a>No route matches</h1><p><img src="http://p16vszsby.bkt.clouddn.com/no_route_matches.png?attname=&e=1514442700&token=NYX5b6QaVFGMB5vzHSgy0lp2jGcBlHXbg7YIca07:ZqqhszZqoE67WXLDgRgK12iS8MM" alt="image"></p>
<p>今天在跟着做 Ruby on Rails 教程第五章的例子时,遇到了一个问题 No route maches</p>
<p>代码如下</p>
<p><img src="http://p16vszsby.bkt.clouddn.com/no_route_maches_code.png?attname=&e=1514442795&token=NYX5b6QaVFGMB5vzHSgy0lp2jGcBlHXbg7YIca07:wX1LfWieeycOo_hyS5VuzqLwlI0" alt="image"></p>
<p>最后发现是在path那里多加了单引号导致的,删掉之后完美运行。</p>
<p><img src="http://p16vszsby.bkt.clouddn.com/no_route_maches_right.png?attname=&e=1514443115&token=NYX5b6QaVFGMB5vzHSgy0lp2jGcBlHXbg7YIca07:gfnTqUBePUl5Rt75RasB0MOzqbQ" alt="image"></p>
]]></content>
<categories>
<category>Rails</category>
</categories>
<tags>
<tag>Rails</tag>
</tags>
</entry>
<entry>
<title>ror教程(ruby on rails)2</title>
<url>/2017/12/27/demo/</url>
<content><![CDATA[<p>test controller 中可以通过使用setup来初始化一些变量</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">require 'test_helper'</span><br><span class="line"></span><br><span class="line">class StaticPagesControllerTest < ActionDispatch::IntegrationTest</span><br><span class="line"></span><br><span class="line"> def setup</span><br><span class="line"> @base_title = "Ruby on Rails Tutorial Sample App"</span><br><span class="line"> end</span><br><span class="line"></span><br><span class="line"> test "should get home" do</span><br><span class="line"> get static_pages_home_url</span><br><span class="line"> assert_response :success</span><br><span class="line"> assert_select "title", "Home | #{@base_title}" </span><br><span class="line"> end</span><br><span class="line"></span><br><span class="line"> test "should get help" do</span><br><span class="line"> get static_pages_help_url</span><br><span class="line"> assert_response :success</span><br><span class="line"> assert_select "title", "Help | #{@base_title}"</span><br><span class="line"> end</span><br><span class="line"></span><br><span class="line"> test "should get about" do</span><br><span class="line"> get static_pages_about_url</span><br><span class="line"> assert_response :success</span><br><span class="line"> assert_select "title", "About | #{@base_title}"</span><br><span class="line"> end</span><br><span class="line">end</span><br></pre></td></tr></table></figure>
<p>定义和使用变量时不要忘记加 @ 符号</p>
<p>provide </p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line"><% provide(:title, "Home") %></span><br><span class="line"><!DOCTYPE html></span><br><span class="line"><html></span><br><span class="line"> <head></span><br><span class="line"> <title><%= yield(:title) %> | Ruby on Rails Tutorial Sample App</title></span><br><span class="line"> </head></span><br><span class="line"> <body></span><br><span class="line"> <h1>Sample App</h1></span><br><span class="line"> <p></span><br><span class="line"> This is the home page for the</span><br><span class="line"> <a href="http://www.railstutorial.org/">Ruby on Rails Tutorial</a></span><br><span class="line"> sample application.</span><br><span class="line"> </p></span><br><span class="line"> </body></span><br><span class="line"></html></span><br></pre></td></tr></table></figure>
<p>provide 与 content_for 区别</p>
<blockquote>
<p>The same as content_for but when used with streaming flushes straight back to the layout. In other words, if you want to concatenate several times to the same buffer when rendering a given template, you should use content_for, if not, use provide to tell the layout to stop looking for more contents.</p>
</blockquote>
<p>not something we can merge</p>
<p>单引号字符串不能进行插值操作</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">>> string = 'dashy'</span><br><span class="line">=> "dashy"</span><br><span class="line">>> puts "The string '#{string}' is nonempty." if string.empty?</span><br><span class="line">=> nil</span><br><span class="line">>> puts "The string '#{string}' is nonempty." unless string.empty?</span><br><span class="line">The string 'dashy' is nonempty.</span><br><span class="line">=> nil</span><br></pre></td></tr></table></figure>
<p>可以使用 !!(读作“bang bang”)对对象做两次取反操作,把对象转换成布尔值</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">>> a = %w[foo bar baz quux]</span><br><span class="line">=> ["foo", "bar", "baz", "quux"]</span><br><span class="line">>> a[0..2]</span><br><span class="line">=> ["foo", "bar", "baz"]</span><br></pre></td></tr></table></figure>
<p>值域的结束值使用 -1 时,不用知道数组的长度就能从起始值开始一直获取到最后一个元素。</p>
]]></content>
<categories>
<category>Rails</category>
</categories>
<tags>
<tag>Rails</tag>
</tags>
</entry>
<entry>
<title>ror教程(ruby on rails)1</title>
<url>/2017/12/26/ror%E6%95%99%E7%A8%8B%EF%BC%88ruby%20rails%EF%BC%891/</url>
<content><![CDATA[<p> git rm -r –cached .<br> 删除暂存区中的全部文件(未commit 已add)<br> git checkout -f<br> 恢复未add 的文件</p>
<p> scaffold 脚手架生成资源<br> 资源可以理解为model(数据模型)+view(web页面),可以通过http协议在网页中创建、读取、更新和删除。</p>
<p> REST 架构由计算机科学家 Roy Fielding 提出,意思是“表现层状态转化”(Representational State Transfer)</p>
<p> REST 是一种架构风格,用于开发分布式、基于网络的系统和软件应用,例如万维网和 Web 应用。REST 理论很抽象,在 Rails 应用中,REST 意味着大多数组件(例如用户和微博)都被模型化,变成资源(resource),可以创建(create)、读取(read)、更新(update)和删除(delete)。这些操作与关系型数据库中的 CRUD 操作和 HTTP 请求方法(POST、GET、PATCH 和 DELETE)对应。</p>
]]></content>
<categories>
<category>Rails</category>
</categories>
<tags>
<tag>Rails</tag>
</tags>
</entry>
<entry>
<title>BMI 计算器(BMI Calculator)</title>
<url>/2017/12/21/BMI%20%E8%AE%A1%E7%AE%97%E5%99%A8(BMI%20Calculator)/</url>
<content><![CDATA[<p>这两天看高見龍老师的为你自己学ruby on rails 教程,其中有一个比较简单的Demo,就是这个BMI <a href="http://railsbook.tw/chapters/12-controllers.html#bmi-calculator" target="_blank" rel="noopener">Calculator</a>,自己动手跟着实现了一下,顺便写一篇博客记录一下,加深印象。</p>
<p>最终效果如下,输入身高体重点击开始计算后会得出BMI值,UI比较简陋,重要的是理解rails的整个流程。<br><img src="http://p16vszsby.bkt.clouddn.com/image/bmi_calculator_1.png?attname=&e=1513831002&token=NYX5b6QaVFGMB5vzHSgy0lp2jGcBlHXbg7YIca07:l3Y4HWpFHBt6bGhG6GaSNcoJnOU" alt="image"></p>
<p><img src="http://p16vszsby.bkt.clouddn.com/image/bmi_calculator_2.png?attname=&e=1513831002&token=NYX5b6QaVFGMB5vzHSgy0lp2jGcBlHXbg7YIca07:coxWBD3UH2mypunrMJHsM5irGVc" alt="image"></p>
<ol start="0">
<li>新建一个rails项目:<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">rails new bmi</span><br></pre></td></tr></table></figure></li>
<li>创建控制器(controller)</li>
</ol>
<p>首先切换到项目</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">cd bmi</span><br></pre></td></tr></table></figure>
<p>之后输入如下指令用来创建控制器</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">rails generate controller bmi index</span><br><span class="line">或者</span><br><span class="line">rails g controller bmi index</span><br></pre></td></tr></table></figure>
<p>上面的指令会自动帮助我们做三件事</p>
<ul>
<li><p>加上route,打开config/route.rb文件</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">Rails.application.routes.draw do</span><br><span class="line"> get 'bmi/index'</span><br><span class="line"></span><br><span class="line"> # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html</span><br><span class="line">end</span><br></pre></td></tr></table></figure>
<p>将其中的</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">get 'bmi/index'</span><br></pre></td></tr></table></figure>
<p>改写成</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">get 'bmi', to: 'bmi#index'</span><br></pre></td></tr></table></figure>
<p>并且添加</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">post "bmi/result", to: "bmi#result"</span><br></pre></td></tr></table></figure>
</li>
<li><p>controller中加上名为 index 的 Action<br>打开app/controllers/bmi_controller.rb,其中内容如下</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">class BmiController < ApplicationController</span><br><span class="line"> def index</span><br><span class="line"> end</span><br><span class="line">end</span><br></pre></td></tr></table></figure></li>
<li><p>创建app/views/bmi/index.html.erb文件<br>打开app/views/bmi/index.html.erb,其中内容如下</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line"><h1>Bmi#index</h1></span><br><span class="line"><p>Find me in app/views/bmi/index.html.erb</p></span><br></pre></td></tr></table></figure>
</li>
</ul>
<ol start="2">
<li>建立输入表单<br>编辑index.html.erb,将其改为如下内容<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line"><h1>BMI 计算器</h1></span><br><span class="line"><%= form_tag 'bmi/result' do %> </span><br><span class="line"> 身高: <%= text_field_tag 'body_height' %> 公分<br/></span><br><span class="line"> 体重: <%= text_field_tag 'body_weight' %> 公斤<br/></span><br><span class="line"> <%= submit_tag '开始计算' %></span><br><span class="line"><% end %></span><br></pre></td></tr></table></figure>
form_tag,text_field_tag 和 submit_tag 是 rails 的 <a href="http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html" target="_blank" rel="noopener">TagHelper</a>,可以点进去详细的看一下。</li>
</ol>
<p>看一下index页面的源码,这些都是刚刚的TagHelper的功劳。<br><img src="http://p16vszsby.bkt.clouddn.com/image/form_tag.png?attname=&e=1513835331&token=NYX5b6QaVFGMB5vzHSgy0lp2jGcBlHXbg7YIca07:0Rg6pMzVRppl4XgWcM2KzySN9tc" alt="image"></p>
<ol start="3">
<li>现在输入的表单有了,需要去实现计算BMI的功能,上一步的表单会把数据提交到result的action计算。编辑app/controller/bmi_controller.rb,添加名为result的action<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">class BmiController < ApplicationController</span><br><span class="line"> def index</span><br><span class="line"> end</span><br><span class="line"></span><br><span class="line"> def result</span><br><span class="line"> height = params[:body_height].to_f / 100</span><br><span class="line"> weight = params[:body_weight].to_f</span><br><span class="line"></span><br><span class="line"> @bmi = (weight/ (height * height)).round(2)</span><br><span class="line"> end</span><br><span class="line">end</span><br></pre></td></tr></table></figure></li>
<li>计算出的结果需要显示出来,所以我们需要新建一个app/views/bmi/result.html.erb文件<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line"><h1>您的BMI值为: <%= @bmi %> <h1></span><br></pre></td></tr></table></figure>
</li>
</ol>
<p>现在项目部署一下应该就可以成功运行了~</p>
]]></content>
<tags>
<tag>Rails</tag>
</tags>
</entry>
<entry>
<title>如何重新命名Git分支(how to rename a git branch locally and remotely?</title>
<url>/2017/12/15/rename-git-branch/</url>
<content><![CDATA[<ol>
<li>git branch -m <old_name> <new_name></li>
<li>git checkout <new_name></li>
<li>git push origin <new_name></li>
<li>git push origin -d <old_name></li>
</ol>
<p>参考自:<a href="https://stackoverflow.com/questions/36999937/how-to-rename-a-git-branch-locally-and-remotely++" target="_blank" rel="noopener">https://stackoverflow.com/questions/36999937/how-to-rename-a-git-branch-locally-and-remotely++</a></p>
]]></content>
<tags>
<tag>Git</tag>
</tags>
</entry>
</search>