11 December 2013

Install Perl CPAN modules behind a firewall

I had to install additional Perl packages using CPAN on a computer behind a firewall. The hack is to install the same version of Perl on a build computer first then copy the Perl/site folder to the destination computer as described in Cloning perl/site/lib directory?.

09 December 2013

An icon called an icon

In Lotus Notes 8.5.3, some of the alternative text for icons in the mail view is useful (e.g. SameTime icons show the user's phone number and availability) but often the alternative text is the useless "icon called an icon" text such as "Paperclip Icon" for a paperclip or "Unopened yellow envelope Icon" for ... you can guess. Searching for the icon names in the Local Help results in 0 hits. Eye-rolling.

14 November 2013

Adding portable programs to Windows 7 Start menu

A tiny addenda to Raymond Chen's series of posts about how programs appear in the Windows Start menu. According to Raymond's posts, Explorer counts the number of times the program is launched to place it in the Start menu. However, Explorer doesn't add the program's icon in the Start menu if you just start an executable (e.g. a PortableApp or a not-installed program) by entering its path in the "Search programs and files" field; a workaround is to add a shortcut to the program in the desktop.

12 November 2013

Showing last modified time with seconds in Windows 7 Explorer

Windows 7 Explorer only shows the last modified time of files and folders in hours and minutes, not seconds, i.e. hh:mm instead of hh:mm:ss. If you use the Properties dialog, you can briefly see the last modified time in hh:mm:ss but if you wait longer, the text in the dialog changes to the pretty useless "n minutes ago" and then a more useless "m hours ago". If you check the file or folder properties the next day, you can see the last modified time in hh:mm:ss again! This misfeature became a problem when I wanted to check the modified time of files created seconds within each other.

The workaround is to change the Long date format in your Region and Language from dddd, d MMMM yyyy to ddd, d MMMM yyyy, which stops last modified date format from changing in the Properties dialog. Note that Windows 7 Explorer's Date Modified column never shows seconds.

Reference to self: use "HH:mm:ss" for 24-hour time format and "dd/MM/yyyy" to ensure that day of month always has two digits.

16 October 2013

Stupid LCM Error EPMIE-25014

When loading groups.csv into Hyperion Shared Services (HSS) using Lifecycle Manager (LCM), you may see these errors:

Importing Artifact - Groups.
error /Native Directory/Groups - EPMIE-25014: Failed to import all of the membership info for group [group name1].
error /Native Directory/Groups - EPMIE-25014: Failed to import all of the membership info for group [group name2].
Migration Status - Completed with failures.

Basically, LCM couldn't find the member(s) (i.e. user or another group) referenced by some groups in its directory. To find the missing member, you have to look for the common missing member in the groups reported in the errors.

This is a stupid error message because LCM must know which member is missing but doesn't include it in the error message!

02 October 2013

UTC using WMI

I wanted to get the current time in UTC (i.e. time without any offset) but there doesn't seem to be a timezone-style function in VBA / VBScript. Here's a function using WMI (Windows Management Instrumentation) to get time in UTC and a hack to pad the numbers so that they always have two digits. The output has this format: yyyy/mm/dd hh:mm:ss

'VBA References
'1. Microsoft WMI Scripting 1.2 Library

Function Utc() As String
  Dim ws As WbemScripting.SWbemServices, colItem As WbemScripting.SWbemObjectSet, objItem As WbemScripting.SWbemObject

  Set ws = GetObject("winmgmts:\\localhost\root\CIMV2")
  Set colItem = ws.ExecQuery("SELECT * FROM Win32_UTCTime")
  For Each objItem In colItem
    Utc = objItem.Year & "/" & Right("00" & objItem.Month, 2) & "/" & Right("00" & objItem.Day, 2) _
      & " " & Right("00" & objItem.Hour, 2) & ":" & Right("00" & objItem.Minute, 2) & ":" & Right("00" & objItem.Second, 2)

End Function

30 September 2013

Claiming Myki Reimbursement

Here is a procedure for quickly claiming a Myki reimbursement if you are clearly overcharged. Myki is the smartcard system used for public transport fares in Melbourne.

Assumptions: Your Myki card(s) is registered on the PTV site so that you can check your trip and charges, and you know your account PIN.

  1. Wait 48 hours after the overcharged trip before contacting the PTV service centre. (You can call the PTV earlier but the operators won't do anything until 48 hours have passed.)
  2. Ensure you know the trip details (route, time, date and stops).
  3. Ensure you know your Myki card number.
  4. Call PTV call centre on 1800 800 007 then press 1 and 6.
  5. When an operator responds, explain that you have been overcharged for some Myki trips.
  6. Give the operator your PIN to confirm your identity.
  7. Give the operator the relevant Myki card number and trip details.
  8. Let the operator confirm that your claim is valid. The operator has to check the route, stops and zones. After confirming your claim, the operator should give you a trouble ticket number for your record.
  9. PTV should send you a confirmation by e-mail within a day or two.
  10. Your Myki card should be credited when you touch on again.

27 September 2013

Vim configuration

My Vim configuration. Probably the only non-obvious thing is to use list to show whitespaces and listchars to display each tab as ">-". See Vim Wikia Highlight unwanted spaces for more information.

set guifont=Consolas:h10:cANSI
set ignorecase
set list
set listchars=tab:>-
set nobackup
set nowritebackup
set printfont=Courier:h8
set shiftwidth=2
set tabstop=2

20 September 2013

Concatenating two specific lines in sed

I wanted to concatenate specific rows of data so that I could analyse and chart them in Excel. My data had rows starting with a date and a keyword:

xyz 0.1
xyz 0.5

And the output I wanted is:

01/01/2013 xyz 0.1
02/01/2013 xyz 0.5

Below is a sed script to concatenate those two lines and ignore the others:

# Use: sed -n -f Concat.sed test.log
# H Hold <- Hold + \n + Pattern
# h Hold <- Pattern
# g Pattern = Hold
# First pattern
/..\/..\/..../ {
# Second pattern
/xyz/ {
 s/\n/ /

The "trick" is to collect the rows that I need into the hold space first then transfer it to the pattern space where the line break can be replaced by a space.

19 September 2013

Cannot read CHM file in Windows 7

If you can't read pages in a CHM (Compiled HTML) file on a Windows 7 computer, you might have to "unblock" the file. Seems to be a security feature to prevent scripts running.

  1. Show the CHM file properties.
  2. In the General tab, press the Unblock button. Note: After you do this, the button no longer appears for this file.

Thankfully, you only need to do this one time for the CHM file.

See longer write-up in StackOverflow.

13 September 2013

Portable GnuWin32

How to make GnuWin32 portable.

  1. Install all the GnuWin32 packages you require on a "build" computer. The packages are normally installed in a "GnuWin32" folder.
  2. Copy the GnuWin32 folder from your "build" computer to your portable drive or target computer.
  3. On your target computer, add the path to the GnuWin32\bin folder to your user (not system) PATH environment variable.

(Moving to portable applications to save time installing programming tools each time I have to work on another computer, especially when I don't have administrator rights.)

26 June 2013

Sed two-line match and replace using pattern and hold space

Sed is a line-oriented text processing tool, so to match and replace a two-line pattern requires accumulating lines in the hold space then testing if those lines should be changed. Today, I had a chance to use this feature to remap some Hyperion Financial Management (HFM) journal files.

HFM journal files have the following heading format. The scenario and year lines only appear once in a journal file.


The task was to remap journal files for only one scenario and year to another scenario. Below is the resulting sed script.

# x = Exchange Pattern and Hold
# H = Hold = Hold + \n + pattern
/!Scenario=/ {
/!Year=2010/ {

Not obvious: In the first rule, there is no output because the pattern space is empty. The second rule always outputs the scenario and year lines regardless of whether they have been changed.

07 June 2013

Excel workbook always prints multiple copies

We had some Excel workbooks that, by default, always printed 7 copies of each sheet. A user had to change the number of copies to 1 each time she printed a sheet and the number of copies always started at 7 after she saved and reopened the workbook. The not obvious solution was to change the printer default for the workbook. Steps below:

  1. Open the workbook in Excel.
  2. Select File, Print, Print Preview.
  3. Select Page Setup.
  4. In the Page Setup dialog, press the Options... button.
  5. In the printer setup dialog, change the field that determines the number of copies. It varies from printer to printer. For example, for HP Laserjet P3005, it is in the Advanced tab, Paper/Output, Copy Count.
  6. Press the OK button to save your change.

30 May 2013

Get Internet Explorer version using WMI StdRegProv

In Windows XP, you could get the version of Internet Explorer on a computer using the "\Applications\MicrosoftIE" namespace in this fragment of VBA: (To use this code in this article in your VBA project, include a reference to Microsoft WMI Scripting 1.2 Library.)
    Dim objSWbemLocator As SWbemLocator
    Dim objSWbemServices As SWbemServices, colSWbemObjectSet As SWbemObjectSet, objSWbemObject As SWbemObject, varValue As Variant

    Set objSWbemServices = objSWbemLocator.ConnectServer(strServer:=".", strNamespace:="\Applications\MicrosoftIE")
    Set colSWbemObjectSet = objSWbemServices.ExecQuery("Select * from MicrosoftIE_Summary")
    For objSWbemObject in colSWbemObjectSet
      Debug.Print objSWbemObject.Version
    Next objSWbemObject
The "\Applications\MicrosoftIE" namespace is not available after the introduction of Vista (and Windows 7), so the alternative is to examine the registry:
Const HKEY_LOCAL_MACHINE = &H80000002
    Dim objSWbemLocator As SWbemLocator
    Dim objSWbemServices As SWbemServices, objSWbemObject As SWbemObject, varValue As Variant

    Set objSWbemServices = objSWbemLocator.ConnectServer(strServer:=".", strNamespace:="\root\default")
    Set objSWbemObject = objSWbemServices.Get("StdRegProv")
    objSWbemObject.GetStringValue HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Internet Explorer\", "Version", varValue
    Debug.Print = varValue

16 February 2013

Google Play Music "Couldn't play the track you requested"

I made some MP3 files and uploaded to my Samsung Nexus. Google Play Music (GPMu) would find the files but when I tried to play any of them, it displayed "Couldn't play the track you requested". If I select the files individually using a file browser, I could play them with GPMu, so the file format was recognised. Clearing GPMu's cache and data did not fix the problem.

My workaround was to attach an image to each file using a media library manager then reload the files. Now GPMu can play the files.

31 January 2013

tr: extra operand

Kept getting this error when trying to delete Ctrl+Z (octal 032) from a file:

tr -d \032 file.txt
tr: extra operand `file.txt'
Only one string may be given when deleting without squeezing repeats.
Try `tr --help' for more information.

I keep forgetting that tr is expecting data from a stream not a file so the solution is to redirect the input: tr -d \032 < file.txt.