this is a test case for python
This file contains hidden or 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 datetime | |
import hashlib | |
import os | |
from functools import wraps | |
import jwt | |
from flask import Flask | |
from flask import request, jsonify, send_from_directory | |
from werkzeug.utils import secure_filename |
This file contains hidden or 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
def condition_sql(path, search_params): | |
from_condition = [] | |
if not search_params: | |
return '' | |
if type(search_params) == list: | |
for i in search_params: | |
from_condition.append('JSON_CONTAINS(param_json, \'%s\', "%s")' % (json.dumps(i), path)) | |
elif type(search_params) == dict: | |
for k, v in search_params.items(): | |
if v: |
This file contains hidden or 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
/** | |
* @author zhangsd | |
* | |
* treeast.com | |
* | |
**/ | |
var gis = | |
{ | |
"0111": "121.391832,31.116809", | |
"0112": "121.399814,31.126929", |
This file contains hidden or 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
#! /bin/bash | |
echo "kill $1" | |
port_array=$(lsof -ti tcp:$1) | |
echo $port_array | |
echo ${#port_array} | |
if [ ${#port_array} -gt 1 ] | |
then |
This file contains hidden or 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
import time | |
import math | |
def retry(tries, delay=3, backoff=2): | |
if backoff <= 1: | |
raise ValueError("backoff must be greater than 1") | |
tries = math.floor(tries) | |
if tries < 0: | |
raise ValueError("tries must be 0 or greater") |
This file contains hidden or 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
def fibonacci(n, cache=None): | |
if cache is None: | |
cache = {} | |
if n in cache: | |
return cache[n] | |
if n <=1: | |
return 1 | |
cache[n] = fibonacci(n - 1, cache) + fibonacci(n - 2, cache) |
This file contains hidden or 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 datetime | |
import arrow | |
from django.conf import settings | |
def get_now(): | |
""" | |
**返回当前时间** |
This file contains hidden or 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
def push_order_po(modeladmin, request, queryset): | |
""" | |
推送指定的PO | |
""" | |
# TODO filter order | |
today = erp_time.day(2016, 3, 22) | |
push_presale_po.process_pre_order(FrappeClient(), today, 1, queryset) |
This file contains hidden or 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
import json | |
from datetime import datetime | |
from uuid import UUID | |
class LogJSONEncoder(json.JSONEncoder): | |
""" | |
专门为了解决各种:``TypeError: xx is not JSON serializable`` | |
""" |