#273 获取 Shell Script 所在脚本
Linux Shell 2018-07-17CURRENT_PATH=$(dirname $(readlink -f "$0"))
coding in a complicated world
CURRENT_PATH=$(dirname $(readlink -f "$0"))
Pico (Pine composer) is a text editor for Unix and Unix-like computer systems. It is integrated with the Pine and Alpine email clients, which were initially designed by the Office of Computing and Communications at the University of Washington.
A clone of Pico called nano, which is part of the GNU Project, was developed because Pico's earlier license had unclear redistribution terms. Newer versions of Pico as part of Alpine are released under the Apache License version 2.0.
Nano 是由于 Pico 编辑器早期授权条款不够 free 而开发,是 GNU 计划的一部分。
Nano 是一个超级轻量级的文本编辑器,是每个 Linux 发行版的标配。
/usr/share/nano/json.nanorc)两个命令:nano,rnano(受限模式,参考 man 文档)
/etc/nanorc,/usr/share/nano/~/.nanorc,~/.nano/date
2018年 07月 03日 星期二 14:09:28 CST
# locale 格式
date +"%c"
2018年07月03日 星期二 14时09分22秒
# RFC3339 格式
date --rfc-3339=s
2018-07-03 14:09:48+08:00
# UTC 时间,ISO 8601 格式
date -u +"%Y-%m-%dT%H:%M:%SZ"
# yyyy-mm-dd hh:mm:ss,mm
date +'%Y-%m-%d %H:%M:%S,%3N'
2018-07-03 14:09:20,902
# 获取时间戳
date +%s
# 时间字符串转时间戳
date -d "2018-07-03 14:09:00" +%s
1530598140
date -d "2018-07-03 14:09:00" +%s --utc
1530626940
# 时间戳转时间字符串
date -d @1530598140
2018年 07月 03日 星期二 14:09:00 CST
date +'%Y-%m-%d %H:%M:%S' -d @1530598140
2018-07-03 14:09:00
# 获取一分钟前的时间
date --rfc-3339=s -d '1 min ago'
date --rfc-3339=s -d '1 minute ago'
date --rfc-3339=s -d '1 minutes ago'
# 获取一个小时前的时间
date --rfc-3339=s -d '1 hour ago'
我本来就想记录一下请求搜集服务的,结果扩大化,发现完全兜不住,好吧,就这样吧!
total 内存总数used 使用内存free 未使用内存shared Memory used (mostly) by tmpfs (Shmem in /proc/meminfo)buffers Memory used by kernel buffers (Buffers in /proc/meminfo)cached Memory used by the page cache and slabs (Cached and SReclaimable in /proc/meminfo)available 可用内存短信的通信协议从 2G 时代一直到现在基本没有什么变化。
所以,
^ ~ \ | { } [ ] € 需要算两个字符。非常重要@ 字符冲突,这时候应该置为 0001101,也就是 GSM-7 中的 \r 回车字符。最后:
补充:
首先你得有 PyPI 的账号,没有注册的话,不用搞了。
然后你肯定要先准备 setup.py 了,如果这个都没弄就不用搞了。
算了,先贴一个简单的样板吧。
# -*- coding: utf-8 -*-
from setuptools import setup
setup(
name='PageageName',
version='0.0.1',
author='YourName',
author_email='YourEmail',
url='PackageSite (e.g. GitHub)',
description='....',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
packages=['PackageDir'],
install_requires=[
'requests>=2.18.4',
'balabala',
],
extras_require={ # 可选
'dev': [
'balabala...',
],
'test': [
'balabala...',
],
},
classifiers=[
'Development Status :: 3 - Alpha',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'License :: OSI Approved :: MIT License',
],
)
python3 -m pip install twine
rm -rf dist
python3 setup.py sdist bdist_wheel
python2 setup.py sdist bdist_wheel
twine upload dist/*
twine 会询问账号密码,如果不想每次这么麻烦,可以创建 ~/.pypirc 文件。
.pypirc 文件[distutils]
index-servers =
pypi
[pypi]
repository = https://upload.pypi.org/legacy/
username = your_username
password = your_password
MIME 是 Multipurpose Internet Mail Extensions 的缩写,多用途互联网邮件扩展 的意思。
最初的电子邮件标准 RFC 822 只支持发送 ASCII 字符文本内容,通过 MIME 这个拓展(RFC 2822),可以发送所有类型的内容。
后面的 HTTP 协议也是在 MIME 这个框架内构建的,Web 开发者比较熟悉的那几个 Content-XXX 头就是从 MIME 里面来的。
| RFC No. | Type | Title |
|---|---|---|
| RFC 2045 | Standards Track | Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies |
| RFC 2046 | Standards Track | Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types |
| RFC 2047 | Standards Track | MIME (Multipurpose Internet Mail Extensions) Part Three: Message Header Extensions for Non-ASCII Text |
| RFC 2048 | Best Current Practice | Multipurpose Internet Mail Extensions (MIME) Part Four: Registration Procedures |
| RFC 2049 | Standards Track | Multipurpose Internet Mail Extensions (MIME) Part Five: Conformance Criteria and Examples |
5 个核心头(RFC 2045)和 Content-Disposition 扩展(RFC 2183):
MIME-Version: 1.0 // MIME 版本
Content-Type: [type]/[subtype]; parameter // 内容类型
Content-Transfer-Encoding: [encoding] // 内容传输编码
Content-ID: xxx
Content-Description: xxx // some descriptive information
Content-Disposition: [disposition] // 内容配置
又叫互联网媒体类型(Internet media type)或者 MIME 类型(MIME type)。
类型信息的注册事宜,由 IANA(Internet Assigned Numbers Authority)统一管理。
按照注册来源分成几种类型,只用关心标准数,这个了解一下就行了:
类型名 / 子类型名 [ + 后缀 ] [ ; 可选参数 ]类型名 / vnd.子类型名 [ + 后缀 ] [ ; 可选参数 ],例如:application/vnd.debian.binary-package类型名 / prs.子类型名 [ + 后缀 ] [ ; 可选参数 ]类型名 / x.子类型名 [ + 后缀 ] [ ; 可选参数 ]详细类型在 IANA 官网有,链接在下面参考资料部分我贴了一个。
| Type | Subtype | Description |
|---|---|---|
| text | plain | 文本 |
| text | html | HTML |
| text | xml | XML |
| text | javascript | JavaScript |
| text | css | CSS |
| text | csv | CSV |
| text | vcard | vCard 电子名片 |
| image | bmp | |
| image | jpeg | |
| image | png | |
| image | gif | |
| image | webp | |
| image | svg+xml | |
| image | icon | |
| audio | mpeg | |
| audio | mp4 | |
| audio | ogg | |
| audio | webm | |
| audio | flac | |
| video | mpeg | |
| video | mp4 | |
| video | ogg | |
| video | webm | |
| application | xml | XML |
| application | json | JSON |
| application | ecmascript | |
| application | javascript | |
| application | zip | |
| application | gzip | |
| application | ||
| application | rss+xml | |
| application | atom+xml | |
| application | octet-stream |
编码类型主要是这几种:“7bit”,“8bit”,“binary”,“quoted-printable”,“base64”。