Skip to content

Instantly share code, notes, and snippets.

>>> from http import cookies
>>> cookies._getdate()
'Tue, 22 Dec 2015 06:47:08 GMT'
@ficapy
ficapy / img_upload.py
Last active April 9, 2018 13:08
当做图床使用,读取粘贴板的图像保存上传,完成后将url地址写入到剪贴板
#!/usr/local/bin/python2
# -*- coding: utf-8 -*-
# Author: Ficapy
# Create: '16/1/1'
import datetime
import os
import sys
import atexit
import requests
@ficapy
ficapy / CSharp_project_recommend.py
Created February 23, 2016 15:23
今天开始学C#,找几个小项目看源码练练手
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: Ficapy
# Create: '16/2/23'
import sys
if sys.version_info[0] < 3:
sys.exit(1)
from github import Github
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: Ficapy
import os
import requests
import base64
import hmac
import datetime
from os.path import join, exists, relpath
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: Ficapy
# Create: '16/3/4'
# !/usr/bin/env python
import ftplib
import hmac
import subprocess, json, base64, binascii, time, hashlib, re, copy, textwrap
@ficapy
ficapy / des3.py
Created April 20, 2016 02:37
3DES双倍长加密
from Crypto.Cipher import DES3
import binascii
# 3DES加密32位ASCII字符串得到32位ASCII字符串
# 密匙长度16bytes
# 3DES密文长度于明文长度相符,所以要加密得到32位明文中间有16进制转换('1F'→→→'\x1f')
# 加密前2个ASCII字符转换成1bytes(限制了只能是0-F)
def des3(key, msg):
cipher = DES3.new(binascii.unhexlify(key), DES3.MODE_ECB)
ret = cipher.encrypt(binascii.unhexlify(msg))
@ficapy
ficapy / exception_architecture.py
Last active July 18, 2016 00:05
打印模块的异常结构
import requests
import inspect
from collections import defaultdict
def _tree(): return defaultdict(_tree)
tree = _tree()
@ficapy
ficapy / hosts.py
Created July 13, 2016 15:12
代替/etc/hosts 当requests.get的时候使用指定的ip
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: Ficapy
# Create: '7/12/16'
import socket
import requests
def getitem(pos, seq):
@ficapy
ficapy / multi_processbar.py
Created July 15, 2016 10:09
使用ANSI控制符实现多行进度条 "\033[r;cH" 参考:https://www.student.cs.uwaterloo.ca/~cs452/terminal.html 缺点:运行时无法获取当前光标行数print('\033[6n', end='')
from __future__ import print_function
import random
import time
import sys
if not sys.stdout.isatty() or sys.version_info[0] == 2:
sys.exit(2)
@ficapy
ficapy / pycallgraph.py
Last active April 29, 2018 16:09
精简pycallgraph代码,生成调用关系图 python3.5.1 代码解读https://ficapy.github.io/2016/07/22/pycallgraph_note/
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: Ficapy
# Create: '20/7/2016'
import inspect
import os
import re
import tempfile
import textwrap
import pkgutil