Skip to content

Instantly share code, notes, and snippets.

sudo yum -y update
sudo yum groupinstall -y 'development tools'
sudo yum install -y zlib-devel bzip2-devel openssl-devel xz-libs wget
wget http://www.python.org/ftp/python/2.7.8/Python-2.7.8.tar.xz
xz -d Python-2.7.8.tar.xz
tar -xvf Python-2.7.8.tar
cd Python-2.7.8
# Run the configure:
@ficapy
ficapy / file_transfer.py
Last active November 16, 2015 15:55
CDN文件中转
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: Ficapy
from __future__ import division, print_function
import sys
import re
import urllib
import sqlite3
import tempfile
@ficapy
ficapy / xiaomi_route_restart.py
Created December 15, 2015 10:46
小米路由器重启脚本,万一有人会用到呢
import time
import random
import requests
from hashlib import sha1
key = 'a2ffa5c9be0748*********' # 登陆页面查看源码获得
deviceId = '98:5a:eb:*****'
pwd = '*************'
url = 'http://192.168.31.1/cgi-bin/luci/api/xqsystem/login'
reboot_url = 'http://192.168.31.1/cgi-bin/luci/;stok={}/api/xqsystem/reboot?client=web'
@ficapy
ficapy / ali_oss.py
Last active December 21, 2015 13:02
阿里云OSS单文件上传
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: Ficapy
import requests
import base64
import hmac
import os
import sys
import datetime
>>> from http import cookies
>>> cookies._getdate()
'Tue, 22 Dec 2015 06:47:08 GMT'
@ficapy
ficapy / VBA_replace.bas
Created December 20, 2013 11:12
建筑资料栋号递增批量打印PDF输出
Option Explicit
'建筑资料栋号递增批量打印PDF输出
Sub replace()
Const F1 As String = "工程名称" '要修改单元格左边相邻单元格包含的内容
Dim k As Integer
Dim sh As Worksheet
Dim myStr As String
Dim myStr2 As String
Dim myStr3 As String
#!/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
@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 / 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)