Thursday, September 2, 2010

Delicious Linkrolls Not Working

I wanted to create a linkroll on my website, an embedded list of my delicious.com links. Problem was, the linkroll code they generated resulted in…nothing. No links appeared on my website using their code.

I tried manually opening the URL in the script tag, which refers to a feeds.www.delicious.com address, and the browser told me it couldn’t find the site!

On a whim I tried removing the “www” from the address, and voila. The script worked. So when you add the code to your site, change feeds.www.delicious.com to feeds.delicious.com.

I have sent a support request to Delicious about this and will update the post when I hear back from them.

Update, June 2011: I don’t know if they've fixed it yet, but after recent developments threw the future of delicious into doubt, many of us have switched to Pinboard. Their linkroll code also happens to work perfectly, you can find the javascrip widget on their resources page.

Friday, July 2, 2010

Quickly apply “Inherit Zoom” to all bookmarks in a PDF file

I often compile PDF reports totaling 1,000 to 2,000 pages, and am always creating hierarchical bookmarks for these files. One of my beefs is that often, clicking a bookmark will change the magnification setting to “fit width” from whatever you had it set at. Ideally, clicking a bookmark should default to just leaving the zoom level at whatever the reader is currently set to use (“Inherit zoom”). I’ve found no way in Acrobat to set the default behaviour for newly-created bookmarks, and changing these links one at a time in Acrobat is extremely tedious.

Thankfully, there is a solution provided by Martin Backschat:

To modify this annoyance you can directly modify the PDF document in your Text editor.

With UltraEdit, for example, I load the PDF document and open the “Search and Replace” box, enable “Regular Expressions” and replace all occurrences of “R/XYZ*]” with “R/XYZ]”, and then also all occurrences of “R/Fit*]” with “R/XYZ]”. Now safe the document.

With the Perl scripting language, this hack is applied with

perl -pe 's#R/(XYZ.*?|Fit.*?)\]#R/XYZ\]#g#' in.pdf >out.pdf

The next time you open the modified document with Acrobat you will get a message that the document is being repaired. Just safe it again with Acrobat and everything is fine.

I don’t have UltraEdit but I was able to make this work using Notepad++. The exact search/replace text was slightly different for my PDF files (note the added space) but the principle is the same:

  1. In Notead++, click the TextFX menu, then TextFX QuickFind/Replace (the standard find/replace tool will not help you here). Make sure you check the “Regular Expr” check box on the right.
  2. Use "R /XYZ(.*)]" (without quotes) as your search string and "R XYZ]" as your replace string and replace all instances.
  3. Do it again using "R /Fit(.*)]" as your search string and the same replace string as above.

Wednesday, June 16, 2010

Vector Theme not available for current version of MediaWiki

You may have noticed Wikipedia has a new interface these days. If you run your own MediaWiki website, the obvious question in your mind is, how can I get these improvements on my site too?

This information is surprisingly hard to find, but the short answer is: you can’t yet.

How can I use Wikipedia’s new skin (Vector) on my wiki?

Vector is not available in MediaWiki versions prior to 1.16, and will be made default skin in 1.17.

— buried in the MediaWiki FAQ

As of the time of this writing (June 2010), 1.16 is still in beta, and 1.17 has no planned release date. Check the MediaWiki version lifecycle for current information.

Thursday, February 18, 2010

Opening the Temporary Internet Files folder for Outlook attachments (OLK5A, for example)

One of our employees opened up a PowerPoint attachment (ugh, I know) from an email in Outlook. He then edited it extensively and saved it using the File → Save As menu command. Unfortunately he did not bother changing the folder he was saving it to, with the result that it was saved in whatever temporary folder Outlook uses for holding email file attachments. The problem is that this folder is hidden and very hard to find. Even typing in the path directly in Windows Explorer does not work. So when he closed out of PowerPoint he realized he was in danger of losing all the work he had done unless he could find and open that folder.

I found the solution here after some searching, but even that page only explains how to learn where this temporary folder is located; it does not make it clear how to actually open the file. I found how to do it though.

Open Registry Editor (Click Start → Run, type regedit and hit Enter). Browse to the following location in the registry structure, depending on the version of Outlook you use:

Outlook 97HKEY_CURRENT_USER\Software\Microsoft\Office\8.0\Outlook\Security
Outlook 98HKEY_CURRENT_USER\Software\Microsoft\Office\8.5\Outlook\Security
Outlook 2000HKEY_CURRENT_USER\Software\Microsoft\Office\9.0\Outlook\Security
Outlook 2002/XPHKEY_CURRENT_USER\Software\Microsoft\Office\10.0\Outlook\Security
Outlook 2003HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Outlook\Security
Outlook 2007HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Outlook\Security

Double click the OutlookSecureTempFolder value, and copy that value to the clipboard (i.e., select all the text, right-click and hit Copy on the popup menu).

Then go to Start → Run and paste the value in, and hit enter. An Explorer window will open showing the folder, containing probably every attachment you’ve ever opened.

Wednesday, February 17, 2010

BBM Messenger Log Cleanup Script

As mentioned previously, the CSV files produced by Blackberry Messenger 5.0+ need some cleaning up before they can be properly used. I finally wrote a short script for doing just that.

You can download the VBScript here: bbmcleaner-1.1.zip. This code is released to the public domain.

Once you have the BBM log file on your computer (email it there from your phone, again, see the last post on this subject), just drag and drop it onto this VBS file, and a “clean” version will be produced as a separate file in the same directory. The new file will have human-readable dates and the message will be properly escaped – in short, it will be something you can just open and use in Excel (e.g.).

Change Log

Version 1.1 (Feb 20, 2010)

  • Added GMTOffset constant to allow timestamps to be properly adjusted for time zones.

Friday, February 12, 2010

No internet access over wifi (the infamous "local access only" problem)

On my Windows laptop, wifi connnects easily to all wireless routers, but every once in awhile it will not allow connections all the way out to the internet. This mainly seems to happen when I switch to a new environment, such as bringing my laptop out of the home and out to a coffee shop. This first started happening to me in Vista, and the problem has persisted in Windows 7 Pro.

The problem, which you can verify by opening a command prompt and typing ipconfig, is that sometimes Windows assigns itself a bizzarro IP address instead of the one given by the DHCP service on the wifi router. This made-up IP address is usually on some odd subnet and never of course on the same one as the actual wifi network.

Here’s the (ugly) solution: Open Notepad and cut/paste in the following:

ipconfig /release
ipconfig /renew

Save it as something like wifi.bat. Save it somewhere permanent but out of the way, and put a shortcut to it somewhere handy (on your Start menu or something).

Now when you have the problem, right-click this file/shortcut and click “Run as Administrator”.1 It might take a little while, but five’ll getcha ten your problem will be all cleared up afterwards.

1 If you have UAC turned off, you can just run it the normal way.

Blackberry Messenger Logs - Timestamp Format

(Update: I've written a VBScript to convert BBM logs into something cleaner and a bit easier to read.) The newer versions of Blackberry Messenger (BBM) include an option to save chat history to your device memory or media card. I was glad to find it save chats in comma-separated value format (CSV) — or at least that the files it creates have a .csv extension — since CSV has been around for decades and is easy to read on any platform. There are a few caveats with BBM’s particular log file format, however.

To get the files off my phone, I just emailed them to myself (they’re stored on my media card under /Media Card/BlackBerry/im/BlackBerry Messenger/your_pin/history). You can open up the file in a text editor like Notepad, and you will see the messages are in the following one-per-line format:

[timestamp], "[sender PIN]", "[receiver PIN]", Message...

Example:

201002101265815660914,"8194BE13","31E12A40",Ok, heading out the door!

The format for the timestamp is a mish-mash of things: the left eight characters are the date in text format (yyyymmdd) while the rest is actually epoch time with an extra three digits added for the milliseconds. So the date part is really redundant (since epoch time includes the date) but whatever.

The other caveat here, as you can see in the example above, is that the actual message portion is not enclosed in quotes, which is unfortunate. A proper CSV file would enclose in quotes any field that may contain a comma (since commas are used to delimit fields in CSV files). Thus, if the message contains any commas, that particular record will appear “broken” to any CSV parser. I consider this to be a bug in the Blackberry Messenger software1. This could be fixed in this case by creating a script2 that cleans the file up into strict CSV form: insert a quote mark before the 45th character of every line, and another at the very end, and double all quote marks in between (that is, in the original message) — again, see the wiki article for more info on the CSV format.

1 The bug is especially weird since the PIN fields, which have no possibility of containing commas, are enclosed in quotes.

2 I will probably do this myself at some point in the future I just can’t say when. I wrote the script: you can read about it and download it in this followup post.