-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
853 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,3 +126,5 @@ golang/pkg/ | |
golang/bin/ | ||
golang/src/github.com/ | ||
golang/src/gopkg.in/ | ||
|
||
site/ |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env python | ||
# -*- coding:utf-8 -*- | ||
# Author: wxnacy([email protected]) | ||
# Description: | ||
import os | ||
|
||
|
||
def read_file(filename): | ||
'''读取文件,并返回列表''' | ||
with open(filename, 'r') as f: | ||
return [o.strip('\n').strip(" ") for o in f.readlines()] | ||
|
||
def read_cmd(filename): | ||
''' | ||
读取指令文件 | ||
''' | ||
lines = read_file(filename) | ||
lines = list(filter(lambda x: x, lines)) | ||
items = [] | ||
num = int(len(lines) / 2) | ||
# 设置 icon | ||
# 查找是否存在如下对应文件 | ||
# ./commands/cmd_{category} | ||
# ./icon/{category}.png | ||
cmd_name = os.path.basename(filename).split("_")[1] | ||
icon = './icon.png' | ||
cmd_icon_path = './icon/{}.png'.format(cmd_name) | ||
if os.path.exists(cmd_icon_path): | ||
icon = cmd_icon_path | ||
for i in range(num): | ||
item = dict( | ||
title = lines[i * 2 + 1], | ||
subtitle = lines[i * 2], | ||
icon = icon, | ||
valid = True, | ||
) | ||
item['arg'] = item['title'] | ||
items.append(item) | ||
return items | ||
|
||
# def read_json(filename): | ||
# lines = [] | ||
# with open(filename, 'r') as f: | ||
# lines = f.readlines() | ||
# return json.loads(''.join(lines)) | ||
|
||
# def read_csv(filename): | ||
# lines = [] | ||
# with open(filename, 'r') as f: | ||
# lines = f.readlines() | ||
# logging.info(lines) | ||
# items = [] | ||
# for line in lines: | ||
# ls = line.split(',') | ||
# item = dict(title = ls[0].strip(" "), subtitle = ls[1].strip(" ")) | ||
# items.append(item) | ||
# return items |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!/usr/bin/env python | ||
# -*- coding:utf-8 -*- | ||
# Author: wxnacy([email protected]) | ||
# Description: | ||
|
||
import os | ||
import shutil | ||
from common import read_cmd | ||
|
||
|
||
YML = ''' | ||
site_name: 常用命令 # 站点名称 | ||
nav: # 文档目录 | ||
- 首页: index.md | ||
{} | ||
theme: readthedocs # 主题 | ||
''' | ||
|
||
SOURCE_DIR = 'commands' | ||
OUTPUT_DIR = 'docs' | ||
|
||
def cmd2md(filename): | ||
filepath = f'{SOURCE_DIR}/{filename}' | ||
outfile = f'{OUTPUT_DIR}/{fmt_name(filename)}.md' | ||
input_lines = read_cmd(filepath) | ||
outlines = [] | ||
input_lines.sort(key = lambda x: x['title']) | ||
title_key = set() | ||
for line in input_lines: | ||
title = line['subtitle'] | ||
cmd = line['title'] | ||
cmd_begin = ' '.join(cmd.split(" ")[:2]) | ||
if cmd_begin not in title_key: | ||
title_key.add(cmd_begin) | ||
outlines.append(f"## {cmd_begin}\n") | ||
|
||
title = f'**{title[2:]}**\n' | ||
cmd = f'```\n{cmd}\n```\n' | ||
|
||
outlines.append(title) | ||
outlines.append(cmd) | ||
with open(outfile, 'w') as out: | ||
out.writelines(outlines) | ||
|
||
def fmt_name(name): | ||
return name[4:] | ||
|
||
def first_upper(name): | ||
return name[0].upper() + name[1:] | ||
|
||
def cmd2mdname(name): | ||
return fmt_name(name) + '.md' | ||
|
||
def main(dirname): | ||
'''转换''' | ||
files = os.listdir(dirname) | ||
files.sort() | ||
navs = [] | ||
for f in files: | ||
if not f.startswith('cmd_'): | ||
continue | ||
cmd2md(f) | ||
navs.append(f'- {first_upper(fmt_name(f))}: {fmt_name(f)}.md') | ||
|
||
# shutil.move(f'{OUTPUT_DIR}/{cmd2mdname(files[0])}', f'{OUTPUT_DIR}/index.md') | ||
nav = '\n '.join(navs) | ||
# nav = nav.replace(cmd2mdname(files[0]), 'index.md') | ||
yml = YML.format(nav) | ||
with open('mkdocs.yml', 'w') as f: | ||
f.write(yml) | ||
|
||
|
||
|
||
|
||
|
||
|
||
if __name__ == "__main__": | ||
main(SOURCE_DIR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env bash | ||
# Author: wxnacy([email protected]) | ||
# Description: | ||
|
||
python convert.py | ||
|
||
for file in `find site | grep '\.'` | ||
do | ||
outfile=`python -c "print('${file}'.replace('site/', ''))"` | ||
ossutil cp -u $file oss://cmd-cn/${outfile} | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
## docker --version | ||
**查看版本** | ||
``` | ||
docker --version | ||
``` | ||
## docker build | ||
**在当前目录创建镜像** | ||
``` | ||
docker build -t <image-name> . | ||
``` | ||
## docker container | ||
**重启容器** | ||
``` | ||
docker container restart <continer-name> | ||
``` | ||
## docker exec | ||
**在交互模式下进入容器,并进入 bash 环境** | ||
``` | ||
docker exec -it <continer-name> /bin/bash | ||
``` | ||
## docker image | ||
**查看镜像列表** | ||
``` | ||
docker image ls | ||
``` | ||
## docker info | ||
**查看 docker 详情** | ||
``` | ||
docker info | ||
``` | ||
## docker logs | ||
**从最后 10 行开始实时查看日志** | ||
``` | ||
docker logs -f --tail 10 <continer-name> | ||
``` | ||
**从最后 10 行开始实时查看日志并过滤信息** | ||
``` | ||
docker logs -f --tail 10 <continer-name> 2>&1 | grep <pattern> | ||
``` | ||
## docker ps | ||
**查看当前运行的进程列表** | ||
``` | ||
docker ps | ||
``` | ||
**查看所有进程列表** | ||
``` | ||
docker ps -a | ||
``` | ||
## docker restart | ||
**重启所有服务** | ||
``` | ||
docker restart `docker ps -a | awk '{print $1}'` | ||
``` | ||
## docker version | ||
**分别查看 client 和 server 的版本** | ||
``` | ||
docker version | ||
``` | ||
## docker-compose up | ||
**重新创建容器,并在后台运行** | ||
``` | ||
docker-compose up --force-recreate -d <name> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
## ffmpeg -i | ||
**m3u8 转为 mp4** | ||
``` | ||
ffmpeg -i <m3u8-file> -bsf:a aac_adtstoasc -vcodec copy -c copy -crf 50 <mp4-file> | ||
``` | ||
## ffmpeg -ss | ||
**截取视频** | ||
``` | ||
ffmpeg -ss <start> -t <end> -i <sourcefile> -vcodec copy -acodec copy <outputfile> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
## git add | ||
**将所有新增、修改的文件提交到索引中** | ||
``` | ||
git add --ignore-removal . | ||
``` | ||
**将所有新增、修改、删除的文件提交到索引中** | ||
``` | ||
git add -A | ||
``` | ||
**将所有修改、删除的文件提交到索引中** | ||
``` | ||
git add -u | ||
``` | ||
**将所有新增、修改、删除的文件提交到索引中** | ||
``` | ||
git add . | ||
``` | ||
## git blame | ||
**查看文件每行的最后提交人和时间** | ||
``` | ||
git blame <file> | ||
``` | ||
**查看文件某个方法的最后提交人和时间** | ||
``` | ||
git blame <file> -L :<funcname> | ||
``` | ||
**查看文件行数范围内的最后提交人和时间** | ||
``` | ||
git blame <file> -L <start>,<end> | ||
``` | ||
## git branch | ||
**查看所有分支,并显示版本信息** | ||
``` | ||
git branch -v | ||
``` | ||
## git checkout | ||
**在本地创建远程分支** | ||
``` | ||
git checkout -b <local-branch-name> origin/<remote-branch-name> | ||
``` | ||
## git config | ||
**全局模式缓存凭证 15 分钟** | ||
``` | ||
git config --global credential.helper cache | ||
``` | ||
**全局模式储存仓库凭证** | ||
``` | ||
git config --global credential.helper store | ||
``` | ||
**全局配置 git 邮箱** | ||
``` | ||
git config --global user.email "[email protected]" | ||
``` | ||
**全局配置 git 用户名** | ||
``` | ||
git config --global user.name "your name" | ||
``` | ||
**储存当前仓库凭证** | ||
``` | ||
git config credential.helper store | ||
``` | ||
## git fetch | ||
**把远程分支拉到本地** | ||
``` | ||
git fetch origin <branch_name> | ||
``` | ||
## git init | ||
**初始化当前目录为仓库** | ||
``` | ||
git init | ||
``` | ||
**创建 <repo_name> 仓库** | ||
``` | ||
git init <repo_name> | ||
``` | ||
## git log | ||
**查看某人一段时间的提交记录,并显示详情** | ||
``` | ||
git log --stat --author=<pattern> --after=<date> --before=<date> | ||
``` | ||
## git merge | ||
**撤销所有合并操作** | ||
``` | ||
git merge --abort | ||
``` | ||
## git pull | ||
**拉取远程分支到本地** | ||
``` | ||
git pull origin <branch-name> | ||
``` | ||
**解决拉取项目到本地新仓库 fatal: refusing to merge unrelated histories 的问题** | ||
``` | ||
git pull origin master --allow-unrelated-histories | ||
``` |
Oops, something went wrong.