Clever Bulk Rename Trick in Windows

Stumbled into a clever way to rename a bunch of files to have the same prefix and a sequential numbered suffix… from the Windows GUI no less.

Ever want to rename a bunch of files to the same prefix, but have an incremental count after them?

From Explorer, select all the files that you want to bulk rename, right click, and select Rename.

While all of the files will be selected, only one is editable. Give the file a name, let’s pretend for the sake of discussion you typed ABC.jpg.

All of the rest of the files will be renamed ABC (1).jpg through ABC (n).jpg, where ‘n’ is the number of files minus one, since the first one doesn’t get a number.

Knowing this, you can do some clever stuff. Create one bogus file renamed to ZZZZZZZZ.TXT at the end of your list; select all the files, and bulk rename them as shown above. Then delete the bogus file, it should be the only one without a number, and you’ve just made a sequence of files.

LIBLDAP2 Not Installable

Unable to find a solution related apt-get failing on Ubuntu while trying to upgrade packages depending on the libldap2 (>= 2.1.17-1) package, I figured out what was causing the problem… additional repositories in my /etc/apt/sources.list file. Here’s what I did to finally be able to upgrade cleanly.

Warning this is a very geeky entry aimed at apt-get users of Ubuntu, readers seeking humorous content should skip this post. Remember, this is a technical blog.

If you’re still with me, then I suspect you’ve just been plagued by the message:

Depends: libldap2 (>= 2.1.17-1) but it is not installable

I’m using Ubuntu 8.04 LTS Server Hardy Heron, specifically on a 64-bit AMD system.

Normally, when I do an $ sudo apt-get update things go very smoothly, but not today. Here’s what I got.

The following packages have been kept back:
alpine dovecot-common dovecot-imapd dovecot-pop3d libpq5 postgresql-8.3 texlive-base-bin trac

The following packages have unmet dependencies:
alpine: Depends: libldap2 (>= 2.1.17-1) but it is not installable
dovecot-common: Depends: libldap2 (>= 2.1.17-1) but it is not installable
Depends: libpq4 (>= 8.1.4) but it is not installable
libpq5: Depends: libldap2 (>= 2.1.17-1) but it is not installable
postgresql-8.3: Depends: libldap2 (>= 2.1.17-1) but it is not installable
texlive-base-bin: Depends: libpoppler0c2 (>= 0.4.2) but it is not installable
trac: Depends: python-genshi (>= 0.5) but it is not going to be installed
E: Broken packages

Unfortunately, where ever I went, I didn’t find a solution. [1] [2] [3]

The ‘recommended’ solution is: $ sudo apt-get -f install
This did not work for me, nor others.

Neither did: $ sudo apt-get dist-upgrade

At this point, I went on an apt-get remove and apt-get autoremove binge. This didn’t help either.

This got me into a horrible loop, where packages sysvinit-utils, sysvinit, and initscripts needed to be installed, but could not because:
Unpacking sysvinit-utils (from …/sysvinit-utils_2.86.ds1-47~bpo40+1_amd64.deb) …

dpkg: error processing /var/cache/apt/archives/sysvinit-utils_2.86.ds1-47~bpo40+1_amd64.deb (–unpack):
trying to overwrite `/usr/share/man/man1/mesg.1.gz’, which is also in package sysvutils

I even tried manually installing packages one at a time. Didn’t work. I was even so desperate as to move the file mesg.1.gz elsewhere. That didn’t work.

Then I tried the following and things got a little better:

$ sudo apt-get clean
$ sudo apt-get autoclean
$ sudo apt-get check
$ sudo apt-get purge
$ apt-get -f upgrade

But I now had a problem where packages, specifically alpine, depended on on libdlap2, and it was telling me that it couldn’t install it, so upgrading wasn’t possible.

I made the mistake of $ sudo apt-get remove alpine, which would not let me undo that mistake by reinstalling.

My hunt brought me to libldap2-dev, but while this installed, it didn’t help alpine’s dependencies.

Even with the super-duper do-everything command, nothing helped:

$ sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get dist-upgrade -y

Then it dawned on me, perhaps some of the repositories that I added to /etc/apt/sources.list were giving conflicting dependencies. Luckily, I annotated heavily what I had ever added to this file.

There were only two things: Subversion, and Mono. Here they are. You want to comment out these lines:

## Subversion obtained from https://edge.launchpad.net/~clazzes.org/+archive
deb http://ppa.launchpad.net/clazzes.org/ubuntu hardy main
deb-src http://ppa.launchpad.net/clazzes.org/ubuntu hardy main

## Mono added by request of FogBugz installation
## http://www.fogcreek.com/FogBugz/docs/60/topics/setup/UnixGettingYourServerRead.html#deb
deb http://www.backports.org/debian etch-backports main contrib non-free

Then, I did a $ sudo apt-get updatee, followed by a $ sudo apt-get dist-upgrade, then a $ sudo apt-get dist-upgrade.

All of my problems were solved. No package dependency problems what-so-ever, and I was able to install alpine, and all the others, bringing me up to the latest and greatest.

Finally, I uncommented my sources.list file back to the way it was and tried the upgrade again. No errors. Everything was fine.

The solution was that something, and I don’t know which one, was causing conflicts. Reverting back to the virgin sources.list file state was enough to get Ubuntu happy to do the upgrades.

Unfortunately, since re-commenting the lines didn’t reintroduce the problem, I’m unable to tell you which repository caused the problem in the first place.

Aurora Feint: Recovered

For some unexplained reason, Aurora Feint would no longer start on my iPhone. Starting the game exited back to the main menu. Here’s how I restored the game and recovered my previous game play.

Aurora Feint won’t start.

I’ve been playing Aurora Feint on the iPhone, and all of the sudden, it quit working. The game, not the phone. I’d go to start it, and then get returned to the main menu. Seems other people were having a similar problem. Some were lucky to get the game working again, others lost data.

Here’s how I recovered mine, preserving game play. Your mileage may vary.

0. Back up your iPhones by syncing it with iTunes.
1. Hold down the Aurora Feint button until the icons jiggle.
2. Press the (X) delete button over the Aurora Feint icon.
3. Acknowledge that you’re deleting the game and that all game files may be lost.
4. Hold down the power button on the phone, slide to Power Off.
5. Power phone back on.
6. Immediately go into App Store, select Search, enter Aurora Feint, and Install.
7. Acknowledge dialog that you already purchased this item and want to install again.
8. Let the game download and install.
9. Again, hold down the power button on the phone, slide to Power Off.
10. Power phone back on. For me the phone went through a very long boot cycle with the Apple logo.
11. Press the Aurora Feint icon to start the game.
12. For me, the screen went blank and stayed there — tap the center of the screen, movie controls appeared.
13. Unpause movie intro and let play to completion.
14. After a moment, I was returned to the map.

I’ve found that I always have the best of luck restoring the game when I’m at the map. Exiting while at the character page or in the middle of a mining activity does work, but not always; this causes the game to be fussy and exit prematurely to the main screen after start (unless you can intercept with a tap in the upper right corner).

Good luck.

Hibernate Schema Update Problems

For a while I’ve been having problems trying to get a SchemaUpdate working with Hibernate. Turns out the problem was me, not Hibernate. Newly created tables had a blank ACL, and I just needed to set them.

I’ve been using Hibernate for relational persistence for a while now, and I have to say it’s been working out pretty well.

That was, until I went to do a SchemaUpdate.

The moment I did an alternation of a table, or created a new entity, things went sour, and I was unable to read my old data. Was it me, or was it Hibernate?

could not initialize a collection
PSQLException: ERROR: permission denied for relation newtablejustadded

It was me.

Turns out Hibernate’s update was working just fine. There was no magic versioning or class hashing going on, detecting the change to the database.

The problem was the ACL was blank for the newly created entity table (I was using Postgres).

By issuing this command, all was fine again:

GRANT INSERT, SELECT, UPDATE, DELETE, REFERENCES ON newtable TO GROUP agroupIwasusing;

Since it took a while to figure out what was going on, I thought I’d post this to help others that follow a similar, yet frustrating, path.

Macbook Pro Screen Goes Dark on Wakeup

My MacBook Pro should have woken up when I lifted the lid, but all was dark. However, while checking the battery level, I noticed it had woken up. The problem was the backlight wasn’t coming on. Here’s the solution. It isn’t the brightness button either.

Today I learned that there’s a nifty little utility called Maintenance 3.8 out on Apple’s site. You can find it by going to Apple / Mac OS X Software…, and when the web page pops up, type Maintenance in the search box.

It’s an automator script to repair permissions, verify preferences, updating prebindings, do cleanup, update databased, rebuild indexes, empty Trash, and so forth. My guess is it’s much like Onyx.

Deciding to give it a try, I downloaded it, opened the .DMG file, and double clicked the automator icon, selecting Restart when done. And while I got a very little in the confirmation department that things were working, I saw a lot of CPU activity running utilities I was familiar with.

So, with the laptop plugged in, I left to to chug away. I heard the restart sound several minutes later. And, I ignored it.

Later, I picked up my laptop and went to login.

Nothing.

The “breathing LED” on the front was off, and nothing was responding keyboard or mouse wise. The screen was black.

So, I decided to check the battery. Full power.

But then I noticed something. At the steep angle, in the near pitch black of my LCD screen, I saw the login window. What was happening: the backlight wasn’t coming on. Fiddling with the brightness control didn’t help either.

Sure enough, I could make out the cursor once I located where it was.

I tried opening and closing the lid. Nope. Backlight still off.

So, I restarted (as I mentioned, it was operational, I could barely make out the GUI).

The machine sprang to life, showed me the blue background, and right before it went to the login screen, the backlight cut out again, leaving me in pitch black.

Titling the screen back again (with the keyboard sticking up in the air and the screen flat on the table), again I could make out the login box and mouse. I did a restart again.

This time I held down Command-V as it booted. And I watched as it came up, lots of normal diagnostic messages, and then the blue background, and right as the login screen appeared, back to pitch black.

Annoying. But now I’m wondering if all the times I’ve ever woken my laptop after a case where the lid didn’t quite clasp perfectly, was this what was happening — could the machine be up, but the backlight off?

So, one last time, I restarted. Only I held down Command-Option-P-R (four fingers) to reset the power management settings. Several chimes later, I let go, and the machine booted perfectly, and the login box appeared, backlight and all.

I’m hoping that my experience may lead to an additional piece of the puzzle about the Mac waking up funny. I would have never have noticed anything on the screen if I looked at it dead on, as I always do.

It’s fairly well known that if you close the Mac’s lid, but down engage it fully, the lid will pop back up, but not after putting the machine to sleep. At that point, it becomes a little dance with the lid, trying to get the lid back down, so that the machine can see it re-open, and that usually wakes it. But sometimes the screen is still dark, and you have to play with the power button (and if frustrated, hold it down to restart).

Sometimes this same problem manifests when you wake the machine, enter your password, and suddenly everything goes dark. You wiggle the cursor and hit the keys and nothing happens. Caps Lock toggles, but it feels like it’s gone back to sleep.

Well no more. From now on, I’m going to tilt my screen back and see if I’m operational. That way I won’t lose data from an unnecessary restart.

Firefox Slow Page Load – Solved

Firefox 3 slow? 20 second page load times? Figured out why. And how to fix it.

A co-worker showed me an interesting problem with Firefox today. He loaded a page from our application (running on localhost) and the page content loaded instantly, but the page load itself didn’t end until a time out 20 seconds later. Literally.

Everything we saw a measured from the browser or from the sending application showed that the content was sent in milliseconds, and the page load was just sitting there doing nothing. We were even using the latest Firefox beta.

Other browsers had no such problem.

Turns out, we figured out what was going on using the Tamper Data add-on.

Turns out there was a Connection: keep-alive in the header. When we changed it from keep-alive to close, the browser behaved as expected. That is, it loaded the page instantly.

A little web investigation showed that when you use the keep-alive attribute, you must also use Content-Length: header, which the sending application wasn’t doing.

A quick application tweak to send the content length, and everything ran super spiffy.

Now, if you don’t have access to the application that’s sending you web pages, you can twiddle with the about:config and change the network.http.keep-alive setting to false.

SQLite Functions

I was trying to figure out how to display an integer as a date and time in SQLite3. And it’s documented, and documented very, very well. Problem is, so is the code base, so when I looked for time conversion functions for SQLite, even browsing the Wiki, I kept getting the developer pages, not the SQL core functions. But, I found them. And now I’m documenting where so I can get to them at a later date.

Seems silly, but I’ve been using SQLite and was having the darnedest time try to convert an integer into a time. Problem was, I knew the functions for Sqlite3 had to be out there, but all I kept getting from search engines and exploring the developer Wiki were the C/C++ API functions, not the ones needed for SQL. I guess the way the pages are indexed, the source pages score higher than the user manual pages.

Anyhow, located the SQL functions and wanted to document their location for myself so I could locate them again later.

Seems they are called Core Functions.

They hide under the language expression page, which is under the SQL language page.

I was thrilled to find that the SQLite C Interface allowed the creation of your own functions. Brilliant!

Turns out, that the date and time functions were hiding in a different part on the Wiki.

The magic I wanted, given a time stored in an integer, was:
SELECT datetime(timevalue, 'unixepoch', 'localtime');

iChat Problems: Fixed

Got Leopard? Find that iChat isn’t working? Do you run Parallels? Guess what, that may be it. What? You’re not running Parallels at the same time you iChat? Not relevant, Parallels has network services active even if the client isn’t. Here’s the workaround to get you chatting…

iChat and Parallels
While trying to iChat using Leopard to a system running Tiger, I ran into a problems that I never had using OS X 10.4 before: bad video quality to downright refusing to connect.

With a little research, I ran across this article and that was enough to resolve the problem.

Here’s how to get iChat working on OS X 10.5
…if you’re running Parallels.

See, turns out that Parallels, I’m using 3.0 Build 5582 (Dec 5, 2007), appears to be running some services, even when the virtual machine is active, that gets in the way of iChat.

Get out of iChat.

Go to Apple / System Preferences…, select Network, and click on Parallels NAT and change the Configure drop down to Off; then go to Parallels Host-Guest an change the Configure drop down to Off. Press Apply.

Get back into iChat and try again. For me, it instantly fixed the problem.

Reasonable Trial Durations: 30/30/30

I’ve come up with a way for trial software to be fair and recover lost sales opportunities. The secret: 30/30/30.

30/30/30While doing Java development, I was looking for a new IDE for Windows. Naturally, my hunt ended with IntelliJ, with Eclipse and NetBeans close on its heels.

What started the whole chain of thought for me, though, was IntelliJ’s trial period. Frankly, I really respect a company that has enough faith in their products that they let you use them, unencumbered, for a month in order to make an informed purchasing decision.

Oddly enough, though, it wasn’t enough. Allow me to explain.

The purpose behind a trial period is to allow end users to “log enough flight time” with the product that they know whether or not it meets their needs.

And here’s the problem. I have an existing code base of inter-related projects that I need to import into the IDE. And, since this is for work, my schedule is fairly swamped. I can only come up for air to do an evaluation once every week or two just for an hour or so.

What inevitably happens is this: I install the software, validate it installs, then a week or so later, I try to import; it fails, so I table the project until I have more time. A week or two goes by, and I try again, getting closer. Then, when I come up for air and try to get a bit further, the evaluation period is over. I’ve realistically had about less than three hours using the software, and none of it in the IDE writing code.

This happened to me last year as well.

And, what’s the natural conclusion at this point? I don’t know if it will meet my needs or not. Thus, a purchase doesn’t happen.

From marketing’s perspective, they think that the following scenario is the norm: a user downloads the project, tries creating a project, slings a bit of code, gets married to the IDE, and is willing to pay to keep the experience. In fact, I’ve done just this, and I really love IntelliJ.

But, no matter how much love I have for the product, if I can’t move our corporate applications into it from an existing source base, I can’t justify the site-wide purchase. End of story.

Oh sure, I could talk with the kind folks at JetBrains and ask for an extension, and I’m sure they’d give me one.

But that isn’t the point.

Being a software provider myself, I see this as a generic problem. What if I want to produce trial software that’s fair. I can’t have my customers not being able to make a well informed decision for running out of time.

Here’s my solution… 30 days, 30 invocations, 30 hours – Whichever Comes Last

Here’s how it works:

  • You’re guaranteed at least a month of physical time.
  • You’re guaranteed at least 30 invocations.
  • You’re guaranteed at least 30 hours.
  • When all three of the above goals are hit, stop the trial.

Implementing this isn’t be hard at all. It’s also quite fair and balanced.

If you are doing real work, making use of the application for 30 days, then you’re going to quickly chew through the 30 invocations and 30 hours.

If you have just haven’t even tried the software enough, you get 30 attempts.

Finally, the 30 hour rule recognizes if you haven’t had time to actually experience the software.

I’d like to see vendors start taking this approach. It’s a good one, too. It would certainly result in more sales.

Vista DeFrag Sucks

Vista’s Disk Defrag leave a lot to be desired. Here’s how to you can defrag your disk for sure.

Well before Vista was even real, I wrote about the problematic issues, bad practices for customers, and locked in formats that would make Apple Mac a highly attractive option. Pretty much most of the things people said couldn’t or wouldn’t happen have. It’s no wonder that the US Government would rather keep XP than move to Vista, that students on college campuses are reporting terrible problems interfacing with the IT departments and campus infrastructure, and that even Office formats are in dispute.

Even in our own offices, Vista has been one disaster after another, causing us all kinds of heart ache and productivity loss.

We thought the nightmare was over when we found a clever hack to make Vista think our networked HP LaserJet was a local printer (and we’d given up on being able to even use sound). However, we’ve been getting terrible disk performance on a laptop with Vista installed. Turns out the drive is badly fragmented.

Obviously, an XP user would simply run Disk Defrag and let that be that.

Not so with Vista. Sure, it has the program, but it provides no indicator of how much work needs to be done, and no visual interface at all about what’s being done. All you get is a stupid message that says the operation could take minutes to hours to complete.

So, we let Vista run overnight. And performance didn’t improve. At all.

You’ve got to see the conversation over on the Microsoft Developer Network about Vista’s defrager.

It seems that Microsoft expects you to leave your machine running all the time, and at some time like 2am on Wednesday, it will run the defrag automatically for you. Whether you want it to or not. And it will do the same crappy job.

If you’re running an enterprise service, you do not want to take an I/O channel hit “just because.” If you’re an IT administrator, you don’t want to screw with scheduling. If you’re a laptop user, you don’t want to leave your machine running.

Now I know I said I wasn’t going to give Microsoft support anymore. But I occasionally will share tips.

Grab the free version of Auslogic’s Disk Defrag. It will impress you. It’s clean, crisp, visual, astoundingly fast, and most importantly: it solved our fragmentation problems.