Wednesday, June 14, 2017

rpdb2 without winpdb

rpdb2 can be used by dropping the rpdb2.py script in the root directory of the remote project then placing the
import rpdb2; rpdb2.start_embedded_debugger('asdf',fAllowRemote=True)
command in the running service. You can then attach to the service when it debugs by using the rpdb2.py command as well, but via the command line with
python -c "import rpdb2; rpdb2.main()"

Then from there do

  > password "asdf"
 Password is set to: "asdf"

 > attach
 Connecting to 'localhost'...
 Scripts to debug on 'localhost':

    pid    name
 --------------------------
    7772   myscript.py

 > attach 7772
 > *** Attaching to debuggee...
 > *** Debug Channel is encrypted.
 > *** Successfully attached to
 > *** 'myscript.py'.
 > *** Debuggee is waiting at break point for further commands.

 > go

Monday, April 3, 2017

Python scripts installation in setup.py

source

in setup.py

from setuptools import setup

setup(name='my_project',
      version='0.1.0',
      packages=['my_project'],
      entry_points={
          'console_scripts': [
              'my_project = my_project.__main__:main'
          ]
      },
      )

in __main__.py in project directory

import sys


def main(args=None):
    """The main routine."""
    if args is None:
        args = sys.argv[1:]

    print("This is the main routine.")
    print("It should do something interesting.")

    # Do argument parsing here (eg. with argparse) and anything else
    # you want your project to do.

if __name__ == "__main__":

    main()

Wednesday, March 22, 2017

Moving around the screen with bash and ascii escape characters

source

Using something like echo -e "\033[3A" lets you move up by 3 lines, indicated by the 3 in "[3A".


- Position the Cursor:
  \033[L;CH
     Or
  \033[L;Cf
  puts the cursor at line L and column C.
- Move the cursor up N lines:
  \033[NA
- Move the cursor down N lines:
  \033[NB
- Move the cursor forward N columns:
  \033[NC
- Move the cursor backward N columns:
  \033[ND

- Clear the screen, move to (0,0):
  \033[2J
- Erase to end of line:
  \033[K

- Save cursor position:
  \033[s
- Restore cursor position:
  \033[u

Thursday, March 16, 2017

python and algorithms

http://interactivepython.org/courselib/static/pythonds/index.html

Wednesday, March 8, 2017

xmonad screen mirroring

This assumes you have the vnc software installed:

sudo apt-get install x11vnc 
sudo apt-get install vncviewer

On workspace to mirror:

x11vnc -usepw -clip xinerama0 -noxdamage -geometry 1920x1080

On workspace to display on projector:

 vncviewer -viewonly -nocursorshape localhost:0