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
class LazyImport: | |
def __init__(self, module_name): | |
self.module_name = module_name | |
self.module = None | |
def __getattr__(self, name): | |
if self.module is None: | |
self.module = __import__(self.module_name) | |
return getattr(self.module, 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
graph = {'A':{'A':0,'B':6,'C':INF,'D':6,'E':7}, | |
'B':{'A':INF,'B':0,'C':5,'D':INF,'E':INF}, | |
'C':{'A':INF,'B':INF,'C':0,'D':9,'E':3}, | |
'D':{'A':INF,'B':INF,'C':9,'D':0,'E':7}, | |
'E':{'A':INF,'B':4,'C':INF,'D':INF,'E':0} |
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
语法为 | |
:[addr]s/源字符串/目的字符串/[option] | |
全局替换命令为: | |
:%s/源字符串/目的字符串/g | |
比如要将文件中的 SCORE 替换为 NEW | |
:%s/SCORE/NEW/g |
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
块选择(Visual Block) | |
v 字符选择,会将光标经过的地方反白选择 | |
V 行选择,会将光标经过的行反白选择 | |
【Ctrl】+v 块选择,可以用长方形的方式选择数据 | |
y 将反白的地方复制起来 |
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
删除名为 xhkdb的数据库: | |
mysql> drop database xhkdb; | |
mysql> drop database if exists drop_database; | |
Query OK, 0 rows affected, 1 warning (0.00 sec) | |
删除MySQL数据表的通用语法: | |
DROP TABLE table_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
⌘ + d: 垂直分屏, | |
⌘ + shift + d: 水平分屏。 | |
⌘ + ]和⌘ + [在最近使用的分屏直接切换. | |
⌘ + opt + 方向键切换到指定位置的分屏。 | |
⌘ + 数字: 切换标签页。 |
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
# 分屏启动Vim | |
# n是数字,表示分成几个屏。 | |
# 在通过vim启动多个文件时,分屏 | |
vim -On file1 file2 ... | |
# 使用小写的o参数来水平分屏。 | |
vim -on file1 file2 ... |
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
统计某文件夹下文件的个数 | |
ls -l |grep "^-"|wc -l | |
统计某文件夹下目录的个数 | |
ls -l |grep "^d"|wc -l | |
统计文件夹下文件的个数,包括子文件夹里的 | |
ls -lR|grep "^-"|wc -l |
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
重启命令: | |
1、reboot | |
2、shutdown -r now 立刻重启(root用户使用) | |
3、shutdown -r 10 过10分钟自动重启(root用户使用) | |
4、shutdown -r 20:35 在时间为20:35时候重启(root用户使用) | |
如果是通过shutdown命令设置重启的话,可以用shutdown -c命令取消重启 | |
关机命令: | |
1、halt 立刻关机 | |
2、poweroff 立刻关机 |
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
# -*- coding:utf-8 -*- | |
import base64 | |
import rsa | |
from Crypto.Cipher import AES | |
from Crypto.PublicKey import RSA | |
from pyDes import des, CBC, PAD_PKCS5 | |
from Crypto.Cipher import DES3 | |
import hashlib | |
import hmac |