Tuesday, January 31, 2023

The Anvil is Gone. Long live the anvil.

I named this blog when I was working through a PhD with a growing family.

I've completed my PhD and had a fun career since then.  My family has continued to grow and now three of the eight children have graduated high school and are off on adventures.  Our fourth graduates this spring, leaving only four at home.

So somehow we made it through the time intensive years with youngsters and did just fine.

But of course there's still an anvil to carry up that mountain -- plenty of goals and expectations and weaknesses to overcome.  But I'll keep moving and I think we'll get where we need to go.

Wednesday, November 27, 2019

The lovely pkill and pgrep

Trouble in Gotham: Guake frozen

This morning my guake terminal froze.  No key combination within guake would work to get it back going, of course, because no keys worked within guake.

So I used ctr-alt-t to open another terminal and top to list open processes.  Perhaps because guake was frozen, it didn't make the top screen.

Enter pkill

Instead, from the other terminal I used pkill.
This killed guake right away.

Thursday, April 6, 2017

ipython magic: effortless module reload

Seeing is huge.  Anything that you can do that lets you see what's happening in a system with more detail or more quickly will help you master that system.  Do you want to understand how your lawn mower works?  Remove the hood.

Python programming can be a pleasure, partly because it's simple to see what you're doing.  If you want to understand a little snippet, you just take it to the interpreter, run it, and get an output.  Edit it and get a new output.

Some effects are trickier to see because they are contextual.  That is, your snippet won't do the same thing if you paste it into the interpreter as it will in the environment where it's meant to live.  This is particularly true for me when I'm working with Django code, which often depends on a Django environment.

The Django shell (./manage.py shell) solves part of this problem.  The Django Extensions shell (./manage.py shell_plus if you've installed the Django Extensions app) can take you further.  But even then if you have code that depends on the actual location of a file, for example, you can't test it in the shell directly.

To get around that issue, I've typically done two different things in the past: 1) run the code in a test and use print statements or ipdb to get the information that I want, or 2) figure out how to reload the interpreter every time I update a module.

This post celebrates the fact that I just learned how to do 2 much more efficiently than before.  So here it is -- effortless ipython reload:


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/