Wednesday, December 30, 2015

Python debugging: ipdb

pdb is python's basic debugger.  It's nice because you can use it in a lot of different circumstances and it's independent of any particular IDE.

Here's a nice introduction:

But most often, if I pull out a debugger, what I really want is to play with the objects in a python shell.  pdb has its own shell, but . . . there are a lot of missing features.  In particular, if you want to explore a particular object it's weak because there isn't a tab completion feature.

If you already have ipython, you can use the pdb functionality of pdb in the more powerful ipython shell by using ipdb.

It's simple to install and more than worth it.  Just do

pip install ipdb.

Then, instead of 
'import pdb'

do 
'import ipdb'

and instead of 
pdb.set_trace()

do 
ipdb.set_trace().

You're welcome!


Friday, June 5, 2015

Friday, May 29, 2015

Lots of named tabs--like a scite session but for Gnome Terminal

Open a bunch of bash tabs simultaneously and give them different titles.  Nice!
 
#!/bin/sh 
gnome-terminal \
--tab -t "notes" --working-directory=$HOME/notes  \
--tab -t "puppet" --working-directory=$HOME/puppet \
--tab -t "beamish" --profile=root-beamish           \
--tab -t "odyssey" --profile=odyssey                \
--tab -t "root" --profile=root

Friday, May 22, 2015

More organized javascript

I do a lot of writing in Python and everything seems to be nicely arranged and easy to follow and then I go to what I've written in Javascript and jQuery and it looks like a mess.  It's comparatively hard to follow even much smaller tracts of code.

So here are a couple of resources on organizing Javascript code.
 
http://alistapart.com/article/the-design-of-code-organizing-javascript
http://addyosmani.com/resources/essentialjsdesignpatterns/book/
http://rmurphey.com/blog/2009/10/15/using-objects-to-organize-your-code/

Wednesday, May 20, 2015

Today I learned that properties can't be accessed as functions

It took a long time for me to debug something that was simple.

I had a method defined as a property and I built another method that took its output.

Out of habit, I called the function.  And my operation failed.  The lesson was pretty simple: don't try to call a property.  It's a value now, not a method.