Monday, July 27, 2020

How To Post Codes In Blogs As Html Using Pygmentize


https://pygments.org/download/


For Command Line Help:-
>pygmentize -h
>pygmentize -H

To see all available lexer (language supported), formatter, etc ...
>pygmentize -L

To see all Options available for HTML formatter:-
>pygmentize -H formatter html

To convert lines of codes into html format so that u can post it to a blog:-
>cat report_waiverfile_errors.py | pygmentize -l python -f html -O noclasses


To include line numbers:-
>cat report_waiverfile_errors.py | pygmentize -l python -f html -O 'noclasses,linenos'

To Highlight certain lines:-
>cat report_waiverfile_errors.py | pygmentize -l python -f html -O 'noclasses,linenos,hl_lines="12 13 14 15 16 17"'

Example:-
1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env python

import os
import sys
#sys.path.insert(0, '/nfs/site/disks/da_infra_1/users/yltan/depot/da/infra/dmx/main/lib/python')
import logging
import dmx.tnrlib.waiver_file


LOGGER = logging.getLogger()


def main():
    wf = dmx.tnrlib.waiver_file.WaiverFile()
    wf.load_from_file(sys.argv[1])

if __name__ == "__main__":
    logging.basicConfig(format='[%(asctime)s] - %(levelname)s-[%(module)s]: %(message)s', level=logging.DEBUG)
    main()




How To Bypass Kerberos(kinit) Authentication

Whenever you try to setuid and impersonate as someone else to run something, it is very likely that you will run into kerberos/kinit issues....