32 |
BlockA
33 |
BlockB
34 |
35 |
36 |
37 | .box{}
38 | .block-a,
39 | .block-b{
40 | float:left;
41 | }
42 | .clear-fix{
43 | clear:both;
44 | }
45 |
46 | 上面的例子中,BlockA与BlockB是紧挨着的向左浮动的,并且.box的高度是正常且不为0的,但是你可以尝试下去掉.clear-fix的clear之后,样式不变,但是,.box的高度变为0了,在后续中如果需要获取.box的高度,显然就不行了,所以,在使用float属性之后,务必记得要清除浮动。
47 |
48 | 所以在更常见的使用中会选择这样使用:
49 |
50 |
51 |
BlockA
52 |
BlockB
53 |
54 |
55 | .box{}
56 | .box:before{
57 | content:' ';
58 | display:table;
59 | }
60 | .box:after{
61 | content:' ';
62 | display:table;
63 | clear:both;
64 | }
65 |
66 | .block-a,
67 | .block-b{
68 | float:left;
69 | }
70 |
71 |
72 | #### 参考文档
73 |
74 | * http://www.w3school.com.cn/css/css_positioning_floating.asp
--------------------------------------------------------------------------------
/frontend-notes/stylesheet/Css-Triangel-And-How-To-Draw.md:
--------------------------------------------------------------------------------
1 | Css的一些使用技巧可以帮助我们快速的创建一个兼容各个浏览器的三角形。
2 |
3 | #### 特殊符号
4 |
5 | 最简单的用法莫过于使用特殊符号,然后设置颜色了。
6 |
7 |
▲
8 |
9 | .triangle {
10 | color: #BADA55;
11 | text-shadow: 0 0 20px black;
12 | }
13 |
14 | #### 使用图片
15 |
16 | 这个就不说了,都懂。
17 |
18 | #### Css旋转
19 |
20 | 利用transform属性对正方形进行旋转,也可以画一个三角形出来,但是兼容性难做保证,尤其在某些“神器”下面,那表现就是...
21 |
22 |
23 |
24 | .triangle-with-shadow {
25 | width: 100px;
26 | height: 100px;
27 | position: relative;
28 | overflow: hidden;
29 | box-shadow: 0 16px 10px -17px rgba(0,0,0,0.5);
30 | }
31 | .triangle-with-shadow:after {
32 | content: "";
33 | position: absolute;
34 | width: 50px;
35 | height: 50px;
36 | background: #999;
37 | transform: rotate(45deg); /* Prefixes... */
38 | top: 75px;
39 | left: 25px;
40 | box-shadow: -1px -1px 10px -2px rgba(0,0,0,0.5);
41 | }
42 |
43 | #### Css Border
44 |
45 | css的border大法可以说是兼容性最好,同时也是最方便的实现方式,当然了,要做实现一些特殊角度的三角形,还是需要稍微计算一下的,学渣不讨论计算问题,自行研究吧~
46 |
47 | .triangel{
48 | width:0;
49 | height:0;
50 | border-left:10px solid #ffff00;
51 | border-right:10px solid #ff00ff;
52 | border-top:10px solid #00ff00;
53 | border-bottom:10px solid #0000ff;
54 | }
55 |
56 | 这里可以看出来是一个正方形通过对角线相连分成了4个三角形。
57 | 然后通过调整对边的长度可以改变它的形状,我建议哦,要是想实现特定角度的三角形,还是画个正方形什么的,自己去算算吧,勾三股四什么的就好好用用吧...
58 |
59 | **消除锯齿**
60 |
61 | -webkit-font-smoothing: antialiased;
62 |
63 | #### Example
64 |
65 | 更多更神奇的形状可以参考这里:
66 |
67 | * http://css-tricks.com/examples/ShapesOfCSS/
--------------------------------------------------------------------------------
/frontend-notes/stylesheet/Css3-align-center-vertical-middle.md:
--------------------------------------------------------------------------------
1 |
2 | 实现Div居中的方法比较多, 但浏览器兼容问题使得实现方式较为多变,这里分享一种最近使用的方法。
3 |
4 | ### HTML
5 |
6 |
9 |
10 | ### CSS(1)
11 |
12 | .box{
13 | position: relative;
14 | width: 200px;
15 | height: 100px;
16 | background-color: yellow;
17 | }
18 |
19 | .goods{
20 | position: absolute;
21 | top: 50%;
22 | left: 50%;
23 |
24 | -ms-transform: translate(-50%,-50%); /* IE 9 */
25 | -webkit-transform: translate(-50%,-50%); /* Safari and Chrome */
26 | -o-transform: translate(-50%,-50%); /* Opera */
27 | -moz-transform: translate(-50%,-50%); /* Firefox */
28 | transform: translate(-50%,-50%);
29 | background-color: red;
30 | }
31 |
32 | ### CSS(2)
33 |
34 | .box{
35 | width: 100%;
36 | height: 100%;
37 | display: table;
38 | }
39 | .goods{
40 | display: table-cell;
41 | vertical-align: middle;
42 | width: 300px;
43 | margin: 0 auto;
44 | }
45 |
46 | ### CSS(3)
47 |
48 | .box{
49 | width: 100%;
50 | height: 100%;
51 | position: relative;
52 | }
53 | .goods{
54 | position: absolute;
55 | top: 0;
56 | bottom: 0;
57 | left: 0;
58 | right: 0;
59 | margin: 0 auto;
60 | }
61 |
62 |
--------------------------------------------------------------------------------
/frontend-notes/stylesheet/css-media-queries-for-standard-devices.md:
--------------------------------------------------------------------------------
1 | css media queries for standard devices
2 |
3 | link: [https://css-tricks.com/snippets/css/media-queries-for-standard-devices/](https://css-tricks.com/snippets/css/media-queries-for-standard-devices/)
4 |
5 | ## iPhone
6 |
7 | ```
8 | /* ----------- iPhone 4 and 4S ----------- */
9 |
10 | /* Portrait and Landscape */
11 | @media only screen
12 | and (min-device-width: 320px)
13 | and (max-device-width: 480px)
14 | and (-webkit-min-device-pixel-ratio: 2) {
15 |
16 | }
17 |
18 | /* Portrait */
19 | @media only screen
20 | and (min-device-width: 320px)
21 | and (max-device-width: 480px)
22 | and (-webkit-min-device-pixel-ratio: 2)
23 | and (orientation: portrait) {
24 | }
25 |
26 | /* Landscape */
27 | @media only screen
28 | and (min-device-width: 320px)
29 | and (max-device-width: 480px)
30 | and (-webkit-min-device-pixel-ratio: 2)
31 | and (orientation: landscape) {
32 |
33 | }
34 |
35 | /* ----------- iPhone 5 and 5S ----------- */
36 |
37 | /* Portrait and Landscape */
38 | @media only screen
39 | and (min-device-width: 320px)
40 | and (max-device-width: 568px)
41 | and (-webkit-min-device-pixel-ratio: 2) {
42 |
43 | }
44 |
45 | /* Portrait */
46 | @media only screen
47 | and (min-device-width: 320px)
48 | and (max-device-width: 568px)
49 | and (-webkit-min-device-pixel-ratio: 2)
50 | and (orientation: portrait) {
51 | }
52 |
53 | /* Landscape */
54 | @media only screen
55 | and (min-device-width: 320px)
56 | and (max-device-width: 568px)
57 | and (-webkit-min-device-pixel-ratio: 2)
58 | and (orientation: landscape) {
59 |
60 | }
61 |
62 | /* ----------- iPhone 6 ----------- */
63 |
64 | /* Portrait and Landscape */
65 | @media only screen
66 | and (min-device-width: 375px)
67 | and (max-device-width: 667px)
68 | and (-webkit-min-device-pixel-ratio: 2) {
69 |
70 | }
71 |
72 | /* Portrait */
73 | @media only screen
74 | and (min-device-width: 375px)
75 | and (max-device-width: 667px)
76 | and (-webkit-min-device-pixel-ratio: 2)
77 | and (orientation: portrait) {
78 |
79 | }
80 |
81 | /* Landscape */
82 | @media only screen
83 | and (min-device-width: 375px)
84 | and (max-device-width: 667px)
85 | and (-webkit-min-device-pixel-ratio: 2)
86 | and (orientation: landscape) {
87 |
88 | }
89 |
90 | /* ----------- iPhone 6+ ----------- */
91 |
92 | /* Portrait and Landscape */
93 | @media only screen
94 | and (min-device-width: 414px)
95 | and (max-device-width: 736px)
96 | and (-webkit-min-device-pixel-ratio: 3) {
97 |
98 | }
99 |
100 | /* Portrait */
101 | @media only screen
102 | and (min-device-width: 414px)
103 | and (max-device-width: 736px)
104 | and (-webkit-min-device-pixel-ratio: 3)
105 | and (orientation: portrait) {
106 |
107 | }
108 |
109 | /* Landscape */
110 | @media only screen
111 | and (min-device-width: 414px)
112 | and (max-device-width: 736px)
113 | and (-webkit-min-device-pixel-ratio: 3)
114 | and (orientation: landscape) {
115 |
116 | }
117 | ```
118 |
119 | ## IPads
120 |
121 | ```
122 | /* ----------- iPad mini ----------- */
123 |
124 | /* Portrait and Landscape */
125 | @media only screen
126 | and (min-device-width: 768px)
127 | and (max-device-width: 1024px)
128 | and (-webkit-min-device-pixel-ratio: 1) {
129 |
130 | }
131 |
132 | /* Portrait */
133 | @media only screen
134 | and (min-device-width: 768px)
135 | and (max-device-width: 1024px)
136 | and (orientation: portrait)
137 | and (-webkit-min-device-pixel-ratio: 1) {
138 |
139 | }
140 |
141 | /* Landscape */
142 | @media only screen
143 | and (min-device-width: 768px)
144 | and (max-device-width: 1024px)
145 | and (orientation: landscape)
146 | and (-webkit-min-device-pixel-ratio: 1) {
147 |
148 | }
149 |
150 | /* ----------- iPad 1 and 2 ----------- */
151 | /* Portrait and Landscape */
152 | @media only screen
153 | and (min-device-width: 768px)
154 | and (max-device-width: 1024px)
155 | and (-webkit-min-device-pixel-ratio: 1) {
156 |
157 | }
158 |
159 | /* Portrait */
160 | @media only screen
161 | and (min-device-width: 768px)
162 | and (max-device-width: 1024px)
163 | and (orientation: portrait)
164 | and (-webkit-min-device-pixel-ratio: 1) {
165 |
166 | }
167 |
168 | /* Landscape */
169 | @media only screen
170 | and (min-device-width: 768px)
171 | and (max-device-width: 1024px)
172 | and (orientation: landscape)
173 | and (-webkit-min-device-pixel-ratio: 1) {
174 |
175 | }
176 |
177 | /* ----------- iPad 3 and 4 ----------- */
178 | /* Portrait and Landscape */
179 | @media only screen
180 | and (min-device-width: 768px)
181 | and (max-device-width: 1024px)
182 | and (-webkit-min-device-pixel-ratio: 2) {
183 |
184 | }
185 |
186 | /* Portrait */
187 | @media only screen
188 | and (min-device-width: 768px)
189 | and (max-device-width: 1024px)
190 | and (orientation: portrait)
191 | and (-webkit-min-device-pixel-ratio: 2) {
192 |
193 | }
194 |
195 | /* Landscape */
196 | @media only screen
197 | and (min-device-width: 768px)
198 | and (max-device-width: 1024px)
199 | and (orientation: landscape)
200 | and (-webkit-min-device-pixel-ratio: 2) {
201 |
202 | }
203 | ```
204 |
205 | ## Non-Retina && Retina
206 |
207 | ```
208 | /* ----------- Non-Retina Screens ----------- */
209 | @media screen
210 | and (min-device-width: 1200px)
211 | and (max-device-width: 1600px)
212 | and (-webkit-min-device-pixel-ratio: 1) {
213 | }
214 |
215 | /* ----------- Retina Screens ----------- */
216 | @media screen
217 | and (min-device-width: 1200px)
218 | and (max-device-width: 1600px)
219 | and (-webkit-min-device-pixel-ratio: 2)
220 | and (min-resolution: 192dpi) {
221 | }
222 | ```
--------------------------------------------------------------------------------
/mt-experimentations/About-Coding-Net-Api.md:
--------------------------------------------------------------------------------
1 |
2 | > 已经有人总结了更详细的文档(⊙o⊙)哦~
3 | >
4 | > [http://api-doc.coding.io/](http://api-doc.coding.io/)
5 |
6 | github上面的api挺明确,使用也很方便,但是墙内的生活,你们懂,
7 |
8 | 所以稍微看了一下coding的代码结构,大体上就是这个样子~
9 |
10 | ### Format
11 |
12 | CODING_API = https://coding.net/api
13 |
14 | * CODING_API/user/USER/project/PROJECT/git/blob/BRANCH/PATH
15 | * CODING_API/user/USER/project/PROJECT/git/treeinfo/BRANCH/PATH
16 |
17 |
18 | 睡觉之前顺便看了一下Coding客户端的源码(好久不用java...现在只会var~ T.T)
19 |
20 | urlProject = String.format(Global.HOST + "/api/user/%s/project/%s", mJumpParam.mUser, mJumpParam.mProject);
21 |
22 | String urlBlob = Global.HOST + "/api/user/%s/project/%s/git/blob/master/%s";
23 | //https://coding.net/api/user/bluishoul/project/AppBubbleDetail/git/blob/master%252F.bowerrc
24 |
25 | String urlImage = Global.HOST + "/u/%s/p/%s/git/raw/master/%s";
26 | //https://coding.net/u/8206503/p/AndroidCoding/git/raw/master/app/src/main/res/drawable-xxhdpi/actionbar_item_normal.png
27 |
28 | private String HOST_GIT_TREE = Global.HOST + "/api/user/%s/project/%s/git/tree/master/%s";
29 | //https://coding.net/api/user/8206503/project/AndroidCoding/git/tree/master
30 |
31 | private String HOST_GIT_TREEINFO = Global.HOST + "/api/user/%s/project/%s/git/treeinfo/master/%s";
32 |
33 | private String host_git_tree_url = "";
34 |
35 | private String host_git_treeinfo_url = "";
36 | //https://coding.net/api/user/8206503/project/AndroidCoding/git/treeinfo/master
37 |
38 |
39 | 和看资源加载信息看到的基本一致,只是没加上path~,顺便吐槽一下,NodeJs大法好,java写这东西是有多难!
40 |
41 |
42 | ### NodeJS
43 |
44 | 这里的不用看了~~,而且代码写的也吐了,已经不用了T.T
45 |
46 | /**
47 | * Created by thonatos on 14/12/19.
48 | */
49 |
50 | var _docRepo = require('./config').conf.docRepo;
51 | var _obj = require('../utils/obj');
52 |
53 | var CODING = {
54 | host: 'https://coding.net/api',
55 | port: 443,
56 | path: 'user/MTTUSER/project/MTTPROJECT/git/'
57 | };
58 |
59 | //https://coding.net/api/user/thonatos/project/Mt.Notes.And.Documents/git/treeinfo/master/
60 |
61 | var GITHUB = {
62 | host: 'api.github.com',
63 | port: 443,
64 | path: '/repos/MTTUSER/MTTPROJECT/contents/'
65 | };
66 |
67 |
68 | exports.create = {
69 | docTemplate : function () {
70 | return {
71 | templateType : '',
72 | templateName : ''
73 | };
74 | },
75 | docRepo: function () {
76 |
77 | if(_docRepo.GC === "G"){
78 |
79 | var _g = _obj.cloneObj(GITHUB);
80 |
81 | _g.path = _g.path.replace(/MTTUSER/g,_docRepo.github.doc_user);
82 | _g.path = _g.path.replace(/MTTPROJECT/g,_docRepo.github.doc_project);
83 |
84 | return _g;
85 |
86 | }else{
87 |
88 | var _c = GITHUB;
89 | _c.path = _c.path.replace(/MTTUSER/g,_docRepo.coding.doc_user);
90 | _c.path = _c.path.replace(/MTTPROJECT/g,_docRepo.coding.doc_project);
91 |
92 | return _c;
93 | }
94 | }
95 | };
96 |
97 | ### Example
98 |
99 | * /user/thonatos/project/grimrock.org/git/treeinfo/master/service
100 | * /user/thonatos/project/grimrock.org/git/blob/master/app.js
101 | * /user/thonatos/project/grimrock.org/git/blob/master/service/queryService.js
102 |
103 | #### Tree
104 |
105 | ```
106 | {
107 | "code": 0,
108 | "data": {
109 | "infos": [
110 | {
111 | "lastCommitMessage": "Init\n",
112 | "lastCommitDate": 1418543563000,
113 | "lastCommitId": "4cbeefe7eec0a03a17d04afdfe334ef6028fa375",
114 | "lastCommitter": {
115 | "name": "Thonatos.Yang",
116 | "email": "thonatos.yang@gmail.com",
117 | "avatar": "https://www.gravatar.com/avatar/281ce5fb158941764bc390600be91610?s=200&d=mm",
118 | "link": "mailto:thonatos.yang@gmail.com"
119 | },
120 | "mode": "file",
121 | "path": "service/queryService.js",
122 | "name": "queryService.js"
123 | },
124 | {
125 | "lastCommitMessage": "Init\n",
126 | "lastCommitDate": 1418543563000,
127 | "lastCommitId": "4cbeefe7eec0a03a17d04afdfe334ef6028fa375",
128 | "lastCommitter": {
129 | "name": "Thonatos.Yang",
130 | "email": "thonatos.yang@gmail.com",
131 | "avatar": "https://www.gravatar.com/avatar/281ce5fb158941764bc390600be91610?s=200&d=mm",
132 | "link": "mailto:thonatos.yang@gmail.com"
133 | },
134 | "mode": "file",
135 | "path": "service/renderService.js",
136 | "name": "renderService.js"
137 | }
138 | ]
139 | }
140 | }
141 | ```
142 |
143 | #### File
144 |
145 | ```
146 | {
147 | "code": 0,
148 | "data": {
149 | "ref": "master",
150 | "can_edit": true,
151 | "isHead": true,
152 | "file": {
153 | "data": "此处省略万字",
154 | "lang": "javascript",
155 | "size": 1252,
156 | "previewed": false,
157 | "lastCommitMessage": "Init\n",
158 | "lastCommitDate": 1418543563000,
159 | "lastCommitId": "4cbeefe7eec0a03a17d04afdfe334ef6028fa375",
160 | "lastCommitter": {
161 | "name": "Thonatos.Yang",
162 | "email": "thonatos.yang@gmail.com",
163 | "avatar": "https://www.gravatar.com/avatar/281ce5fb158941764bc390600be91610?s=200&d=mm",
164 | "link": "mailto:thonatos.yang@gmail.com"
165 | },
166 | "mode": "file",
167 | "path": "service/queryService.js",
168 | "name": "service/queryService.js"
169 | }
170 | }
171 | }
172 | ```
--------------------------------------------------------------------------------
/mt-experimentations/Structure-of-VBigger-Based-On-Angular.md:
--------------------------------------------------------------------------------
1 | VBigger前端基于AngularJS(以下简称ng)框架构建,后端通过Api为前端提供所需数据,实现了前后端分离,特点如下:
2 |
3 | * 前端MVC(基于ng的MVVM/MVC的编程模式)
4 | * 自动构建(基于gulp.js的less/sass自动构建方案,此处可以也可以实现css,js,图像等资源的合并压缩)
5 | * 模块化开发(基于sea.js的模块化构建方案)
6 | * 模块化管理(业务模块通过spm.js为sea.js提供符合CMD规范的组件,bower.js管理常用插件和模块的管理)
7 |
8 | ### 项目架构
9 |
10 | 前端架构设计总体上依赖系统架构进行设计。
11 |
12 | ### 项目结构
13 |
14 | ```
15 | .
16 | ├── Application (Back-End)
17 | ├── apps
18 | │ ├── dist
19 | │ │ └── bigint
20 | │ ├── spm_modules
21 | │ │ ├── expect.js
22 | │ │ ├── jquery
23 | │ │ ├── seajs
24 | │ │ └── seajs-wrap
25 | │ └── src
26 | │ ├── components
27 | │ ├── event
28 | │ ├── general
29 | │ └── post
30 | ├── bower.json
31 | ├── index.html
32 | ├── gulpfile.js
33 | ├── node_modules
34 | ├── package.json
35 | ├── public
36 | │ ├── css
37 | │ │ ├── dev
38 | │ │ ├── fonts
39 | │ │ ├── less
40 | │ │ └── vendors
41 | │ ├── images
42 | │ └── vendors
43 | │ ├── bower_components
44 | │ └── custom_components
45 | └── ThinkPHP3.2.2 (Back-End)
46 |
47 | ## 未说明的部分皆属于前端。
48 |
49 | ```
50 |
51 | ### 前端结构
52 |
53 | 前端分为apps和public两部分,apps为前端系统目录,public为资源文件目录,其余为构建与管理的相关配置文件/脚本。
54 |
55 | 依照项目系统架构将前端系统分为以下模块:
56 |
57 | * general(全站)
58 | * event(事件)
59 | * post(片段)
60 | * components(共有组件)
61 |
62 | 三个层级进行模块设计和开发,目录结构如下:
63 |
64 | ```
65 | .
66 | ├── app.js
67 | ├── components
68 | │ ├── conf
69 | │ │ └── conf.js
70 | │ ├── directive
71 | │ │ ├── chartDirective.html
72 | │ │ ├── devDirective.html
73 | │ │ ├── errorDirective.html
74 | │ │ ├── pagerDirective.html
75 | │ │ ├── searchDirective.html
76 | │ │ └── sidebarDirective.html
77 | │ ├── example
78 | │ │ ├── component.js
79 | │ │ ├── main.js
80 | │ │ └── model.js
81 | │ ├── factory
82 | │ │ └── directive.js
83 | │ ├── service
84 | │ │ ├── ajaxService.js
85 | │ │ ├── service.js
86 | │ │ └── shareService.js
87 | │ ├── util
88 | │ │ ├── fmtChart.js
89 | │ │ ├── fmtTool.js
90 | │ │ ├── logger.js
91 | │ │ └── WordCloud.js
92 | ├── event
93 | │ ├── event.js
94 | │ ├── layout.html
95 | │ ├── main.eventSlotViewCount.html
96 | │ ├── main.html
97 | │ ├── main.keywordInfo.html
98 | │ ├── main.onlineTotal.html
99 | │ ├── main.postInfo.html
100 | │ └── main.userAccessMethod.html
101 | ├── general
102 | │ ├── general.js
103 | │ ├── layout.html
104 | │ ├── main.eventsList.html
105 | │ ├── main.eventViewCount.html
106 | │ └── main.html
107 | └── post
108 | ├── layout.html
109 | ├── main.breakSource.html
110 | ├── main.html
111 | └── post.js
112 |
113 | ```
114 |
115 | ### 设计思想
116 |
117 | 为实现更灵活自主的配置,依照模块化开发的思想,采用了**模块内部定义配置**方式:
118 | 自主定义路由和视图,**分离通用模块**统一组织在components下进行管理,**app.js**作为程序入口,仅引入并初始化相关模块,配置皆在模块内部配置。
119 |
120 | ### 设计实现
121 |
122 | #### 模块
123 |
124 | 以general为例,通过app.js(入口)引入general,并手动启动(bootstrap,这里主要是区别于在HTML中加入ng-app="ASS"这样的自动引导方式),并在general内部进行配置general.config(),代码上的体现为:
125 |
126 | ```
127 | general.config(['$stateProvider', '$urlRouterProvider', function ($stateProvider, $urlRouterProvider) {
128 | $stateProvider
129 | .state('general', {
130 | url: '/general',
131 | views: {
132 | '': {
133 | templateUrl: 'apps/src/general/layout.html',
134 | controller: 'generalCtrl'
135 | },
136 | 'main@general': {
137 | templateUrl: 'apps/src/general/main.html',
138 | controller: 'generalMainCtrl'
139 | }
140 | }
141 | })
142 | .state('general.eventViewCount', {
143 | url: '/eventViewCount',
144 | views: {
145 | 'main@general': {
146 | templateUrl: 'apps/src/general/main.eventViewCount.html',
147 | controller: 'generalViewEventViewCountCtrl'
148 | }
149 | }
150 | });
151 | }]);
152 | ```
153 |
154 | * 路由 --> 采用angular-ui-router第三方ng插件实现更灵活的路由配置
155 | * 视图 --> 将视图分解为单独的模块,ui-view="main"为模块下变化的部分(命名为main.xxx.html),不变内容定义在layout.html中
156 |
157 | * 控制器 -->
158 | * 引入了layout.html做模块下的通用配置,故而使用了一个“根”级别的controller进行通用配置。
159 | * layout.html中ui-view=“main”定义基于main@general的”次“级别controller进行非通用的方法或功能。
160 |
161 | #### 指令
162 |
163 | ng指令,在具体的功能中体现为一个类div的标签,在系统中将一些通用的功能封装成指令,在系统内部皆可调用,例如sidebar-Directive。
164 |
165 | * components/directive/
166 |
167 | #### 服务
168 |
169 | 将前端App中的一些通用或者全局的内容作为服务,例如ajax,提供setDataJson()或者getDataJson()给外部调用,以此异步获取数据。
170 |
171 | **# 这里使用异步请求获取数据,数据获取完成后使用$broadcast进行广播,在当前ctrl中监听广播,收到广播后进行绘制。**
172 |
173 | **# share提供了项目公用的eid和pid的get/set方法(这里会修改,更多全局的内容会放进这里)**
174 |
175 | * /components/service/
176 |
177 | #### 工具
178 |
179 | 项目目前比较简单,并未包含很多内容,工具主要是提高对数据二次处理的一些方法。
--------------------------------------------------------------------------------
/mt-experimentations/Test-And-Debug-For-Front-End-Dev-Based-On-Environments.md:
--------------------------------------------------------------------------------
1 | ### 前端测试与异常处理
2 |
3 | 前端测试是一个较为繁重但又不可或缺的任务,涉及的版本较多同时受各种环境的影响较大,为了能为不同的用户提供类似的使用体验,在当前未全面引入**自动化测试**之前,引入一些基本的测试规范,进而未将来展开全面的前端测试做基础。
4 |
5 | #### 测试流程
6 |
7 | * 测试标准:通过列表的形式列出需要进行测试的页面、效果和行为
8 | * 参考标准:通过设计图/标准页面提供预期的页面效果与行为
9 | * 测试进行:在列出的浏览器中与**测试标准**进行对比并**记录异常**
10 | * 测试反馈:在测试标准约束下将**异常结果**反馈在**反馈结果**中
11 |
12 | #### 异常处理
13 |
14 | * 异常处理:对**异常结果**进行Debug并记录原因,收录进**浏览器差异数据库**
15 | * 异常解决:更新Debug后的版本到工作分支,通知分支负责人->通知主分支负责人
16 |
17 | #### 浏览器版本
18 |
19 |
20 |
21 |
22 | Internet Explorer |
23 | 8.0 |
24 | 9.0 |
25 | 10.0 |
26 | 11.0 |
27 |
28 |
29 | Chrome † |
30 | Latest stable |
31 |
32 |
33 | Firefox † |
34 | Latest stable |
35 |
36 |
37 | Safari |
38 | iOS 5.† |
39 | iOS 6.† |
40 | iOS 7.† |
41 | Safari 6.1 (OS X 10.8) |
42 | Safari 7.† (OS X 10.9) |
43 |
44 |
45 | Android |
46 | 2.3.† |
47 | 4.† |
48 |
49 |
50 | Node.js* |
51 | 0.8.† |
52 | 0.10.† |
53 |
54 |
55 | Windows (Native) |
56 | Windows 8 Apps (WinJS >= 2.†) |
57 |
58 |
59 |
60 |
61 | #### 系统版本
62 |
63 |
64 |
65 |
66 | winddows |
67 | 7 |
68 | 8 |
69 | 8.1 |
70 |
71 |
72 | osx |
73 | Latest stable |
74 |
75 |
76 | linux |
77 | Latest stable |
78 |
79 |
80 | android |
81 | Latest stable |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/mt-experimentations/Trying-For-Separating-FrontEnd-From-BackEnd.md:
--------------------------------------------------------------------------------
1 | 前后端分离的实现在SPA(Single-Page App)中应用较为广泛,如AngularJS,React 使用Ajax技术与后端通过RESTFul方式进行数据的请求与发送,
2 |
3 | 如我们的数据统计就是通过ng(AngularJS)的SPA项目,但它并不适用于我们对外的的项目(如SEO体验较差)。
4 |
5 | 考虑到之前曾听到的未来可能会换到JAVA的后端服务的可能性,重新看了一遍淘宝UED的”淘宝前后端分离的思考与实践“的文章,下面两张图是我对他们结构的理解。
6 |
7 | ----
8 |
9 | ### 结构
10 |
11 | 1.经典的结构
12 |
13 | 
14 |
15 | 2.前后端分离的结构
16 |
17 | 
18 |
19 | ----
20 |
21 | ### 优势
22 |
23 | 1.后端实现业务逻辑和数据的查询计算,独立部署后端服务。(例如后端服务部署在8080端口)
24 |
25 | 2.前端路由,MVC,实现相对于后端的独立,自主控制视图层。(同样实现独立部署如部署在80端口)
26 |
27 | ## 这里的Model如上图所示,是与8080端口的后端进行交互
28 |
29 | 3.通过Server(Nginx模块)判断客户端请求类型,自助引导至不同的模块,仅需要一次判断,后续无需重复判断。
30 |
31 | 4.前端通过步骤3的预处理,可以在页面渲染前对例如css/images/js资源进行压缩处理,如置换渲染所需资源到所需的CDN(如icon/icon-mobile/icon@1x/icon@2x)
32 |
33 | 5.传统的SPA通常由于资源的处理时间问题(网络环境影响),在完成前可能出现”空白页“(等待阶段),这里可以参考BigPipe方式,持续输出。
34 |
35 | ## 虽然可以通过一些手段实现渲染完成前的一些预处理,但采用这里说到的方法,实现上更加优雅。
36 |
37 | 6.相对于传统,这样的分离更加明确各自的职责,后端职责更加明确,前端自由度更高,耦合度却有所降低。
38 |
39 | ----
40 |
41 | ### 疑问
42 |
43 | 1.关于通信效率
44 |
45 | 用node做前端的一部分,MODEL(这里应该是伪Model了,毕竟他只是通过http之类的方式)与后端(如java的逻辑、运算服务器)的通讯效率问题。
46 |
47 | 效率问题,放在整个项目的生命周期里的话,是缩短的,所以这部分,我认为效率增加了。
48 |
49 | 2.关于前后端定义
50 |
51 | 有人对于这里存在不同的理解,其实之前就说过了,这里是对也许进行了分离,将MVC中的VC部分纳入前段,M部分交过后端,也许你不认可,但是这种的分离,给了前端更大的自由度,也让后端能够更专注于业务本身,而非交互逻辑。
52 |
53 | 我认为,所谓前端,是指一切与用户/客户端的交互相关的部分。
54 |
55 | 3.关于职责明确
56 |
57 | 前后端分离的源动力在于系统的分离,使得团队人员的职责明确,过去后端参与太多交互相关的内容,对他们来说,其实是在浪费他们的时间和精力,例如tp中($this->display('index'))这样的东西,每次你一改动就让他们改,不觉得eggTeng?(别说什么模板之类的,同样的功能,我们有N种实现方法,我们只是在找一种更好的,更合理的对吧~)
58 |
59 | 4.关于使用与否
60 |
61 | 生命在于折腾,不是为了技术而技术,技术是在改善。
62 |
63 | 这样的讨论的目的是根据具体应用场景来定的,比如我需要一个庞大的数据运算模块,这里我也许可以用C来实现,如果为了语言统一,大可以将C写成node的组件,可当我们面对的时十台百台服务器,但并非每一台都要做运算,有必要每一台都要一个这样的node组件么?
64 |
65 | 成员职责的划分,项目模块的划分,是源动力吧~
66 |
67 |
68 | ----
69 |
70 | ### 试验
71 |
72 | 话说就是参考上面的图来做,所以结构请参考前面的内容,不过顺便说一下吧...
73 |
74 | #### 简介
75 |
76 | Nginx作为服务器入口,对所有请求进行转发,即设置一个反向代理,将80端口的请求全部转发到我们的nodejs应用,这里我设置的是8084端口。
77 |
78 | 补充一下,在CentOS上设置配置一下iptables,禁止外部访问端口,因为内部不仅仅只有这样应用,可能还会有其他的服务,例如我还有一个跑在内网的tp服务器在做接口,然后这个请求,并不是直接用nodejs进行http请求去获取数据,而是通过nginx进行映射,当然,你可以有更多的实现,说到底,只是为了未来进行负载均衡。
79 |
80 | #### Demo
81 |
82 | 暂时还没到完整的试验阶段,团队又有一个博客,作为一个曾经忠实的WP粉到现在的WP半黑(其实只是懒,不想登录上去发文章),在Github上面建立了一个Repo用来放平时写的Markdown文档,使用Github Api来获取数据,并Render到这个Demo的页面上。
83 |
84 | ***这里Github暂时充当了我们的Model,MVC中我们尝试分离的,就是Model这一块。***
85 |
86 | ##### URL:
87 | [http://to-fuck.me/](http://to-fuck.me/)
88 |
89 | ##### Markdown Files:
90 | https://github.com/thonatos/Mt.Notes.And.Documents
91 |
92 | ##### Resources
93 | * NodeJS
94 | * Marked.js
95 | * Gulp.js
96 | * SpmJS
97 | * SeaJS
98 |
99 | ##### Other
100 |
101 | * Github Api拿到的md文件是base64的,需要转换一下:
102 |
103 | ```
104 | var _raw = new Buffer(result.content, result.encoding).toString('utf8');
105 | var _html = marked(_raw);
106 | ```
107 |
108 | * 由于需要从Github上拿数据,程序跑在国外的一台VPS上,拿数据速度快一点。
109 |
110 | * 作为前端狗,未来自然在其中加入很多蛋疼的功能,console大法你好。
111 |
112 |
113 |
114 |
115 | ——————————(我是牛逼的分割线。)
116 |
117 | 未完待续。
--------------------------------------------------------------------------------
/mt-notes/Why-it-is-difficult-to-learn-nodejs-for-frontend-developer.md:
--------------------------------------------------------------------------------
1 |
2 | 为什么前端精通node.js的这么少?
3 |
4 | 那我们来梳理问题啊,前端通常做什么,后端要做什么?
5 | 不对不对,应该这么问:前端和后端分别要掌握哪些知识点以及分别要求有哪些认识?
6 |
7 | #### 一个页面仔的日常
8 |
9 | ```
10 |
11 |
12 |
13 |
Example
14 |
15 |
16 |
17 |
18 |
19 |
20 | name |
21 | age |
22 | sex |
23 |
24 |
25 | a |
26 | 1 |
27 | 1 |
28 |
29 |
30 | b |
31 | 2 |
32 | 1 |
33 |
34 |
35 | c |
36 | 3 |
37 | 1 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
78 |
79 |
80 |
81 | ```
82 |
83 | 上面这玩意的效果大概是当用户点击表格中的某一行的时候,从后台查询数据,然后添加到页面里。(随手写给后端的东西,请不要纠结细节~),
84 |
85 | ##### 基础知识
86 |
87 | - html中table、tbody、tr、td使用,以及标签的class设置
88 | - js中选择器的使用,jquery中ajax的post提交,标签内容的获取与修改
89 |
90 | ##### 错误处理
91 |
92 | ajax提交数据后返回status,response,status通常是网络正常与否之类的东东,但是还有服务器返回数据的错误呢?
93 | 所以这边定义了一个response对象,结构大概是{code:200/500(int),data:{}},然后对应了服务器内部查询的错误处理。
94 |
95 | 这些都比较简单,我这里只是举了一个特别简单的例子。
96 | 不过事实上呢,通常情况下,前端主要做的大概就是这个了~
97 |
98 | (动画啊,特效啊,什么的,那也是!但是和nodejs这边关系不大,用expressjs加载几个页面什么の,乃不是精通!请不要跟我撕逼,谢谢。)
99 |
100 | #### nodejs实例
101 |
102 | 前面是给后端哥哥写了一段便于他查询数据的简单代码,我们现在具体到实际开发喽,具体是一个“微信公众号“开发的小例子(只是粗略的写一写~)。
103 |
104 | - 代理:nginx
105 | - 语言:nodejs
106 | - 框架:expressjs
107 | - 存储:redis
108 |
109 | 微信公众号jssdk的接入,需要验证签名,获取token,接着拿到jsTicket,并最终生成签名。
110 |
111 | ##### 基础知识
112 |
113 | ###### Nginx
114 |
115 | 对于一个独立开发者,服务器的管理是必然的,况且,一个vps上面,你肯定要放很多蛋疼的小玩意,我们这边是nodejs来做基础环境,为了不影响其他服务的正常使用,最好是通过nginx前端代理,把请求转发到nodejs得web程序上面去,配置参考下面链接。(这里还有一堆进程守护什么的东西,随便听听就好了~)
116 |
117 | https://www.thonatos.com/docs/backend-notes/Conf-App-Based-Express-With-Nginx-On-CentOs-7-x64.md
118 |
119 | ###### ExpressJs
120 |
121 | 不管你是用nodejs的http/https直接创建web程序,还是用expressjs框架,其实都是差不多的,对req,res的处理都一定要有所了解,有兴趣就去查官方api吧~
122 |
123 | http://expressjs.com/4x/api.html
124 |
125 | ###### redis
126 |
127 | 为什么要这个呢?如果你看过微信的官方文档,应该知道签名相关的那些接口是有调用次数限制的,过期时间是7200s(2h),所以吧,肯定是要存在你服务器的,cookie、session之类的存储也不是不可以,我这里用redis来做缓存的。
128 |
129 | ##### 具体实现
130 |
131 | 暂定前面的那些你都搞定了或者你都用不到,我们直接进入实现的流程。
132 |
133 | ##### 关于结构、配置、部署等等
134 |
135 | 一个web服务器,路由肯定要有的,我这里是expressjs的,那么就是涉及到一个代码组织的问题,我一开始是使用expressjs生成的那种结构,大概是类似传统的mvc模式(不知道的自行搜索),但是问题来了,当你目录的层级到一定深度的时候,require()使用起来就蛋碎的一笔~
136 |
137 | 前一段时间爬了好久angular的坑(之所以说坑是因为1.3.x和2.x已经不是一个东西~),所以组织代码的方式变成了现在的这样样子,主要代码全部放在了app目录,资源文件放在public目录,conf那边就是调试和运行的一些配置文件了,app下面除了common那边以外是以功能来组织代码。
138 |
139 | ```
140 | .
141 | ├── README.md
142 | ├── app
143 | │ ├── api
144 | │ ├── blog
145 | │ ├── common
146 | │ ├── doc
147 | │ ├── fm
148 | │ ├── index
149 | │ ├── mood
150 | │ ├── route.js
151 | │ └── user
152 | ├── app.js
153 | ├── bin
154 | │ ├── autoload.js
155 | │ └── gulpfile.js
156 | ├── bower.json
157 | ├── conf
158 | │ ├── api_develop.json
159 | │ ├── api_product.json
160 | │ ├── app_develop.json
161 | │ └── pm2_develop.json
162 | ├── node_modules
163 | ├── package.json
164 | ├── public
165 | │ ├── css
166 | │ ├── css-gulp
167 | │ ├── favicon.ico
168 | │ ├── html
169 | │ ├── images
170 | │ ├── js-spm
171 | │ └── vendors
172 | └── static
173 | ```
174 |
175 | 也许有人觉得随便怎么放都行,是我事太多(好像我真的是个事b...),可是我发现啊,我改了好多次结构以后,现在用起来很方便,一目了然,给别人解释起来也比较方便(哼,咱目标可是架构,怎能实现功能就行?笑~),所以嘛,配置啊,模块啊,代码组织啊,运行啊,编译什么的,都要考虑嘛~,再说了,你要做nodejs啊,你是后端啊!你不考虑?不考虑部署?不考虑结构?不考虑配置?——行行行,你什么都不考虑,但是总得考虑这玩意公开以后别人能不能看得懂吧?
176 |
177 | ##### 其实写代码是最好做的那一部分~
178 |
179 | 先把所有请求全转到router那边来处理吧~
180 |
181 | ```
182 | # app.js
183 | // ------------- ROUTERS -------------
184 | require('./app/route')(app, passport);
185 |
186 | # router.js
187 | // Api
188 | var api = require('./api/api');
189 | app.use('/api',api);
190 |
191 | # api.js
192 | // Router
193 | var apiApi = require('../api/apiModule').Api;
194 | router.route('/wechat/signature')
195 | .get(apiApi.wechat().checkSignature);
196 |
197 | router.route('/wechat/signature/gen')
198 | .get(apiApi.wechat().genSignature);
199 |
200 | router.route('/wechat/token/get')
201 | .get(apiApi.wechat().getToken);
202 | ```
203 |
204 |
205 | 然后我们就来写代码吧~
206 |
207 | ```
208 | var obj = {};
209 |
210 | // 签名检查
211 | obj.checkSignature = function (req,res){
212 |
213 | var WECHAT_CONFIG = CONFIG_APP.weixin;
214 | var signature = req.query.signature;
215 | var timestamp = req.query.timestamp;
216 | var nonce = req.query.nonce;
217 | var echostr = req.query.echostr;
218 |
219 | var shasum = crypto.createHash('sha1');
220 | var arr = [WECHAT_CONFIG.token, timestamp, nonce].sort();
221 | shasum.update(arr.join(''));
222 |
223 | if(shasum.digest('hex') === signature){
224 | res.send(echostr);
225 | }else {
226 | res.send('err');
227 | }
228 | };
229 |
230 | ```
231 |
232 |
233 | 未完待续。
234 |
235 | 让我静静,后面的那些不忍心贴了,太长....
--------------------------------------------------------------------------------
/mt-projects/Cyanogenmod-htc-one-sprint-model-chinese-version.md:
--------------------------------------------------------------------------------
1 | > * title: "CyanogenMod HTC One (Sprint model) Chinese Version"
2 | > * date: 2014-07-23 18:13:59
3 |
4 |
5 | 此前一直在使用 CyanogenMod 官方Rom,但由于美版的配置和中国大陆网络的不同,往往无法直接使用,会出现无法读取手机卡,无法上网等问题,当然,通过自己的修改是可以使他正常的,但是作为一个懒人,真的没那么好的心情一个个去修改文件,添加配置,尤其是经常更新的时候,一次次的修改真的太痛苦了,所以Copy了一份CyanogenMod Device Tree中的android_device_htc_m7spr并默认修改了system.prop与xml中的一些未汉化的部分,用于直接编译,这样生成的版本基本可以通过“首选网络”与“RUIM”选项之后便能够正常使用了。
6 |
7 | 由于硬件相同,CyanogenMod 建议不分离一个新的版本,故而作为非官方版本存在了github上,有兴趣的同学可以看看。
8 |
9 | #### Github
10 |
11 | * [https://github.com/thonatos/android_device_htc_m7sprcn](https://github.com/thonatos/android_device_htc_m7sprcn "android_device_htc_m7sprcn")
12 | * [https://github.com/thonatos/android_device_htc_m7-common](https://github.com/thonatos/android_device_htc_m7-common "android_device_htc_m7-common")
13 |
14 | #### Change
15 |
16 | ### Changed Logs
17 |
18 | +2014.07.19
19 |
20 | ADD : packages/apps/GrimRock-Theme-White
21 |
22 | MOD : vendor/htc/m7spr/m7spr-vendor-blobs.mk
23 | # Custom Theme
24 | PRODUCT_PACKAGES += \
25 | GrimRock-Theme-White
26 |
27 | +2014.07.18
28 |
29 | MOD : device/htc/m7spr/system.prop
30 |
31 | rild.libargs=-d /dev/smd0
32 | rild.libpath=/system/lib/libril-qc-qmi-1.so
33 | persist.radio.snapshot_enabled=1
34 | persist.radio.snapshot_timer=2
35 | ro.telephony.default_network=10
36 | telephony.lteOnCdmaDevice=1
37 | persist.radio.apm_sim_not_pwdn=1
38 | ro.cdma.home.operator.numeric=46003
39 | ro.cdma.home.operator.alpha=ChinaTelecom
40 | gsm.sim.operator.alpha=ChinaTelecom
41 | gsm.sim.operator.numeric=46003
42 | gsm.sim.operator.iso-country=cn
43 | gsm.operator.alpha=ChinaTelecom
44 | gsm.operator.numeric=46003
45 | gsm.operator.iso-country=cn
46 | persist.radio.use_nv_for_ehrpd=true
47 | persist.radio.mode_pref_nv10=1
48 | ril.subscription.types=NV,RUIM
49 | persist.radio.always_send_plmn=true
50 |
51 | ADD : device/htc/m7spr/overlay/packages/apps/Settings/res/values-zh-rCN/cm_strings.xml
52 | %% Clock_Style
53 |
时钟样式
54 |
默认
55 |
居中
56 |
隐藏
57 | %% Seting String
58 |
编译版本
59 |
版本更新
60 |
61 |
62 | 由于是个人使用,部分字符串我修改了,保留了CM的标志阿,只是有点“强迫症”,看着字符串一样长心里不舒服...
63 |
64 | #### ScreenShot
65 |
66 | 在我的微博上可以看到编译版本的截图,[http://weibo.com/thonatos](http://weibo.com/thonatos)
--------------------------------------------------------------------------------
/mt-projects/MT-NOTES.md:
--------------------------------------------------------------------------------
1 |
2 | MT.NoteAnd.Documents && MT.NOTES
3 |
4 | 一个在试验前后端分离方案时候顺便搭建起来的类博客站点。
5 |
6 | #### About
7 |
8 | 我们曾经就前后端分离做过很多的讨论,停留在讨论阶段的讨论始终没有实际意义,讨论的最终目的是用于实际使用,故而将讨论变为实际可行的应用才是我们要达到的效果。
9 |
10 | 作为一个使用WP长达六年的屌丝前端,对WP有欣赏也有不满,安装便捷,插件丰富,文档齐全让使用变得简单方便;但与此同时,也变得更加“臃肿”,我始终相信博客的本质在于内容,功能最多只是锦上添花,内容才是核心。
11 |
12 | 所以最终还是在试验的时候放弃了WP,用Github提供的API搭建了这个类博客站,并替换了原先的个人站。
13 |
14 | #### Why
15 |
16 | * 为什么不用数据库?
17 |
18 | 为什么我这里不用数据来存储文章内容的原因在之前的一篇文章中已经说明过 —— 这个小程序的核心是试验前 后端分离方案;所以程序本身不包含数据和信息的存储与读写处理。
19 |
20 | * 为什么用NodeJS?
21 |
22 | 个人倾向算是其中一个原因,过去对后端的依赖过大,往往新加C(Controller)或者V(View)都需要后端帮忙,自主性太差,频繁的找后端测试什么的实在是很蛋疼,所以,干脆把那部分权利剥夺了吧,我们自己来写,让后端专心的去弄他得数据好了~
23 |
24 | * 为什么用中间件?
25 |
26 | 曾经试验过SPA解决方案,但是SPA在SEO和加载的速度上,存在较大的问题,另外从后端接受数据的时间受网络影响比较大,尤其是涉及数据运算的时候,等待时间过长,在等待中页面需要显示loading或者空白,给人的感觉是程序bug,体验上得优化虽然能解决问题,但始终不是最佳方案。
27 |
28 | * 有什么优点?
29 | * 自主性(我们有足够的权限做自己想做的事情)
30 | * 独立性(再也不用一起部署测试了!后端去部署后端,前端去部署前端,just do what we want ! )
31 | * 其他..(前后端分离的优缺点还是自己去找吧)
32 |
33 | * 有什么问题?
34 | * 试验项目(这是一个实验项目,知乎大神说没有需要还是不要去尝试~)
35 | * 未知问题(听说未来会遇到一些列的瓶颈什么的,但我认为有问题不要紧,去解决就好~)
36 |
37 |
38 | #### How
39 |
40 | * 文档托管
41 |
42 | Documents/Posts存放在Github,格式为Markdown或者其他(html也可以)
43 |
44 | * 运行环境
45 |
46 | 程序依赖于NodeJS,基于ExpressJS搭建,本质上就是一个常规的基于NodeJS的WebProject,区别在于未使用数据库进行数据的存储与读取,将Model的职责分配给后端,在这个项目中,是将该职责转交到Github Api,如果是在公司项目中,这里会交给后端的API进行处理。
47 |
48 | #### Changelog
49 |
50 | - [https://github.com/MT-Libraries/MT-Notes](https://github.com/MT-Libraries/MT-Notes)
51 | - [https://coding.net/u/thonatos/p/MT-Notes/git](https://coding.net/u/thonatos/p/MT-Notes/git)
52 |
53 | #### Thanks
54 |
55 | * SeaJS 模块化开发
56 | * GulpJS 流式构建
57 | * Github 文档API服务
58 | * MongoDB 数据库
59 | * AngularJS MVVM前端框架
60 | * ExpressJS 网站核心程序
61 | * PassportJS 网站认证模块
62 |
63 | 感谢用到类库作者的无私奉献以及Github。
64 |
65 | #### License
66 |
67 | The MIT License (MIT)
68 |
69 | Copyright (c) 2014 [@Thonatos.Yang](http://github.com/thonatos)
70 |
71 | Permission is hereby granted, free of charge, to any person obtaining a copy
72 | of this software and associated documentation files (the "Software"), to deal
73 | in the Software without restriction, including without limitation the rights
74 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
75 | copies of the Software, and to permit persons to whom the Software is
76 | furnished to do so, subject to the following conditions:
77 |
78 | The above copyright notice and this permission notice shall be included in all
79 | copies or substantial portions of the Software.
80 |
81 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
82 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
83 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
84 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
85 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
86 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
87 | SOFTWARE.
88 |
--------------------------------------------------------------------------------
/mt-projects/MagiciTerm-Golang.md:
--------------------------------------------------------------------------------
1 | MagiciTerm Golang版本的请求结构接口。
2 |
3 | #### Structure
4 |
5 | * Api (interface)
6 | * post
7 | * user
8 | * Request
9 | (/:model/:action/:parm)
10 | * post
11 | (文章:增,删,改,查)
12 | * add (对应的数据库中文章表的字段 数据类型)
13 | * title
14 | * tags
15 | * type
16 | * date
17 | * time
18 | * author
19 | * content
20 | * shortname
21 | * category
22 | * del
23 | * update
24 | * list
25 | * lists
26 | * user
27 | (用户:登陆,退出)
28 | * login
29 | request:
30 | * username
31 | * userpass
32 | * verified_code
33 | * verified_token
34 | return:
35 | * user_id
36 | * user_role
37 | * logout
38 | request:
39 | * null
40 | return:
41 | * user_id
42 | * user_role
--------------------------------------------------------------------------------
/mt-projects/Qrcode-Gen.md:
--------------------------------------------------------------------------------
1 | ## Qrcode-Gen
2 |
3 | 离线二维码生成,Generate Qrcode offline (Chrome Extension)
4 |
5 | [https://github.com/thonatos/Qrcode-Gen](https://github.com/thonatos/Qrcode-Gen)
6 |
7 | #### Changelogs
8 |
9 | 2015.02.09
10 |
11 | - 支持生成svg
12 | - 添加下载功能
13 | - 开启类型选择
14 | - 更新代码结构
15 |
16 |
17 | #### Install & Usage
18 |
19 | - 将dist中得crx拖入chrome浏览器即可(请先在扩展程序中开启开发选项。)
20 | - 在要生成二维码的页面单击Qrcode-Gen的icon,默认生成当前页面的二维码。
21 | - 需要临时生成的地址或内容,请手动在text中输入要添加的内容,点击Generate
22 |
23 | #### Thanks:
24 |
25 | - Icon [@illusate](https://github.com/illusate)
26 | - Jquery
27 | - qrcode.js https://github.com/davidshimjs/qrcodejs
28 | - qrcodesvg https://github.com/pinchtools/qrcodesvg
29 |
--------------------------------------------------------------------------------
/other-notes/Backup-Data-While-Mac-Can-Be-Booted-Normally.md:
--------------------------------------------------------------------------------
1 | Mac无法启动情况下的Single-User-Mode数据备份,记录备用。
2 |
3 | - 开机启动
4 |
5 | command+s
6 |
7 | - 加载根分区
8 |
9 | /sbin/mount -uw /
10 | # 根分区挂载
11 |
12 | /sbin/fsck -fy
13 | # 磁盘检查
14 |
15 | - 列出磁盘信息
16 |
17 | ls /dev/disk*
18 | # 一般自己的移动硬盘为disk1s1
19 |
20 | - 挂载移动硬盘
21 |
22 | mkdir /Volumns/mobile_driver
23 | /sbin/mount_msdos /dev/disk1s1 /Volumns/mobile_driver
24 |
25 | - 备份个人数据
26 |
27 | cd /Volumns/mobile_driver
28 | mkdir backup_mac_data
29 |
30 | cp -R /your_dir_or_file ./
31 |
32 | 尝试过其他方式,这种方法是最为简单简洁的,但是在某些情况下,这样的方式不生效,那就使用可移动的光盘进行命令行操作,方法其实是一样的,挂载移动硬盘,复制数据。
--------------------------------------------------------------------------------
/other-notes/Change-Remote-Git-Address.md:
--------------------------------------------------------------------------------
1 | 之前是私有项目,为了速度,代码放在coding上面,现在决定开源,所以要放到github上面了。
2 |
3 | #### 换仓
4 |
5 | 一种不错的方法:
6 |
7 | git branch -r
8 | # 如果结果显示origin/master,那么就可以直接进入下一步了。
9 |
10 | git remote set-url origin remote_git_address
11 | # 这里的地址换成你的repo的地址
12 |
13 | git push origin master
14 |
15 | 还有一种方法:
16 |
17 | git commit -m "Change repo."
18 | # 先把所有为保存的修改打包为一个commit
19 |
20 | git remote remove origin
21 | # 删掉原来git源
22 |
23 | git remote add origin [YOUR NEW .GIT URL]
24 | # 将新源地址写入本地版本库配置文件
25 |
26 | git push -u origin master
27 | # 提交所有代码
28 |
29 | #### 优点
30 |
31 | - 第一种方法,的好处就是所有的历史记录都会保留下来
32 |
33 | - 第二种方法,注释说的很明白了,不过我没测试,代码丢了不关我事情啊~
--------------------------------------------------------------------------------
/other-notes/FFMPEG-Commands.md:
--------------------------------------------------------------------------------
1 | some ffmpeg commands .
2 |
3 | ## Base Usages
4 |
5 | 常用的一些命令。
6 |
7 | #### Get Video
8 |
9 | ```
10 | ffmpeg -i ./vpano_a.flv -s 1024x512 -r 30 -b:v 850k -c:a copy -c:v libx264 -profile:v baseline -an v.mp4
11 | ```
12 |
13 | #### Get Audio
14 |
15 | ```
16 | ffmpeg -i ./vpano_a.flv -vn -ar 44100 -ac 2 -ab 128k -f mp3 Sample.mp3
17 | ```
18 |
19 | #### Get Poster
20 |
21 | ```
22 | ffmpeg -i ./v.mp4 -ss 0 -f image2 -vframes 1 poster.jpg
23 | # -ss 0 表示第一帧
24 | ```
25 |
26 | #### Send rtsp
27 |
28 | ```
29 | ffmpeg -re -i input.mp4 -c copy -f flv rtmp://192.168.3.8/hls/test
30 | ffplay http://192.168.1.122:8080/hls/test.m3u8
31 | ```
32 |
33 | #### convert mp4 to m3u8
34 |
35 | ```
36 | ffmpeg -i v2048x1024.mp4 -c:v libx264 -c:a aac -strict -2 -hls_list_size 0 -hls_time 2 -f hls output.m3u8
37 | ```
38 |
39 | ## other
40 |
41 | 一些其他奇葩的应用。
42 |
43 | ```
44 | # 直接转换
45 | ffmpeg -i video.avi -s 320x540 -r 10 out.gif
46 |
47 | # 另一种方法
48 | ffmpeg -i video.avi -t 1 out%01d.gif
49 | gifsicle --delay=10 --loop out*.gif > anim.gif
50 | ```
51 |
52 | ## More
53 |
54 | 组合命令,可以更方便的处理一些视频。
55 |
56 | #### convert mp4 to m3u8 (different size)
57 |
58 | ```
59 | ffmpeg -i v2048x1024.mp4 -c:v libx264 -c:a aac -strict -2 -hls_list_size 0 -hls_time 2 -s 1920x1080 -r 30 -b:v 850k -f hls ./1920x1080/m3u8/demo.m3u8
60 |
61 | ffmpeg -i scene2.mov -c:v libx264 -c:a aac -strict -2 -hls_list_size 0 -hls_time 2 -s 1280x720 -r 30 -b:v 3M -movflags faststart scene2@1280x720.mp4
62 |
63 | -movflags faststart
64 | ## 可在视频在未加载完之前播放
65 |
66 | -hls_time n
67 | ## 设置每片的长度,默认值为2。单位为秒
68 |
69 | -hls_list_size n
70 | ## 设置播放列表保存的最多条目,设置为0会保存有所片信息,默认值为5
71 |
72 | -hls_wrap n
73 | ## 设置多少片之后开始覆盖,如果设置为0则不会覆盖,默认值为0.这个选项能够避免在磁盘上存储过多的片,而且能够限制写入磁盘的最多的片的数量
74 |
75 | -hls_start_number n
76 | ## 设置播放列表中sequence number的值为number,默认值为0
77 | 注意:播放列表的sequence number 对每个segment来说都必须是唯一的,而且它不能和片的文件名(当使用wrap选项时,文件名有可能会重复使用)混淆
78 |
79 | ffmpeg -i H5小星球动态-有logo.mov -an -vcodec libx264 -pix_fmt yuv420p H5.mp4
80 | # Mac转换的视频转码异常的处理。
81 |
82 | -preset veryslow
83 |
84 | -movflags faststart
85 |
86 | ```
87 |
88 |
89 | #### concat demuxer
90 |
91 | [Concatenate](https://trac.ffmpeg.org/wiki/Concatenate)
92 |
93 | ```
94 | ## create file list.txt
95 |
96 | # this is a comment
97 | file '/path/to/file1'
98 | file '/path/to/file2'
99 | file '/path/to/file3'
100 |
101 |
102 | ## ffmpeg
103 | ffmpeg -f concat -safe 0 -i list.txt -c copy output
104 |
105 | ffmpeg -i "concat:input1.mpg|input2.mpg|input3.mpg" -c copy output.mpg
106 |
107 | ```
108 |
--------------------------------------------------------------------------------
/other-notes/Reinstall-OSX-Yosemite-And-Make-Create-Install-Media.md:
--------------------------------------------------------------------------------
1 | Reinstall OSX - Yosemite && Make Create Install Media
2 |
3 | ##### Format Disk
4 |
5 | - 找一个大于8G的U盘或者移动硬盘
6 | - 创建新分区MacOS日志格式
7 | - 记得选择GUID分区(创建分区时候在选项那边)
8 |
9 | #### Make Create Install Media
10 |
11 | - 下载安装镜像并放到Appliactions目录
12 | - 执行以下命令
13 |
14 | sudo /Applications/Install\ OS\ X\ Yosemite.app/Contents/Resources/createinstallmedia --volume /Volumes/Install --applicationpath /Applications/Install\ OS\ X\ Yosemite.app --nointeraction
15 |
16 | - Install 为磁盘名称(可以ls /Volumns/查看可用的磁盘)
17 |
18 | #### More
19 |
20 | - 时间问题
21 |
22 | > 格式化磁盘并重新安装的时候,可能出现“应用损坏或验证...”类的信息,记得改下时间,方法是:
23 |
24 | # 在终端中输入
25 | date 062202082015.30
26 |
27 | # 06 hour
28 | # 22 minute
29 | # 02 month
30 | # 08 day
31 | # 2015 year
32 | # 30 second
--------------------------------------------------------------------------------
/other-notes/android-notes/Android-Zip-Apk-Sign-Script-For-Linux.md:
--------------------------------------------------------------------------------
1 | Android zip/apk 签名脚本
2 |
3 | 反编译、定制修改Android ROM或者程序的时候,需要用到签名工具,使用方法自行搜索。
4 |
5 | 下面是在linux上可以用得一个sh脚本。
6 |
7 | #### Script
8 |
9 | #!/bin/sh
10 |
11 | # ====Sign Function
12 | # ** input file with name like "file.zip/file.apk"
13 | # ** output file with name like "file_signde.zip/file_signed.apk"
14 | Sign(){
15 | f_i=$1;
16 | f_o=$2;
17 | jar_dir=$3;
18 | java -jar $jar_dir/SignApk.jar $jar_dir/testkey.x509.pem $jar_dir/testkey.pk8 $f_i $f_o;
19 | }
20 |
21 | # ====Main Function
22 | # ** Parm : "file.zip/file.apk"
23 | # ** Useage: "Signtool file.zip / Signtool file.apk"
24 | echo "\n";
25 | echo "\t--------===== SignTool For Apk/Zip =====--------";
26 | echo "\t\t\t——http://www.thonatos.com";
27 | echo "\t\t\t——By.Thonatos.Yang.2014.07.19\n";
28 |
29 | # Define The var
30 | in=$1;
31 | out_name=${in%%.*} ;
32 | out_suffix=${in##*.} ;
33 | out_file=${out_name}"_signed."${out_suffix};
34 | sign_jar=$(cd "$(dirname "$0")"; pwd);
35 |
36 | # Print The Sign Info
37 | echo "==:Input : $out_name";
38 | echo "==:Type : $out_suffix";
39 | echo "==:Output : $out_file";
40 |
41 | # Sign The File
42 | Sign $in $out_file $sign_jar;
43 | wait ;
44 | echo "==:Result : Sign Successful !\n";
45 | exit;
--------------------------------------------------------------------------------
/other-notes/android-notes/CyanogenMod-SMSC.md:
--------------------------------------------------------------------------------
1 | > * title: CyanogenMod SMSC
2 | > * date: 2012-01-07 16:10:30
3 |
4 | **CyanogenMod使用中很多人遇到GSM网络短信无法发送的问题,这个是因为SMSC设置有问题。**
5 |
6 | **中文对照:**
7 |
8 | SMS(短消息服务)是指定由ETSI(标准GSM 03.401和03.382)。它最多可包含160个字符,每个字符是根据7位GSM默认字母表书面。
9 |
10 | 短信还包含一些元数据,例如:
11 |
12 | > * 有关发件人的信息(服务中心号码,发送号码)
13 | > * 协议信息(协议标识符,数据编码方案)
14 | > * 时间戳
15 |
16 | 有2种方式接收和发送短信消息的PDU(协议份比单 位)和文本模式。在此页中,我们集中在PDU模式,这是什么的Android 2.3和更高的认识。旅行通过SMSC网关SMS消息发送和接收。一个急需配置SMSC的一个常见的症状是您的设备能够接收短信“,但不能发送(通常作为发送报告,但没有在接收端接收) 。
17 |
18 | 首先,你将需要运营商的SMSC网关号码。下面是美国主要运营商(运营商的谷歌)的数字:
19 |
20 | > * 斯普林特:17044100000
21 | > * Verizon公司:316540951000
22 | > * AT&T:13123149810
23 | > * 的T - Mobile:12063130004
24 |
25 | 请注意数字包括“+”,为接下来的步骤的这个事项
26 |
27 | 转换为PDU格式
28 | > 1. 拿你的,包括“+”号,并[去 http://www.twit88.com/home/utility/sms-pdu-encode-decode](http://www.twit88.com/home/utility/sms-pdu-encode-decode)
29 | > 2. 接近页面的底部,有一个当场进入SMSC的,接收器和消息
30 | > 1. 输入您的完整的短信服务中心号码(包括+)
31 | > 2. 离开接收器和消息框空白
32 | > 3. 选择字母7
33 | > 4. 点击转换
34 | > 3. 您将获得右侧在框中输出
35 | > 4. 从第16位的第二行(上面列出的运营商例子)
36 | > * 斯普林特:17044100000 = 07917140140000F0
37 | > * Verizon公司:316540951000 = 0791135604590100
38 | > * AT&T公司:13123149810 = 0713121139418f0
39 | > * 的T - Mobile:12063130004 = 07912160130300f4
40 |
41 | 您的SMSC号码现在是在PDU格式,现在来更新您的手机:
42 |
43 | > 1. 打开拨号
44 | > 2. 键入下列顺序'*#*# 4636 #*#*'
45 | > 3. 开放手机信息
46 | > 4. 向下滚动到SMSC
47 | > 1. 可选:点击刷新查看当前使用的短信服务中心号码
48 | > 5. 请输入您的PDU格式的短信服务中心号码
49 | > 6. 新闻更新
50 | 一旦进入,可能需要长达10分钟的电话“握手”新网关。还建议重新启动电源周期的无线电。
51 |
52 | 假设一切正常,您现在应该能够正常发送和接收短信“。
53 |
54 | 注:MMS是在APN的控制Android的。如果彩信失败,请仔细检查您的APN 信息
55 |
56 | **英文原文:**
57 |
58 | SMS (Short Message Service) is specified by the ETSI (standards GSM 03.401 and 03.382 ). It can contain up to 160 characters, where each character is written according to the 7-bits GSM default alphabet.
59 |
60 | SMS also contains some meta-data, e.g.
61 |
62 | > * Info about the senders ( Service center number, sender number)
63 | > * Protocol information (Protocol identifier, Data coding scheme)
64 | > * Timestamp
65 |
66 | There are 2 ways to receive and send SMS messages a, PDU (protocol discription unit) and Text mode. In this page we focus on PDU mode, which is what Android 2.3 and higher recognize. The SMS messages travel through the SMSC gateway to send and receive. A common symptom of a badly configured SMSC is your device is able to receive SMS' but not send (usually reporting as sent, but without reception on the receiving end).
67 |
68 | First, you will need your carrier's SMSC gateway number. Below are the numbers for major US carriers (Google for your carrier's):
69 |
70 | > * Sprint: +17044100000
71 | > * Verizon: +316540951000
72 | > * AT&T: +13123149810
73 | > * T-Mobile: +12063130004
74 |
75 | Notice the numbers include the +, this matters for the next steps
76 |
77 | Converting to PDU format
78 |
79 | > 1. Take your number, including the + and go to [http://www.twit88.com/home/utility/sms-pdu-encode-decode](http://www.twit88.com/home/utility/sms-pdu-encode-decode)
80 | > 2. Towards the bottom of the page, there is a spot to enter SMSC, Receiver and Message
81 | > 1. Enter your full SMSC number (including the +)
82 | > 2. Leave Receiver and message box blank
83 | > 3. Select Alphabet 7
84 | > 4. Hit Convert
85 | > 3. You will get an output in the box on the right side
86 | > 4. Take the first 16 digits from the second line (examples for above carriers listed)
87 | > * Sprint: +17044100000 = 07917140140000F0
88 | > * Verizon: +316540951000 = 0791135604590100
89 | > * AT&T: +13123149810 = 0713121139418f0
90 | > * T-Mobile: +12063130004 = 07912160130300f4
91 | Your SMSC number is now in PDU format, now to update your phone:
92 | > 1. Open Dialer
93 | > 2. Type the following sequence '*#*#4636#*#*'
94 | > 3. Open Phone Information
95 | > 4. Scroll down to SMSC
96 | > 1. Optional: Hit Refresh to see current SMSC number used
97 | > 5. Enter in your PDU formatted SMSC number
98 | > 6. Press Update
99 |
100 | Once entered, it can take up to 10 minutes for the phone to 'handshake' with the new gateway. A reboot is also suggested to power cycle the radio.
101 |
102 | Assuming everything worked, you should now be able to send and receive SMS' properly.
103 |
104 | Note: MMS is controlled by the APN in Android. If MMS is failing, double check your APN information
--------------------------------------------------------------------------------
/other-notes/android-notes/Edit-and-compile-odex.md:
--------------------------------------------------------------------------------
1 | > * title: 编辑并重建odex文件
2 | > * date: 2011-09-03 21:20:27
3 |
4 |
5 | 从现在开始不再发布ROM,只发布一些常用的教程,这是系列教程之一。
6 | 修改系统文件,未Deodex的系统文件不易修改,修改了,也有很多人不知道如何重建。
7 |
8 | #### 预准备
9 |
10 | * 电脑必须安装了Java环境(不会配置的在我博客搜索)
11 | * 首先复制手机的framework文件夹内的全部内容到电脑
12 | * 并在在该文件夹中放入编译的工具,Basksmali和Smali、最好再加入一个cmd.exe
13 | * 然后还需要提取你需要修改的APK和ODEX文件到该目录
14 | * 所需的软件我会在日志的末尾处放出来,大家也可以自行搜索
15 |
16 | 【合并APK和ODEX】
17 |
18 | 1.通过odex生成class文件
19 |
20 | java -jar baksmali.jar -x ex.odex
21 |
22 | 2.通过class生成classes.dex 文件。
23 |
24 | java -Xmx512M -jar smali.jar out -o classes.dex
25 |
26 | 3.将classes.dex放到apk文件
27 |
28 | 因为apk是zip的mime编码类型,直接将dex拖入到apk改名为zip的压缩包中即可
29 |
30 | 4.现在最好将该apk重新签名一下,这样可以方便一些
31 |
32 | 【反编译】
33 |
34 | 1.反编译APK文件
35 |
36 | apktool d ex.apk ex
37 |
38 | 2.然后在ex目录里面修改你打算修改的内容
39 |
40 | 3.重新打包APK
41 |
42 | apktool b ex ex-new.apk
43 |
44 | 【生成ODEX】
45 |
46 | 1.将tool目录下的dexopt-wrapper复制到手机systembin目录下,并修改好权限
47 |
48 | xxx
49 | x-x
50 | x-x
51 |
52 | 2.将重建的ex-new.apk复制内存根目录
53 | 3.开启手机调试模式,并修改连接模式“仅充电”
54 | 4.在tool目录下的cmd.exe中输入并等待出现$
55 |
56 | adb shell
57 |
58 | 5.输入su命令,记得要授权,成功后出现#(已经是#的就不用管了)
59 | 6.输入
60 |
61 | cd /sdcard/
62 |
63 | 7.输入
64 |
65 | dexopt-wrapper ex-new.apk ex-new.odex
66 |
67 | 8.现在如果看到SUCCESS字样应该就是成功了,对比与原来的ODEX文件差异,相近则成功
68 |
69 | 注意:
70 |
71 | 1.现在在内存卡根目录更名ex-new.odex为ex.odex并放回原来的位置就可以,权限必须与原来相同
72 |
73 | 2.重建的apk不要放进原来提取的位置,你应该提取相应的.xml文件替换到最初提取并备份的apk里面.
74 |
75 | 【相关下载及补充说明】
76 |
77 | 该部分说明到此为止,下一部分随后更新。
78 | 好了,现在修改的方法就是这样了,相关软件的下载,请自行搜索。
79 |
--------------------------------------------------------------------------------
/other-notes/android-notes/Modify-dialer-panel-pinyin-method-for-blur.md:
--------------------------------------------------------------------------------
1 | > * title: Blur拨号面板拼音检索修改方法
2 | > * date: 2011-10-10 13:00:48
3 |
4 | #### 预准备
5 |
6 | * 电脑必须安装了Java环境(不会配置的在我博客搜索)
7 | * 首先复制手机的framework文件夹内的全部内容到电脑
8 | * 并在在该文件夹中放入编译的工具,Basksmali和Smali、最好再加入一个cmd.exe
9 | * 然后还需要提取你需要修改的APK和ODEX文件到该目录
10 | * 所需的软件我会在日志的末尾处放出来,大家也可以自行搜索
11 |
12 | #### 修改文件说明
13 |
14 | 主要修改文件:BlurDialer.apk BlurDialer.odex
15 |
16 | 主要修改位置:SmartDialerAdapter$4.smali
17 |
18 | #### 关键代码
19 |
20 | 源代码:
21 |
22 | const-string v5, "( REPLACE(UPPER(display_name), ' ','') GLOB ? OR UPPER(display_name) GLOB ? OR REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(UPPER(data1), '-',''),'.',''),' ',''),'(',''),'/',''),')','') GLOB ?)"
23 |
24 | 修改后代码:
25 |
26 | const-string v5, "( REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(UPPER(sort_key_alt),SUBSTR(display_name,1,1),''),SUBSTR(display_name,2,1),''),SUBSTR(display_name,3,1),''),SUBSTR(display_name,4,1),''),' ','') GLOB ? OR UPPER(display_name) GLOB ? OR REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(UPPER(data1), '-',''),'.',''),' ',''),'(',''),'/',''),')','') GLOB ?)"
27 |
28 | #### 反编译
29 |
30 | 1.反编译APK文件
31 |
32 | apktool d ex.apk ex
33 |
34 | 2.然后在ex目录里面修改你打算修改的内容
35 |
36 | 3.重新打包APK
37 |
38 | apktool b ex ex-new.apk
39 |
40 | ##### 生成ODEX
41 |
42 | 1.将tool目录下的dexopt-wrapper复制到手机systembin目录下,并修改好权限
43 |
44 | xxx
45 | x-x
46 | x-x
47 |
48 | 2.将重建的ex-new.apk复制内存根目录
49 | 3.开启手机调试模式,并修改连接模式“仅充电”
50 | 4.在tool目录下的cmd.exe中输入并等待出现$
51 |
52 | adb shell
53 |
54 | 5.输入su命令,记得要授权,成功后出现#(已经是#的就不用管了)
55 | 6.输入
56 |
57 | cd /sdcard/
58 |
59 | 7.输入
60 |
61 | dexopt-wrapper ex-new.apk ex-new.odex
62 |
63 | 8.现在如果看到SUCCESS字样应该就是成功了,对比与原来的ODEX文件差异,相近则成功
64 |
65 | 注意:
66 |
67 | 1.现在在内存卡根目录更名ex-new.odex为ex.odex并放回原来的位置就可以,权限必须与原来相同
68 |
69 | 2.重建的apk不要放进原来提取的位置,你应该提取相应的.xml文件替换到最初提取并备份的apk里面.
70 |
71 | #### 相关下载及补充说明
72 |
73 | 该部分说明到此为止,下一部分随后更新。
74 | 好了,现在修改的方法就是这样了,相关软件的下载,请自行搜索。
--------------------------------------------------------------------------------
/other-notes/android-notes/Run-android-in-emulator.md:
--------------------------------------------------------------------------------
1 | > * title: 模拟器中运行编译好的Android
2 | > * date: 2012-01-09 21:27:15
3 |
4 | 编译android4.0成功以后,肯定要测试的,下面就要想办法运行了,也许你跟我一样,既安装了sdk又下载了源码,然后输入emulator命令时候就会提示错误了。
5 |
6 |
7 |
8 | 首先你需要设置一下emulator工具的目录之类的,这个不细说了,
9 |
10 | 要在.bashrc中新增环境变量,如下
11 |
12 | ANDROID_PRODUCT_OUT=~/android/out/target/product/generic
13 | ANDROID_PRODUCT_OUT_BIN=~/android/out/host/linux-x86/bin
14 |
15 | 这里是设置你的输出文件的位置和bin工具目录,不用多解释吧?
16 | 然后在命令行输入:
17 |
18 | export PATH=${PATH}:${ANDROID_PRODUCT_OUT_BIN}:${ANDROID_PRODUCT_OUT};
19 |
20 | 上面是导入了相关的配置,然后使之生效。
21 |
22 | source ~/.bashrc
23 |
24 | 接着切换到输出的system文件夹
25 |
26 | cd ~/android/out/target/product/generic
27 |
28 | 然后来创建模拟器
29 |
30 | emulator -system system.img -data userdata.img -ramdisk ramdisk.img
31 |
32 | 如果你运气够好的话,也许现在已经在运行了,不过我运气明显不够好。
33 |
34 | 提示一:
35 |
36 | emulator: ERROR: You did not specify a virtual device name, and the system
37 | directory could not be found.
38 | If you are an Android SDK user, please use '@
' or '-avd '
39 | to start a given virtual device (see -help-avd for details).
40 | Otherwise, follow the instructions in -help-disk-images to start the emulator
41 |
42 | 既然人家提示了,那就按照步骤走吧,输入命令:
43 |
44 | emulator -help-avd
45 |
46 | 接着提示如下:
47 |
48 | use '-avd ' to start the emulator program with a given Android
49 | Virtual Device (a.k.a. AVD), where must correspond to the name
50 | of one of the existing AVDs available on your host machine.
51 | See -help-virtual-device to learn how to create/list/manage AVDs.
52 | As a special convenience, using '@' is equivalent to using
53 | '-avd '.
54 |
55 | 跟着提示继续走,输入命令:
56 |
57 | emulator -help-virtual-device
58 |
59 | 又是提示了:
60 |
61 | An Android Virtual Device (AVD) models a single virtual
62 | device running the Android platform that has, at least, its own
63 | kernel, system image and data partition.
64 | Only one emulator process can run a given AVD at a time, but
65 | you can create several AVDs and run them concurrently.
66 | You can invoke a given AVD at startup using either '-avd '
67 | or '@', both forms being equivalent. For example, to launch
68 | the AVD named 'foo', type:
69 | emulator @foo
70 | The 'android' helper tool can be used to manage virtual devices.
71 | For example:
72 | android create avd -n -t 1 # creates a new virtual device.
73 | android list avd # list all virtual devices available.
74 | Try 'android --help' for more commands.
75 | Each AVD really corresponds to a content directory which stores
76 | persistent and writable disk images as well as configuration files.
77 | Each AVD must be created against an existing SDK platform or add-on.
78 | For more information on this topic, see -help-sdk-images.
79 | SPECIAL NOTE: in the case where you are *not* using the emulator
80 | with the Android SDK, but with the Android build system, you will
81 | need to define the ANDROID_PRODUCT_OUT variable in your environment.
82 | See -help-build-images for the details.
83 |
84 | 说实在的,这提示看着很郁闷,让你跳来跳去,就是不能解决问题。
85 |
86 | 直接创建avd吧,先看下说明:
87 |
88 | Usage:
89 | android [global options] create avd [action options]
90 | Global options:
91 | -h --help : Help on a specific command.
92 | -v --verbose : Verbose mode, shows errors, warnings and all messages.
93 | -s --silent : Silent mode, shows errors only.
94 | Action "create avd":
95 | Creates a new Android Virtual Device.
96 | Options:
97 | -c --sdcard : Path to a shared SD card image, or size of a new sdcard for
98 | the new AVD.
99 | -n --name : Name of the new AVD. [required]
100 | -a --snapshot: Place a snapshots file in the AVD, to enable persistence.
101 | -p --path : Directory where the new AVD will be created.
102 | -f --force : Forces creation (overwrites an existing AVD)
103 | -s --skin : Skin for the new AVD.
104 | -t --target : Target ID of the new AVD. [required]
105 | -b --abi : The ABI to use for the AVD. The default is to auto-select the
106 | ABI if the platform has only one ABI for its system images.
107 |
108 | 看明白了吧?
109 |
110 | android create avd -n test2 -f -p /home/thonatos/test -t 1
111 |
112 | 然后会有提示:
113 |
114 | Auto-selecting single ABI armeabi-v7a
115 | Android 4.0.3 is a basic Android platform.
116 | Do you wish to create a custom hardware profile [no]no
117 | Created AVD 'test2' based on Android 4.0.3, ARM (armeabi-v7a) processor,
118 | with the following hardware config:
119 | hw.lcd.density=240
120 | vm.heapSize=48
121 | hw.ramSize=512
122 |
123 | 创建好了,不过你的模拟器估计一运行就出错吧。(我故意滴。。。别怪我。。)
124 |
125 | 切换到刚才创建模拟器的目录,然后看看有什么东东,打开config.ini
126 |
127 | hw.lcd.density=240
128 | skin.name=WVGA800
129 | skin.path=platforms/android-15/skins/WVGA800
130 | hw.cpu.arch=arm
131 | abi.type=armeabi-v7a
132 | hw.cpu.model=cortex-a8
133 | vm.heapSize=48
134 | hw.ramSize=512
135 | image.sysdir.1=system-images/android-15/armeabi-v7a/
136 |
137 | 知道该做什么了吧?改吧,把相关的目录改成你自己的,然后再执行一下
138 |
139 | emulator @test2
140 |
141 | 怎么样!是不是已经运行啦?呵呵,恭喜哈!
142 |
143 | 本说明到此为止,同学们,好好学习哈,其实很简单,主要就是一种思路而已,加油吧
--------------------------------------------------------------------------------
/other-notes/android-notes/Show-ChinaTelecom-in-Chinese-On-D2G.md:
--------------------------------------------------------------------------------
1 | > * title: D2G中国电信中文显示
2 | > * date: 2011-07-21 19:45:10
3 |
4 | 今天又兄弟问道如何能够使我们的机器显示中国电信,这里我做下说明。
5 | 主要修改的文件就是framework-res.apk
6 |
7 | #### 准备工作:
8 |
9 | 一,安装java环境,这里我就不多说了,去百度一下。
10 |
11 | 二,下载工具包,android-apktool
12 |
13 | http://code.google.com/p/android-apktool/
14 |
15 | 下载apktool-1.0.0.tar.bz2 和apktool-install-windows-2.1_r01-1.zip
16 |
17 | 解压apktool.jar 到 C:/Windows文件夹下
18 |
19 | 解压apktool-install-windows.zip到任意文件夹
20 |
21 | 开始-运行-输入CMD回车,用cd命令转到刚刚解压apktool-install-windows所在的文件夹,输入
22 |
23 | apktool
24 |
25 | 出现一些命令说明即成功安装。
26 |
27 | #### 修改过程:
28 |
29 | 一,首先提取你的framework-res.apk(记得备份一下,电脑上用到的有两处)
30 |
31 | 二,在解压后的apktool目录下(cmd下cd命令切换....)
32 |
33 | apktool d framework-res.apk framework #反编译 framework-res.apk 到文件夹framework
34 |
35 | 三,切换到framework目录下找到eri.xml文件,然后修改其中的China Telecom(全部替换好了,在刚开始的地方,总共三处)
36 |
37 | 四,重建文件。
38 |
39 | apktool b framework framework.apk 编译 文件夹framework 到文件framework.apk
40 |
41 | 并将其中的eri.xml提取出来,备用。
42 |
43 | 五,现在打开你的备份文件,(之前让备份了的那个),用winrar打卡,然后找到eri.xml,将刚才从重新编译的framework.apk中提取的那个eri.xml直接拖进去。选择为存储哦。
44 |
45 | 六,现在就是很简单也很容易忘记的地方了,不知多少人变砖就是因为这个。。。。。。
46 |
47 | 将framework.apk放进内存卡根目录并更名为framework-res.apk
48 |
49 | 先复制到system目录并修改权限,为:
50 |
51 | xx-
52 |
53 | x--
54 |
55 | x--
56 |
57 | 然后选择移动到framework目录覆盖已有文件。(记得先在root文件浏览器上面选择为读写模式)
58 |
59 | 好了,重启吧,现在电信卡应该可以显示“中国电信”字样了。
--------------------------------------------------------------------------------
/other-notes/gyro-hack-in-iframe.md:
--------------------------------------------------------------------------------
1 | # # gyro hack in iframe
2 |
3 | > If you use the gyro plugin in an iframe, it can only work if the domain of the main window is the same domain as the iframe. This is a (security) limitation of the browser.
4 |
5 | ## #solution
6 |
7 | get gyro information in the main window & post it to the child iframe.
8 |
9 | - iframe
10 | - postMessage
11 | - JSON
12 |
13 | 在主窗体获取传感器信息,并使用postMessage传递信息到iframe子页面,测试中发现postMessage需要的信息为字符串,所有先做一次JSON.stringify,在子页面做一次JSON.parse即可。
14 |
15 | ## #code
16 |
17 | ```
18 | //main window
19 |
20 | if (window.DeviceOrientationEvent) {
21 |
22 | var iframe_embed_hack = {
23 | enabled: true
24 | };
25 |
26 | function onUpdate(){
27 | document.getElementById('child').contentWindow.postMessage(JSON.stringify(iframe_embed_hack),"*");
28 | }
29 |
30 | function onScreenOrientationChangeEvent(){
31 | iframe_embed_hack.screenOrientation = window.orientation || 0;
32 | }
33 |
34 | function onDeviceOrientationChangeEvent(event){
35 | iframe_embed_hack.deviceOrientation = event;
36 | onUpdate();
37 | }
38 |
39 | window.addEventListener('orientationchange', onScreenOrientationChangeEvent, false);
40 | window.addEventListener('deviceorientation', onDeviceOrientationChangeEvent, false);
41 |
42 | }
43 | ```
44 |
45 | ```
46 | //the child iframe
47 | function messageHandler(data){
48 | window.iframe_embed_hack = data;
49 | }
50 |
51 | window.addEventListener("message", function(ev) {
52 | messageHandler(JSON.parse(ev.data));
53 | }, false );
54 | ```
--------------------------------------------------------------------------------
/other-notes/idl/Convert-To-Envi.md:
--------------------------------------------------------------------------------
1 | Convert To Envi
2 |
3 | 通过IDL批量将移动平滑后的txt数据文件转换Envi标准文件。
4 |
5 | #### Script
6 |
7 | pro port
8 |
9 | ;File array to deal
10 | files=["n1-1","n1-2","n1-3","n1-7","n2-1","n2-11","n2-2","n2-3","n2-5","n2-8","n4-1","n4-10","n4-11","n4-12","n4-2","n4-3","n4-4","n4-5","n4-6","n4-7","n4-8","n4-9","n5-1","n5-10","n5-11","n5-12","n5-2","n5-3","n5-4","n5-5","n5-6","n5-7","n5-8","n5-9"]
11 |
12 | currentDir = "X:\data\SmoothedText\"
13 | currentDes = "X:\data\SmoothedEnvi\"
14 |
15 | for f=0,33 do begin
16 |
17 | ;Define Vars
18 | currentName = files[f]
19 | currentFileData = currentDir+currentName+".tif.smoothed.txt"
20 | currentFileInfo = currentDir+currentName+".tif.info.txt"
21 | currentFileDest = currentDes+currentName
22 | currentFileHead = currentDes+currentName+".hdr"
23 | print,"Deal File: "+currentFileData
24 |
25 | ;Read file info
26 | print,"Read File Info: "+currentFileInfo
27 | info=fltarr(3)
28 | openr,lun0,currentFileInfo,/get_lun
29 | readf,lun0,info
30 | free_lun,lun0
31 | print,"Show File Info:",info
32 |
33 | ;Assign value to x,y,z
34 | x=long(info[1])
35 | y=long(info[0])
36 | z=long(info[2])
37 | sum=long(x*y)
38 | print,"X,Y,Z,Sum:",x,y,z,sum
39 |
40 | ;Read input text
41 | data=fltarr(sum,520)
42 | openr,lun1,currentFileData,/get_lun
43 | readf,lun1,data
44 | free_lun,lun1
45 |
46 | ;Port file to envi
47 | band=fltarr(x,y,520)
48 | for i=0,519 do begin
49 | print,"Reform Band:",i
50 | band[*,*,i]=reform(data[*,i],x,y)
51 | endfor
52 |
53 | band_1=transpose(band,[1,0,2])
54 | openw,lun2,currentFileDest,/get_lun
55 | writeu,lun2,band_1
56 | free_lun,lun2
57 |
58 | ;Write *.hdr
59 | openw,lun3,currentFileHead,/get_lun
60 | printf,lun3,"ENVI"
61 | printf,lun3,"description = {"
62 | printf,lun3," File Imported into ENVI.}"
63 | printf,lun3,"samples = "+string(x)
64 | printf,lun3,"lines = "+string(y)
65 | printf,lun3,"bands = "+string(z)
66 | printf,lun3,"header offset = 0"
67 | printf,lun3,"file type = ENVI Standard"
68 | printf,lun3,"data type = 4"
69 | printf,lun3,"interleave = bsq"
70 | printf,lun3,"sensor type = Unknown"
71 | printf,lun3,"byte order = 0"
72 | printf,lun3,"wavelength units = Unknown"
73 | free_lun,lun3
74 |
75 | ;Clear Vars
76 | delvar,info,x,y,z,sum,data,band,band_1
77 |
78 | endfor
79 |
80 | print,"All Done."
81 |
82 | end
83 |
--------------------------------------------------------------------------------
/other-notes/idl/Convert-To-Tiff.md:
--------------------------------------------------------------------------------
1 | Convert To Tiff
2 |
3 | 通过IDL+Envi批量转换Envi标准文件为Tif格式。
4 |
5 | #### Script
6 |
7 | pro converttif
8 |
9 | ;Workspace dir
10 | currentDir = "Y:\Thonatos.Yang\data\FlatField\"
11 | currentDes = "Y:\Thonatos.Yang\data\TiffStd\"
12 |
13 | ;File array to deal
14 | files=["n1-1","n1-2","n1-3","n1-7","n2-1","n2-11","n2-2","n2-3","n2-5","n2-8","n4-1","n4-10","n4-11","n4-12","n4-2","n4-3","n4-4","n4-5","n4-6","n4-7","n4-8","n4-9","n5-1","n5-10","n5-11","n5-12","n5-2","n5-3","n5-4","n5-5","n5-6","n5-7","n5-8","n5-9"]
15 | filesSize = 33
16 |
17 | ;working on 5
18 | for f=5,filesSize do begin
19 |
20 | currentName = files[f]
21 | currentFileOrgn = currentDir+currentName
22 | currentFileDest = currentDes+currentName+".tif"
23 |
24 | print,"Compelte:" + string(f+1) + " in " + string(filesSize+1)
25 | print,"Deal File: "+currentFileOrgn
26 |
27 | ;获取待存储的文件fid
28 | envi_open_file,currentFileOrgn,r_fid = fid
29 |
30 | ;获取文件相关信息
31 | envi_file_query,fid,dims = dims,nb = nb
32 |
33 | ;调用函数输出为tiff文件
34 | ENVI_OUTPUT_TO_EXTERNAL_FORMAT, dims = dims,pos = lindgen(nb),out_name = currentFileDest,/tiff,fid = fid
35 |
36 | ;删除原文件
37 | envi_file_mng,id = fid,/remove
38 |
39 | endfor
40 |
41 | print,"All Completed."
42 |
43 | end
44 |
45 |
--------------------------------------------------------------------------------
/other-notes/matlab/Moving-Mean-Smooth.md:
--------------------------------------------------------------------------------
1 | Moving Mean Smooth
2 |
3 | 使用Matlab通过移动平均对Tiff数据进行批量平滑处理。
4 |
5 | #### Script
6 |
7 | % Clear Workspace Var
8 | clear;
9 | clc;
10 |
11 | % Read Tiff Dir & Save file name to
12 | tiffDir = 'Y:\Thonatos.Yang\data\TiffStd\';
13 | smoothedDir = 'Y:\Thonatos.Yang\data\Smoothed\';
14 | tiffFileArray = dir(tiffDir);
15 |
16 | for f = 6:length(tiffFileArray)
17 |
18 | currentTiffFile = strcat(tiffDir,tiffFileArray(f).name);
19 | currentSmoothed = strcat(smoothedDir,tiffFileArray(f).name);
20 | fprintf('Processing : %s\n',currentTiffFile);
21 |
22 | % Read Fiff file
23 | originalTiff = imread(currentTiffFile);
24 |
25 | % Size of Tiff array
26 | [Tx,Ty,Tz] = size(originalTiff);
27 |
28 | % Calc Piexls for each wavelength
29 | pixels = Tx*Ty;
30 |
31 | % Save Tiff file info to text;
32 | dlmwrite(strcat(currentSmoothed,'.info.txt'),[Tx,Ty,Tz],'delimiter', '\t');
33 |
34 | % Reshape Array
35 | for k = 1:520;
36 | fprintf('\tReshaping Band: %d\n',k);
37 | reshapedTiff(k,:) = reshape(originalTiff(:,:,k),1,pixels);
38 | end
39 |
40 | % Smooth data
41 | for i = 1:520 % number of wavelength
42 | fprintf('\tSmoothing Band : %d\n',i);
43 | for j = 1:size(reshapedTiff,2) % number of sampling
44 | if i<=3
45 | smoothedTiff(i,j) = mean(reshapedTiff(i:(i+2),j));
46 | elseif i>3 & i<=250
47 | smoothedTiff(i,j) = mean(reshapedTiff((i-2):(i+2),j));
48 | elseif i>250 & i<=300
49 | smoothedTiff(i,j) = reshapedTiff(i,j);
50 | elseif i>300 & i<=516
51 | smoothedTiff(i,j) = mean(reshapedTiff((i-4):(i+4),j));
52 | else
53 | smoothedTiff(i,j) = mean(reshapedTiff((i-4):i,j));
54 | end
55 | end
56 | end
57 |
58 |
59 | % Save Result to text
60 | dlmwrite(strcat(currentSmoothed,'.smoothed.txt'),smoothedTiff,'delimiter', '\t');
61 |
62 | % Calc Average Value Of Each Band ,Save Average Value to csv
63 | % csvwrite(strcat(currentSmoothed,'.average.csv'),mean(smoothedTiff,2)');
64 |
65 | % Show Proress
66 | fprintf('Processed %s : %s\n\n',strcat(num2str((f-2)/(length(tiffFileArray)-2)),'%'),currentTiffFile);
67 |
68 | % Cat Matrix
69 | % if f<4
70 | % sum = mean(smoothedTiff,2)';
71 | % else
72 | % tmp = sum;
73 | % clear sum;
74 | % sum = [tmp;mean(smoothedTiff,2)'];
75 | % end
76 |
77 | % Clear Var
78 | clearvars -except tiffDir tiffFileArray smoothedDir f; %sum;
79 | end
80 |
81 | % Save Sum Value to csv
82 | % csvwrite(strcat(smoothedDir,'average.cat.csv'),sum);
83 |
84 | fprintf('All Processed');
--------------------------------------------------------------------------------