Out of Hanwell

January 27, 2006

Learning Python

Filed under: Uncategorized — Matthias Miller @ 9:53 pm

I admit it. When I read Chad Fowler’s book My Job Went to India, I took some of his suggestions and made a list of technologies I want to explore. However, the list has been sitting neglected on my desktop or in my inbox all this time. This week I’m finally tackling one of those ideas.

I recently bought a copy of Learning Python and have since been engrossed in the world of a very different programming language. The book, from what little I’ve read so far, has been very helpful. I keep getting distracted by opening Xcode and writing code instead of reading the book! (I do read the book, mind you–I want to do more than write C++ programs with Python syntax.) Before you buy the book, however, take note that you must remember everything you read. The reference in the book is very incomplete, and if you’re like me, chances are you won’t be able to go back and find what you need.

Of the many ways that Python differs from C/C++, I find the use of lists and dictionaries, together with lambdas, to be the most profound. Last night I took on a real-world problem: finding the best way to transform a list of objects representing success or failure operations into a list of user summary messages (where success messages are grouped by a time period, and failure details are shown individually). I spent what must have been nearly an hour writing nine lines of code–and that was just solving part of the problem! Today I reordered some loops, added some list comprehensions, put in some filters, and sorted the results. It’s looking a lot better now.

Although I don’t foresee my job requiring proficiency in Python in the near future, I don’t regret the time I’m spending to dig into the language. I can easily foresee this lending creativity in how I solve problems in C/C++. Besides (as every Python programmer would attest), it’s a fun language to work in!

Advertisements

January 21, 2006

Programming on Mac

Filed under: Uncategorized — Matthias Miller @ 8:40 pm

New Mac Mini. Last week I finally gave up on my iBook after I managed to corrupt some libraries during development. The prospect of reinstalling Panther and the development tools (not to mention recompiling certain sizeable development libraries) pushed me over the edge. I sold my iBook to a friend and ordered a Mac Mini, mostly for its size, affordability, and reasonable performance (1.5GHz G4, up from 500MHz G3). I can develop a lot more productively now.

svnX. After a week of downtime, I’m back to development on the Mac. I’ve recently been trying out svnX, a Subversion client for the Mac. I’m impressed with its simple design and ease-of-use. I’ve dropped back to the shell a time or two for more advanced features, but it provides a nice interface for day-to-day source code control. I really wish this client would be available on Linux and Windows.

KeePass/L. Today I resolved the installation problems with KeePass/L, and I’m now writing some automated tests to ensure that the data is loaded and saved correctly on a PowerPC processor. Until it passes these tests, KeePass should only be used for read-only access to a password database.

If you would like to experiment with KeePass on the Mac, you can install Qt. After you’ve downloaded the latest KeePass snapshot, run the following commands to compile and install:

qmake
make
make install

You will find an icon for KeePass under “Applications” in the Finder. Just remember, this is a development build.

January 16, 2006

KeePass for the Mac (Update)

Filed under: Uncategorized — Matthias Miller @ 12:52 pm

My patches for KeePass (excluding the endian patch) have been integrated into the source and can be downloaded from the subversion repository. There are some installation issues to deal with, which I can hopefully deal with in the next week or two.

January 10, 2006

JavaScript: Property Names vs. Variables

Filed under: Uncategorized — Matthias Miller @ 7:23 am

I was going to respond to dIon Gillard’s Better JavaScript – Objects with a comment, but that didn’t work, so here’s my response:

Does it matter when a property name duplicates the name of a variable? Take this code, for example:

var val = 10;
var obj = {};
obj.val = val;
obj.val++;
/* val == 10 */
/* obj.val == 11 */

It could easily confuse a human reader (which may be reason enough to avoid it) but the JavaScript interpreter should not confuse “obj.val” for “val”.

For what it’s worth, SpiderMonkey changes obj[“val”] to be tokenized identically to obj.val.

January 5, 2006

Here, let me put everything in the header for you.

Filed under: Uncategorized — Matthias Miller @ 7:29 pm

KeePass has a file called build/ui/ui_MainWindow.h. I’m not sure if it’s the Main window or the Main header. If I counted correctly, about 35 source files depend upon it. It’s also Big. I just got done moving three functions from ui_MainWindow.h to ui_MainWindow.cpp; that was over 4500 lines of code.

I just realized that Qt probably automatically generates this file from src/forms/ui_MainWindow.ui. When the build finally stopped, it turned out that it had only nuked the source file. That means the build failed with a link error, and I’m back to square one.

I really need to figure out what to do while this thing compiles.

January 4, 2006

KeePass for the Mac

Filed under: Macintosh — Matthias Miller @ 6:50 am

I’ve recently decided to manage my passwords using KeePass. One of the greatest things, I think, is the Linux and Macintosh port. Of course, the port doesn’t feel like a native application, but it does allow me to use the same password database on all of my computers.

I just got done compiling a working version on my iBook. Here’s what it took:

  • Download and install the Qt/Mac framework. (My iBook was busy all day Saturday; compiling Qt/Mac took about 15 hours.)
  • In .profile (if your shell is bash), add the following lines:

    QTDIR=/usr/local/Trolltech/Qt-4.1.0
    export QTDIR

    In .login (in case your shell is csh or tcsh), add the following line:

    setenv QTDIR /usr/local/Trolltech/Qt-4.1.0

  • Download the latest snapshot from subversion:

    svn co svn://svn.berlios.de/keepass/trunk

  • Open src/global.h and uncomment the appropriate little/big endian line (my iBook is big endian).
  • Apply the patch included at the bottom of this post to fix memory corruption bug on big endian processors and to correct path resolution to the share folder. The former resulted in a bus error (segmentation fault). The latter resulted in a warning: “Translation file ‘_DEUTSCH_’ could not be loaded.”
  • Run the following commands to compile and install:

    qmake
    make
    sudo make install

KeePass will be installed to:

/usr/local/bin/keepass.app/Contents/MacOS/keepass “Applications”

Enjoy!

Update: I forgot to mention a problem I had with path resolution. I have included the details above and have updated the diff below.

Update 2: With recent changes to the source, no patches need to be applied. KeePass will be installed into “Applications”.

Blog at WordPress.com.