Skip to content

Instantly share code, notes, and snippets.

# coding=utf-8
import os
import logging
from datetime import datetime, timedelta
import tarfile
from glob import glob
DATETIME = datetime.today().strftime("%Y-%m-%d-%H-%M")
FORMAT = '%(asctime)-15s %(message)s'
# coding=utf-8
import logging
from datetime import datetime, timedelta
import os.path
import csv
# from collections import Iterable
DATETIME = datetime.today().strftime("%Y%m%d")
FORMAT = '%(asctime)-15s %(message)s'
#!/usr/bin/env python
#-*- coding: utf8 -*-
import logging
import MySQLdb
MYSQL_CONFIG = {
'host': 'localhost',
'port': 3306,
# coding=utf-8
from ftplib import FTP
import os
import logging
from datetime import datetime, timedelta
from sys import argv
import tarfile
DATETIME = datetime.today().strftime("%Y-%m-%d-%H-%M")
FORMAT = '%(asctime)-15s %(message)s'
# coding=GBK
import os
import shutil
os.chdir('/pro/udp')
cfg_text = r'''<?xml version="1.0" encoding="GBK"?>
<system version="3.8">
<ip>10.34.57.57</ip>
#!/usr/bin/env python2.7
#-*- coding: utf-8 -*-
from hashlib import md5
from fabric.api import env, run, cd, local # , settings
from fabric.tasks import execute
from fabric.decorators import with_settings # , task
from datetime import datetime as dt, timedelta
result = []
@hipro
hipro / get_func_args_dict.py
Created October 13, 2014 08:57
获取一个函数的参数列表
class FuncArgsDict(object):
@staticmethod
def generate_dic(f, args):
return {k: v for (k, v) in zip(f.func_code.co_varnames[1:], args)}
def func(self, a, b, c):
kws = self.generate_dic(self.func, [a, b, c])
for k in kws:
print k, ':', kws[k]
// http://tour.golang.org/#58
package main
import (
"fmt"
)
type ErrNegativeSqrt float64
@hipro
hipro / methods.go
Created September 28, 2014 02:43
两个代码的结果相同。v *Vertex ---- v Vertex
// http://tour.golang.org/#52
// code - 1
package main
import (
"fmt"
"math"
)
@hipro
hipro / qsort.go
Last active August 29, 2015 14:06
package main
import "fmt"
func qsort(data []int) {
if len(data) <= 1 {
return
}
mid, i := data[0], 1
head, tail := 0, len(data)-1