Tuesday, May 11th, 2010
Installing PyQt 4.7.3
Abbreviated notes for installing PyQt 4.7.3 on Mac OS 10.6 (Snow Leopard). This assumes you have already downloaded and installed the Qt SDK.
cd tmp
wget http://www.riverbankcomputing.co.uk/static/Downloads/sip4/sip-4.10.2.tar.gz
untar sip-4.10.2.tar.gz
open doc/html/index.html
cd sip-4.10.2
python configure.py --arch i386 --sdk MacOSX10.4u.sdk
make
sudo make install
cd ..
rm -rf sip-4.10.2/
wget http://www.riverbankcomputing.co.uk/static/Downloads/PyQt4/PyQt-mac-gpl-4.7.3.tar.gz
untar PyQt-mac-gpl-4.7.3.tar.gz
cd PyQt-mac-gpl-4.7.3
python configure.py --use-arch i386
make
sudo make install
cd ..
rm -rf PyQt-mac-gpl-4.7.3/
Then, do a quick test.
python
>>> from PyQt4 import QtGui
>>> a = QtGui.QApplication([])
>>> w = QtGui.QWidget()
>>> w.show()
>>> w.hide()
Smile.
/developer 〆
permalink
Wednesday, February 24th, 2010
Hg Init
Hg Init: a Mercurial tutorial by Joel Spolsky is awesome. Consise, funny, clear, and true. Plus the domain name is perfect.
/developer 〆
permalink
Wednesday, February 24th, 2010
Simplicity
dive into mark asks his wife to let him replace his car with nothing. Hilarious, yet interesting how hard it can be to simplify.
/life 〆
permalink
Tuesday, February 23rd, 2010
Software Carpentry
Software Carpentry’s tag line is “Basic software development practices for scientists and engineers.” Definitely worthwhile — although I’d recommend hg or git over subversion.
/developer 〆
permalink
Tuesday, February 23rd, 2010
Best Explanation of Git and Mercurial’s Similarities
Mercurial for Git users answered many of my questions on the nuances of Mercurial. The branch model, bare repositories, and command equivalence table were especially helpful for someone like myself who has used both systems but never fully understood the distinctions.
/developer 〆
permalink
Wednesday, February 10th, 2010
TortoiseHg Usage Introduction (Mercurial on Windows)
I wanted to share a quick introduction to using a Mercurial repository on Windows with TortoiseHg. This assumes someone has already setup the repository on a shared network drive (we’ll call \\Shared\Repo\Project44) and you want to keep up do date with the changes directly in Windows Explorer.
Initial Checkout
- Download and install the latest TortoiseHg at http://bitbucket.org/tortoisehg/stable/downloads/.
- After rebooting, Right-click -> TortoiseHG -> Settings -> Global -> Commit, and set your Username to something. I’m using “Alan Brooks”.
- Right-click -> TortoiseHG -> Clone a Repository.
- Put your
\\Shared\Repo\Project44 in “Source Path”.
- Click “clone” in the upper left.
- The folder “Project44” on your hard drive is a working copy of all the latest files and also a complete copy of the entire history of the project (a.k.a. the repository in the “.hg” folder). I’ll call this folder your “local repo” for short.
Example Workflow
- Edit some code or files until you get to a point where you’d like to record a small incremental change in your local repo.
- Notice that the files/folders you’ve changed all have little red marks in Windows Explorer.
- Commit to your local repo. Right-click -> HG Commit …, select files to commit, write a checkin comment, then click Commit. This commit will be an atomic action for all the files as a group.
- Sync with the remote repo. Right-click -> TortoiseHG -> Synchronize…, click Pull to get anyone else’s changes. If there are changes, they may need merged before you push. If no changes, click Push to publish your changes to the repo.
- Look at the history. Right-click -> TortoiseHG -> View Changelog.
References
A couple of good things to read to get started with Mercurial are:
/developer 〆
permalink
Tuesday, February 2nd, 2010
Homebrew: a retake on Fink and MacPorts
The Homebrew Mac OS X package manager sounds like it might be worth a try.
/mac 〆
permalink
Saturday, January 23rd, 2010
Index Source Code with Spotlight
I was frustrated that Spotlight wasn’t indexing any of my source code. What’s the point of Great, instant, system-wide search that doesn’t look in files I care about most? What’s going on?
Thanks to the article Terminal commands for improving Spotlight on Mac OS X Tips (which, by the way is a nice tips site I never knew about) for showing me the way.
The method I used was to edit the info.plist file in RichText.mdimporter (found in /System/Library/Spotlight/), adding <string>public.python-script</string>. Then, I told Spotlight to re-index the RichText file format via:
mdimport -r /System/Library/Spotlight/RichText.mdimporter
/mac 〆
permalink
Saturday, January 23rd, 2010
PAM and launchd Interaction
While experimenting with /etc/sshd_config settings on Snow Leopard (10.6), I had disabled PAM (by setting UsePAM no). This had an unintended side effect of making launchctl behave poorly for periodic tasks I run from the ~/Library/LaunchAgents folder. I turned PAM back on (set UsePAM yes) and all was happy.
launchd must use the Pluggable Authentication Module interface as part of the mechanism that allows user agents to run.
If you see something like the following error message when trying to run launchctl commands, you may also have this problem:
Bug: launchctl.c:2325 (23930):13: (dbfd = open
(g_job_overrides_db_path, O_RDONLY | O_EXLOCK | O_CREAT,
S_IRUSR | S_IWUSR)) != -1
launch_msg(): Socket is not connected
Thanks to these threads for getting me thinking along this solution path.
/mac 〆
permalink
Saturday, January 23rd, 2010
A Style Guide and pychecker
I came across Google’s Python Style Guide and enjoyed it. It mentioned pychecker which is a nice static analysis tool for helping to find bugs in Python code.
/developer 〆
permalink
Saturday, January 23rd, 2010
grin: Easy Search of Directorys Full of Source Code
I am loving the grin tool. It’s like a find/grep mashup with good defaults. In human-speak, that means you can easily search source code on the command line with a short command.
Just go pip install grin it already (or easy_install grin if you’re old school).
/developer 〆
permalink
Saturday, January 23rd, 2010
View Python Profiles
Profiling tools are essential to understanding where to focus your attention when improving software performance. RunSnakeRun is a nice way to visualize, sort, and better understand Python profiling data.
/developer 〆
permalink
Saturday, January 23rd, 2010
Instant Ubuntu GUIs with Quickly
I like the idea of Quickly: make easy one-line commands for creating, editing, designing, running, packaging, and releasing Ubuntu GUI projects. Ars’s overview captures the gist of it well.
/developer 〆
permalink
Thursday, January 14th, 2010
Mercurial Command Line Quick Reference
There are two main ways I’ve been using Mercurial over the last couple years: on the command line and via tortoisehg (right-click) on Windows. This is a quick reference to the command-line interface. Mercurial on the command line is called “hg” (a reference to the element Mercury).
Help
>> hg % lists basic commands
>> hg help % lists all commands
>> hg help pull % gives detailed help on command "hg pull"
Where am I?
>> hg status % tell which files have been modified
>> hg st % same as hg status (you can abbrevitate
% non-ambiguous commands)
>> hg log -l 5 % log of last 5 commits
>> hg diff % current changes to your working directory
>> hg diff -c 9 % changes made by revision 9
Committing as you work
>> hg commit -m "change 1" % regular commit
>> hg add new.c % tell hg to start tracking a file
>> hg ci -m "change 2" % "ci" is short for commit (legacy)
>> hg rename new.c blue.c % rename a file (like copy + remove)
>> hg revert ---all % oops, I didn't want to rename
>> !del blue.c % del manually (stop tracking blue.c)
>> hg mv new.c red.c % "mv" is short for rename
>> hg ci -A -m "change 3" % "-A" adds/del's files, avoids
% the "hg add, hg remove" dance
Syncing with another repository
>> hg pull % grab any new changes from default repo
>> hg update % update your working directory with the changes
>> hg merge % merge new code with your code
>> hg ci -m "merge" % commit merge result
>> hg fetch % short for "hg pull, hg update, hg merge, hg ci"
>> hg push % send your changes to the default repo
Merging
>> hg heads % list the potential heads that could be merged
>> hg merge % auto-merge (specify rev with -r if >2 heads)
>> hg resolve % if auto-merge failed, retry after manual edits
Repository management
>> hg init % make a new repo in the current dir
>> hg clone C:\Repo % clone the repo to work on a branch/idea
Advanced, but nice (many require enabling extentions)
>> hg view % launches a graphical history viewer
>> hg paths % where this repo pushes and pulls from
>> hg rollback % undo the last commit (only OK if not pushed)
>> hg shelve % stash work-in-progress to fix something else
>> hg unshelve % resume your work-in-progress
>> hg rebase % move a set of commits to a new baseline
>> hg tip -p % show latest committed changes
Hope this helps. Please send me ideas for other commands that you like to use often.
/developer 〆
permalink
Sunday, January 10th, 2010
Congrats, Jessica!
I’d like to congratulate my sister, Jessica, on winning Best of Show in the Madden Arts Center Art Show. Read all about it in the Herald and Review. Well done, sis!

/life 〆
permalink
Sunday, January 10th, 2010
Is Microsoft Security Essentials Good?
Is the free anti-virus tool now available directly from Microsoft any good? Any one out there used it? Ars Technica reviewed it positively. When I need to run Windows, I’ve never loved Norton or the free AVG. I have been using ESET NOD32 lately and it is ok. But next time I set up a Windows machine, I think I’ll give Microsoft Security Essentials a try.
/mac 〆
permalink
Saturday, January 9th, 2010
Why I Like Mercurial
Mercurial is a great version control tool. I like it for the following reasons:
- distributed (you can checkin changes with no network connection)
- free, open-source
- written in Python (easy to customize with workflows)
- works well on Mac, Linux, and Windows
- TortoiseHG on Windows means non-developers at work can use it
- simple to get started with, but powerful features available
hg is the shortest and easiest name to type on the command line compared to the only credible competitors: git, svn, bzr … it doesn’t get any better than 2 adjacent letters on the home row!
/developer 〆
permalink
Saturday, January 9th, 2010
lxml.objectify == Best Python XML API
I’ve used a couple different XML parsing libraries in the past, but have always had a desire for XML to behave just like an object where accessing attributes maps directly to accessing XML children. Who would have known it — the lxml library, one of the fastest XML processors offers exactly this API, calling it lxml.objectify. I can’t wait to try it …
/developer 〆
permalink
Saturday, January 9th, 2010
Generate Microsoft Word 2007/2008 docx Files from Python Code
In some situations, it would be nice to be able to spit out an automated report as a Word document. Mike Maccana has come up with a new tool for doing just that and shared the code on github as project python-docx. I like it.
/developer 〆
permalink