Skip to content

Commit 2a9ac2d

Browse files
author
xiaobeicn
committed
init
0 parents  commit 2a9ac2d

40 files changed

+6095
-0
lines changed

LICENSE

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 宋小北
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

README.md

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
## 编程技巧汇总 :books:
2+
===
3+
4+
为了方便快速编写代码,创建了这个公开库。旨在提高编写效率和编写质量,避免多次google一样的代码。这是一个在线公开笔记,也是一个提高自己能力的文档,会收集大量优秀的代码片段。
5+
6+
#### 贡献方式:
7+
8+
* [`fork`](https://github.com/xiaobeicn/programming-skills-summary/fork) 项目,然后推送给我
9+
* 创建 [`issues`](https://github.com/xiaobeicn/programming-skills-summary/issues/new) ,我会及时处理
10+
11+
#### 贡献要求
12+
13+
* 在对应文件夹内创建单独文件(推荐)或在文件夹内对应文件直接扩充
14+
* 文件内容不宜过大,最好控制在百行以内
15+
* 如果是多个片段一个归属类,最好只创建一个文件
16+
* 代码质量要高,可以是自己代码的提炼,也可以是开源优秀代码段(注明来源)
17+
* `pull` 的时候必须写好 `commit`,并且检查好代码的格式与缩进
18+
* 不满足以上条件不予 *通过*
19+
20+
### 列表状态
21+
22+
- [x] [api](https://github.com/xiaobeicn/programming-skills-summary/tree/master/api)
23+
- [x] [git](https://github.com/xiaobeicn/programming-skills-summary/tree/master/git)
24+
- [x] [html-css](https://github.com/xiaobeicn/programming-skills-summary/tree/master/html-css)
25+
- [x] [js](https://github.com/xiaobeicn/programming-skills-summary/tree/master/js)
26+
- [x] [markdown](https://github.com/xiaobeicn/programming-skills-summary/tree/master/markdown)
27+
- [x] [mysql](https://github.com/xiaobeicn/programming-skills-summary/tree/master/mysql)
28+
- [x] [nosql](https://github.com/xiaobeicn/programming-skills-summary/tree/master/nosql)
29+
- [x] [PHP](https://github.com/xiaobeicn/programming-skills-summary/tree/master/php)
30+
- [x] [server](https://github.com/xiaobeicn/programming-skills-summary/tree/master/server)
31+
- [x] [open-source](https://github.com/xiaobeicn/programming-skills-summary/tree/master/open-source)
32+
- [x] [python](https://github.com/xiaobeicn/programming-skills-summary/tree/master/python)
33+
- [ ] other
34+
35+
### 贡献者(排名不分先后)
36+
| 贡献者 | 贡献目录| Github |
37+
| -------- | :-----: | :----: |
38+
| xiaobeicn | all | https://github.com/xiaobeicn |
39+
| overtrue | php | https://github.com/overtrue |
40+
| Lin-H | js | https://github.com/Lin-H |
41+
| feilengcui | php | https://github.com/feilengcui |
42+
| joshle | php | https://github.com/joshle |
43+
| itsmikej | php | https://github.com/itsmikej |
44+
| lifesign | laravel | https://github.com/lifesign |
45+
| lovecn | php/js/python | https://github.com/lovecn |
46+
| ... | ... | ... |
47+
48+
#### 开源协议
49+
基于 [MIT License](https://github.com/xiaobeicn/programming-skills-summary/blob/master/LICENSE) 开源,使用代码只需说明来源即可。
50+
部分源码来源网络收集,如果不希望我们展示或者侵权的地方联系我 <[email protected]> ,我会及时处理。

amuse.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
*
3+
*    ┏┓   ┏┓
4+
*   ┏┛┻━━━┛┻┓
5+
*   ┃       ┃
6+
*   ┃   ━   ┃
7+
*   ┃ ┳┛ ┗┳ ┃
8+
*   ┃       ┃
9+
*   ┃   ┻   ┃
10+
*   ┃       ┃
11+
*   ┗━┓   ┏━┛Code is far away from bug with the animal protecting
12+
*     ┃   ┃ 神兽保佑,代码无bug
13+
*     ┃   ┃
14+
*     ┃   ┗━━━┓
15+
*     ┃      ┣┓
16+
*     ┃     ┏┛
17+
*     ┗┓┓┏━┳┓┏┛
18+
*      ┃┫┫ ┃┫┫
19+
*      ┗┻┛ ┗┻┛
20+
*
21+
*/

api/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
### 让RESTful Web services更实用的10个技巧
2+
* 不要寻找一个官方的“REST 标准”
3+
* 还是坚持一些标准
4+
* 确保你的文档是完美无瑕疵的
5+
* 提供 JSON 输出
6+
* 不要漏掉 XML
7+
* 理解 HTTP 动词
8+
* 理解 URI 路由的重要性
9+
* 在版本管理下进行更新维护
10+
* 与你的用户保持联系
11+
* 提供示例代码
12+
13+
> via:[link](http://www.huahuaxia.net/cs-research/restful-api-resource-naming/)
14+
----

api/github.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
### github api
2+
* 获取用户项目的json数据 [github api owner](https://api.github.com/users/xiaobeicn/repos?type=owner)
3+
* 获取现有的api https://api.github.com
4+
5+
```json
6+
{
7+
"current_user_url": "https://api.github.com/user",
8+
"authorizations_url": "https://api.github.com/authorizations",
9+
"code_search_url": "https://api.github.com/search/code?q={query}{&page,per_page,sort,order}",
10+
"emails_url": "https://api.github.com/user/emails",
11+
"emojis_url": "https://api.github.com/emojis",
12+
"events_url": "https://api.github.com/events",
13+
"feeds_url": "https://api.github.com/feeds",
14+
"following_url": "https://api.github.com/user/following{/target}",
15+
"gists_url": "https://api.github.com/gists{/gist_id}",
16+
"hub_url": "https://api.github.com/hub",
17+
"issue_search_url": "https://api.github.com/search/issues?q={query}{&page,per_page,sort,order}",
18+
"issues_url": "https://api.github.com/issues",
19+
"keys_url": "https://api.github.com/user/keys",
20+
"notifications_url": "https://api.github.com/notifications",
21+
"organization_repositories_url": "https://api.github.com/orgs/{org}/repos{?type,page,per_page,sort}",
22+
"organization_url": "https://api.github.com/orgs/{org}",
23+
"public_gists_url": "https://api.github.com/gists/public",
24+
"rate_limit_url": "https://api.github.com/rate_limit",
25+
"repository_url": "https://api.github.com/repos/{owner}/{repo}",
26+
"repository_search_url": "https://api.github.com/search/repositories?q={query}{&page,per_page,sort,order}",
27+
"current_user_repositories_url": "https://api.github.com/user/repos{?type,page,per_page,sort}",
28+
"starred_url": "https://api.github.com/user/starred{/owner}{/repo}",
29+
"starred_gists_url": "https://api.github.com/gists/starred",
30+
"team_url": "https://api.github.com/teams",
31+
"user_url": "https://api.github.com/users/{user}",
32+
"user_organizations_url": "https://api.github.com/user/orgs",
33+
"user_repositories_url": "https://api.github.com/users/{user}/repos{?type,page,per_page,sort}",
34+
"user_search_url": "https://api.github.com/search/users?q={query}{&page,per_page,sort,order}"
35+
}
36+
```

git/README.md

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
### git工作流
2+
https://github.com/xirong/my-git/blob/master/git-workflow-tutorial.md
3+
4+
### 让你们clone laravel更快(by [overtrue](https://github.com/overtrue)
5+
我们通常在克隆github上的项目时做法如下:
6+
7+
```git
8+
git clone [email protected]:laravel/laravel.git
9+
```
10+
11+
你会发现各种慢(如果该项目历史比较悠久,也就是说有很多commits),那么其实你clone的时候是把历史也拉下来。可是我们需要这些东西吗?不需要,那么就加一个选项吧:
12+
13+
```git
14+
git clone [email protected]:laravel/laravel.git --depth=1
15+
```
16+
17+
--depth=1 是指只拉取最后一次的提交结果。
18+
19+
----
20+
21+
### 开发者私人信息保密方法
22+
实际开发中(类似邮件功能)需要开发者私人密码的文件,可以采用以下方法进行隐私保护。请在命令行中使用。
23+
24+
```git
25+
// 假设文件无改动,作用于版本库中已存在的文件。
26+
// 此方法将确保本地文件不提交,并且版本库中此文件的变更无法影响本地文件。
27+
git update-index --assume-unchanged app/config/mail.php
28+
// 取消并恢复为普通文件
29+
git update-index --no-assume-unchanged app/config/mail.php
30+
```
31+
32+
----
33+
34+
### 设置全局代理(来自网络)
35+
36+
```git
37+
git config --global https.proxy https://user:password@address:port
38+
```
39+
40+
### clone某个特定分支
41+
42+
```git
43+
mkdir $BRANCH
44+
cd $BRANCH
45+
git init
46+
git remote add -t $BRANCH -f origin $REMOTE_REPO
47+
git checkout $BRANCH
48+
```
49+
50+
### 比较某个文件和远程分支上的区别
51+
52+
```git
53+
git diff localbranch remotebranch filepath
54+
```
55+
56+
### 在版本库所有版本中搜寻一条字符串
57+
58+
```git
59+
git rev-list --all | (
60+
while read revision; do
61+
git grep -F 'Your search string' $revision
62+
done
63+
)
64+
```
65+
66+
### 向分支提交一个初始的空commit,保证完全复位
67+
68+
```git
69+
1.创建一个新的空分支,例如:newroot
70+
71+
git checkout --orphan newroot
72+
git rm --cached -r .
73+
git clean -f -d
74+
2.创建空的commit
75+
76+
git commit --allow-empty -m '[empty] initial commit'
77+
3.重新发送分支的全部内容
78+
79+
git rebase --onto newroot --root master
80+
4.删除临时分支newroot
81+
82+
git branch -d newroot
83+
现在master就已经包含了一个空的root commit了。
84+
```
85+
86+
### 如何修改一个特定的commit
87+
88+
```git
89+
当你想在推送前重做你最后的commit时,可以使用修改命令(git commit --amend)。如果你想修改的不是最后一个commit呢?
90+
91+
这种情况下,你可以使用git rebase,例如,你想要修改bbc643cd commit,运行下面的命令:
92+
93+
$git rebase bbc643cd^ --interactive
94+
在默认的编辑器中选择并修改你期望修改的,然后保存修改并输入:
95+
96+
$ git add
97+
<
98+
filepattern
99+
>
100+
101+
现在你就可以使用
102+
103+
$git commit --amend
104+
来修改commit,之后使用
105+
106+
$ git rebase --continue
107+
返回之前最新的commit。
108+
```
109+
110+
### 密钥登录
111+
* 生成密钥
112+
> ssh-keygen -t rsa -C "[email protected]"
113+
* 上传服务器
114+
> ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]
115+
116+
### git 给远程库 添加多个url地址
117+
118+
* 第一个地址 git remote add origin <url1>
119+
* 第二个地址 git remote set-url --add origin <url2>
120+
* 第三个地址 git remote set-url --add origin <url3>
121+
122+
> 注意:使用git push origin master时,你可以push到origin的多个url地址。但是使用 git pull时,只能拉取origin里的一个url地址,这个fetch-url默认为 你添加的到origin的第一个地址

git/github.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
### 通过Web界面创建文件夹
2+
由"/"结束创建新文件夹。或者指定文件扩展名,点击提交文件也可创建新文件夹
3+
4+
### 使用Git URL短地址
5+
使用Github的Git.io。Git.io将会缩短你的项目地址连接。也可以使用gitio命令,Git.io的命令行接口来缩短地址。
6+
7+
### 文件查找
8+
处理新建文件,你还可以在任何存储库快速浏览这些文件。该功能不是太明显,需要快捷方式,在键盘上按"T"激活文件查找功能。在按上下键上下查找。当然,也可以输入文件名称来选择特定的文件 。
9+
10+
### 连接
11+
有时候我们需要在自己的文件项目中分享或者输出特殊行。Github可以实现,我们只需要添加"#L "放在URL行号后面
12+
13+
### 任务清单
14+
15+
Github 扩展了markdown来满足自己的需要,现在你可以在Github上添加一个复选框列表,使用 - [ ] or - [x]来表示一个检查项目。请注意,复选框只会出现在列表项中。"[ ]"必须以"‐"开始。下面有一盒例子:
16+
17+
- [x] create a post.
18+
- [x] create a page.
19+
- [x] add images.
20+
- [ ] published the post.
21+
22+
----
23+
24+
25+
26+
27+
28+
29+

git/ssh.md

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
2+
### Checking for existing SSH keys
3+
4+
```shell
5+
ls -al ~/.ssh
6+
# Lists the files in your .ssh directory, if they exist
7+
```
8+
9+
### Generating a new SSH key
10+
11+
```shell
12+
ssh-keygen -t rsa -b 4096 -C "[email protected]" -f ~/.ssh/id_rsa_[custom file name]
13+
```
14+
15+
### Adding your SSH key to the ssh-agent
16+
17+
* Start the ssh-agent in the background.
18+
```shell
19+
eval "$(ssh-agent -s)"
20+
### Agent pid 59566
21+
```
22+
* modify your ~/.ssh/config file
23+
```shell
24+
# gitHub user Self
25+
Host github.com
26+
User xiaobeicn
27+
AddKeysToAgent yes
28+
UseKeychain yes
29+
IdentityFile ~/.ssh/id_rsa_github
30+
31+
# gitlab user
32+
Host gitlab.com
33+
User xiaobeicn
34+
AddKeysToAgent yes
35+
UseKeychain yes
36+
IdentityFile ~/.ssh/id_rsa_gitlab
37+
```
38+
* Add your SSH private key to the ssh-agent and store your passphrase in the keychain.
39+
```shell
40+
ssh-add -K ~/.ssh/id_rsa
41+
```
42+
43+
44+
45+
46+
47+

html-css/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
### 建议
2+
* 用 firebug 或 console
3+
* 用 CSS animation 取代 Javascript
4+
* 不修改 image width & height attribute
5+
* 使用 max width and height 调整 image 比例
6+
* 善用 :before and :after
7+
* 減少 CSS 程式码

0 commit comments

Comments
 (0)