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
from functools import wraps | |
def inject(klass): | |
def decorator(func): | |
@wraps(func) | |
def wrapper(*args, **kwargs): | |
return func(*args, **kwargs) | |
setattr(klass, func.__name__, func) |
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 importlib | |
import inspect | |
from flask import Flask | |
from flask_restful import Resource | |
app = Flask(__name__) | |
for module_name in ['v1', 'v2']: | |
module = importlib.import_module(module_name) |
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 | |
# | |
# extra_args.sh -l args script_args -- -l extra args | |
# | |
# OUTPUT | |
# opt: l=args | |
# arg: %script_args% | |
# extra_args: %-l extra args% | |
# |
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
[defaults] | |
gathering = smart | |
fact_caching = redis | |
fact_caching_timeout = 86400 | |
fact_caching_connection = <redis-host> | |
roles_path = ~/ansible/roles | |
filter_plugins = ~/ansible/plugins/filter_plugins | |
sudo_exe = sudo | |
sudo_flags = -i | |
accelerate_multi_key = yes |
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 | |
from functools import wraps | |
class timeit(object): | |
"""measure execution time and print(or log) it | |
Args: | |
printer: message print function | |
if None, print message to stdout | |
msg: messsage |
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
from functools import wraps | |
class synchronized(object): | |
"""synchronized decorator | |
usage: | |
@synchronized(lock) | |
def foo(): |
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
#!/usr/bin/env python | |
# -*- coding: utf8 -*- | |
"""very very simple profile viewer | |
To generate profile data run: | |
python -m cProfile -o profile.dump myscript | |
OR |
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
"""Just simple combination | |
todo recursive call s should be call by reference | |
""" | |
import itertools | |
import string | |
import unittest | |
def combination(s, n): |
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
#!/usr/bin/python | |
"""network interface address를 관리하는 ansible 모듈 | |
library 디렉토리에 넣어서 사용하면 됩니다. | |
""" | |
import re | |
from ansible.module_utils.basic import AnsibleModule | |
DOCUMENTATION = ''' | |
--- |
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
"""Test Helper""" | |
from unittest.mock import patch | |
class MockMixin(object): | |
"""TestCase Helper | |
아래처럼 사용하면, Mocking된 object가 cleanup되지 않아서 다음 테스트에도 | |
영향을 미친다. :: |