tag:blogger.com,1999:blog-85084083860872245002024-02-19T09:50:53.342+08:00Bring elegant by indirectionAnonymoushttp://www.blogger.com/profile/01293468005249034620noreply@blogger.comBlogger41125tag:blogger.com,1999:blog-8508408386087224500.post-17376349351975545722016-02-01T21:53:00.003+08:002016-02-02T22:19:28.045+08:00Open Source my iOS game: Mission999<span style="background-color: white; color: #333333; font-family: "helvetica neue" , "helvetica" , "stheiti" , , , "arial" , "tahoma" , sans-serif , serif; font-size: medium; line-height: 1.5em; outline: none;">iOS Game Mission999<br style="outline: none;" /><br style="outline: none;" />itunes: <a href="https://itunes.apple.com/au/app/mission-999/id1036686316?mt=8" id="url_1" style="color: #0070af; margin: 0px; outline: none; padding: 0px; text-decoration: none;" target="_blank">https://itunes.apple.com/au/app/mission-999/id1036686316?mt=8</a><br style="outline: none;" />code : <a href="https://github.com/whunmr/Mission999" id="url_2" style="color: #0070af; margin: 0px; outline: none; padding: 0px; text-decoration: none;" target="_blank">https://github.com/whunmr/Mission999</a><br style="outline: none;" />map editor code: <a href="https://github.com/whunmr/Method-Draw-Game-Map-Editor" id="url_3" style="color: #0070af; margin: 0px; outline: none; padding: 0px; text-decoration: none;" target="_blank">https://github.com/whunmr/Method-Draw-Game-Map-Editor</a></span><br />
<br />
<br />
The map is in edited by Method-Draw in SVG format, after edit the map can be send through by WebSocket directly into iOS app, to achieve a short edit-->try-->re-edit loop feedback.<br />
<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGyj1U0EGRi4ErLMM0sFdsmcRElZoFT8JFZk0G7x6G78Eb94NDZh-9endTopUgxm14ve_SUoKkgVrUNIOa5eMcT9duMRuQPnraE5zIBSKg7T2jr1DnHYFAT1DZ8qrHGbCcnAKR7_xgxSc/s1600/1.jpg" imageanchor="1"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGyj1U0EGRi4ErLMM0sFdsmcRElZoFT8JFZk0G7x6G78Eb94NDZh-9endTopUgxm14ve_SUoKkgVrUNIOa5eMcT9duMRuQPnraE5zIBSKg7T2jr1DnHYFAT1DZ8qrHGbCcnAKR7_xgxSc/s1600/1.jpg" /></a><br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjETR0iDKhA3EiFBNBfcJeDCfAxt3Z8GlnrFeCagtQdR_rN-0GPKNN8kxbZ7pWRJBuaMopxJvIO_svh0pBbVkykKfT0ieI1X6qFnu59kEGMxKN_6dKomJUqBuiENUNqv-nluf1Vxr1IHZU/s1600/2.jpg" imageanchor="1"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjETR0iDKhA3EiFBNBfcJeDCfAxt3Z8GlnrFeCagtQdR_rN-0GPKNN8kxbZ7pWRJBuaMopxJvIO_svh0pBbVkykKfT0ieI1X6qFnu59kEGMxKN_6dKomJUqBuiENUNqv-nluf1Vxr1IHZU/s1600/2.jpg" /></a><br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsGZJG_6CTwjTYtZ877ms5DqQaCBqA5aEelRiwl5Bvm5BxQuZylUvriuH_KrDiB19waVdrTtYqHvr_kd4FrnSVMnYoaMK5kFA4I5CfpBjvIA7c0SA19pDs1z7slRDWGa4MEmsa2ygnQeE/s1600/3.jpg" imageanchor="1"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsGZJG_6CTwjTYtZ877ms5DqQaCBqA5aEelRiwl5Bvm5BxQuZylUvriuH_KrDiB19waVdrTtYqHvr_kd4FrnSVMnYoaMK5kFA4I5CfpBjvIA7c0SA19pDs1z7slRDWGa4MEmsa2ygnQeE/s1600/3.jpg" /></a><br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNc_vnOVf_FXPzWJotGwGClGANMsb_l04UY3eDFKDbZzX6AuddKefvVWHybKdA98hnjEDF2FxNLEuFRTi1YTy-qriJdhYf6cpRySjEKbyXjDhssatuCSxjLfrOPWI4CwjM8VzEnIVfyVo/s1600/4.jpg" imageanchor="1"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNc_vnOVf_FXPzWJotGwGClGANMsb_l04UY3eDFKDbZzX6AuddKefvVWHybKdA98hnjEDF2FxNLEuFRTi1YTy-qriJdhYf6cpRySjEKbyXjDhssatuCSxjLfrOPWI4CwjM8VzEnIVfyVo/s1600/4.jpg" /></a><br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen="" class="YOUTUBE-iframe-video" data-thumbnail-src="https://i.ytimg.com/vi/0RuEkEmvKkw/0.jpg" frameborder="0" height="266" src="https://www.youtube.com/embed/0RuEkEmvKkw?feature=player_embedded" style="clear: left; float: left;" width="320"></iframe></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<iframe allowfullscreen="" class="YOUTUBE-iframe-video" data-thumbnail-src="https://i.ytimg.com/vi/Avy3sNBRVzM/0.jpg" frameborder="0" height="266" src="https://www.youtube.com/embed/Avy3sNBRVzM?feature=player_embedded" width="320"></iframe><br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<iframe allowfullscreen="" class="YOUTUBE-iframe-video" data-thumbnail-src="https://i.ytimg.com/vi/m1L5oyUA1dI/0.jpg" frameborder="0" height="266" src="https://www.youtube.com/embed/m1L5oyUA1dI?feature=player_embedded" width="320"></iframe><br />
<br />
<br />
<a href="https://camo.githubusercontent.com/751724d3f2ef57cf2657c618cb7f3a6efb739809/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c302e737667" target="_blank"><img alt="Alt text" data-canonical-src="https://cdn.rawgit.com/whunmr/Mission999/master/findit/level0.svg" src="https://camo.githubusercontent.com/751724d3f2ef57cf2657c618cb7f3a6efb739809/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c302e737667" style="max-width: 100%;" /></a><br />
<a href="https://camo.githubusercontent.com/9f0f0826e20f180448f3d7653cba822505a1ffcc/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c312e737667" target="_blank"><img alt="Alt text" data-canonical-src="https://cdn.rawgit.com/whunmr/Mission999/master/findit/level1.svg" src="https://camo.githubusercontent.com/9f0f0826e20f180448f3d7653cba822505a1ffcc/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c312e737667" style="max-width: 100%;" /></a><br />
<a href="https://camo.githubusercontent.com/c11f1805cc5f8b83636d96c220bbc222238ffb5e/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c322e737667" target="_blank"><img alt="Alt text" data-canonical-src="https://cdn.rawgit.com/whunmr/Mission999/master/findit/level2.svg" src="https://camo.githubusercontent.com/c11f1805cc5f8b83636d96c220bbc222238ffb5e/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c322e737667" style="max-width: 100%;" /></a><br />
<a href="https://camo.githubusercontent.com/5686532885a71ba4228449d9fbb845c466c3bceb/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c332e737667" target="_blank"><img alt="Alt text" data-canonical-src="https://cdn.rawgit.com/whunmr/Mission999/master/findit/level3.svg" src="https://camo.githubusercontent.com/5686532885a71ba4228449d9fbb845c466c3bceb/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c332e737667" style="max-width: 100%;" /></a><br />
<a href="https://camo.githubusercontent.com/13f2798bdada20eefbdce68cadd0879dda77358b/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c342e737667" target="_blank"><img alt="Alt text" data-canonical-src="https://cdn.rawgit.com/whunmr/Mission999/master/findit/level4.svg" src="https://camo.githubusercontent.com/13f2798bdada20eefbdce68cadd0879dda77358b/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c342e737667" style="max-width: 100%;" /></a><br />
<a href="https://camo.githubusercontent.com/18205534ac2445811ede4d72332eb8cc93a48dc9/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c352e737667" target="_blank"><img alt="Alt text" data-canonical-src="https://cdn.rawgit.com/whunmr/Mission999/master/findit/level5.svg" src="https://camo.githubusercontent.com/18205534ac2445811ede4d72332eb8cc93a48dc9/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c352e737667" style="max-width: 100%;" /></a><br />
<a href="https://camo.githubusercontent.com/14c2dea38caf7ac66cf0911e34c26a2de76fff9f/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c362e737667" target="_blank"><img alt="Alt text" data-canonical-src="https://cdn.rawgit.com/whunmr/Mission999/master/findit/level6.svg" src="https://camo.githubusercontent.com/14c2dea38caf7ac66cf0911e34c26a2de76fff9f/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c362e737667" style="max-width: 100%;" /></a><br />
<a href="https://camo.githubusercontent.com/fbed4bbcffa0e97aead4bb0d42d2632f744f78ff/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c372e737667" target="_blank"><img alt="Alt text" data-canonical-src="https://cdn.rawgit.com/whunmr/Mission999/master/findit/level7.svg" src="https://camo.githubusercontent.com/fbed4bbcffa0e97aead4bb0d42d2632f744f78ff/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c372e737667" style="max-width: 100%;" /></a><br />
<a href="https://camo.githubusercontent.com/01a3df14db8c36981946e6eef0e338e8006d8e19/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c382e737667" target="_blank"><img alt="Alt text" data-canonical-src="https://cdn.rawgit.com/whunmr/Mission999/master/findit/level8.svg" src="https://camo.githubusercontent.com/01a3df14db8c36981946e6eef0e338e8006d8e19/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c382e737667" style="max-width: 100%;" /></a><br />
<a href="https://camo.githubusercontent.com/00b4ac170c34b6a9e887aa3440c33430dd1544a5/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c392e737667" target="_blank"><img alt="Alt text" data-canonical-src="https://cdn.rawgit.com/whunmr/Mission999/master/findit/level9.svg" src="https://camo.githubusercontent.com/00b4ac170c34b6a9e887aa3440c33430dd1544a5/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c392e737667" style="max-width: 100%;" /></a><br />
<a href="https://camo.githubusercontent.com/ad6cebad92dceca03b5ae3b7ae7cdeae7db64d01/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c31302e737667" target="_blank"><img alt="Alt text" data-canonical-src="https://cdn.rawgit.com/whunmr/Mission999/master/findit/level10.svg" src="https://camo.githubusercontent.com/ad6cebad92dceca03b5ae3b7ae7cdeae7db64d01/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c31302e737667" style="max-width: 100%;" /></a><br />
<a href="https://camo.githubusercontent.com/89a771e2c2fd8d26a820ac13a6a4a57a5e5285ee/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c31312e737667" target="_blank"><img alt="Alt text" data-canonical-src="https://cdn.rawgit.com/whunmr/Mission999/master/findit/level11.svg" src="https://camo.githubusercontent.com/89a771e2c2fd8d26a820ac13a6a4a57a5e5285ee/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c31312e737667" style="max-width: 100%;" /></a><br />
<a href="https://camo.githubusercontent.com/e43e5984dd98709e509f6db1ea312f5312f6d3ad/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c31322e737667" target="_blank"><img alt="Alt text" data-canonical-src="https://cdn.rawgit.com/whunmr/Mission999/master/findit/level12.svg" src="https://camo.githubusercontent.com/e43e5984dd98709e509f6db1ea312f5312f6d3ad/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c31322e737667" style="max-width: 100%;" /></a><br />
<a href="https://camo.githubusercontent.com/5d638159939a87b84ac54d2f3b325abd47796d40/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c31332e737667" target="_blank"><img alt="Alt text" data-canonical-src="https://cdn.rawgit.com/whunmr/Mission999/master/findit/level13.svg" src="https://camo.githubusercontent.com/5d638159939a87b84ac54d2f3b325abd47796d40/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c31332e737667" style="max-width: 100%;" /></a><br />
<a href="https://camo.githubusercontent.com/d47a8920a148a8edd0715ec7ec67a51238676a28/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c31342e737667" target="_blank"><img alt="Alt text" data-canonical-src="https://cdn.rawgit.com/whunmr/Mission999/master/findit/level14.svg" src="https://camo.githubusercontent.com/d47a8920a148a8edd0715ec7ec67a51238676a28/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c31342e737667" style="max-width: 100%;" /></a><br />
<a href="https://camo.githubusercontent.com/972853367457ca0404c411719c161baec22f6d6a/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c31352e737667" target="_blank"><img alt="Alt text" data-canonical-src="https://cdn.rawgit.com/whunmr/Mission999/master/findit/level15.svg" src="https://camo.githubusercontent.com/972853367457ca0404c411719c161baec22f6d6a/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c31352e737667" style="max-width: 100%;" /></a><br />
<a href="https://camo.githubusercontent.com/20ba22616b61c89bbb18f4770f7fddbb39eb4628/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c31362e737667" target="_blank"><img alt="Alt text" data-canonical-src="https://cdn.rawgit.com/whunmr/Mission999/master/findit/level16.svg" src="https://camo.githubusercontent.com/20ba22616b61c89bbb18f4770f7fddbb39eb4628/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c31362e737667" style="max-width: 100%;" /></a><br />
<a href="https://camo.githubusercontent.com/e4e6487d50b7e3f451e5995d337aedb51ba6e927/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c31372e737667" target="_blank"><img alt="Alt text" data-canonical-src="https://cdn.rawgit.com/whunmr/Mission999/master/findit/level17.svg" src="https://camo.githubusercontent.com/e4e6487d50b7e3f451e5995d337aedb51ba6e927/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c31372e737667" style="max-width: 100%;" /></a><br />
<a href="https://camo.githubusercontent.com/82a96dfc27c942395f51c5504a698c2fc4cd6074/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c31382e737667" target="_blank"><img alt="Alt text" data-canonical-src="https://cdn.rawgit.com/whunmr/Mission999/master/findit/level18.svg" src="https://camo.githubusercontent.com/82a96dfc27c942395f51c5504a698c2fc4cd6074/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c31382e737667" style="max-width: 100%;" /></a><br />
<a href="https://camo.githubusercontent.com/3b68aee13403cdda79f8f8b3a7137b42b9148e51/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c31392e737667" target="_blank"><img alt="Alt text" data-canonical-src="https://cdn.rawgit.com/whunmr/Mission999/master/findit/level19.svg" src="https://camo.githubusercontent.com/3b68aee13403cdda79f8f8b3a7137b42b9148e51/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c31392e737667" style="max-width: 100%;" /></a><br />
<a href="https://camo.githubusercontent.com/4b585f1a39a27e52e3af007a13920dfbf810d4b7/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c32302e737667" target="_blank"><img alt="Alt text" data-canonical-src="https://cdn.rawgit.com/whunmr/Mission999/master/findit/level20.svg" src="https://camo.githubusercontent.com/4b585f1a39a27e52e3af007a13920dfbf810d4b7/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c32302e737667" style="max-width: 100%;" /></a><br />
<a href="https://camo.githubusercontent.com/15d90a9951e1f050e50da4a2ae4df7d10f383176/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c32312e737667" target="_blank"><img alt="Alt text" data-canonical-src="https://cdn.rawgit.com/whunmr/Mission999/master/findit/level21.svg" src="https://camo.githubusercontent.com/15d90a9951e1f050e50da4a2ae4df7d10f383176/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c32312e737667" style="max-width: 100%;" /></a><br />
<a href="https://camo.githubusercontent.com/f68323652a3fd3b57802b61b387ad0aa4b707c55/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c32322e737667" target="_blank"><img alt="Alt text" data-canonical-src="https://cdn.rawgit.com/whunmr/Mission999/master/findit/level22.svg" src="https://camo.githubusercontent.com/f68323652a3fd3b57802b61b387ad0aa4b707c55/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c32322e737667" style="max-width: 100%;" /></a><br />
<a href="https://camo.githubusercontent.com/bb812217e2aac723f6b61d320f330fff64129be4/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c32332e737667" target="_blank"><img alt="Alt text" data-canonical-src="https://cdn.rawgit.com/whunmr/Mission999/master/findit/level23.svg" src="https://camo.githubusercontent.com/bb812217e2aac723f6b61d320f330fff64129be4/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c32332e737667" style="max-width: 100%;" /></a><br />
<a href="https://camo.githubusercontent.com/8d0297c650154c5c82d497052933f42383749d26/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c32342e737667" target="_blank"><img alt="Alt text" data-canonical-src="https://cdn.rawgit.com/whunmr/Mission999/master/findit/level24.svg" src="https://camo.githubusercontent.com/8d0297c650154c5c82d497052933f42383749d26/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c32342e737667" style="max-width: 100%;" /></a><br />
<a href="https://camo.githubusercontent.com/8a64076e0721b23c431d521f1c781a5086e0112b/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c35382e737667" target="_blank"><img alt="Alt text" data-canonical-src="https://cdn.rawgit.com/whunmr/Mission999/master/findit/level58.svg" src="https://camo.githubusercontent.com/8a64076e0721b23c431d521f1c781a5086e0112b/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c35382e737667" style="max-width: 100%;" /></a><br />
<a href="https://camo.githubusercontent.com/b98c148ff8037f0ce224b21b7d357ef21df20f2a/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c35392e737667" target="_blank"><img alt="Alt text" data-canonical-src="https://cdn.rawgit.com/whunmr/Mission999/master/findit/level59.svg" src="https://camo.githubusercontent.com/b98c148ff8037f0ce224b21b7d357ef21df20f2a/68747470733a2f2f63646e2e7261776769742e636f6d2f7768756e6d722f4d697373696f6e3939392f6d61737465722f66696e6469742f6c6576656c35392e737667" style="max-width: 100%;" /></a><br />
<br />
<br />Anonymoushttp://www.blogger.com/profile/01293468005249034620noreply@blogger.com0tag:blogger.com,1999:blog-8508408386087224500.post-82522026144007404502016-01-29T11:42:00.002+08:002016-01-29T11:43:50.684+08:00Internal DSL or External DSL?<div style="font-family: -webkit-standard; font-size: 14px;">
<b><span style="font-size: 24px;">DSL:</span></b></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<span style="font-family: "minionpro"; font-size: 11.000000pt;">A</span> <span style="font-family: "minionpro"; font-size: 11.000000pt; font-style: italic;">domain-specific language</span> <span style="font-family: "minionpro"; font-size: 11.000000pt;">(DSL) is a programming language that mimics the terms, idioms, and expressions used among experts in the targeted domain.</span>
</div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<span style="font-size: 11pt;"><span style="font-family: "minionpro";"><br /></span></span></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<hr />
</div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<b><span style="font-size: 24px;"><span style="font-family: "minionpro";">DSL优势:</span></span></b></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<b><span style="font-size: 24px;"><span style="font-family: "minionpro";"><br /></span></span></b></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<b><span style="font-family: "minionpro"; font-size: 11pt; font-style: italic;">Encapsulation</span></b></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<br /></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<span style="font-family: "minionpro"; font-size: 11.000000pt;">A DSL hides implementation details and exposes only those abstractions relevant to the domain.</span></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<b><span style="font-family: "minionpro"; font-size: 11.000000pt; font-style: italic;">Productivity</span></b></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<span style="font-family: "minionpro"; font-size: 11.000000pt;">Because implementation details are encapsulated, a DSL optimizes the effort re</span><span style="font-family: "minionpro"; font-size: 11.000000pt;">‐</span> <span style="font-family: "minionpro"; font-size: 11.000000pt;">quired to write or modify code for application features.</span>
</div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<br /></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<b><span style="font-family: "minionpro"; font-size: 11.000000pt; font-style: italic;">Communication</span></b></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<span style="font-family: "minionpro"; font-size: 11.000000pt;">A DSL helps developers understand the domain and domain experts to verify that the implementation meets the requirements.</span><span style="font-size: 11pt;"><span style="font-family: "minionpro";"> A domain expert with little experience in programming can read, understand, and validate this code</span></span></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<span style="font-size: 11pt;"><span style="font-family: "minionpro";"><br /></span></span></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8lyu9OyvfD6aj33HYyhRXkSiLTWuYYUo3jqNVMoge3fHJKu6hAV5AZ5qsD6TvchCBN4mOFtEsAEalRf4hJZLOgCoZ_d_2H8Xf_yZFHDDrpN0MGDiSDVjLcZ4fqXfNWvWWozZRu0oHjAo/s1600/Screen+Shot+2016-01-29+at+11.39.13+AM.png" imageanchor="1"><img border="0" height="279" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8lyu9OyvfD6aj33HYyhRXkSiLTWuYYUo3jqNVMoge3fHJKu6hAV5AZ5qsD6TvchCBN4mOFtEsAEalRf4hJZLOgCoZ_d_2H8Xf_yZFHDDrpN0MGDiSDVjLcZ4fqXfNWvWWozZRu0oHjAo/s320/Screen+Shot+2016-01-29+at+11.39.13+AM.png" width="320" /></a></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<span style="font-size: 11pt;"><span style="font-family: "minionpro";"><br /></span></span></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<span style="font-size: 11pt;"><span style="font-family: "minionpro";"><br /></span></span></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<hr />
</div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<span style="font-size: 24px;"><b><span style="font-family: "minionpro";">DSL劣势:</span></b></span></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<br /></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<b><span style="font-family: "minionpro"; font-size: 11.000000pt; font-style: italic;">DSLs are difficult to create</span></b></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<span style="font-family: "minionpro"; font-size: 11.000000pt;">Although writing a DSL is “cool,” the effort shouldn’t be underestimated. </span><span style="font-family: "minionpro"; font-size: 11pt;">First, the implementation techniques can be nontrivial (see the following example). </span><span style="font-family: "minionpro"; font-size: 11pt;">Second, good DSLs are harder to design than traditional APIs.</span></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<br /></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<b><span style="font-family: "minionpro"; font-size: 11.000000pt; font-style: italic;">DSLs are hard to maintain</span></b></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<span style="font-family: "minionpro"; font-size: 11.000000pt;">DSLs can require more maintenance over the long term as the domain changes, </span><span style="font-family: "minionpro"; font-size: 11pt;">because of the nontrivial implementation techniques used. </span><span style="font-family: "minionpro"; font-size: 11pt;"> Implementation sim</span><span style="font-family: "minionpro"; font-size: 11pt;">plicity is often sacrificed for a better user experience.</span></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<span style="font-size: 11pt;"><span style="font-family: "minionpro";"><br /></span></span></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<span style="font-size: 11pt;"><span style="font-family: "minionpro";"><br /></span></span></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgdQcKoxrCppBg3GmekHvd31qCbbrvS-uRHIqfz1UzOYYZBJUVF5WGsB3v0AEbybpYv0xkncqyOxS5aEqt00uN6c2iS1gDXnuMLBjm_SeCTEKwubuj-TPnUXrATFA2GlDoDhRmxUVNGFw/s1600/Screen+Shot+2016-01-29+at+11.40.37+AM.png" imageanchor="1"><img border="0" height="265" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgdQcKoxrCppBg3GmekHvd31qCbbrvS-uRHIqfz1UzOYYZBJUVF5WGsB3v0AEbybpYv0xkncqyOxS5aEqt00uN6c2iS1gDXnuMLBjm_SeCTEKwubuj-TPnUXrATFA2GlDoDhRmxUVNGFw/s320/Screen+Shot+2016-01-29+at+11.40.37+AM.png" width="320" /></a></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<hr />
</div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<span style="font-size: 11pt;"><span style="font-family: "minionpro";"><br /></span></span></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<br /></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<span style="font-weight: 600;"><span style="font-size: 19pt;"><span style="font-family: "myriadpro";"><br /></span></span></span></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<span style="font-family: "myriadpro"; font-size: 19.000000pt; font-weight: 600;">Internal DSLs:</span></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
From Programming Scala</div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<br /></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<br /></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<span style="font-family: "minionpro"; font-size: 11.000000pt;">If the DSL is “close-enough” that it can be implemented internally with reasonable effort and ro</span><span style="font-family: "minionpro"; font-size: 11.000000pt;">‐</span> <span style="font-family: "minionpro"; font-size: 11.000000pt;">bustness, the user experience will generally be better. It’s clearly the best choice for the test libraries mentioned earlier.</span>
</div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<span style="font-size: 11pt;"><span style="font-family: "minionpro";"><br /></span></span></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<br /></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<span style="font-family: "myriadpro"; font-size: 19.000000pt; font-weight: 600;">External DSLs:</span></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<br /></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
</div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<br /></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<span style="font-family: "minionpro"; font-size: 11.000000pt;">The external DSL is simpler, but the user must embed the DSL in strings. Hence, code completion, refactoring, color coding, and other IDE features aren’t available.</span></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<span style="font-family: "minionpro"; font-size: 11.000000pt;">If the DSL is too far removed from Scala syntax, perhaps because it’s a well-known language, like SQL, using an external DSL with quoted strings is probably best.</span></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<span style="font-size: 11pt;"><span style="font-family: "minionpro";"><br /></span></span></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<span style="font-size: 11pt;"><span style="font-family: "minionpro";"><br /></span></span></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<span style="font-size: 11pt;"><span style="font-family: "minionpro";"><br /></span></span></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<hr />
</div>
<div style="font-family: -webkit-standard; font-size: 14px;">
From <a href="http://modeling-languages.com/internal-external-dsls/">http://modeling-languages.com/internal-external-dsls/</a>
</div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<span style="background-color: white; color: #646464; float: none; font-family: "noto sans" , sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">As a starting point for the discussion let’s take this </span><a href="http://martinfowler.com/bliki/DslQandA.html" style="-webkit-tap-highlight-color: rgb(255, 94, 153); -webkit-text-stroke-width: 0px; background-color: white; border: 0px; color: #ff6c00; font-family: 'Noto Sans', sans-serif; font-size: 14px; font-stretch: inherit; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; padding: 0px; text-align: start; text-decoration: none; text-indent: 0px; text-transform: none; transition: background-color, color 0.2s linear; vertical-align: baseline; white-space: normal; widows: 1; word-spacing: 0px;" target="_blank">definition from Martin Fowler</a><span style="background-color: white; color: #646464; float: none; font-family: "noto sans" , sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"> </span><em style="-webkit-text-stroke-width: 0px; background-color: white; border: 0px; color: #646464; font-family: georgia; font-size: 14px; font-stretch: inherit; font-style: italic; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; vertical-align: baseline; white-space: normal; widows: 1; word-spacing: 0px;">“An internal DSL is just a particular idiom of writing code in the host language. So a Ruby internal DSL is Ruby code, just written in particular style which gives a more language-like feel. As such they are often called Fluent Interfaces or Embedded DSLs. An external DSL is a completely separate language that is parsed into data that the host language can understand”.</em></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<i><span style="font-family: "georgia";"><span style="background-color: white;"><span style="color: #646464;"><br /></span></span></span></i></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<div style="-webkit-text-stroke-width: 0px; background-color: white; border: 0px; color: #646464; font-family: 'Noto Sans', sans-serif; font-size: 14px; font-stretch: inherit; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; vertical-align: baseline; white-space: normal; widows: 1; word-spacing: 0px;">
Erik started the controversy with this highly provocative statement:
</div>
<blockquote style="-webkit-text-stroke-width: 0px; background-color: white; border: 0px; color: #646464; font-family: Georgia, serif; font-size: 15px; font-stretch: inherit; font-style: italic; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; padding: 0px 10px 20px 27px; quotes: none; text-align: start; text-indent: 0px; text-transform: none; vertical-align: baseline; white-space: normal; widows: 1; word-spacing: 0px;">
<div style="border: 0px; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; padding: 0px; vertical-align: baseline;">
I fully ascribe to Hudak-style embedded DSL, which really just are well-designed APIs. <span style="background-color: rgba(100 , 100 , 100 , 0.14902); border: 0px; color: inherit; cursor: inherit; float: inherit; font-family: inherit "important"; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; padding: 0px; vertical-align: inherit;">External DSLs on the other hand are like puppies, they all start out cute and happy, but without exception turn into vicious beasts as they grow up<span style="background-color: transparent; background-position: 4px 0px; background-repeat: no-repeat; border: 0px; box-shadow: none; color: rgb(94 , 171 , 223); font-family: inherit; font-size: xx-small; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: normal; padding: 0px 4px 0px 18px; vertical-align: middle; visibility: visible;">1</span></span> (make, XSLT, regular expressions, …).
</div>
</blockquote>
<div style="-webkit-text-stroke-width: 0px; background-color: white; border: 0px; color: #646464; font-family: 'Noto Sans', sans-serif; font-size: 14px; font-stretch: inherit; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; vertical-align: baseline; white-space: normal; widows: 1; word-spacing: 0px;">
and from there, all hell broke loose, with supporters of external DSLs claiming that better tool support in the shape of language workbenches made the statement untrue or at least made the cost of creating those DSLs acceptable
</div>
<blockquote style="-webkit-text-stroke-width: 0px; background-color: white; border: 0px; color: #646464; font-family: Georgia, serif; font-size: 15px; font-stretch: inherit; font-style: italic; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; padding: 0px 10px 20px 27px; quotes: none; text-align: start; text-indent: 0px; text-transform: none; vertical-align: baseline; white-space: normal; widows: 1; word-spacing: 0px;">
<div style="border: 0px; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; padding: 0px; vertical-align: baseline;">
external DSLs are ugly: I think they are, but so are death and taxes
</div>
</blockquote>
<div style="-webkit-text-stroke-width: 0px; background-color: white; border: 0px; color: #646464; font-family: 'Noto Sans', sans-serif; font-size: 14px; font-stretch: inherit; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; vertical-align: baseline; white-space: normal; widows: 1; word-spacing: 0px;">
while internal DSLs fans discredited the tool support argument by saying that this was only a small part of the problem.
</div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; border: 0px; font-stretch: inherit; font-variant: normal; font-weight: normal; letter-spacing: normal; margin-left: 40px; orphans: auto; padding: 0px 10px 20px 27px; quotes: none; text-align: start; text-indent: 0px; text-transform: none; vertical-align: baseline; white-space: normal; widows: 1; word-spacing: 0px;">
<div>
<i><span style="font-size: 15px;"><span style="font-family: "georgia" , serif;"><span style="color: #646464;"><br /></span></span></span></i></div>
<div style="border: 0px; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; padding: 0px; vertical-align: baseline;">
<div>
<i><span style="color: #646464;"><span style="font-family: inherit;"><span style="font-size: inherit;">External DSLs … have no mother language to depend upon, and so they must reinvent much general purpose behavior.</span></span></span></i></div>
</div>
</div>
</div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<br /></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<hr />
</div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<br /></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<span style="font-family: "myriadpro"; font-size: 19.000000pt; font-weight: 600;">使用内部还是外部DSL?</span></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<span style="font-weight: 600;"><span style="font-size: 19pt;"><span style="font-family: "myriadpro";"><br /></span></span></span></div>
<div style="background-color: white; font-family: -webkit-standard; font-size: 9pt;">
<span style="font-size: 9pt;"><span style="font-family: "menlo";"><span style="color: navy; font-weight: bold;">if </span>( 领域概念清晰 and 领域概念数目可控 ) { <span style="color: grey; font-style: italic;">//可尝试采用DSL</span></span></span></div>
<div style="background-color: white; color: black; font-family: 'Menlo'; font-size: 9.0pt;">
<span style="color: grey; font-style: italic;"> </span> <span style="color: navy; font-weight: bold;">if </span>( 目标DSL的代码量大 and 表达复杂度高 ) {<br />
<span style="color: grey; font-style: italic;">//建议采用内部DSL</span><span style="color: grey; font-style: italic;"> </span><br />
<span style="color: grey; font-style: italic;"> //1. 可借助编程语言本身的 图灵可计算性 来提升DSL能力</span><span style="color: grey; font-style: italic;"> </span><br />
<span style="color: grey; font-style: italic;"> //2. 写DSL表达业务时,可借助编译器对语法正确与否的判断提示</span>
</div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<span style="font-size: 9pt;"><span style="font-family: "menlo";"><span style="color: grey; font-style: italic;"> //3. 重构DSL时,可借助IDE的重构功能, 因为内部DSL本身就是正常的代码</span></span></span></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<span style="font-size: 9pt;"><span style="font-family: "menlo";"><span style="color: grey; font-style: italic;"> </span></span></span></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<span style="font-size: 9pt;"><span style="font-family: "menlo";"><span style="color: grey; font-style: italic;"> </span> } <span style="color: navy; font-weight: bold;">else if </span>( 想突破编程语言语法限制,使用更符合领域的表达 ) {</span></span></div>
<div style="background-color: white; color: black; font-family: 'Menlo'; font-size: 9.0pt;">
<span style="color: grey; font-style: italic;">//采用外部DSL</span><span style="color: grey; font-style: italic;"> </span><br />
}<br />
<br />
} <span style="color: navy; font-weight: bold;">else </span>{<br />
<span style="color: grey; font-style: italic;">//领域经常变化,会加大DSL维护成本</span><br />
}</div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<br /></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<br /></div>
<div style="font-family: -webkit-standard; font-size: 14px;">
<hr />
</div>
<div style="font-family: -webkit-standard; font-size: 14px;">
参考书箱 Programming Scala
</div>
<!--?xml version="1.0" encoding="UTF-8" standalone="no"?-->
<br />
<div style="font-family: -webkit-standard; font-size: 14px;">
<a href="http://martinfowler.com/books/dsl.html">http://martinfowler.com/books/dsl.html</a></div>
Anonymoushttp://www.blogger.com/profile/01293468005249034620noreply@blogger.com0tag:blogger.com,1999:blog-8508408386087224500.post-2563951835549237712014-11-29T18:06:00.001+08:002014-11-29T18:06:19.836+08:00draw msgflow in reactive app<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"><br />
<!-- Created by htmlize-1.34 in css mode. --><br />
<html><br />
<head><br />
<title>cpp_idioms.org</title><br />
<style type="text/css">
<!--
body {
color: #000000;
background-color: #ffffff;
}
.hi-blue {
/* hi-blue */
background-color: #add8e6;
}
.org-footnote {
/* org-footnote */
color: #7f007f;
text-decoration: underline;
}
.org-link {
/* org-link */
color: #3a5fcd;
text-decoration: underline;
}
.org-table {
/* org-table */
color: #0000ff;
}
a {
color: inherit;
background-color: inherit;
font: inherit;
text-decoration: inherit;
}
a:hover {
text-decoration: underline;
}
-->
</style><br />
</head><br />
<body><br />
<pre><span class="hi-blue">usually we got log like following:</span>
[sys1] ----> [sys2] 00001 MSG_0 0x00010002 0x00030004
[sys2] ----> [sys3] 00002 MSG_1 0x00010002 0x00030004
[sys3] ----> [sys1] 00003 MSG_2 0x00010002 0x00030004
<span class="hi-blue">but a diagram like following is more readable:</span>
sys1 sys2 sys3
<span class="org-table">|----->| | MSG_0 [0x00010002 0x00030004]</span>
<span class="org-table">| |----->| MSG_1 [0x00010002 0x00030004]</span>
<span class="org-table">|<------------| MSG_2 [0x00010002 0x00030004]</span>
I implemented a simple app to draw this diagram: <span class="org-link">https://github.com/whunmr/msgflow</span>
<span class="hi-blue">more complicated diagram generated from log:</span>
ss3 kk3 zz1 qq1 qq2 kk1 bb1 aa1 ss1
<span class="org-table">| | | | | | | | * MSG_0 </span><span class="org-footnote">[1]</span><span class="org-table"> [0x00010002 0x00030004]</span>
<span class="org-table">| | | | | | | |<----| MSG_1 </span><span class="org-footnote">[2]</span><span class="org-table"> [0x00010002 0x00030004]</span>
<span class="org-table">| | | | | | | |---->| MSG_2 </span><span class="org-footnote">[3]</span><span class="org-table"> [0x00010002 0x00030004]</span>
<span class="org-table">| | | | | |<----| | | MSG_3 </span><span class="org-footnote">[4]</span><span class="org-table"> [0x00010002 0x00030004]</span>
<span class="org-table">| | | | | |---------------->| MSG_4 </span><span class="org-footnote">[5]</span><span class="org-table"> [0x00010002 0x00030004]</span>
<span class="org-table">| | | | | |<----------------| MSG_5 </span><span class="org-footnote">[6]</span><span class="org-table"> [0x00010002 0x00030004]</span>
<span class="org-table">| | | | | | | |<----| MSG_6 </span><span class="org-footnote">[7]</span><span class="org-table"> [0x00010002 0x00030004]</span>
<span class="org-table">| | | | |<----------------------| MSG_7 </span><span class="org-footnote">[8]</span><span class="org-table"> [0x00010002 0x00030004]</span>
<span class="org-table">| | |<----| | | | | | MSG_8 </span><span class="org-footnote">[9]</span><span class="org-table"> [0x00010002 0x00030004]</span>
<span class="org-table">| | |---------------------------->| | MSG_9 </span><span class="org-footnote">[10]</span><span class="org-table"> [0x00010002 0x00030004]</span>
<span class="org-table">| | | | | | | |---->| MSG_2 </span><span class="org-footnote">[11]</span><span class="org-table"> [0x00010002 0x00030004]</span>
<span class="org-table">| |<----------------------------| | | MSG_3 </span><span class="org-footnote">[12]</span><span class="org-table"> [0x00010002 0x00030004]</span>
<span class="org-table">| | | | | |---------------->| MSG_4 </span><span class="org-footnote">[13]</span><span class="org-table"> [0x00010002 0x00030004]</span>
<span class="org-table">| |<----------------------------------------| MSG_5 </span><span class="org-footnote">[14]</span><span class="org-table"> [0x00010002 0x00030004]</span>
<span class="org-table">|---------------------------------------->| | MSG_6 </span><span class="org-footnote">[15]</span><span class="org-table"> [0x00010002 0x00030004]</span>
<span class="org-table">|---------------->| | | | | | MSG_7 </span><span class="org-footnote">[16]</span><span class="org-table"> [0x00010002 0x00030004]</span>
<span class="org-table">| | |<----------------------------------| MSG_8 </span><span class="org-footnote">[17]</span><span class="org-table"> [0x00010002 0x00030004]</span>
<span class="org-table">| | |---------------------------------->| MSG_9 </span><span class="org-footnote">[18]</span><span class="org-table"> [0x00010002 0x00030004]</span>
</pre> </body><br />
</html><br />
Anonymoushttp://www.blogger.com/profile/01293468005249034620noreply@blogger.com0tag:blogger.com,1999:blog-8508408386087224500.post-45272456693916989702014-11-29T18:00:00.001+08:002014-12-07T11:55:10.512+08:00DSL for reactive application implementation in C++<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"><br />
<!-- Created by htmlize-1.34 in css mode. --><br />
<html><br />
<head><br />
<title>cpp_idioms.org</title><br />
<style type="text/css">
<!--
body {
color: #000000;
background-color: #ffffff;
}
.function-name {
/* font-lock-function-name-face */
color: #0000ff;
}
.org-block-background {
}
a {
color: inherit;
background-color: inherit;
font: inherit;
text-decoration: inherit;
}
a:hover {
text-decoration: underline;
}
-->
</style><br />
</head><br />
<body><br />
<pre><span class="function-name"><span class="org-block-background">def_mi(Basic_mi_x) {
step(sync_call_1);
step(sync_call_2);
sysd<----------------------------async_step(async_call_1) {
sysd-------------------->ack(msg_ack_1, on_msg_ack_1);
sysd-------------------->ack(msg_ack_2, on_msg_ack_2);
sysd-------------------->ack_ex(msg_ack_4)
{
step(sync_call_nested_1);
sysx<------------async_step(nested_async_call_1)
{
sysx---->ack(nested_msg_ack_1, on_nested_msg_ack_1);
sysx---->ack(nested_msg_ack_2, on_nested_msg_ack_2);
sysx---->ack(msg_ack_1, on_nested_msg_ack_3);
} async_step_end;
} on_msg_ack_ex_end;
}async_step_end;
} def_mi_end;
</span></span></pre><br />
<br />
<a href="https://github.com/whunmr/reactive_cpp">https://github.com/whunmr/reactive_cpp</a><br />
<br />
</body><br />
</html><br />
Anonymoushttp://www.blogger.com/profile/01293468005249034620noreply@blogger.com0tag:blogger.com,1999:blog-8508408386087224500.post-51897542008701741502014-05-09T19:20:00.000+08:002014-05-09T19:47:01.139+08:00Generate dynamic examples for cucumber Scenario outline<body><br />
<br />
<div id="preamble"><br />
</div><br />
<div id="content"><h1 class="title"></h1><br />
<p style="
background: lightcyan;
">In following scenario outline, examples will be generated by `generate_example_data_func`:<br />
</p><br />
<br />
<pre class="src src-c++"><span style="color: #008b8b;">Feature</span>: test feature
<span style="color: #228b22;">Scenario</span> <span style="color: #a0522d;">Outline</span>: testing
* test_tool __________________* <span style="color: #8b2252;">"<foo>"</span>
* test_tool *__________________ <span style="color: #8b2252;">"<bar>"</span>
Examples:
| foo | bar |
| `generate_example_data_func` | |
</pre><br />
<br />
<p style="
background: lightcyan;
">implementation of `generate_example_data_func`, and steps:<br />
</p><br />
<br />
<pre class="src src-ruby"><span style="color: #228b22;">Given</span>(<span style="color: #8b2252;">/^test_tool __________________\* "(.*?)"$/</span>) <span style="color: #7f007f;">do</span> |arg1|
<span style="color: #7f007f;">end</span>
<span style="color: #228b22;">Given</span>(<span style="color: #8b2252;">/^test_tool \*__________________ "(.*?)"$/</span>) <span style="color: #7f007f;">do</span> |arg1|
<span style="color: #7f007f;">end</span>
<span style="color: #7f007f;">def</span> <span style="color: #0000ff;">generate_example_data_func</span> table
table << [<span style="color: #8b2252;">"xxx"</span>, <span style="color: #8b2252;">"yyy"</span>]
table << [<span style="color: #8b2252;">"aaa"</span>, <span style="color: #8b2252;">"bbb"</span>]
table
<span style="color: #7f007f;">end</span>
</pre><br />
<p style="
background: lightcyan;
">running result:<br />
$ cucumber –expand<br />
</p><br />
<br />
<pre class="src src-ruby"><span style="color: #228b22;">Feature</span>: test feature
<span style="color: #228b22;">Scenario</span> <span style="color: #228b22;">Outline</span>: testing <span style="color: #b22222;"># </span><span style="color: #b22222;">features/reading_report/test.feature:2</span>
* test_tool __________________* <span style="color: #8b2252;">"<foo>"</span> <span style="color: #b22222;"># </span><span style="color: #b22222;">features/step_definitions/new_step.rb:1</span>
* test_tool *__________________ <span style="color: #8b2252;">"<bar>"</span> <span style="color: #b22222;"># </span><span style="color: #b22222;">features/step_definitions/new_step.rb:4</span>
<span style="color: #228b22;">Examples</span>:
<span style="color: #228b22;">Scenario</span>: | xxx | yyy | <span style="color: #b22222;"># </span><span style="color: #b22222;">features/reading_report/test.feature:-1</span>
* test_tool __________________* <span style="color: #8b2252;">"xxx"</span> <span style="color: #b22222;"># </span><span style="color: #b22222;">features/step_definitions/new_step.rb:1</span>
* test_tool *__________________ <span style="color: #8b2252;">"yyy"</span> <span style="color: #b22222;"># </span><span style="color: #b22222;">features/step_definitions/new_step.rb:4</span>
<span style="color: #228b22;">Scenario</span>: | aaa | bbb | <span style="color: #b22222;"># </span><span style="color: #b22222;">features/reading_report/test.feature:-1</span>
* test_tool __________________* <span style="color: #8b2252;">"aaa"</span> <span style="color: #b22222;"># </span><span style="color: #b22222;">features/step_definitions/new_step.rb:1</span>
* test_tool *__________________ <span style="color: #8b2252;">"bbb"</span> <span style="color: #b22222;"># </span><span style="color: #b22222;">features/step_definitions/new_step.rb:4</span>
2 scenarios (2 passed)
4 steps (4 passed)
0m0.028s
</pre><br />
<br />
<p style="
background: lightcyan;
">To support dynamic generate example data, we need change the scenario_outline.rb`:<br />
</p><br />
<br />
<pre class="src src-ruby"><span style="color: #7f007f;">def</span> <span style="color: #0000ff;">create_examples_table</span>(example_section_and_gherkin_examples)
example_section = example_section_and_gherkin_examples[0]
gherkin_examples = example_section_and_gherkin_examples[1]
examples_location = example_section[0]
examples_comment = example_section[1]
examples_keyword = example_section[2]
examples_title = example_section[3]
examples_description = example_section[4]
examples_matrix = example_section[5]
<span style="color: #b22222;">#</span><span style="color: #b22222;">CHANGE BEGIN#####################################################</span>
<span style="color: #b22222;">#</span><span style="color: #b22222;">~/.rvm/gems/ruby-1.9.3-p392/gems/cucumber-1.3.14/lib/cucumber/ast/scenario_outline.rb</span>
<span style="color: #7f007f;">if</span> examples_matrix.length > 1 && examples_matrix[1].length > 1
using_function_to_generate_examples = !(examples_matrix[1][0] =~ <span style="color: #8b2252;">/^`.*`$/</span>).nil?
<span style="color: #7f007f;">if</span> using_function_to_generate_examples
function_str = examples_matrix[1][0].gsub!(<span style="color: #8b2252;">/`(.*)`/</span>, <span style="color: #8b2252;">'\1'</span>) + <span style="color: #8b2252;">"(["</span> + examples_matrix[0].to_s + <span style="color: #8b2252;">"])"</span>
examples_matrix = eval(function_str)
<span style="color: #7f007f;">end</span>
<span style="color: #7f007f;">end</span>
<span style="color: #b22222;">#</span><span style="color: #b22222;">CHANGE END#####################################################</span>
examples_table = <span style="color: #228b22;">OutlineTable</span>.new(examples_matrix, <span style="color: #a0522d;">self</span>)
ex = <span style="color: #228b22;">Examples</span>.new(examples_location, examples_comment, examples_keyword, examples_title, examples_description, examples_table)
ex.gherkin_statement(gherkin_examples)
ex
<span style="color: #7f007f;">end</span>
</pre><br />
</div><br />
<br />
<br />
<br />
</body>Anonymoushttp://www.blogger.com/profile/01293468005249034620noreply@blogger.com0tag:blogger.com,1999:blog-8508408386087224500.post-72321442366576170902013-11-01T02:01:00.002+08:002013-11-01T02:01:56.271+08:00Make message interaction more readable, by using c++ local class<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"><br />
<!-- Created by htmlize-1.34 in css mode. --><br />
<html><br />
<head><br />
<title>main (1).cpp</title><br />
<style type="text/css">
<!--
body {
color: #000000;
background-color: #ffffff;
}
.comment {
/* font-lock-comment-face */
color: #b22222;
}
.comment-delimiter {
/* font-lock-comment-delimiter-face */
color: #b22222;
}
.constant {
/* font-lock-constant-face */
color: #008b8b;
}
.function-name {
/* font-lock-function-name-face */
color: #0000ff;
}
.header-line {
/* header-line */
color: #333333;
background-color: #e5e5e5;
}
.helm-ff-prefix {
/* helm-ff-prefix */
color: #000000;
background-color: #ffff00;
}
.hi-blue {
/* hi-blue */
background-color: #add8e6;
}
.icicle-search-current-input {
/* icicle-search-current-input */
color: #000000;
background-color: #00ff00;
}
.keyword {
/* font-lock-keyword-face */
color: #7f007f;
}
.preprocessor {
/* font-lock-preprocessor-face */
color: #483d8b;
}
.string {
/* font-lock-string-face */
color: #8b2252;
}
.type {
/* font-lock-type-face */
color: #228b22;
}
.variable-name {
/* font-lock-variable-name-face */
color: #a0522d;
}
a {
color: inherit;
background-color: inherit;
font: inherit;
text-decoration: inherit;
}
a:hover {
text-decoration: underline;
}
-->
</style><br />
</head><br />
<body><br />
<pre><span class="icicle-search-current-input">Make message interaction more readable, by using c++ local class::::</span>
<span class="hi-blue">c++ local class:</span>
<span class="type">http</span>:<span class="header-line">//publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8l.doc%2Flanguage%2Fref%2Fcplr062.htm</span><span class="comment">
</span>
<span class="header-line">/////////////////////////////////////////////////////////////////////////////</span><span class="comment">
</span><span class="preprocessor">#include</span> <span class="string"><iostream></span>
<span class="preprocessor">#include</span> <span class="string"><map></span>
<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="constant">std</span>;
<span class="preprocessor">#define</span> <span class="variable-name">MESSAGE_SEND</span> 3
<span class="preprocessor">#define</span> <span class="variable-name">MESSAGE_TIME_OUT</span> 4
<span class="preprocessor">#define</span> <span class="variable-name">MESSAGE_RESPONSE</span> 5
<span class="header-line">/////////////////////////////////////////////////////////////////////////////</span><span class="comment">
</span><span class="keyword">struct</span> <span class="type">Worker</span> {
<span class="keyword">virtual</span> <span class="type">void</span> <span class="keyword">operator</span><span class="function-name">()</span>() = 0;
};
<span class="header-line">/////////////////////////////////////////////////////////////////////////////</span><span class="comment">
</span><span class="keyword">struct</span> <span class="type">HandlerPool</span> {
<span class="type">void</span> <span class="function-name">addMsg</span>(<span class="type">int</span> <span class="variable-name">msg</span>, <span class="type">Worker</span>& <span class="variable-name">a</span>) {
maps[msg] = &a;
}
<span class="type">void</span> <span class="function-name">run</span>(<span class="type">int</span> <span class="variable-name">msg</span>) {
<span class="keyword">if</span> (maps.find(msg) != maps.end()) {
(*maps[msg])();
} <span class="keyword">else</span> {
cout << <span class="string">"no handler"</span> << endl;
}
}
<span class="type">map</span><<span class="type">int</span>, <span class="type">Worker</span>*> <span class="variable-name">maps</span>;
};
<span class="type">HandlerPool</span> <span class="variable-name">g_handlePool</span>;
<span class="header-line">/////////////////////////////////////////////////////////////////////////////</span><span class="comment">
</span><span class="preprocessor">#define</span> <span class="function-name">if_on_msg</span>(<span class="variable-name">msg</span>) IF_ON_MSG(onMsg_##msg)
<span class="preprocessor">#define</span> <span class="function-name">IF_ON_MSG</span>(<span class="variable-name">msg_handler_class</span>) \
<span class="keyword">static</span> <span class="keyword">struct</span> <span class="type">msg_handler_class</span> : <span class="type">Worker</span> { \
<span class="type">void</span> <span class="keyword">operator</span><span class="function-name">()</span>()
<span class="preprocessor">#define</span> <span class="function-name">end_if_on_msg</span>(<span class="variable-name">msg</span>) END_IF_ON_MSG(msg, onMsg_##msg##_handler)
<span class="preprocessor">#define</span> <span class="function-name">END_IF_ON_MSG</span>(<span class="variable-name">msg</span>, <span class="variable-name">handler_instance_name</span>) \
} handler_instance_name; \
g_handlePool.addMsg(msg, handler_instance_name)
<span class="header-line">/////////////////////////////////////////////////////////////////////////////</span><span class="comment">
</span><span class="keyword">struct</span> <span class="type">Worker_Before_refactor</span> : <span class="type">Worker</span> {
<span class="type">void</span> <span class="function-name">processMsg</span>(<span class="comment-delimiter">/*</span><span class="comment">const Message& msg*/</span>) {
<span class="header-line">//</span><span class="helm-ff-prefix">`people can not see which message came first, which is the last one`</span><span class="comment">
</span> <span class="header-line">//</span><span class="helm-ff-prefix">`so can not know the message_interaction by reading code`</span><span class="comment">
</span>
<span class="keyword">switch</span> (msg) {
<span class="keyword">case</span> MESSAGE_TIME_OUT:
....
<span class="keyword">case</span> MESSAGE_RESPONSE:
....
<span class="keyword">case</span> MESSAGE_XXXX:
....
<span class="keyword">case</span> MESSAGE_YYYY:
....
}
}
};
<span class="header-line">/////////////////////////////////////////////////////////////////////////////</span><span class="comment">
</span><span class="keyword">struct</span> <span class="type">WorkerAfterRefactor</span> : <span class="type">Worker</span> {
<span class="type">void</span> <span class="keyword">operator</span><span class="function-name">()</span>() {
sender------->receiver(MessageBody);
<span class="variable-name">if_on_msg</span>(sender<------------receiver(MESSAGE_TIME_OUT)) {
sender------->receiver(MessageBody);
<span class="variable-name">if_on_msg</span>(sender<------------receiver(MESSAGE_TIME_OUT)) {
cout << <span class="string">"retry still got timeout..."</span> << endl;
} end_if_on_msg(MESSAGE_TIME_OUT);
} end_if_on_msg(MESSAGE_TIME_OUT);
<span class="variable-name">if_on_msg</span>(sender<-----receiver(MESSAGE_RESPONSE)) {
cout << <span class="string">"succeeded got ack"</span> << endl;
} end_if_on_msg(MESSAGE_RESPONSE);
}
};
<span class="header-line">/////////////////////////////////////////////////////////////////////////////</span><span class="comment">
</span><span class="type">int</span> <span class="function-name">main</span>(<span class="type">int</span> <span class="variable-name">argc</span>, <span class="keyword">const</span> <span class="type">char</span> * <span class="variable-name">argv</span>[])
{
<span class="type">WorkerAfterRefactor</span> <span class="variable-name">a</span>;
g_handlePool.addMsg(MESSAGE_SEND, a);
g_handlePool.run(MESSAGE_SEND);
g_handlePool.run(MESSAGE_TIME_OUT);
g_handlePool.run(MESSAGE_TIME_OUT);
g_handlePool.run(MESSAGE_RESPONSE);
<span class="keyword">return</span> 0;
}
<span class="header-line">/////////////////////////////////////////////////////////////////////////////</span><span class="comment">
</span><span class="header-line">//output:</span><span class="comment">
</span><span class="header-line">//------>send sca config to slave board</span><span class="comment">
</span><span class="header-line">//<----timeout...</span><span class="comment">
</span><span class="header-line">//----->retry send sca config to slave board</span><span class="comment">
</span><span class="header-line">//<-----retry still got timeout...</span><span class="comment">
</span><span class="header-line">//<----succeeded got ack</span><span class="comment">
</span><span class="header-line">//</span><span class="comment">
</span><span class="header-line">//Process finished with exit code 0</span><span class="comment">
</span></pre> </body><br />
</html><br />
Anonymoushttp://www.blogger.com/profile/01293468005249034620noreply@blogger.com0tag:blogger.com,1999:blog-8508408386087224500.post-67505494469633192052013-10-25T00:46:00.000+08:002014-03-30T12:19:03.559+08:00USING operator overload to make your C++ functional test more readable<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"><br />
<!-- Created by htmlize-1.34 in css mode. --><br />
<html><br />
<head><br />
<title>tricks-cpp-operator-for-sendmsg.org</title><br />
<style type="text/css">
<!--
body {
color: #000000;
background-color: #ffffff;
}
.ATTRLIST {
/* (foreground-color . "black") */
color: #000000;
}
.ATTRLIST-1 {
/* (background-color . "yellow") */
background-color: #ffff00;
}
.c-nonbreakable-space {
/* c-nonbreakable-space-face */
color: #ffffff;
background-color: #000000;
font-weight: bold;
}
.comment {
/* font-lock-comment-face */
color: #b22222;
}
.header-line {
/* header-line */
color: #333333;
background-color: #e5e5e5;
}
.helm-ff-prefix {
/* helm-ff-prefix */
color: #000000;
background-color: #ffff00;
}
.log-edit-summary {
/* log-edit-summary */
color: #0000ff;
}
.org-level-1 {
/* org-level-1 */
color: #0000ff;
}
.yasXfield-highlight {
/* yas/field-highlight-face */
background-color: #c1ffc1;
}
a {
color: inherit;
background-color: inherit;
font: inherit;
text-decoration: inherit;
}
a:hover {
text-decoration: underline;
}
-->
</style><br />
</head><br />
<body><br />
<pre><span class="org-level-1">* usually we need test message communication between sub-systems, so the ft maybe looks like following: </span>
<span class="c-nonbreakable-space">before refactor:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::</span>
struct HeartBeatAckTest : testing::Test {
protected:
SubSystemA aaa;
SubSystemB bbb;
Request request;
};
TEST_F(HeartBeatAckTest, should_able_to_reply_heart_beat_ack) {
MOCKER(shouldReceiveMsg) <span class="header-line"> //using mockcpp</span>
.expects(exactly(1))
.with( eq(MSG_HEART_BEAT_ACK)
, any()
, eq(bbb.address())
, eq(aaa.address()));
Msg::send(aaa, bbb, MSG_HEART_BEAT, &request);
}
<span class="yasXfield-highlight">//By using operator overload we can make send and receive more easy to read</span>
<span class="yasXfield-highlight">//we can set MOCKER by operator<, --, () and send msg by operator>, --, ()</span>
<span class="c-nonbreakable-space">after refactor:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::</span>
<span class="comment">#define </span><span class="log-edit-summary">expects_msg</span><span class="comment"> if(true)</span>
TEST_F(AckTest, aaa_should_able_to_reply_heart_beat_ack) {
<span class="log-edit-summary">expects_msg</span> {
aaa<-----bbb(MSG_HEART_BEAT_ACK);
}
aaa---->bbb(MSG_HEART_BEAT, &request);
}
TEST_F(AckTest, bbb_should_reply_heart_beat_ack___AND___forward_heart_beat_to_ccc) {
<span class="log-edit-summary">expects_msg</span> {
aaa<-----bbb(MSG_HEART_BEAT_ACK);
ccc<-----bbb(MSG_HEART_BEAT);
}
aaa---->bbb(MSG_HEART_BEAT, &request);
}
<span class="c-nonbreakable-space">more thoughts::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::</span>
<span class="yasXfield-highlight">// the <----- is used to set MOCKER before ----->, can we? put the <---- after -----> ,</span>
<span class="yasXfield-highlight">// to make the message interaction more easy to comprehensive.</span>
<span class="yasXfield-highlight">// similar to </span><span class="helm-ff-prefix">`RAII`</span><span class="yasXfield-highlight">, actually we can defer the send message operation of -----> to the end of scope expects_msg.</span>
struct SendAllBufferedMessageAtEndOfScope {
SendAllBufferedMessageAtEndOfScope(int i) { } <span class="header-line"> //make it can init from dummy int </span>
~SendAllBufferedMessageAtEndOfScope() {
send_all_buffered_message_in_sequence();
}
operator bool() { return true; }
};
<span class="comment">#define </span><span class="log-edit-summary">expects_msg_interaction</span><span class="comment"> if (SendAllBufferedMessageAtEndOfScope </span><span class="ATTRLIST"><span class="ATTRLIST-1">sendMsgAtEnd</span></span><span class="comment"> = 1)</span>
TEST_F(AckTest, should_able_to_reply_heart_beat_ack) {
<span class="log-edit-summary">expects_msg_interaction</span> {
aaa ----> bbb (MSG_HEART_BEAT, &request); <span class="header-line"> //buffer the messge</span>
aaa <---- bbb (MSG_HEART_BEAT_ACK); <span class="header-line"> //set the MOCKER specification</span>
<span class="header-line"> //invisible destructor code of </span><span class="ATTRLIST"><span class="ATTRLIST-1">sendMsgAtEnd</span></span>
}
}
TEST_F(AckTest, bbb_should_reply_heart_beat_ack___AND___forward_heart_beat_to_ccc) {
<span class="log-edit-summary">expects_msg_interaction</span> {
aaa ----> bbb (MSG_HEART_BEAT, &request);
aaa <---- bbb (MSG_HEART_BEAT_ACK);
ccc <---- bbb (MSG_HEART_BEAT);
}
}
<span class="c-nonbreakable-space">example code::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::</span>
struct SubSystemB {
SubSystemB& operator--(int) {
return *this;
}
template<typename T>
bool operator >(const T& target) {
target.receiveMsg();
return true;
}
};
struct SubSystemA {
const SubSystemA& operator()(int msgId, int* p) {
msgId_ = msgId;
return *this;
}
void receiveMsg() const {
std::cout << "cc got message: " << msgId_ << std::endl;
}
int msgId_;
};
int main(int argc, const char * argv[])
{
SubSystemB bbb;
SubSystemA aaa;
int param = 0;
bbb---->aaa(1, &param);
return 0;
}
//another example:
TEST_F(AckTest, bbb_should_reply_heart_beat_ack___AND___forward_heart_beat_to_ccc) {
expects_msg_interaction(
op1 ----------------> xx (MSG_HEART_BEAT, &request);
op1 <---------------- xx (MSG_HEART_BEAT_ACK);
op2 ------------> xx (MSG_HEART_BEAT, &request);
op3 --------> xx (MSG_HEART_BEAT, &request);
op3 <-------- xx (MSG_HEART_BEAT_ACK);
op4 ----> xx (MSG_HEART_BEAT, &request);
op4 <---- xx (MSG_HEART_BEAT_ACK);
op1 ----------------> xx (MSG_HEART_BEAT, &request);
op1 <---------------- xx (MSG_HEART_BEAT_ACK);
op2 ------------> xx (MSG_HEART_BEAT, &request);
op3 --------> xx (MSG_HEART_BEAT, &request);
op3 <-------- xx (MSG_HEART_BEAT_ACK);
op4 ----> xx (MSG_HEART_BEAT, &request);
op4 <---- xx (MSG_HEART_BEAT_ACK);
);
}
</pre>
</body>
</html>
Anonymoushttp://www.blogger.com/profile/01293468005249034620noreply@blogger.com0tag:blogger.com,1999:blog-8508408386087224500.post-84126408523555504912013-06-19T21:24:00.001+08:002013-06-26T22:27:56.082+08:00using emacs to manage temporary files during debugging<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"><br />
<!-- Created by htmlize-1.34 in css mode. --><br />
<html><br />
<head><br />
<title>a.lisp</title><br />
<style type="text/css">
<!--
body {
color: #000000;
background-color: #ffffff;
}
.comment {
/* font-lock-comment-face */
color: #b22222;
}
.comment-delimiter {
/* font-lock-comment-delimiter-face */
color: #b22222;
}
.custom-variable-tag {
/* custom-variable-tag */
color: #0000ff;
font-weight: bold;
}
.function-name {
/* font-lock-function-name-face */
color: #0000ff;
}
.helm-ff-prefix {
/* helm-ff-prefix */
color: #000000;
background-color: #ffff00;
}
.keyword {
/* font-lock-keyword-face */
color: #7f007f;
}
.semantic-tag-boundary {
/* semantic-tag-boundary-face */
text-decoration: overline;
}
.string {
/* font-lock-string-face */
color: #8b2252;
}
a {
color: inherit;
background-color: inherit;
font: inherit;
text-decoration: inherit;
}
a:hover {
text-decoration: underline;
}
-->
</style><br />
</head><br />
<body><br />
<pre><span class="custom-variable-tag">We always need some temporary files to do editing work.</span>
<span class="custom-variable-tag">for example, we got 10000+ line logs to trace bug in it, first thing to do is create a tmp file.</span>
1. To create a tmp file we'd like to
- quick open the files in a directory without naming collision, with short-key <span class="helm-ff-prefix">`C-; t`</span><span class="comment">
</span>- store the tmp files for future search/grep
<span class="comment-delimiter">;;</span><span class="comment">code
</span> <span class="semantic-tag-boundary">(defun create-and-open-tmp-file ()
</span> (interactive)
(find-file (s-concat
<span class="string">"~/Documents/hongmin.wang/Google Drive/notes/tmp"</span>
(format-time-string <span class="string">"%Y%m%d___%H_%M_%S"</span>)
(uuid-string)
<span class="string">".temp"</span>)))
(global-set-key (kbd <span class="string">"C-; t"</span>) 'create-and-open-tmp-file)
2. To manage versions of tmp file, we like to put it in a git direcotry
and <span class="helm-ff-prefix">`C-x v i`</span> to register the tmp file to git
and <span class="helm-ff-prefix">`C-x v v`</span> to commit new version of the tmp file to git.
3. sometime, you think the tmp file is no longer an tmp file,
do a <span class="string">"Save As..."</span> by <span class="helm-ff-prefix">`C-x C-w`</span>
</pre></body><br />
</html><br />
Anonymoushttp://www.blogger.com/profile/01293468005249034620noreply@blogger.com0tag:blogger.com,1999:blog-8508408386087224500.post-15824294860606873362013-06-09T22:16:00.001+08:002013-06-09T22:16:04.027+08:00To be a central service<br><div class="separator" style="clear: both;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9aWdjB__u3A8UanJ5EsTq1SvS4UaeSVn3AhbAscXU3JezcZhOZv7NJ10FVmUpKuRa3NZYdt_ydA3xD2cs8FUpFHUk_jceZ47McsdM_lY8qfao1tmAcTxSqaLHUv6NU9O6dUZn2Ptvj48/s640/blogger-image-1849181406.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9aWdjB__u3A8UanJ5EsTq1SvS4UaeSVn3AhbAscXU3JezcZhOZv7NJ10FVmUpKuRa3NZYdt_ydA3xD2cs8FUpFHUk_jceZ47McsdM_lY8qfao1tmAcTxSqaLHUv6NU9O6dUZn2Ptvj48/s640/blogger-image-1849181406.jpg"></a></div>Anonymoushttp://www.blogger.com/profile/01293468005249034620noreply@blogger.com0tag:blogger.com,1999:blog-8508408386087224500.post-4578962847236088482013-06-06T21:43:00.000+08:002013-06-06T21:43:26.198+08:00record and mock http interactions of third-party server<style type="text/css">
<!--
body {
color: #000000;
background-color: #ffffff;
}
.italic {
/* italic */
font-style: italic;
}
.org-level-1 {
/* org-level-1 */
color: #0000ff;
}
.org-link {
/* org-link */
color: #3a5fcd;
text-decoration: underline;
}
.org-todo {
/* org-todo */
color: #ff0000;
font-weight: bold;
}
a {
color: inherit;
background-color: inherit;
font: inherit;
text-decoration: inherit;
}
a:hover {
text-decoration: underline;
}
</style>
<pre><span class="org-level-1">* Can not setup env in home. so i can not debug my application at home remotely</span>
I am debugging and web application, but I need an ESP fast server to
always return XML data for my search, then I can debug things.
but i can not access the fast server at home, so i can not work remotely at home.
I want have an application to monitor my web application's interactions with
fast server, and recording the interacting data(including delays),
and can replay/mock the services at home.
<span class="org-level-1">* python -m SimpleHTTPServer 9000</span>
<span class="org-level-1">* </span><span class="org-link">http://localhost:9000/null_main.c</span>
<span class="org-level-1">* sudo justniffer -i lo0 -r -p "port 9000"</span>
GET /null_main.c HTTP/1.1
Host: localhost:9000
Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
If-Modified-Since: Sat, 20 Oct 2012 09:17:23 GMT
HTTP/1.0 200 OK
Server: SimpleHTTP/0.6 Python/2.7.1
Date: Thu, 06 Jun 2013 13:27:41 GMT
Content-type: text/plain
Content-Length: 46
Last-Modified: Sat, 20 Oct 2012 09:17:23 GMT
<span class="italic">/* null_main.c */</span>
int main() {
return 0;
}
<span class="org-level-1">* </span><span class="org-todo">TODO</span><span class="org-level-1"> need running the mock server according the recorded http data</span>
</pre>
<br />
-->Anonymoushttp://www.blogger.com/profile/01293468005249034620noreply@blogger.com0tag:blogger.com,1999:blog-8508408386087224500.post-61543015754873432622013-05-11T10:43:00.002+08:002013-05-11T10:52:27.170+08:00TWI PeChaKuCha<div style="-x-system-font: none; display: block; font-family: Helvetica,Arial,Sans-serif; font-size-adjust: none; font-size: 14px; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; margin: 12px auto 6px auto;"><a href="http://www.scribd.com/doc/140729859/TWI-Pechakucha" style="text-decoration: underline;" title="View TWI Pechakucha on Scribd">TWI Pechakucha</a></div><iframe class="scribd_iframe_embed" data-aspect-ratio="undefined" data-auto-height="false" frameborder="0" height="600" id="doc_89384" scrolling="no" src="http://www.scribd.com/embeds/140729859/content?start_page=1&view_mode=scroll" width="100%"></iframe>Anonymoushttp://www.blogger.com/profile/01293468005249034620noreply@blogger.com0tag:blogger.com,1999:blog-8508408386087224500.post-78933150350910825192013-04-20T18:49:00.000+08:002013-06-13T20:14:06.705+08:00daily debugging tips and toolbox<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"><br />
<!-- Created by htmlize-1.34 in css mode. --><br />
<html><br />
<head><br />
<title>debugging.org</title><br />
<style type="text/css">
<!--
body {
color: #000000;
background-color: #ffffff;
}
.dired-mark {
/* dired-mark */
color: #008b8b;
}
.header-line {
/* header-line */
color: #333333;
background-color: #e5e5e5;
}
.hi-black-hb {
/* hi-black-hb */
font-size: 167%;
font-weight: bold;
}
.org-level-1 {
/* org-level-1 */
color: #0000ff;
}
.org-link {
/* org-link */
color: #3a5fcd;
text-decoration: underline;
}
.yasXfield-highlight {
/* yas/field-highlight-face */
background-color: #c1ffc1;
}
a {
color: inherit;
background-color: inherit;
font: inherit;
text-decoration: inherit;
}
a:hover {
text-decoration: underline;
}
-->
</style><br />
</head><br />
<body><br />
<pre><span class="org-level-1">* debugging tips</span>
<span class="hi-black-hb">strace::</span>
<span class="org-link">http://www.thegeekstuff.com/2011/11/strace-examples/</span>
<span class="hi-black-hb">where is the log files of specified process (e.g. nginx)?</span>
<span class="yasXfield-highlight">@firstly, find your process's pid</span>
ubuntu@ip:~<span class="header-line"> $ ps -ef | grep nginx</span>
root 13622 1 0 Mar03 ? 00:00:00 nginx: master process /usr/sbin/nginx
www-data 13623 13622 0 Mar03 ? 00:03:19 nginx: worker process
www-data 13624 13622 0 Mar03 ? 00:00:00 nginx: worker process
www-data 13625 13622 0 Mar03 ? 00:03:19 nginx: worker process
www-data 13626 13622 0 Mar03 ? 00:03:19 nginx: worker process
ubuntu 19058 18961 0 10:31 pts/0 00:00:00 grep --color=auto nginx
<span class="yasXfield-highlight">@secondly, using lsof to find all handle of that "pid", then grep it</span>
ubuntu@ip:~<span class="header-line"> $ sudo lsof -f -p 13622 | grep log</span>
nginx 13622 root 2w REG 202,1 0 145222 /var/log/nginx/error.log
nginx 13622 root 5w REG 202,1 0 135398 /var/log/nginx/access.log
nginx 13622 root 6w REG 202,1 0 145222 /var/log/nginx/error.log
<span class="hi-black-hb">which process is listen on port 80?</span>
ubuntu@ip:~<span class="header-line"> $ sudo lsof -i:80</span>
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 13622 root 7u IPv4 27232 0t0 TCP *:http (LISTEN)
nginx 13623 www-data 7u IPv4 27232 0t0 TCP *:http (LISTEN)
nginx 13624 www-data 7u IPv4 27232 0t0 TCP *:http (LISTEN)
nginx 13625 www-data 7u IPv4 27232 0t0 TCP *:http (LISTEN)
nginx 13626 www-data 7u IPv4 27232 0t0 TCP *:http (LISTEN)
<span class="hi-black-hb">what's my process's environemnt variables?</span>
[vagrant@vagrant-centos-6-64 ~]<span class="header-line"> $ ps -ef | grep apache</span>
apache 2136 1382 0 10:11 ? 00:00:00 /usr/sbin/httpd
[vagrant@vagrant-centos-6-64 ~]<span class="header-line"> $ sudo cat /proc/1382/environ</span>
TERM=linuxPATH=/sbin:/usr/sbin:/bin:/usr/binrunlevel=3RUNLEVEL=3LANGSH_SOURCED=1PWD=/LANG=Cprevious=NPREVLEVEL=NCONSOLETYPE=vtSHLVL=3UPSTART_INSTANCE=UPSTART_EVENTS=runlevelUPSTART_JOB=rc_=/usr/sbin/httpd
<span class="hi-black-hb">let mysql log the queries?</span>
<span class="yasXfield-highlight">@execute following command in mysql console</span>
SET GLOBAL log_output = 'FILE'; Set GLOBAL general_log_file = '/tmp/mysql.log'; SET GLOBAL general_log = 'ON';
<span class="yasXfield-highlight">@ or directly in bash</span>
<span class="header-line"> $ mysql -uroot -pYOUR-PASSWORD -e "SET GLOBAL log_output = 'FILE'; Set GLOBAL general_log_file = '/tmp/mysql.log'; SET GLOBAL general_log = 'ON';"</span>
<span class="yasXfield-highlight">@ then tail /tmp/mysql.log, see the quries against mysql</span>
<span class="header-line"> $ tail -f /tmp/mysql.log</span>
<span class="hi-black-hb">how to monitor http request/response of this machine?</span>
<span class="yasXfield-highlight">@install justniffer on mac</span>
<span class="header-line"> $ brew install boost</span>
<span class="header-line"> $ brew install justniffer</span>
<span class="yasXfield-highlight">@ Capture all tcp traffic</span>
<span class="header-line"> $ sudo justniffer -i eth0 -r</span>
<span class="dired-mark"> GET /null_main.c HTTP/1.1</span>
<span class="dired-mark"> Host: localhost:9000</span>
<span class="dired-mark"> Connection: keep-alive</span>
<span class="dired-mark"> Cache-Control: max-age=0</span>
<span class="dired-mark"> Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8</span>
<span class="dired-mark"> User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36</span>
<span class="dired-mark"> Accept-Encoding: gzip,deflate,sdch</span>
<span class="dired-mark"> Accept-Language: en-US,en;q=0.8</span>
<span class="dired-mark"> If-Modified-Since: Sat, 20 Oct 2012 09:17:23 GMT</span>
<span class="dired-mark"> </span>
<span class="dired-mark"> HTTP/1.0 200 OK</span>
<span class="dired-mark"> Server: SimpleHTTP/0.6 Python/2.7.1</span>
<span class="dired-mark"> Date: Thu, 06 Jun 2013 13:27:41 GMT</span>
<span class="dired-mark"> Content-type: text/plain</span>
<span class="dired-mark"> Content-Length: 46</span>
<span class="dired-mark"> Last-Modified: Sat, 20 Oct 2012 09:17:23 GMT</span>
<span class="dired-mark"> </span>
<span class="dired-mark"> /* null_main.c */</span>
<span class="dired-mark"> </span>
<span class="dired-mark"> int main() {</span>
<span class="dired-mark"> return 0;</span>
<span class="dired-mark"> }</span>
<span class="yasXfield-highlight">@ Capture only http traffic</span>
<span class="header-line"> $ sudo justniffer -i eth0 -r -p "port 80 or port 8080"</span>
<span class="yasXfield-highlight">@Capture smtp traffic (usually using tcp port 25)</span>
<span class="header-line"> $ sudo justniffer -i eth0 -r -p "port 25"</span>
<span class="dired-mark"> 220 plecno.com ESMTP Postfix (Ubuntu)</span>
<span class="dired-mark"> </span>
<span class="dired-mark"> EHLO unknown.localnet</span>
<span class="dired-mark"> 250-plecno.com </span>
<span class="dired-mark"> 250-PIPELINING </span>
<span class="dired-mark"> 250-SIZE </span>
<span class="dired-mark"> 250-VRFY </span>
<span class="dired-mark"> 250-ETRN </span>
<span class="dired-mark"> 250-STARTTLS </span>
<span class="dired-mark"> 250-ENHANCEDSTATUSCODES</span>
<span class="dired-mark"> 250-8BITMIME </span>
<span class="dired-mark"> 250 DSN</span>
<span class="dired-mark"> ...</span>
<span class="dired-mark"> --Boundary-00=_ZI47J3FTNXn+25g</span>
<span class="dired-mark"> Content-Type: text/html;</span>
<span class="dired-mark"> charset="us-ascii"</span>
<span class="dired-mark"> Content-Transfer-Encoding: 7bit</span>
<span class="dired-mark"> </span>
<span class="dired-mark"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"</span>
<span class="dired-mark"> "http://www.w3.org/TR/REC-html40/strict.dtd"></span>
<span class="dired-mark"> <html></span>
<span class="dired-mark"> <head></span>
<span class="dired-mark"> ...</span>
<span class="hi-black-hb">How to monitor changes in directory?</span>
<span class="yasXfield-highlight">@run following command, and try to touch/rm files. the results of `watch` will changing.</span>
<span class="header-line"> $ watch -d -n 0.1 "ls"</span>
<span class="hi-black-hb">How to start a HTTP server on port 3000 for files in directory ~?</span>
<span class="header-line"> $ cd ~</span>
<span class="header-line"> $ python -m SimpleHTTPServer 3000</span>
<span class="hi-black-hb">TO BE CONTINUE::::</span></pre> </body><br />
</html><br />
Anonymoushttp://www.blogger.com/profile/01293468005249034620noreply@blogger.com0tag:blogger.com,1999:blog-8508408386087224500.post-43302555406842552132013-04-08T21:37:00.001+08:002013-04-29T20:09:26.030+08:00Unix system programming workshop<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-cPnC1f2-yDq6NOJG65yGSqDNw59tEGRi2QMwVgWJ3P8iFk9g2oYAd7NNETZzp-X_-oe9ACFSzwabSg454cSwIGoub3XsAel-CqMZHSOZT9ZqvYR3-purSs8pbyNBgFXpfcag7Nzu1o4/s640/blogger-image-845220556.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-cPnC1f2-yDq6NOJG65yGSqDNw59tEGRi2QMwVgWJ3P8iFk9g2oYAd7NNETZzp-X_-oe9ACFSzwabSg454cSwIGoub3XsAel-CqMZHSOZT9ZqvYR3-purSs8pbyNBgFXpfcag7Nzu1o4/s640/blogger-image-845220556.jpg" /></a></div>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgH8zekp1nxalO54B0Q0G2prqGf3VN68bywq6GXtOQ-_j3UbSVHWMLDl4FOzlKxJhbPfCJVQv49zOzJZwkP0O00WN7Hawcospp7xb3H7kC4JMrBqml3r4G4Fk1cDN6a9kUObkvfYvq2p2o/s1600/blogger-image-774419326.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="150" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgH8zekp1nxalO54B0Q0G2prqGf3VN68bywq6GXtOQ-_j3UbSVHWMLDl4FOzlKxJhbPfCJVQv49zOzJZwkP0O00WN7Hawcospp7xb3H7kC4JMrBqml3r4G4Fk1cDN6a9kUObkvfYvq2p2o/s200/blogger-image-774419326.jpg" style="text-align: center;" width="200" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwjEDvhxzgw6UGm1xLlwWxXxkiPumn64UumC4hoJR-P6WIGPoD248tVXfzTiUZCR6Hn6PXC8l3gwFQHsXiiYl3VXB3QzOx6Bispk7bq4j0YUV10Xe6k88aiybW_Puebek9J-SDC85Yd3M/s640/blogger-image--1591743130.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="150" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwjEDvhxzgw6UGm1xLlwWxXxkiPumn64UumC4hoJR-P6WIGPoD248tVXfzTiUZCR6Hn6PXC8l3gwFQHsXiiYl3VXB3QzOx6Bispk7bq4j0YUV10Xe6k88aiybW_Puebek9J-SDC85Yd3M/s200/blogger-image--1591743130.jpg" style="clear: both; text-align: center;" width="200" /></a></div>
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkp2aMi72Xykm6cRrCc_faemXida4WLYWxpo-wtw3GSAMBAWRPmi75RgokNjAivowdO0YBnZaqjCHsPqBOB-Atba8090rAgikvjptSfbZJhSMYsorST_1D-k80gbz0RaqQo7DLQxfvwQg/s640/blogger-image-1331897552.jpg" imageanchor="1" style="clear: both; text-align: center;"></a><br />
<br />
<br />
<br />
<br />
<br />Anonymoushttp://www.blogger.com/profile/01293468005249034620noreply@blogger.com0tag:blogger.com,1999:blog-8508408386087224500.post-70248147391847986242013-04-06T20:51:00.001+08:002013-06-01T00:21:31.616+08:00express-IOChttps://github.com/whunmr/express-ioc <br />
https://github.com/johnelf/express-mvc<br />
https://github.com/whunmr/express-orm<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6KFnIXEg1fRqseqjWjNPhmCboTeV76w0XWoDAX69pU4W8-WsZLqRVlqV0sG15LcGyGNnhxiqyoy8n-h7cljywKVHnO2Q0XaazOtWTliHFmsuTJo_3mnLqsRXD6tC0rlrXG3MYUw5rQYU/s640/blogger-image-1334742843.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6KFnIXEg1fRqseqjWjNPhmCboTeV76w0XWoDAX69pU4W8-WsZLqRVlqV0sG15LcGyGNnhxiqyoy8n-h7cljywKVHnO2Q0XaazOtWTliHFmsuTJo_3mnLqsRXD6tC0rlrXG3MYUw5rQYU/s200/blogger-image-1334742843.jpg" width="150" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTyz58GoRJhFAIjuMEu-wJJCUBdDyAYH90soKpcCb6uDw1IEnrgvvY6OyEthVwzg6GG7JrEZ1elaKLJOTiko_XP5iqSBzio7iX0JV6eai9MiLheK1zz1VOZqamdRTgT3-bUz0XTM8OEQc/s640/blogger-image-1204841203.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTyz58GoRJhFAIjuMEu-wJJCUBdDyAYH90soKpcCb6uDw1IEnrgvvY6OyEthVwzg6GG7JrEZ1elaKLJOTiko_XP5iqSBzio7iX0JV6eai9MiLheK1zz1VOZqamdRTgT3-bUz0XTM8OEQc/s200/blogger-image-1204841203.jpg" width="150" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhunXeGeJ55AVUR-XR4Kzgq0-kxN5YS8B-qmelsXrdWy5CYzj1B-WJruSSPR-_jJ7K1ZHTvy0MKStj1ZhPOhmljOni0lioUgHTP9_frDeqxh0Wxd9wJNWmtwYUj4IP7p9ZuCgPHwY58S0Q/s640/blogger-image--1629648921.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhunXeGeJ55AVUR-XR4Kzgq0-kxN5YS8B-qmelsXrdWy5CYzj1B-WJruSSPR-_jJ7K1ZHTvy0MKStj1ZhPOhmljOni0lioUgHTP9_frDeqxh0Wxd9wJNWmtwYUj4IP7p9ZuCgPHwY58S0Q/s200/blogger-image--1629648921.jpg" width="150" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyrgwnzv2T-e_Ji6lFMigVorqWYiVQxitX53DuF0LJLm-KPntOK30hz365xV9_wQlH8GMJy6BmGoYNPZKXTZYGqnUawUYMoKC3JqO0HXgN5-BxDmPYbeBnMlNzpaVnQD5WYWdIr1NR9I0/s1600/photo+(1).JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyrgwnzv2T-e_Ji6lFMigVorqWYiVQxitX53DuF0LJLm-KPntOK30hz365xV9_wQlH8GMJy6BmGoYNPZKXTZYGqnUawUYMoKC3JqO0HXgN5-BxDmPYbeBnMlNzpaVnQD5WYWdIr1NR9I0/s320/photo+(1).JPG" width="240" /></a></div>
<br />
<div>
<b>Framework design:</b></div>
<div>
<ul>
<li>less intrusiveness</li>
<li>simple to use</li>
<li>Flent API: User.find_all().includes(Article.class);</li>
<li>Convention over configuration</li>
</ul>
</div>
<div>
<b><br />
</b></div>
<div>
<b>DEMO CODE</b></div>
<div>
<span style="-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; border-collapse: separate; color: black; font-family: Arial; font-size: xx-small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"> git@github.com:whunmr/express-orm.git</span></div>
<div>
<b><br />
</b></div>
<div>
<b><br />
</b></div>
<div>
<b>IMPLEMENTATION of Lazy List</b></div>
<div>
<a href="https://github.com/whunmr/express-orm/blob/master/core/src/main/java/com/thoughtworks/query/QueryList.java">https://github.com/whunmr/express-orm/blob/master/core/src/main/java/com/thoughtworks/query/QueryList.java</a><b><br />
</b></div>
<div>
<br /></div>
<div>
<b><br />
</b></div>
<div>
<b>Harmcrest: </b><a href="http://net.tutsplus.com/tutorials/php/expressive-tests-with-hamcrest/">http://net.tutsplus.com/tutorials/php/expressive-tests-with-hamcrest/</a></div>
<div>
<ul>
<li>allOf</li>
<li>anyOf</li>
<li>both</li>
<li>either</li>
<li>describedAs</li>
<li>everyItem</li>
<li>is</li>
<li>anything</li>
<li>hasItem</li>
<li>hasItems</li>
<li>equalTo</li>
<li>instanceOf</li>
<li>any</li>
<li>not</li>
<li>nullValue</li>
<li>notNullValue</li>
<li>sameInstance</li>
<li>containsString</li>
<li>endsWith</li>
<li>startsWith</li>
<li>hasProperty</li>
<li>samePropertyValuesAs</li>
<li>array</li>
<li>hasItemInArray</li>
<li>arrayContainingInAnyOrder</li>
<li>arrayContaining</li>
<li>arrayWithSize</li>
<li>emptyArray</li>
<li>hasSize</li>
<li>empty</li>
<li>emptyIterable</li>
<li>isIn</li>
<li>isOneOf</li>
<li>containsInAnyOrder</li>
<li>contains</li>
<li>iterableWithSize</li>
<li>hasEntry</li>
<li>hasKey</li>
<li>hasValue</li>
<li>closeTo</li>
<li>comparesEqualTo</li>
<li>greaterThan</li>
<li>greaterThanOrEqualTo</li>
<li>lessThan</li>
<li>lessThanOrEqualTo</li>
<li>hasToString</li>
<li>typeCompatibleWith</li>
<li>eventFrom</li>
<li>isEmptyString</li>
<li>isEmptyOrNullString</li>
<li>equalToIgnoringCase</li>
<li>equalToIgnoringWhiteSpace</li>
<li>stringContainsInOrder</li>
<li>hasXPath</li>
<li>matcher1</li>
<li>matcher2</li>
<li>matcher3</li>
<li>firstMethod</li>
<li>secondMethod</li>
<li>notStatic</li>
<li>notPublic</li>
<li>goodMethod</li>
<li>anotherGoodMethod</li>
<li>wrongReturnType</li>
<li>generifiedType</li>
<li>noGenerifiedType</li>
<li>crazyType</li>
<li>withParam</li>
<li>withArray</li>
<li>withVarArgs</li>
<li>withGenerifiedParam</li>
<li>withExceptions</li>
<li>documented</li>
<li>subclassMethod</li>
</ul>
</div>
<div>
<b>GUAVA</b></div>
<div>
<a href="https://code.google.com/p/guava-libraries/wiki/ImmutableCollectionsExplained">https://code.google.com/p/guava-libraries/wiki/ImmutableCollectionsExplained</a></div>
<div>
<b>moco:</b></div>
<div>
<a href="https://github.com/dreamhead/moco">https://github.com/dreamhead/moco</a> </div>
<div>
<br /></div>
<b>cglib introduction:</b><br />
<div>
<a href="http://markbramnik.blogspot.jp/2010/04/cglib-introduction.html">http://markbramnik.blogspot.jp/2010/04/cglib-introduction.html</a></div>
<div>
<br /></div>
<div>
<b>dynamic-proxy:</b></div>
<div>
git@github.com:whunmr/java-demos.git</div>
<div>
<br />
<div>
<b>javassist:</b></div>
<div>
<a href="http://www.csg.ci.i.u-tokyo.ac.jp/~chiba/javassist/tutorial/tutorial.html">http://www.csg.ci.i.u-tokyo.ac.jp/~chiba/javassist/tutorial/tutorial.html</a> </div>
<div>
<br /></div>
</div>
<br />
<div>
<b>intelliJ IDEA</b></div>
<div>
<b><span style="-webkit-text-stroke-width: 0px; background-color: whitesmoke; color: #333333; display: inline !important; float: none; font-family: 'Helvetica Neue', Arial, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: 18px; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; word-spacing: 0px;">foreach: </span></b></div>
<div>
<ul>
<li><span style="-webkit-text-stroke-width: 0px; background-color: whitesmoke; color: #333333; display: inline !important; float: none; font-family: 'Helvetica Neue', Arial, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: auto; word-spacing: 0px;">iter (for each..in) </span></li>
<li><span style="-webkit-text-stroke-width: 0px; background-color: whitesmoke; color: #333333; display: inline !important; float: none; font-family: 'Helvetica Neue', Arial, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: auto; word-spacing: 0px;">itin (for..in)</span></li>
<li><span style="-webkit-text-stroke-width: 0px; background-color: whitesmoke; color: #333333; display: inline !important; float: none; font-family: 'Helvetica Neue', Arial, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: auto; word-spacing: 0px;">itli Iterate List itar Iterate array</span></li>
<li><span style="-webkit-text-stroke-width: 0px; background-color: whitesmoke; color: #333333; display: inline !important; float: none; font-family: 'Helvetica Neue', Arial, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: auto; word-spacing: 0px;">ritar reverse order</span></li>
</ul>
</div>
<div style="text-align: left;">
<span style="color: #333333; font-family: 'Helvetica Neue', Arial, sans-serif;"><span style="font-size: 14px; line-height: 18px; white-space: pre-wrap;"><b><br /></b></span></span></div>
<div style="text-align: left;">
<span style="color: #333333; font-family: 'Helvetica Neue', Arial, sans-serif;"><span style="font-size: 14px; line-height: 18px; white-space: pre-wrap;"><b>WORKSHOP about dynamic-proxy/cglib/javassist</b></span></span></div>
<div style="text-align: left;">
<span style="color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif; font-weight: bold;">a. how to using instrument lib</span></div>
<ol style="-webkit-text-stroke-width: 0px; border: 0px; color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 25px; margin-bottom: 0px !important; margin-left: 0px; margin-right: 0px; margin-top: 15px; orphans: auto; padding: 0px 0px 0px 30px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
<li style="border: 0px; margin: 0px; padding: 0px;"><code style="background-color: #f8f8f8; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(221, 221, 221); font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; margin: 0px 2px; padding: 0px 5px; white-space: nowrap;">gradle clean idea</code></li>
<li style="border: 0px; margin: 0px; padding: 0px;">in instrument folder, execute <code style="background-color: #f8f8f8; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(221, 221, 221); font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; margin: 0px 2px; padding: 0px 5px; white-space: nowrap;">gradle jar</code></li>
<li style="border: 0px; margin: 0px; padding: 0px;">setup configuration so we can using the instrument agent jar, when running junit test. In IntelliJ IDEA, Run-->Edit Configurations…-->Defaults-->JUnit: set "VM Options:" to <strong style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">-javaagent:./instrument/build/libs/instrument.jar</strong></li>
</ol>
<span style="color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif; font-weight: bold;"><br /></span>
<br />
<div>
<span style="color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif; font-weight: bold;">b. get the task from here </span><a href="https://github.com/whunmr/java-demos">https://github.com/whunmr/java-demos</a><span style="color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif; font-weight: bold;"> </span></div>
<div>
<span style="color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif;"><b><br /></b></span></div>
<div>
<span style="color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif;"><b>c. find //TASK1 //TASK2 //TASK3, and finish the //TODOs in the task.</b></span></div>
<div style="text-align: left;">
<span style="color: #333333; font-family: 'Helvetica Neue', Arial, sans-serif;"><span style="font-size: 14px; line-height: 18px; white-space: pre-wrap;"><br /></span></span></div>
<div style="text-align: left;">
<span style="color: #333333; font-family: 'Helvetica Neue', Arial, sans-serif;"><span style="font-size: 14px; line-height: 18px; white-space: pre-wrap;"><br /></span></span></div>
<div style="text-align: left;">
<span style="color: #333333; font-family: 'Helvetica Neue', Arial, sans-serif;"><span style="font-size: 14px; line-height: 18px; white-space: pre-wrap;"><b>FUTHER READING:</b></span></span></div>
<div style="text-align: left;">
<span style="color: #333333; font-family: 'Helvetica Neue', Arial, sans-serif;"><span style="font-size: 14px; line-height: 18px; white-space: pre-wrap;">Inside the Java Virtual Machine</span></span><br />
<span style="color: #333333; font-family: 'Helvetica Neue', Arial, sans-serif;"><span style="font-size: 14px; line-height: 18px; white-space: pre-wrap;"><br /></span></span>
<br />
<br /></div>
<div style="text-align: left;">
<span style="color: #333333; font-family: 'Helvetica Neue', Arial, sans-serif;"><span style="font-size: 14px; line-height: 18px; white-space: pre-wrap;"><br /></span></span></div>
Anonymoushttp://www.blogger.com/profile/01293468005249034620noreply@blogger.com0付村花园 China34.183708 108.860561tag:blogger.com,1999:blog-8508408386087224500.post-75889192355947502952013-03-24T13:06:00.001+08:002013-04-29T20:02:45.058+08:00Box2d game inception<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFHmDsLj3bDrmZPqFN1NlIC55zDxz1nwA0mRVS6SuXCodk-j6DwCBdZotts2NW5LkGg2YaN6qZ0nUrI4h1hfgGxL0eDnzILwJQReHa4kKk3slPW64kwyFPzKa2vEhshe89zsnnxRzQHk4/s640/blogger-image--987044266.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFHmDsLj3bDrmZPqFN1NlIC55zDxz1nwA0mRVS6SuXCodk-j6DwCBdZotts2NW5LkGg2YaN6qZ0nUrI4h1hfgGxL0eDnzILwJQReHa4kKk3slPW64kwyFPzKa2vEhshe89zsnnxRzQHk4/s200/blogger-image--987044266.jpg" width="150" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuxE5mkiwytN2tN428SXb1xHmP3tUP52eFUQJvQGegL0J8-F6kxkkEdke9baZSfGCiQE_m91SwknNTyTaRnZzAP8OAZ619yunBduPLfMEOwu3YiF6JDYlYNB0WiWgfk9G8zQXfOKoPysM/s640/blogger-image--1432519094.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuxE5mkiwytN2tN428SXb1xHmP3tUP52eFUQJvQGegL0J8-F6kxkkEdke9baZSfGCiQE_m91SwknNTyTaRnZzAP8OAZ619yunBduPLfMEOwu3YiF6JDYlYNB0WiWgfk9G8zQXfOKoPysM/s200/blogger-image--1432519094.jpg" width="150" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqAOHwpSySUOvVWEAS2zTcCxdud8ow0E6uckBJTkS2mixO3Th6ctNHNAgF_BbxUJpei2HRfWGIKaPwDgi3RFZPUfZdHv_UYWV6osL6x2AVH3dJ0pNtNXY7qsTqjShIOTds3sINLrFbKXU/s640/blogger-image--1673333242.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqAOHwpSySUOvVWEAS2zTcCxdud8ow0E6uckBJTkS2mixO3Th6ctNHNAgF_BbxUJpei2HRfWGIKaPwDgi3RFZPUfZdHv_UYWV6osL6x2AVH3dJ0pNtNXY7qsTqjShIOTds3sINLrFbKXU/s200/blogger-image--1673333242.jpg" width="150" /></a></div>
<br />
<br />
<br />
<br />Anonymoushttp://www.blogger.com/profile/01293468005249034620noreply@blogger.com0tag:blogger.com,1999:blog-8508408386087224500.post-74286104716653071182013-01-20T18:32:00.000+08:002013-01-22T22:17:54.732+08:00Intellij IDEA plugin "emacsIDEAs" introduction<br />
<!-- Created by htmlize-1.34 in css mode. --><br />
<html><br />
<head><br />
<title>tmp20130120___18_22_24035445a0-708d-6194-29cb-eaa258d94fed.temp</title><br />
<style type="text/css">
<!--
body {
color: #000000;
background-color: #ffffff;
}
.ATTRLIST {
/* (:foreground "Magenta" :weight bold) */
color: #ff00ff;
font-weight: bold;
}
.ATTRLIST-1 {
/* (:foreground "Blue" :weight bold) */
color: #0000ff;
font-weight: bold;
}
.ATTRLIST-2 {
/* (:foreground "Purple" :weight bold) */
color: #7f007f;
font-weight: bold;
}
.ATTRLIST-3 {
/* (:foreground "Red" :weight bold) */
color: #ff0000;
font-weight: bold;
}
.ATTRLIST-4 {
/* (:foreground "Orange" :weight bold) */
color: #ff7f00;
font-weight: bold;
}
.ATTRLIST-5 {
/* (:foreground "Black" :weight bold) */
color: #000000;
font-weight: bold;
}
.rainbow-delimiters-unmatched {
/* rainbow-delimiters-unmatched-face */
color: #88090B;
}
a {
color: inherit;
background-color: inherit;
font: inherit;
text-decoration: inherit;
}
a:hover {
text-decoration: underline;
}
</style></head></html>
<br />
<pre>This is introduction to plugin emacsIDEAs of Intellij IDEA.
1<span class="rainbow-delimiters-unmatched">)</span> normal jump demo C-L <char></pre>
<pre></pre>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBUi4dX8Y6MjVfOw7xgSZB5hDVr5rFUQF6nA5FTndzukIfkEjK5yF7d3h_w-elLtKFkCU4h8wTDx_IDrx45sYIp6B6EG3O_ys6t3Hrbi07mtnSsRQgbUmDsNehwMKaAqAj60jdhYwTl3c/s1600/Screen+Shot+2013-01-20+at+6.28.19+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBUi4dX8Y6MjVfOw7xgSZB5hDVr5rFUQF6nA5FTndzukIfkEjK5yF7d3h_w-elLtKFkCU4h8wTDx_IDrx45sYIp6B6EG3O_ys6t3Hrbi07mtnSsRQgbUmDsNehwMKaAqAj60jdhYwTl3c/s1600/Screen+Shot+2013-01-20+at+6.28.19+PM.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1X9fWN3d_4p1rPVR6uEfUMAsUcf5vB8GANfQIOMS9Ub-TapE8iPvWkGjGjiR98PU66NurYVl50BAnuDp4GugU89AyMIFcR_AoR9qdCGDzdwTchB5rG_Cv1XVyx9pzxhgX8QKRXpHjN0o/s1600/JumpToChar.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1X9fWN3d_4p1rPVR6uEfUMAsUcf5vB8GANfQIOMS9Ub-TapE8iPvWkGjGjiR98PU66NurYVl50BAnuDp4GugU89AyMIFcR_AoR9qdCGDzdwTchB5rG_Cv1XVyx9pzxhgX8QKRXpHjN0o/s1600/JumpToChar.gif" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<pre>2<span class="rainbow-delimiters-unmatched">)</span> jump to line end C-L <space>
type space to show line end.</pre>
<pre></pre>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHBz_7itAagsp-HWwh6Wyxoc71SBp2WqnVPw7fzI2uBCfdZSpy39A_rrBuyNi-K0OjzdFRqUpu6W6LEJixGrlYSu7o5FN7jIBf417SVLnTkF9OdlJ3pZh0oKDMUVsevfWzeR0DCx8GTJE/s1600/Screen+Shot+2013-01-20+at+6.30.49+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHBz_7itAagsp-HWwh6Wyxoc71SBp2WqnVPw7fzI2uBCfdZSpy39A_rrBuyNi-K0OjzdFRqUpu6W6LEJixGrlYSu7o5FN7jIBf417SVLnTkF9OdlJ3pZh0oKDMUVsevfWzeR0DCx8GTJE/s1600/Screen+Shot+2013-01-20+at+6.30.49+PM.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNwWNqre2Lqpn1b3MkaPmPFKV4ZROYHMM62tCuDEh_MCwXyXGTjEjU-zWvxbhMFgHnsDOsxPbS9iZyFtQmV2ZHnhRaBSHkeO4p_hvEIlHiCJyvamFIv2OMrYGxn6ds9gc85gVpgNklfTc/s1600/JumpToLineEnd.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNwWNqre2Lqpn1b3MkaPmPFKV4ZROYHMM62tCuDEh_MCwXyXGTjEjU-zWvxbhMFgHnsDOsxPbS9iZyFtQmV2ZHnhRaBSHkeO4p_hvEIlHiCJyvamFIv2OMrYGxn6ds9gc85gVpgNklfTc/s1600/JumpToLineEnd.gif" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<pre>3<span class="rainbow-delimiters-unmatched">)</span> Jump and Copy C-L <char> c <marker_char>
after markers show up, type 'c' to copy jump area.</pre>
<pre>
</pre>
<pre>
4<span class="rainbow-delimiters-unmatched">)</span> Jump and Paste C-L <char> p <marker_char>
after markers show up, type 'p' to paste clipboard contents to jump target position.
</pre>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVQUcXqcm1SbUGEoDYAWjZBqMCQjhMio-UlmV8X_BW1JC2GtUWVRD8VuZ4yoG1E12tb7Xo3IVsh3nAE-OE53P60p610k3hpUnMMZV8k4T_gTAQ0GqZa9Y_wqiVkE8s4RXu7t5MWb9PWGo/s1600/JumpAndPaste.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVQUcXqcm1SbUGEoDYAWjZBqMCQjhMio-UlmV8X_BW1JC2GtUWVRD8VuZ4yoG1E12tb7Xo3IVsh3nAE-OE53P60p610k3hpUnMMZV8k4T_gTAQ0GqZa9Y_wqiVkE8s4RXu7t5MWb9PWGo/s1600/JumpAndPaste.gif" /></a></div>
<pre>
</pre>
<pre>5<span class="rainbow-delimiters-unmatched">)</span> Jump and Cut C-L <char> x <marker_char>
after markers show up, type x before marker_char to cut jump area.
</pre>
<pre>
</pre>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbPvxrHMOssATskG93qcDpIiivEk1TxMKUncqNc9iUNE-zzhbzRHZvt7GNGybwx4lp2FZs_LY8YQOknU_uOw6oQT-snfOzCr1eZpRka2UgHtYtkaFPibJwH7sioi3gjNtJpnUlC_bQf74/s1600/JumpAndCut.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbPvxrHMOssATskG93qcDpIiivEk1TxMKUncqNc9iUNE-zzhbzRHZvt7GNGybwx4lp2FZs_LY8YQOknU_uOw6oQT-snfOzCr1eZpRka2UgHtYtkaFPibJwH7sioi3gjNtJpnUlC_bQf74/s1600/JumpAndCut.gif" /></a></div>
<pre> </pre>
<pre>
</pre>
<pre></pre>
<pre>6)Jump and Selection Cmd-L <char> s <marker_char></pre>
<pre></pre>
<pre><span class="rainbow-delimiters-unmatched">7)</span> during jump, type ESC to exit.
</pre>
<pre></pre>
<pre></pre>
<pre>
</pre>
<pre>Installation:</pre>
<pre> Preferences... --> Plugins --> Browse repositories -> search "emacsIDEAs" to install</pre>
<pre>
</pre>
<pre> </pre>
<pre></pre>
<pre></pre>
<pre></pre>
<pre></pre>
<pre></pre>
<pre></pre>
<a href="https://github.com/whunmr/emacsIDEAs">https://github.com/whunmr/emacsIDEAs</a><br />
<a href="http://plugins.intellij.net/plugin?pr=idea&pluginId=7163">http://plugins.intellij.net/plugin?pr=idea&pluginId=7163</a><br />
<br />
<br />
<br />
-->Anonymoushttp://www.blogger.com/profile/01293468005249034620noreply@blogger.com0tag:blogger.com,1999:blog-8508408386087224500.post-31737091409551734912013-01-18T01:57:00.001+08:002013-05-28T22:10:28.309+08:00AceJump for Intellij IDEA development notes<br />
<!-- Created by htmlize-1.34 in css mode. --><br />
<html><br />
<head><br />
<title>intellijmacs.org</title><br />
<style type="text/css">
<!--
body {
color: #000000;
background-color: #ffffff;
}
.org-done {
/* org-done */
color: #228b22;
font-weight: bold;
}
.org-level-2 {
/* org-level-2 */
color: #a0522d;
}
.org-todo {
/* org-todo */
color: #ff0000;
font-weight: bold;
}
a {
color: inherit;
background-color: inherit;
font: inherit;
text-decoration: inherit;
}
a:hover {
text-decoration: underline;
}
</style></head></html>
<br />
<br />
<br />
<br />
<pre><span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> C-I C-R (w | s | l | q | a | A | e | E | p | u | d) 't' 'm' : copy current word/line/paragraph, jump, then replace target word/line/paragraph</span>
<span class="org-level-2">** </span><span class="org-todo">TODO</span><span class="org-level-2"> remove space chars (let only one space?)</span>...
<span class="org-level-2">** </span><span class="org-todo">TODO</span><span class="org-level-2"> join selected lines</span>
<span class="org-level-2">** </span><span class="org-todo">TODO</span><span class="org-level-2"> C-c n <char> to copy until</span>
<span class="org-level-2">** </span><span class="org-todo">TODO</span><span class="org-level-2"> add a function like Cmd+Space to left only one space after caret</span>
<span class="org-level-2">** </span><span class="org-todo">TODO</span><span class="org-level-2"> let C+, and C+. search exactly for currently selected string</span>
<span class="org-level-2">** </span><span class="org-todo">TODO</span><span class="org-level-2"> add Cmd+c to zip copy char to ' '</span>
<span class="org-level-2">** </span><span class="org-todo">TODO</span><span class="org-level-2"> access left project file panel to jump</span>
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> rename to emacsIDEAs</span>
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> remove KeyEventDispatcher</span>
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> remove unused comment</span>
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> ESC to dismiss markers panel</span>
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> bug: when show markers in one file, switch to another file can not jump again.</span>
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> supports punctuation chars, such as !@#$%^&*()_-=+</span>
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> support max larger than 26 points to jump</span>
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> test C-l ' ' will show markers of ' ' '\t'</span>
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> test C-l '/' will show markers of line end.</span>
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> jump to end of line </span>
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> direct jump to location when only one jump candicate</span>...
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> fix bug: when has horizental scroll</span>
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> fix bug: when a-z as marker char set, typing 'A' should find 'a'</span>
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> acejump selection mode</span>
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> communicate system in intellij</span>
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> jump to begin </span>
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> acejump line mode</span>
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> use different marker color for multiple jump markers</span>
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> using C-l C-c for copy, and C-l C-x for cut, and C-l C-s for select</span>
<span class="org-level-2">** </span><span class="org-todo">TODO</span><span class="org-level-2"> add C-c f to copy file name, C-c F to copy fullpath filename</span>
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> add visiual effect after jump Copy</span>
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> move to nearest intention area</span>
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> C-c e copy to end</span>
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> C-c b copy block</span>
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> C-c ' ' A to cut to file beginning</span>
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> C-c ' ' E to cut to file end</span>
<span class="org-level-2">** </span><span class="org-todo">TODO</span><span class="org-level-2"> C-c P to copy paragraph but not copy trailling }</span>
<span class="org-level-2">** </span><span class="org-todo">TODO</span><span class="org-level-2"> C-c E copy to end, but remove trialling unbalanced parenthesis</span>
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> C-c ' ' p to cut paragraph</span>
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> C-c ' ' ' ' p to select paragraph</span>
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> C-c Q to copy quoted string with parenthesis</span>
<span class="org-level-2">** </span><span class="org-todo">TODO</span><span class="org-level-2"> NOT_FOUND replace -1</span>
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> move focus to editor window when focus on some other window when type C-L</span>
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> acejump word mode</span>
<span class="org-level-2">** </span><span class="org-todo">TODO</span><span class="org-level-2"> add turn on and turn off function </span>
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> show visual bell when error, such as not such key in document, no such marker char.</span>
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> selection by execute two aceJump</span>
<span class="org-level-2">** </span><span class="org-todo">TODO</span><span class="org-level-2"> replace char in line A->B</span>...
<span class="org-level-2">** </span><span class="org-todo">TODO</span><span class="org-level-2"> shrink less used member variables </span>...
<span class="org-level-2">** </span><span class="org-todo">TODO</span><span class="org-level-2"> redraw panel when editor window resized.</span>
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> copy word, paragraph, in "a"</span>
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> add visiual effect after copy-without-selection.</span>
<span class="org-level-2">** </span><span class="org-todo">TODO</span><span class="org-level-2"> create markers for left project navigation panel</span>
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> show intention after move to quickfix intention</span>...
<span class="org-level-2">** </span><span class="org-todo">TODO</span><span class="org-level-2"> replace true and false in key listener handler to boolean constant</span>
<span class="org-level-2">** </span><span class="org-todo">TODO</span><span class="org-level-2"> cut to next char location</span>
<span class="org-level-2">** </span><span class="org-todo">TODO</span><span class="org-level-2"> Anything in intellij</span>
<span class="org-level-2">** </span><span class="org-done">DONE</span><span class="org-level-2"> support word jump mode</span>
<span class="org-level-2">** </span><span class="org-todo">TODO</span><span class="org-level-2"> support line jump mode</span>
<span class="org-level-2">** </span><span class="org-todo">TODO</span><span class="org-level-2"> C-c f copy file name, C-c F copy file path name, C-c c copy class name, C-c C copy full class name</span>
</pre>
<br />
-->Anonymoushttp://www.blogger.com/profile/01293468005249034620noreply@blogger.com0tag:blogger.com,1999:blog-8508408386087224500.post-48911533068080986892012-12-26T22:38:00.000+08:002013-05-02T18:01:29.958+08:00Adding Customized HTTP Header in HTTPServletRequest in JettySometimes we need Adding some customized HTTP header in Jetty's Request.<br />
<br />
Here is a way to change Request.getHeader() using <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/instrument/package-summary.html">java.lang.instrument</a> and <a href="http://www.jboss.org/javassist">javassist</a>.<br />
<br />
<script src="https://gist.github.com/4380607.js"></script><br />
<br />
<br />
<b>contents of MANIFEST.MF:</b><br />
<script src="https://gist.github.com/4380624.js"></script><br />
<br />
<b>command to compile and pack jar:</b><br />
javac -classpath ./javassist.jar HeaderAgent.java <br />
jar -cmf MANIFEST.MF sslagent.jar HeaderAgent.class <br />
<br />
<br />
adding following option to your java command, then Request.getHeader() method will be customized after Request.class loaded.<br />
-javaagent:$HOME/bin/jettySSLPlugin/sslagent.jar <br />
<br />
git@github.com:whunmr/jettyHeaderAgent.gitAnonymoushttp://www.blogger.com/profile/01293468005249034620noreply@blogger.com0tag:blogger.com,1999:blog-8508408386087224500.post-64176695438081317542012-11-18T11:18:00.001+08:002012-11-18T11:46:55.958+08:00[emacs]go to end-of-buffer ignore whitespaces<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBC1G_ZhSQT_Bz33hsyfXJQPRIwrA3MyBbNTI1bYY_IUjkS-4MlqVJKy-5cP8JjvEelUN3Ei0bl1KCrXeG98y1Sog9-Y_7FUxCYPXRBbnbXGH7lJFOoxe8c7uEZHZXsJvw5gP7aqDqpkY/s1600/emacs-end-of-buffer.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="364" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBC1G_ZhSQT_Bz33hsyfXJQPRIwrA3MyBbNTI1bYY_IUjkS-4MlqVJKy-5cP8JjvEelUN3Ei0bl1KCrXeG98y1Sog9-Y_7FUxCYPXRBbnbXGH7lJFOoxe8c7uEZHZXsJvw5gP7aqDqpkY/s640/emacs-end-of-buffer.gif" width="640" /></a></div>
<br />
<!-- Created by htmlize-1.34 in css mode. --><br />
<html><br />
<head><br />
<title>init.el</title><br />
<style type="text/css">
<!--
body {
color: #000000;
background-color: #ffffff;
}
.comment {
/* font-lock-comment-face */
color: #b22222;
}
.comment-delimiter {
/* font-lock-comment-delimiter-face */
color: #b22222;
}
.doc {
/* font-lock-doc-face */
color: #8b2252;
}
.function-name {
/* font-lock-function-name-face */
color: #0000ff;
}
.keyword {
/* font-lock-keyword-face */
color: #7f007f;
}
.negation-char {
}
.rainbow-delimiters-depth-1 {
/* rainbow-delimiters-depth-1-face */
color: #707183;
}
.rainbow-delimiters-depth-2 {
/* rainbow-delimiters-depth-2-face */
color: #7388d6;
}
.rainbow-delimiters-depth-3 {
/* rainbow-delimiters-depth-3-face */
color: #909183;
}
.rainbow-delimiters-depth-4 {
/* rainbow-delimiters-depth-4-face */
color: #709870;
}
.rainbow-delimiters-depth-5 {
/* rainbow-delimiters-depth-5-face */
color: #907373;
}
.rainbow-delimiters-depth-6 {
/* rainbow-delimiters-depth-6-face */
color: #6276ba;
}
.string {
/* font-lock-string-face */
color: #8b2252;
}
a {
color: inherit;
background-color: inherit;
font: inherit;
text-decoration: inherit;
}
a:hover {
text-decoration: underline;
}
</style></head></html>
<br />
<br />
<br />
<br />
<pre><span class="comment-delimiter">;;</span><span class="comment">we always need goto end-of-buffer, so we bind it to C-. for simple.
</span><span class="comment-delimiter">;;</span><span class="comment">sometimes we need goto end-of-buffer, but ignore whitespaces at end-of-buffer
</span><span class="comment-delimiter">;;</span><span class="comment">so by give end-of-buffer an advice, it'll switch between these points, when you
</span><span class="comment-delimiter">;;</span><span class="comment">continue typing C-.
</span><span class="rainbow-delimiters-depth-1">(</span><span class="keyword">defadvice</span> <span class="function-name">end-of-buffer</span> <span class="rainbow-delimiters-depth-2">(</span>around move-backward-skip-whitespace<span class="rainbow-delimiters-depth-2">)</span>
<span class="doc">"Never use tabs for alignment."</span>
<span class="rainbow-delimiters-depth-2">(</span><span class="keyword">let</span> <span class="rainbow-delimiters-depth-3">(</span><span class="rainbow-delimiters-depth-4">(</span>point-before-move <span class="rainbow-delimiters-depth-5">(</span>point<span class="rainbow-delimiters-depth-5">)</span><span class="rainbow-delimiters-depth-4">)</span><span class="rainbow-delimiters-depth-3">)</span>
ad-do-it
<span class="rainbow-delimiters-depth-3">(</span><span class="keyword">if</span> <span class="rainbow-delimiters-depth-4">(</span>and <span class="rainbow-delimiters-depth-5">(</span>eq point-before-move <span class="rainbow-delimiters-depth-6">(</span>point<span class="rainbow-delimiters-depth-6">)</span><span class="rainbow-delimiters-depth-5">)</span> <span class="rainbow-delimiters-depth-5">(</span>eq last-command this-command<span class="rainbow-delimiters-depth-5">)</span><span class="rainbow-delimiters-depth-4">)</span>
<span class="rainbow-delimiters-depth-4">(</span><span class="keyword">progn</span> <span class="rainbow-delimiters-depth-5">(</span>search-backward-regexp <span class="string">"[</span><span class="string"><span class="negation-char">^</span></span><span class="string">\n\s-]\\W*"</span><span class="rainbow-delimiters-depth-5">)</span>
<span class="rainbow-delimiters-depth-5">(</span>forward-char<span class="rainbow-delimiters-depth-5">)</span><span class="rainbow-delimiters-depth-4">)</span><span class="rainbow-delimiters-depth-3">)</span>
<span class="rainbow-delimiters-depth-2">)</span><span class="rainbow-delimiters-depth-1">)</span>
<span class="rainbow-delimiters-depth-1">(</span>ad-activate 'end-of-buffer<span class="rainbow-delimiters-depth-1">)</span>
<span class="rainbow-delimiters-depth-1">(</span>define-key my-keys-minor-mode-map <span class="rainbow-delimiters-depth-2">(</span>kbd <span class="string">"C-."</span><span class="rainbow-delimiters-depth-2">)</span> 'end-of-buffer<span class="rainbow-delimiters-depth-1">)</span>
</pre>
<br />
-->Anonymoushttp://www.blogger.com/profile/01293468005249034620noreply@blogger.com0tag:blogger.com,1999:blog-8508408386087224500.post-20255879643907805102012-11-09T21:11:00.002+08:002012-11-09T21:40:17.053+08:00[emacs] compare with clipboard like IntelliJ IDEA<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2HjQIyWqEvG2dM9vbwOnOFdSgWDAivlncma3cfP3m3Kg31JwlBQawAm2Mu6Q-XJv3CE8b_LwERdIphoqf7EhG0YMn_zH3HdWul8O6A78beFphCmM7ynIq8hPPEU1OiazYp286FrGw3t8/s1600/emacs-compare.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2HjQIyWqEvG2dM9vbwOnOFdSgWDAivlncma3cfP3m3Kg31JwlBQawAm2Mu6Q-XJv3CE8b_LwERdIphoqf7EhG0YMn_zH3HdWul8O6A78beFphCmM7ynIq8hPPEU1OiazYp286FrGw3t8/s640/emacs-compare.gif" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<!-- Created by htmlize-1.34 in css mode. --><br />
<html><br />
<head><br />
<title>comparewithclipboard.el</title><br />
<style type="text/css">
<!--
body {
color: #000000;
background-color: #ffffff;
}
.ATTRLIST {
/* (:foreground "firebrick1" :weight bold) */
color: #ff3030;
font-weight: bold;
}
.ATTRLIST-1 {
/* (:foreground "IndianRed1" :weight bold) */
color: #ff6a6a;
font-weight: bold;
}
.ATTRLIST-2 {
/* (:foreground "IndianRed3" :weight bold) */
color: #cd5555;
font-weight: bold;
}
.ATTRLIST-3 {
/* (:foreground "IndianRed4" :weight bold) */
color: #8b3a3a;
font-weight: bold;
}
.doc {
/* font-lock-doc-face */
color: #8b2252;
}
.function-name {
/* font-lock-function-name-face */
color: #0000ff;
}
.keyword {
/* font-lock-keyword-face */
color: #7f007f;
}
.semantic-highlight-func-current-tag {
/* semantic-highlight-func-current-tag-face */
background-color: #e5e5e5;
}
.semantic-tag-boundary {
/* semantic-tag-boundary-face */
text-decoration: overline;
}
.string {
/* font-lock-string-face */
color: #8b2252;
}
a {
color: inherit;
background-color: inherit;
font: inherit;
text-decoration: inherit;
}
a:hover {
text-decoration: underline;
}
</style></head></html>
<br />
<br />
<br />
<br />
<pre><span class="semantic-tag-boundary">
</span>(<span class="keyword">defun</span> <span class="function-name">compare-with-clipboard</span> ()
<span class="doc">"compare current buffer with contents in clipboard"</span>
(interactive)
(<span class="keyword">let</span> ((clipboard-buffer (get-buffer-create <span class="string">"*clipbord*"</span>))
(orig-buffer (current-buffer)))
(switch-to-buffer clipboard-buffer)
(delete-region (point-min) (point-max))
(yank)
(ediff-buffers clipboard-buffer orig-buffer)))
</pre>
<br />
-->Anonymoushttp://www.blogger.com/profile/01293468005249034620noreply@blogger.com0tag:blogger.com,1999:blog-8508408386087224500.post-76782237345617611832012-11-06T00:19:00.003+08:002012-11-07T20:35:40.209+08:00Monitor process file operations by windbg command<br />
<!-- Created by htmlize-1.34 in css mode. --><br />
<html><br />
<head><br />
<title>windbg.org</title><br />
<style type="text/css">
<!--
body {
color: #000000;
background-color: #ffffff;
}
.completions-first-difference {
/* completions-first-difference */
font-weight: bold;
}
.cscope-mouse {
/* cscope-mouse-face */
color: #ffffff;
background-color: #0000ff;
}
.org-level-3 {
/* org-level-3 */
color: #7f007f;
}
a {
color: inherit;
background-color: inherit;
font: inherit;
text-decoration: inherit;
}
a:hover {
text-decoration: underline;
}
</style></head></html>
<br />
<br />
<br />
<br />
<pre><span class="completions-first-difference">* Monitor windows process activities by set breakpoint on API, and print out the parameter contents.</span>
0:000<span class="cscope-mouse">> bp kernel32!CreateFileW ".echo ---------------------------------------;kL;du poi(@esp+4);gu;.echo =======;r eax;g" </span>
0:000<span class="cscope-mouse">> g </span>
ModLoad: 62c20000 62c29000 C:/WINDOWS/system32/LPK.DLL
ModLoad: 77180000 77283000 C:/WINDOWS/WinSxS/x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2982_x-ww_ac3f9c03/comctl32.dll
---------------------------------------
ChildEBP RetAddr
0012e374 7c814d65 kernel32!CreateFileW
0012e5dc 7c801d3a kernel32!BasepLoadLibraryAsDataFile+0x125
0012e640 7c8171dd kernel32!LoadLibraryExW+0x178
0012e66c 7c81715d kernel32!BasepSxsFindSuitableManifestResourceFor+0x51
0012e96c 7720b80d kernel32!CreateActCtxW+0x69e
0012eba4 7720b83f comctl32_77180000!SHFusionInitializeIDCC+0x83
0012ebb8 7720b857 comctl32_77180000!SHFusionInitializeID+0x12
0012ebc8 771841a9 comctl32_77180000!SHFusionInitialize+0xf
0012ebdc 77184267 comctl32_77180000!_ProcessAttach+0x32
0012ebe8 7c9211a7 comctl32_77180000!LibMain+0x21
0012ec08 7c93cbab ntdll!LdrpCallInitRoutine+0x14
0012ed10 7c936178 ntdll!LdrpRunInitializeRoutines+0x344
0012efbc 7c9362da ntdll!LdrpLoadDll+0x3e5
0012f264 7c801bb9 ntdll!LdrLoadDll+0x230
0012f2cc 7c80ae5c kernel32!LoadLibraryExW+0x18e
0012f2e0 77f5b1a3 kernel32!LoadLibraryW+0x11
0012f504 766a1110 SHLWAPI!LoadLibraryWrapW+0x51
0012f53c 766a10af WININET!SHFusionLoadLibrary+0x29
0012f548 766a107d WININET!DelayLoadCC+0x15
0012f77c 766a0ff7 WININET!SHFusionInitializeIDCC+0x92
0012e3d0 <span class="cscope-mouse">"C:/WINDOWS/WindowsShell.Manifest"</span>
0012e410 <span class="cscope-mouse">""</span>
=======
eax=00000794
---------------------------------------
ChildEBP RetAddr
0012f8cc 7c801a4f kernel32!CreateFileW
0012f8f0 76d357ff kernel32!CreateFileA+0x30
0012f954 76d3570a iphlpapi!OpenIPDriver+0x115
0012f99c 76d35454 iphlpapi!OpenTCPDriver+0xee
0012f9d0 76d35351 iphlpapi!DllMain+0x157
0012f9f0 7c9211a7 iphlpapi!_DllMainCRTStartup+0x52
0012fa10 7c93cbab ntdll!LdrpCallInitRoutine+0x14
0012fb18 7c94173e ntdll!LdrpRunInitializeRoutines+0x344
0012fc94 7c941639 ntdll!LdrpInitializeProcess+0x1131
0012fd1c 7c92eac7 ntdll!_LdrpInitialize+0x183
00000000 00000000 ntdll!KiUserApcDispatcher+0x7
7ffdfc00 <span class="cscope-mouse">"//./Ip"</span>
=======
eax=00000780
---------------------------------------
<span class="org-level-3">*** ERROR: Symbol file could not be found. Defaulted to export symbols for C:/Program Files/Tencent/QQ2009/Bin/KernelUtil.dll - </span>
ChildEBP RetAddr
0012fc34 0044a69c kernel32!CreateFileW
<span class="org-level-3">*** ERROR: Module load completed but symbols could not be loaded for QQ.exe </span>
WARNING: Stack unwind information not available. Following frames may be wrong.
0012fca8 004029bd KernelUtil!Version::Init+0x8c
0012ff08 004027d9 QQ+0x29bd
0012ff28 00402635 QQ+0x27d9
0012ffc0 7c816fd7 QQ+0x2635
0012fff0 00000000 kernel32!BaseProcessStart+0x23
00c8eca8 <span class="cscope-mouse">"C:/Program Files/Tencent/QQ2009/"</span>
00c8ece8 <span class="cscope-mouse">"Bin/vi.dat"</span>
=======
eax=00000720
---------------------------------------
ChildEBP RetAddr
0012eab4 0044a2ad kernel32!CreateFileW
WARNING: Stack unwind information not available. Following frames may be wrong.
0012fbb4 0044a4ea KernelUtil!Util::URL::OpenUrlWithTT+0x1cd
0012fc4c 0044a6fc KernelUtil!Version::GetBuildVer+0xca
0012fca8 004029bd KernelUtil!Version::Init+0xec
0012ff08 004027d9 QQ+0x29bd
0012ff28 00402635 QQ+0x27d9
0012ffc0 7c816fd7 QQ+0x2635
0012fff0 00000000 kernel32!BaseProcessStart+0x23
00c8ede0 <span class="cscope-mouse">"C:/Program Files/Tencent/QQ2009/"</span>
00c8ee20 <span class="cscope-mouse">"Bin/QQ.exe"</span>
=======
eax=00000720
</pre>
<br />
-->Anonymoushttp://www.blogger.com/profile/01293468005249034620noreply@blogger.com0tag:blogger.com,1999:blog-8508408386087224500.post-28368492805395322392012-11-05T23:47:00.001+08:002012-11-11T20:15:48.932+08:00Start from helloworld.asm<br />
<!-- Created by htmlize-1.34 in css mode. --><br />
<html><br />
<head><br />
<title>asm_notes.org</title><br />
<style type="text/css">
<!--
body {
color: #000000;
background-color: #ffffff;
}
.bold {
/* bold */
font-weight: bold;
}
.comment {
/* font-lock-comment-face */
color: #b22222;
}
.cscope-mouse {
/* cscope-mouse-face */
color: #ffffff;
background-color: #0000ff;
}
.custom-invalid {
/* custom-invalid */
color: #ffff00;
background-color: #ff0000;
}
.header-line {
/* header-line */
color: #333333;
background-color: #e5e5e5;
}
.menu {
}
.org-level-1 {
/* org-level-1 */
color: #0000ff;
}
.org-level-2 {
/* org-level-2 */
color: #a0522d;
}
.org-link {
/* org-link */
color: #3a5fcd;
text-decoration: underline;
}
a {
color: inherit;
background-color: inherit;
font: inherit;
text-decoration: inherit;
}
a:hover {
text-decoration: underline;
}
</style></head></html>
<br />
<br />
<br />
<br />
<pre><span class="org-level-1">* asm</span>
<span class="custom-invalid">** gdb:::</span>
<span class="cscope-mouse">resource ::</span><span class="menu">$ http://www.chemie.fu-berlin.de/chemnet/use/info/gdb/gdb_toc.html</span>
<span class="cscope-mouse">stop at main ::</span><span class="menu">$ b main | r</span>
<span class="cscope-mouse">view register ::</span>info registers
<span class="cscope-mouse">show single reg ::</span>print/(d|t|x) $eax
<span class="cscope-mouse">show memory value ::</span>x/<num>(c|d|x)(b|h|w) x/42cb &output
(gdb) x/s $edi+28
0x600104 <output+28>: "GenuineIntel'\n"
<span class="org-level-2">** common </span>
<span class="cscope-mouse">Code of helloworld.asm::</span>
SECTION .data
EatMsg: db "hello world", 10
EatLen: equ $-EatMsg
SECTION .bss
SECTION .text
global _start
_start:
nop
mov eax, 4
mov ebx, 1
mov ecx, EatMsg
mov edx, EatLen
int 80H
mov eax, 1
mov ebx, 0
int 80H
<span class="cscope-mouse">Command to build::</span>
[vagrant@vagrant-centos-6-64 vagrant]<span class="menu">$ nasm -f elf -g -F stabs helloworld.asm </span>
helloworld.asm helloworld.o
[vagrant@vagrant-centos-6-64 vagrant]<span class="menu">$ ld -o helloworld helloworld.o -melf_i386</span>
helloworld helloworld.asm helloworld.o
[vagrant@vagrant-centos-6-64 vagrant]<span class="menu">$ ./helloworld </span>
hello world
<span class="cscope-mouse">dump all sections ::</span><span class="menu">$ objdump -D eatsyscall</span>
08048080 <_start>: <span class="header-line">||break *_start+1 then %epi will contains 0x08048080</span>
8048080: 90 nop
8048081: b8 04 00 00 00 mov $0x4,%eax
8048086: bb 01 00 00 00 mov $0x1,%ebx
<span class="cscope-mouse">gcc output ::</span><span class="menu">$ gcc -S ctest.c</span>
<span class="cscope-mouse">gcc -E ::</span><span class="menu">$ gcc -E ctest.c</span>
<span class="cscope-mouse">compile wit debug info ::</span><span class="menu">$ gcc -gstabs -gp -o ctest ctest.c </span>
<span class="cscope-mouse">dump code with assembly ::</span><span class="menu">$ objdump -S ctest</span>
int foo()
{
400684: 55 push %rbp
400685: 48 89 e5 mov %rsp,%rbp
400688: 48 83 ec 10 sub $0x10,%rsp
40068c: e8 a7 fe ff ff callq 400538 <<a href="mailto:mcount@plt">mcount@plt</a>> <span class="header-line">||<--insert by -gp for gprof</span>
<span class="comment">#include <stdio.h></span>
int main()
{
400504: 55 push %rbp
400505: 48 89 e5 mov %rsp,%rbp
printf("Hello, World!\n");
400508: bf 18 06 40 00 mov $0x400618,%edi
40050d: e8 de fe ff ff callq 4003f0 <<a href="mailto:puts@plt">puts@plt</a>>
exit(0);
400512: bf 00 00 00 00 mov $0x0,%edi
400517: e8 e4 fe ff ff callq 400400 <<a href="mailto:exit@plt">exit@plt</a>>
<span class="cscope-mouse">dump out dynamic symbol table entries::</span><span class="menu">$ objdump -T ctest</span>
ctest: file format elf64-x86-64
DYNAMIC SYMBOL TABLE:
0000000000000000 w D <span class="bold">*UND*</span> 0000000000000000 __gmon_start__
0000000000000000 DF <span class="bold">*UND*</span> 0000000000000000 GLIBC_2.2.5 puts
0000000000000000 DF <span class="bold">*UND*</span> 0000000000000000 GLIBC_2.2.5 exit
0000000000000000 DF <span class="bold">*UND*</span> 0000000000000000 GLIBC_2.2.5 __libc_start_main
<span class="cscope-mouse">dump dynamic entries::</span><span class="menu">$ readelf -d cpuid2</span>
Dynamic section at offset 0x2b0 contains 15 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
<span class="cscope-mouse">show used share libs::</span><span class="menu">$ ldd cpuid2</span>
libc.so.6 => /lib64/libc.so.6 (0x00007f0e83eb4000)
/lib/ld64.so.1 => /lib64/ld-linux-x86-64.so.2 (0x00007f0e8424f000)
<span class="cscope-mouse">mov::</span> movl(long word) movw(16-bit word) movb(byte) | movl %eax, %ebx | movw %ax %bx | movb %al %bh
<span class="cscope-mouse">conditional move::</span> movl value, %ecx | cmp %ebx, %ecx | cmova %ebx, %ecx
<span class="cscope-mouse">XCHG::</span>exchange value between two general purpos registers, or betwen a register and a memory location.
when one of the operands is a memory location, the processor's <a class="org-link" href="http://www.jaist.ac.jp/iscenter-new/mpc/altix/altixdata/opt/intel/vtune/doc/users_guide/mergedProjects/analyzer_ec/mergedProjects/reference_olh/mergedProjects/instructions/instruct32_hh/vc160.htm">LOCK</a> signal is automatically asserted,
to turns the instruction into an atomic instruction in multiple processor environment.
<span class="cscope-mouse">CMPXCHG::</span> cmpxchg src dest | compare dest with EAX,AX,or AL. if equal, load src to dest.
otherwise load dest to EAX, AX, or AL.
<span class="cscope-mouse">unconditional branches::</span>jump calls interrupts
call: 1) push the $eip, modifies the %eip to point to called function address
2) call function and ret
3) pop %eip to continue
<span class="cscope-mouse">asm function template::</span>
function_label:
pushl %ebp
movl %esp, %ebp
<normal function code>
movl %ebp, %esp
popl %ebp
<span class="cscope-mouse">software interrupts::</span>are provided by OS to enable app to tap info function into the OS. (system calls).
<span class="org-level-2">** resources</span>
<span class="org-link">http://www.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html</span></pre>
<br />
-->Anonymoushttp://www.blogger.com/profile/01293468005249034620noreply@blogger.com0tag:blogger.com,1999:blog-8508408386087224500.post-16338063466095940372012-11-02T21:43:00.002+08:002012-12-15T12:24:51.991+08:00What Emacs can do?<div>
<br /></div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://v.youku.com/v_show/id_XNDcwMzYxNjg4.html?f=18514207" target="_blank">Click to see video version</a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
code alignment (gif video)</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1wKhW_UL22PQ0b73fF3S-cGoH5mBW3x_Vh_pCD1mCHeXy8VeJu9sLq5CEEjcy0mpjwaMRYa-uqbMS6kdbP3cHqFhSBfeyB8pUQhFPTBtFkxVTfzchpnZ4rp-_XL8L95AJqYc_5FY4iLo/s1600/emacs_align-regex.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1wKhW_UL22PQ0b73fF3S-cGoH5mBW3x_Vh_pCD1mCHeXy8VeJu9sLq5CEEjcy0mpjwaMRYa-uqbMS6kdbP3cHqFhSBfeyB8pUQhFPTBtFkxVTfzchpnZ4rp-_XL8L95AJqYc_5FY4iLo/s1600/emacs_align-regex.gif" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
column editing (gif video)</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrCfKOGvSC_R8MawQjkbAFZ_AaisGSxOtpTKM_SplKDduzPd-fHGVtJF5ClmKanhpnSCqv_SPiXPBjN0JUq8rqt6hL4V4whtEAYTpwD5c_vloeZ0ikX-7KVULupsMhtRpUKv9JOnRNS88/s1600/emacs_column-editing.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrCfKOGvSC_R8MawQjkbAFZ_AaisGSxOtpTKM_SplKDduzPd-fHGVtJF5ClmKanhpnSCqv_SPiXPBjN0JUq8rqt6hL4V4whtEAYTpwD5c_vloeZ0ikX-7KVULupsMhtRpUKv9JOnRNS88/s1600/emacs_column-editing.gif" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
WEIBO, git, git blame, rainbow (gif video)</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://i403.photobucket.com/albums/pp120/whunmr/emacs_weibo-git-rainbow.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://i403.photobucket.com/albums/pp120/whunmr/emacs_weibo-git-rainbow.gif" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
dynamic selection and Code browsing (gif video)</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://i403.photobucket.com/albums/pp120/whunmr/emacs_code-browsing.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://i403.photobucket.com/albums/pp120/whunmr/emacs_code-browsing.gif" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
org-mode + googledriver to manage your notes in one file (gif video)</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://i403.photobucket.com/albums/pp120/whunmr/emacs_org-mode.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://i403.photobucket.com/albums/pp120/whunmr/emacs_org-mode.gif" /></a></div>
<br />
<br />
weibo and music<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzJC2YyCV6wSSZ4_qyayLcrOC6CuDBjpzBHNirz0d6OgxwiKedP5P1cHMaaL4YYuep0ukvt84jz_P7PiXsZLCHo0RP-jmqyhmH-4IvT7LWVQHjxKpcpy6uBqjzHIO9tK6WWZsW-enNtwg/s1600/Screen+Shot+2012-12-14+at+10.12.58+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzJC2YyCV6wSSZ4_qyayLcrOC6CuDBjpzBHNirz0d6OgxwiKedP5P1cHMaaL4YYuep0ukvt84jz_P7PiXsZLCHo0RP-jmqyhmH-4IvT7LWVQHjxKpcpy6uBqjzHIO9tK6WWZsW-enNtwg/s1600/Screen+Shot+2012-12-14+at+10.12.58+PM.png" /></a></div>
<br />
Task management in TDD<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGxCLrRZQk2jCbnJgoXbkYUEa0ISvWuttD9HpSMaVADnkOEBm43Gn_apGAhxSH1s1c6IWicOVsr4ddvpgq0AU38zH2uqKxF9lrfgQyCTZAA6Eiq1BmPOVroG3d5ZcxQYv57XBgkR6sivY/s1600/Screen+Shot+2012-12-15+at+12.22.42+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGxCLrRZQk2jCbnJgoXbkYUEa0ISvWuttD9HpSMaVADnkOEBm43Gn_apGAhxSH1s1c6IWicOVsr4ddvpgq0AU38zH2uqKxF9lrfgQyCTZAA6Eiq1BmPOVroG3d5ZcxQYv57XBgkR6sivY/s1600/Screen+Shot+2012-12-15+at+12.22.42+PM.png" /></a></div>
<br />
<br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://v.youku.com/v_show/id_XNDcwMzYxNjg4.html?f=18514207" target="_blank">Click to see video version</a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://github.com/whunmr/dotemacs" target="_blank">dot emacs configuration link</a></div>
<br />Anonymoushttp://www.blogger.com/profile/01293468005249034620noreply@blogger.com0tag:blogger.com,1999:blog-8508408386087224500.post-26904974985485082832012-10-23T22:43:00.003+08:002012-10-23T22:45:24.668+08:00Reading notes of Learning the vi and Vim Editors<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"><br />
<!-- Created by htmlize-1.34 in css mode. --><br />
<html><br />
<head><br />
<title>book_learning_vi.org</title><br />
<style type="text/css">
<!--
body {
color: #000000;
background-color: #ffffff;
}
.icicle-input-completion-fail {
/* icicle-input-completion-fail */
color: #000000;
background-color: #dda0dd;
}
.org-level-1 {
/* org-level-1 */
color: #0000ff;
}
.org-link {
/* org-link */
color: #3a5fcd;
text-decoration: underline;
}
a {
color: inherit;
background-color: inherit;
font: inherit;
text-decoration: inherit;
}
a:hover {
text-decoration: underline;
}
-->
</style><br />
</head><br />
<body><br />
<pre><span class="org-level-1">* Notes of Learning the vi and Vim Editors</span>
<img src="http://ww2.sinaimg.cn/thumbnail/5142910cjw1dy4dx4fowuj.jpg" />
<span class="icicle-input-completion-fail">repeat last command ::</span> .
<span class="icicle-input-completion-fail">Movements ::</span> w W b B e E ( ) { } [[ 0 ^ n| $ gg G 200G
<span class="icicle-input-completion-fail">move to char ::</span> fx Fx tx Tx (; continue forward and ' for backward)
<span class="icicle-input-completion-fail">move on screen ::</span> H M L 2H
<span class="icicle-input-completion-fail">Actions ::</span> d c y
<span class="icicle-input-completion-fail">append at line end ::</span> A
<span class="icicle-input-completion-fail">insert at line begin ::</span> I
<span class="icicle-input-completion-fail">delete char ::</span> x X
<span class="icicle-input-completion-fail">open line up and down ::</span> o O
<span class="icicle-input-completion-fail">paste up and line ::</span> p P
<span class="icicle-input-completion-fail">delete line and insert ::</span> S //same as ddi or cc
<span class="icicle-input-completion-fail">(number prefix)write 50 * ::</span> 50i*
<span class="icicle-input-completion-fail">set-mark in vi ::</span> mx (x for any letter)
<span class="icicle-input-completion-fail">goto mark ::</span> `x
<span class="icicle-input-completion-fail">delete line ::</span> dd
<span class="icicle-input-completion-fail">delete from cursor to end ::</span> D
<span class="icicle-input-completion-fail">undo ::</span> u U
<span class="icicle-input-completion-fail">redo ::</span> ctrl+R
<span class="icicle-input-completion-fail">center current line ::</span> Z.
<span class="icicle-input-completion-fail">paste from named delete buffer ::</span> "3p
<span class="icicle-input-completion-fail">yank to named buffera ::</span> "a4yy
<span class="icicle-input-completion-fail">append to named buffer a ::</span> "A4yy
<span class="icicle-input-completion-fail">paste from named buffer ::</span> "ap
<span class="icicle-input-completion-fail">paste ::</span> p P
<span class="icicle-input-completion-fail">single char ::</span> x r
<span class="icicle-input-completion-fail">search ::</span> / ? n N
<span class="icicle-input-completion-fail">line-matches-regex ::</span> g/pattern/p
<span class="icicle-input-completion-fail">line-non-matches-regex ::</span> g!/pattern
<span class="icicle-input-completion-fail">replace once ::</span> s/old/new
<span class="icicle-input-completion-fail">emit another replace in command mode ::</span> &
<span class="icicle-input-completion-fail">replace all occurs in line ::</span> s/old/new/g
<span class="icicle-input-completion-fail">replace all occurs in file ::</span> %s/old/new/g (% stands for all lines, like 1,% prefix to s command 1,%s/old/new/g)
<span class="icicle-input-completion-fail">replace with confirm ::</span> s/old/new/gc
<span class="icicle-input-completion-fail">only do replace in line matches patterns ::</span> :g/pattern/s/old/new/g
<span class="icicle-input-completion-fail">add () to lines ::</span> :%s/.*/(&)/ (& stands for whole match line)
<span class="icicle-input-completion-fail">replace with regex ::</span> :%s/\(this\) or \(that\)/\2 or \1/g
<span class="icicle-input-completion-fail">replace Fortran to FORTRAN ::</span> %s/Fortran/\U&/ (also has \L for lowercase)
<span class="icicle-input-completion-fail">save buffer before replace ::</span> :w
<span class="icicle-input-completion-fail">revert buffer to last saved state ::</span> e!
<span class="icicle-input-completion-fail">edit another file foo ::</span> :e foo
<span class="icicle-input-completion-fail">switch files in vi ::</span> :n :rewind :last
<span class="icicle-input-completion-fail">line info ::</span> ctrl+G
<span class="icicle-input-completion-fail">append to word end ::</span> ea
<span class="icicle-input-completion-fail">delete to file end ::</span> dG
<span class="icicle-input-completion-fail">change to line end ::</span> c$ C
<span class="icicle-input-completion-fail">goto line 100 ::</span> 100G
<span class="icicle-input-completion-fail">toggle line number ::</span> :set nu :set nonu
<span class="icicle-input-completion-fail">split window ::</span> :split :vsplit
<span class="icicle-input-completion-fail">move between windows ::</span> ^wj ^wk ^wh ^wl
</pre> </body><br />
</html><br />
Anonymoushttp://www.blogger.com/profile/01293468005249034620noreply@blogger.com0tag:blogger.com,1999:blog-8508408386087224500.post-8986502030096611462012-10-10T20:23:00.000+08:002012-10-16T19:33:35.254+08:00[emacs] copy until char (like zap-to-char) <!-- Created by htmlize-1.34 in css mode. --><br />
<html><br />
<head><br />
<title>sdfasdfsadf</title><br />
<style type="text/css">
<!--
body {
color: #000000;
background-color: #ffffff;
}
.ATTRLIST {
/* (:foreground "firebrick1" :weight bold) */
color: #ff3030;
font-weight: bold;
}
.ATTRLIST-1 {
/* (:foreground "IndianRed1" :weight bold) */
color: #ff6a6a;
font-weight: bold;
}
.ATTRLIST-2 {
/* (:foreground "IndianRed3" :weight bold) */
color: #cd5555;
font-weight: bold;
}
.ATTRLIST-3 {
/* (:foreground "IndianRed4" :weight bold) */
color: #8b3a3a;
font-weight: bold;
}
.nxml-element-local-name {
/* nxml-element-local-name */
color: #0000ff;
}
.nxml-tag-delimiter {
}
.nxml-tag-slash {
}
.nxml-text {
}
.rng-error {
/* rng-error */
color: #ff0000;
font-weight: bold;
}
a {
color: inherit;
background-color: inherit;
font: inherit;
text-decoration: inherit;
}
a:hover {
text-decoration: underline;
}
</style></head></html>
<br />
<pre><span class="nxml-text"><span class="rng-error">Today, When we doing a story with a piece of XML like this:
</span></span><span class="nxml-tag-delimiter"><</span><span class="nxml-element-local-name">suburb</span><span class="nxml-tag-delimiter">></span><span class="nxml-text">S-123456789</span><span class="nxml-tag-delimiter"><</span><span class="nxml-tag-slash">/</span><span class="nxml-element-local-name">suburb</span><span class="nxml-tag-delimiter">></span><span class="nxml-text"><span class="rng-error">
I feel not convenient to copy out the S-123456789
So I wrote a new copy-without-selection function copy-to-char function (like zap-to-char):</span></span></pre>
<!-- Created by htmlize-1.34 in css mode. -->
<html>
<head>
<title>init.el</title>
<style type="text/css">
<!--
body {
color: #000000;
background-color: #ffffff;
}
.doc {
/* font-lock-doc-face */
color: #8b2252;
}
.function-name {
/* font-lock-function-name-face */
color: #0000ff;
}
.keyword {
/* font-lock-keyword-face */
color: #7f007f;
}
.string {
/* font-lock-string-face */
color: #8b2252;
}
a {
color: inherit;
background-color: inherit;
font: inherit;
text-decoration: inherit;
}
a:hover {
text-decoration: underline;
}
</style></head></html>
<br />
<pre>(<span class="keyword">defun</span> <span class="function-name">copy-to-char</span> (arg char)
<span class="doc">"Copy until char like zap-to-char"</span>
(interactive <span class="string">"p\ncZap to char: "</span>)
(<span class="keyword">let</span> ((start (point)))
(<span class="keyword">save-excursion</span>
(copy-region-as-kill start (<span class="keyword">progn</span>
(search-forward (char-to-string char) nil nil arg)
(backward-char)
(point)))
)
)
)
(global-set-key (kbd <span class="string">"C-c c"</span>) 'copy-to-char)
</pre>
<br />Anonymoushttp://www.blogger.com/profile/01293468005249034620noreply@blogger.com0