Skip to content

Instantly share code, notes, and snippets.

@naixwf
naixwf / gist:8ea4ca8a96eb4a395425
Created June 9, 2015 12:34
zabbix自动创建screen
#!/usr/bin/env python
# coding=utf8
import urllib2
import json
import argparse
def authenticate(url, username, password):
values = {'jsonrpc': '2.0',
'method': 'user.login',
'params': {
'user': username,
@naixwf
naixwf / aes.py
Created October 24, 2014 02:37
这个脚本可以兼容java的AES加密解密 ``` Cipher cipher = Cipher.getInstance("AES"); SecretKeySpec keySpec = new SecretKeySpec(ROW_BYTES, "AES"); cipher.init(2, keySpec); byte[] ciphertext = cipher.doFinal(Base64.decodeBase64(content)); ```
# -*- coding: utf-8 -*-
import base64
from Crypto.Cipher import AES
BS = AES.block_size
pad = lambda s: s + (BS - len(s) % BS) * chr(BS - len(s) % BS)
unpad = lambda s: s[0:-ord(s[-1])]
key = '80e36e39f34e678c'
cipher = AES.new(key)
@naixwf
naixwf / aes.py
Created October 22, 2014 09:51
aes加密解密 这个实现可以和java的实现兼容
# coding=utf-8
from Crypto.Cipher import AES
import base64
import os
# via http://sentdex.com/sentiment-analysisbig-data-and-python-tutorials-algorithmic-trading/encryption-and-decryption-in-python-code-example-with-explanation/
# key从p2p StringHelper来
key = '80e36e39f34e678c'
@naixwf
naixwf / ldapAuthManager.java
Created June 7, 2012 12:29
java使用ldap验证用户登陆
/**
* 连接ldap服务器验证用户
*
* @author wangfei
* @created 2012-2-22
*
* @version 1.0
*/
public class LDAPManager {
@naixwf
naixwf / gist:2832949
Created May 30, 2012 02:22
mysql 2进制日志
-- 查看mysql 二进制日志天数
show variables like '%expire%';
-- 将二进制日志天数设置为10天
set global expire_logs_days=10;
@naixwf
naixwf / exportcsv.sh
Created April 11, 2012 10:44
导出mysql语句执行结果并转换为windows下excel可打开的csv
#/bin/bash
function __help(){
echo "usage: exportcsv.sh <mysql用户名> <mysql密码>"
}
function __export(){
mysql -u$USERNAME -p$PASSWD --default-character-set=utf8 -Dmeituanwage -B -e "$SQL" > ${OUTFILE}.origin
sed -e 's/"/\"/g;s/ /","/g;s/^/"/g;s/$/"/g;' ${OUTFILE}.origin > utf8.${OUTFILE}.csv
iconv -f "UTF-8" -t "gbk" utf8.${OUTFILE}.csv > gbk.${OUTFILE}.csv