Skip to content

Instantly share code, notes, and snippets.

View pavan538's full-sized avatar

Pavan Kumar pavan538

View GitHub Profile
@pavan538
pavan538 / unicode_in_python.md
Last active September 17, 2018 12:05
Unicode
  • codepoint The Unicode standard describes how characters are represented by code points. A code point is an integer value, usually denoted in base 16. In the standard, a code point is written using the notation U+12CA to mean the character with value 0x12ca (4,810 decimal). The Unicode standard contains a lot of tables listing characters and their corresponding code points:

    U+12CA is a codepoint, which represents some particular character;

  • A Unicode string is a sequence of code points, which are numbers from 0 through 0x10FFFF (1,114,111 decimal). This sequence needs to be represented as a set of bytes (meaning, values from 0 through 255) in memory. The rules for translating a Unicode string into a sequence of bytes are called an encoding.

  • A character is represented on a screen or on paper by a set of graphical elements that’s called a glyph. The glyph for an uppercase A, for example, is two diagonal strokes and a horizontal stroke, though the exact details will depend on the font being used.

sample docker compose

version: '3'
services:
  blob-consumer:
    container_name: article-blob-consumer-container-compose
    image: blob-consumer-image:1.0
    build:
 context: .
@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:

@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 / 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 / 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 / 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 / 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 / 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 / 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]
    }' *