Blogging From My Droid

Yes it’s possible to write a blog post on an Android phone using WordPress for Android.  Why anyone would want to write a post on the Droid’s clunky keyboard is an excellent question.  I suppose if there is something you just can’t wait to write about, and it’s short… 

Posted in Computers & Software | Leave a comment

Emacs Word Wrap Modes

I had problems sending posts to WordPress from weblogger on Emacs because of formatting errors. I have been using auto-fill-mode in Emacs to avoid lines extending off the screen. Auto-fill-mode works by inserting newline characters (ASCII 0A, C-j) at the end of each line. Turning off auto-fill-mode does not eliminate these characters. If you want to see for yourself, use auto-fill-mode to write something and then use hexl-mode to examine the buffer. You will see that instead of spaces between some words there are little periods, which are linefeed characters. You can also use whitespace-mode to see the same thing. The linefeed characters in this mode are dollar signs ($). Anyway, these characters completely mess up the formatting in WordPress, leaving you with a ragged right margin, and lines split in odd places. If you don’t use auto-fill-mode, all is well, but don’t try using it and then turning it off. The newlines are there to stay. You can remove them by search and replace (M-%), searching for linefeeds (use C-q C-j to enter a linefeed) and replacing with spaces. Unfortunately this also deletes legitimate paragraph splits. So I read about and started using longlines-mode. This mode inserts the linefeeds, but also removes them again when you toggle it off. Again you can demonstrate this effect by using whitespace-mode. Seems like just what you need to make text look better without causing permanent changes to your text file, and perfect for weblogger-mode.

Then I read about visual-line-mode. It seems to do the same thing as longline-mode, except it doesn’t insert the linefeeds into the text. It just wraps the text on the screen somehow without putting in the linefeeds. You can see what it does again by using whitespace-mode. So, that’s a wrap!

Posted in Computers & Software | 1 Comment

The C++ Way. Part 0.

I’ve decided to write a series of posts on what I call “The C++ Way” analogous to “The Ruby Way,” a book and philosophy of the Ruby Language. After programming in C++ for years, I still struggle to think in C++. I constantly ask myself “what would Bjarne (Stroustroup) do (WWBD)?” when attacking a programming problem. This struggle to become one with the language — to understand the Zen of C++ — is a rite of passage that all C++ programmers must go through. C++ is a colossus of a language, built upon an ancient foundation (The C Programming Language), atop which feature is piled upon feature, resulting in an architectural nightmare akin to the Dark Tower of Barad-Dur in the Lord of the Rings. Its roots in the C Language result in a language that is “close to the medal,” in which pointers are actual machine memory addresses, in which you can shift and test individual bits in a machine word, in which you have to micro-manage your computer’s memory, so that you don’t end up with a memory leak or worse yet delete a pointer twice and bring on Armageddon. Its syntax is terse, to say the least, stemming from the days of clattering teletypes when it was worth naming the Unix command to unmount a disk “umount,” — the missing letter adding up over time to a savings of ink, paper, and sanity from the resultant slight reduction in teletype clattering. On top of this risky, high-level assembler base language is added support for classes and objects, albeit with so-called private members left hanging out fully exposed in public header files, much like the neighbor’s laundry hung out to dry (not the metaphor you were expecting?). The object oriented programming support is very good, including polymorphism, friend functions, pure virtual classes, public, protected and private inheritance, operator overloading, etc., etc. As every function and class needs to be declared before it is used, C++ code is divided between header files containing these declarations, and source files containing definitions. Header files can only be included once per program, forcing the programmer to use #ifdef and #define statements from the C preprocessor (thus using macros which are deprecated by the authorities for any other situation, but mandatory in this setting) to basically hack around a language limitation. Then there is support for another programming paradigm, generic programming, which seems to be the complete opposite to the OOP approach. Generic programming is implemented with templates, and allows the same code to be used with different types, as long as the types support the functions used in the template code. But templates can be used to create classes as well as functions, and these template classes can be polymorphic as well…. It’s certainly enough to create headaches, as well as providing source material for countless C++ programming books. Add in exceptions, namespaces, the Standard Template Library, and the rest of the kitchen sink, and you end up either appreciating the incredible subtlety of the language, or get tired of it all and program in Python.

Posted in Computers & Software | Leave a comment

Lose The Loose

Most commonly misused word on the Internet? Not your vs you’re, not its vs it’s, it’s …. loose for lose.

Posted in Language | Leave a comment

Testing Emacs Weblogger Mode

I installed WebloggerMode into Emacs 23.1 and am testing it out. Yes,
right here, live! Typing text into Emacs, even some simple
HTML is much faster and more fun than typing into the
Wordpress text editor. I’ve got all my memorized shortcuts in Emacs to
create my text. Supposedly I can post and publish my entry straight
into my blog site with a few simple keystrokes. I don’t know. I haven’t
tried it yet, but if you are reading this presumably it worked. So this
is just a short testing post; hopefully more will follow from Emacs.

Well, here I am back in the WordPress editor box. My Weblogger post posted fine, only problem was it got assigned to the uncategorized category. Haven’t figured out how to set categories in Weblogger — yet. Otherwise, pretty cool Emacs mode.

Posted in Computers & Software | Leave a comment

What’s Happened To The Bookstores?

If you are a bookstore aficionado you can’t have avoided noticing how they have deteriorated over the last ten years. Fewer books, less variety, more open spaces and chairs, fewer people, most of whom are there to drink coffee and work on their laptops using free Wifi connections — it’s hard to pin it down exactly, but the bookstores today are just not as good as they used to be. Are they going the way of video stores (e.g. Blockbuster which is dying) or CD stores (e.g. Tower Records, already deceased)? I can make a quick judgment of the quality of a bookstore by two tests: how many different Thomas Hardy books they stock and how large their computer book section is. At the Borders near Park Meadows Mall outside of Denver back in the 1990′s every Thomas Hardy book, even the obscure ones, from Desperate Remedies to The Hand of Ethelbertha, was there, alongside the more common Tess of the D’Urbervilles and The Return of the Native, in multiple editions (Penguin, Oxford, others). Nowadays, you’ll find a handful of the latter famous books, in some generic Barnes and Noble edition (Hardy wrote several versions of his books — the Penguin editions contain his first version and the Oxford edition his last, so the edition is important) and none of the more obscure novels. I don’t think there is anything unique about Thomas Hardy books, the same thing is true if you look at Charlotte Bronte (where is a copy of The Professor?), or Thackerary (you might find Vanity Fair, but good luck finding Pendennis), and so forth. The thinning out of the Thomas Hardy selection over time is just a symptom of the general malaise that is afflicting bookstores, gradually sapping them of their strength. The other barometer is the size of the computer book section. Back in the 90′s the computer book section at the above mentioned Borders took up a whole corner of the building. There was shelf after shelf of computer books, whole walls just devoted to C++ books alone. Nowadays at the downtown Borders in Louisville, KY there is one side of one shelf with computer books. That’s it. As for the huge Borders near Park Meadows Mall outside of Denver — it’s closed. Out of Business. Very sad.

Of course it’s all due to economics, to electronic book readers, to the iPad, to the Internet, to Amazon.com, and so forth. And it’s good for the trees. True enough. But I fear the downfall of the traditional bookstore is also due to fewer people reading books, to a general lack of interest in books and reading — in short to illiteracy. I could have written a post “What’s Happened To The Libraries?” to make the same point. Libraries have become a place for free Internet access, much like Starbucks without the coffee. The books are still there, but are ignored. Oh I know there are still plenty of book lovers out there. But we are a dying breed. I remember with great joy going to the Universal Books Store on 5th Street in Philadelphia as a teen and seeing the newly minted glossy covers of the Ace and Ballentine editions of Edgar Rice Burroughs books, or even more special, going downtown to Leary’s Bookstore, where I purchased the Ace book edition of The Fellowship of the Ring when it first came out in the 1960′s. Sure, now I can get any book I want on Amazon — in some ways it is better for a book lover nowadays then back when I was growing up. But I miss the browsing experience, the thrill of discovery, the impulse purchase that opens up a new author and new literary world at a bookstore, and am saddened to see this change.

Posted in Books, Computers & Software, Language | Leave a comment

Singleton Madness

I’ve been spending the last few weeks trying to exorcise a pesky singleton class from EP Simulator. This is the Options class, which contains all the program options that are saved from session to session. There is only one set of Options, so I had naively made the class a singleton. Singletons being what they are, the class soon started infiltrating many other classes, sitting there as a hidden dependency, rendering classes untestable, and generally causing trouble. Having read such posts as Singleton Considered Stupid I realized the error of my ways and I have been diligently trying to exterminate the nasty thing. It’s not easy! The concept behind a singleton seems worthwhile: you only want one instance of the object. So what do you do instead of making a singleton? Just create one instance of the object! Make sure you just are using the same instance throughout your program and it can be an ordinary class, which you can then subclass to create mock classes for unit testing, and which you just pass around as needed to your objects, making the dependency explicit. Don’t hide dependencies in singletons! My advice: if you have singletons mixed into your code, the sooner you remove them, the better. Right now I am tearing the code apart to eliminate the nasty singleton, breaking code right and left, but I know the results will be worth it, eventually.

Posted in Computers & Software, Electrophysiology | Leave a comment

Emacs Tip of the Month

Want real shell mode in Emacs? Using M-x shell only gives terminal emulation, which sometimes doesn’t display things correctly and which, since it supports all Emacs key bindings, makes you do things like use M-p instead of C-p to bring up previous commands in the command buffer ring. Most of the time Shell mode is fine and actually preferable, but if you need a true terminal/shell mode, use M-x term. In this mode it at first appears none of the usual Emacs key-bindings work — How do you change windows?? The secret is to use C-c instead of C-x as your command prefix, e.g. use C-c o instead of C-x o to change windows. To use the M-x commands or any other command, just precede the command with C-c. Thus use C-c M-x compile instead of just M-x compile. Try it. You’ll like it. (Hey I know this is too simple for Emacs gurus with megabyte long .emacs configuration files, but not all of us know these tricks, not even some long time users).

Posted in Computers & Software | Leave a comment

EP Studios Projects Update

Here’s a rundown of current activity at the EP Studios mothership:

EP Office

EP Office is the flagship project of EP Studios. Version 1.7 is out and basically is the culmination of the original software, which started out as a Microsoft Access version 2 database way back in 1995. It is proprietary software, but very cheap as such things go (less than $100 for the multi-user version). It is basically a Microsoft Office add-on, and as such is tied inextricably to Microsoft Windows. Version 2 of EP Office is a complete rewrite from the ground up, utilizing all the lessons learned from the original program, as well as new perspectives gleaned from my moving from academics to private practice. Version 2 is hosted an a Ruby on Rails platform, is open-source software, and completely web/browser based. Right now the database schema is being designed. As we go along we will upload the program as a demo to the Heroku website.

EP Simulator

EP Simulator despite several years of off and on again work remains in a very alpha-like stage of development. Basically we are trying to work on the Navigator functions first, which have to do with file organization. We are in the process of rewriting the data processing to use a database backbone such as SQLite and MySql. The hard part of EP Simulator, i.e. the actual simulation of arrhythmias, is still somewhat far in the future…

Clickit

We are working on a gui frontend to configure Clickit scripts using Tkinter and Python. This should allow easy customization of number of clicks, time between clicks, etc.

MorbidMeter

MorbidMeter also deserves a gui frontend. We would also like to port it to Android, although that will mean rewriting the program in Java. It’s a small and simple program however and this shouldn’t be too hard.

We have some other projects in mind. Stay tuned.

Posted in Computers & Software, Electrophysiology | Leave a comment

Stupid Bug

Having just spent the last several hours chasing down a weird bug, there is a sense of anticlimax having finally figured it out.  I have to say the debugger was less than useless in this matter: various functions mysteriously were not working, although identical code seemed to work elsewhere, variables were listed as “not in scope” when they clearly had to be … it was just weird!  Since Qt C++ is not really C++, that is, the language is extended, mostly by using evil MACROS, I was half-convinced there was some bug in the Qt meta-compiler that I would never in a million years solve.  Then I was thinking I should be using a mutable iterator instead of a plain one, then I was sure that something was wrong with my copy constructors, then that some global scope library variable was hiding my variable or vice versa, around and around it went.  I actually found a few other bugs in trying to fix this, but the ultimate problem eluded me for hours.  Until…

There it was, staring me in the face all along:

while (iter.hasNext());
    names << iter.next().name();

Unbelievably, a misplaced semicolon at the end of the while() line was causing all the trouble. Sometimes (maybe more than sometimes) C++ can drive you crazy, as much as I love it. It certainly is making me appreciate "cleaner" higher level languages like Python and Ruby.

Posted in Computers & Software | Leave a comment