Skip to content

Instantly share code, notes, and snippets.

View python012's full-sized avatar

Reed Xia python012

View GitHub Profile
@python012
python012 / py_unittest.py
Last active April 14, 2018 00:56
Try patch and mock functions in unit test
#!/usr/bin/env python3
from unittest import TestCase
from unittest.mock import patch
from unittest import main
class Person(object):
def __init__(self, name):
self.name = name
@python012
python012 / settings.xml
Created April 20, 2017 03:10
Maven settings.xml with aliyun mirror
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
@python012
python012 / gist:4cf7fe6a4dc63ef047b4
Last active August 29, 2015 14:11
Try the code with multiprocessing
#!/usr/bin/env python
# -*- coding:utf-8 -*-
from multiprocessing import Process
from multiprocessing import Queue
from multiprocessing import Pool
import multiprocessing
path_list = range(10)
bad_path_list = []
@python012
python012 / gist:81e159df93665c465005
Created December 9, 2014 02:31
Use yield in Fibonacci list
#!/usr/bin/env python
# -*- coding:utf-8 -*-
def fab(max):
n, a, b = 0, 0, 1
while n < max:
yield b
a, b = b, a + b
n = n + 1
@python012
python012 / gist:21317c81469326bd3100
Last active August 29, 2015 14:10
Practice multiple threads code, will improve one of my Python programs' efficiency.
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
Created on 2014年12月7日
@author: reed
'''
import thread
import time