Skip to content

Instantly share code, notes, and snippets.

View pavan538's full-sized avatar

Pavan Kumar pavan538

View GitHub Profile
@pavan538
pavan538 / jmxremote_arguments.sh
Created December 20, 2017 15:35 — forked from rponte/jmxremote_arguments.sh
Arguments to enable JMX on JVM - Example of setenv.sh file
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=8086
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
@pavan538
pavan538 / python_dictconfig_logging
Created December 30, 2017 04:49
python logging dict config example
logconfig = {
"version": 1,
"disable_existing_loggers": 0,
"root": {
"level": "DEBUG",
"handlers": [
"console",
"file",
"debugfile"
]
@pavan538
pavan538 / awk.md
Last active August 19, 2019 10:43
  • matching groups
gawk '{
    match($0, /ns0:OpenDate>(.+?)<\/ns0:OpenDate.+?ns0:CloseDate>(.+?)<\/ns0:CloseDate/, Arr)
    printf "%s %s\n", Arr[1], Arr[2]
    }' *
@pavan538
pavan538 / threads
Created February 7, 2018 06:27
Threads Notes
Threads:
Thread is a small piece of code executed separately.
Threads are created with three pieces of information
Thread name
Runnable target - run()
stack size
Life cycle of a Thread:
By using Thread.getState() - we can know the state of the thread.
Thread.getState() returns enum state of a thread.
@pavan538
pavan538 / python_install_build_packages.txt
Last active July 30, 2018 05:07
Python installation and packages
setup tools:
when ever there isa source distribution which consists of setup.py file, we can directly install using the following command
# cd foo.1.0/
# python setup.py install
if we need to split the build we can use the following commands
# python setup.py build
# python setup.py install
prefix, exec-prefix stands for the directories that Python is installed to, and where it finds its libraries at run-time.
@pavan538
pavan538 / supervisor.txt
Last active January 3, 2019 07:01
supervisor - mange processes
Install supervisor python3
pip3 install git+https://github.com/Supervisor/supervisor
[supervisord]
nodaemon=false
[supervisorctl]
@pavan538
pavan538 / abstract_class_docstring_in_derived_class.py
Created February 14, 2018 10:34
automatically get docstring of abstract class docstring in derived class
import abc
class SuperclassMeta(type):
def __new__(mcls, classname, bases, cls_dict):
cls = super().__new__(mcls, classname, bases, cls_dict)
for name, member in cls_dict.items():
if not getattr(member, '__doc__'):
member.__doc__ = getattr(bases[-1], name).__doc__
return cls
@pavan538
pavan538 / import_modules_dynamically.py
Last active February 15, 2018 10:16
import python modules dynamically
"""
The built-in __import__ function accomplishes the same goal as using the import statement,
but it's an actual function, and it takes a string as an argument.
"""
sys = __import__('sys')
os = __import__('os')
re = __import__('re')
unittest = __import__('unittest')
@pavan538
pavan538 / sphinx_doc.txt
Last active February 18, 2018 07:20
Sphinx tutorial
$ sphinx-quickstart
In conf.py add the path of the project as follows
sys.path.insert(0, os.path.abspath('/home/pavan/code/kafka_project'))
# to generate rst files from modules, use the following command
$ sphinx-apidoc -o build_docs/api/ -f /home/pavan/code/kafka_project/framework
To build the module use the following command in root_directory of sphinx where conf.py, static and templates files are included.
$ sphinx-build . _build/
@pavan538
pavan538 / tox.md
Last active February 19, 2018 06:06
python tox build tool

How to pass command line parameters to tox command

Try adding {posargs} in the commands section of your tox.ini, like this:

commands =
    python manage.py test {posargs}

Then at the command line, something like: