How to run PowerShell scripts from Far Manager

Let’s say you use Far Manager and want to launch PowerShell script. With default installation pressing Enter on PowerShell script in Far Manager will open the script in Notepad. Not very helpful.

Here’s how to configure Far Manager to launch PowerShell script by pressing Enter key:

  1. Open Commands menu, select File associations.
  2. Press Ins key to add new association.
  3. Enter *.ps1 as file mask.
  4. Enter the following as execute command:
    powershell.exe -file "!.!"

Bonus: how to change colour of PowerShell scripts to green:

  1. Open Options menu, select Files highlighting.
  2. Locate *.exe,*.com,*.bat entry, press Enter to edit.
  3. Add *.ps1 to the list, select Ok to save.

See also: Running Windows PowerShell Scripts

Update: there is an enhancement that allows passing arguments to the script and launch script in a separate window.

I Want to Start My Own Business

Hi, my name is Pavel and I want to quit my day job.

Where am I now

At the moment I’m working full time as software developer.

Where do I want to go

I have had an idea of starting my own business for quite some time. I decided to build my business on the side. I’m going to work on it part-time. My goal is to grow my business to the level where it could support me and my family. At that stage I’ll be able to quit my day job.

I have a lot of distance to cover. I need at least $5,000 per month to quit my day job:

  • $1,900 – home mortgage
  • $2,000 – living expenses (food, electricity, gas etc)
  • $1,000 – just in case (buffer)

Fortunately we don’t have any credit card debt.

I definitely don’t want to take any investments. I want to bootstrap my way up. My business should pay for itself.

I will post updates about my actions here, on this blog. Hopefully this will prevent somebody from making the same stupid mistakes as I do.

With this blog I’ll try to answer this question: “Is it possible to start home-based business on the side, without quitting day job?”.

Onward!

How to insert new GUID with one key press

When I work with WiX source code I need to create lots of GUIDs. In my Visual Studio 2005 editor all I need to do is to press Alt+G and new GUID magically appears at the cursor. Achieving this is very easy:

  1. Open Macros IDE by selecting Tools | Macros | Macros IDE.
  2. Create new macro:
  3. Public Sub InsertGuid()

    DTE.ActiveDocument.Selection.Text = Guid.NewGuid().ToString()

    End Sub

  4. Bind new macro to Alt+G keyboard shortcut. Open Options dialog, select Environment, then Keyboard on the left. Type “InsertGuid” to locate the macro you just created. Assign Alt+G to it.

    Fortunately, no standard command is assigned to Alt+G by default.

How to enable links in Windows Messenger 5.1

I use classic Windows Messenger. The latest Windows Live Messenger (version 2008) is way too fancy for me. Compare:

I don’t like anything moving on the screen and I don’t like screen space to be wasted.

The only problem with classic Windows Messenger 5.1 (you can download it here) is that links are non-clickable. They are blue, when you type them (http://www.google.com) but they become black in the main chat window:

messenger-no-links.gif

To fix this problem, open regedit and create HKLM\Software\Policies\Microsoft\Messenger\Client key (it might be already there). Create DWORD value EnableURL under that key. Set it to 1. Restart Windows Messenger.

How to find address in Melway quickly

Sometimes I need find address on Melway site. Most of the time, I already have address in electronic form. I don’t need to type, just copy and paste.

The problem is I need to enter address parts separately on Melways site: street number, street name and suburb:

melway.gif

For example, if I have 235 Russell St Melbourne I need to copy and paste 235 first (click-Ctrl+C-switch-click-Ctrl+V), then Russell St (switch-click-Ctrl+C-switch-click-Ctrl+V) and finally Melbourne (switch-click-Ctrl+C-switch-click-Ctrl+V-down-down-Enter).

If I can save 30 seconds of my time why not to do it? Introducing:

Melway address lookup

It has just one field for address. Now all I need to do is to copy address (click-Ctrl+C), paste it (switch-click-Ctrl+V) and press Ctrl+Enter. Done.

How to turn off animations in Firefox

I can’t bear having something moving on a web page. It just distracts my attention while I’m reading. Here’s how to disable most of animations in Firefox:

  1. Open about:config page, set image.animation_mode to none. This will disable gif animation.
  2. Disable blinking. On about:config page, set browser.blink_allowed to false. Now <blink> tag doesn’t blink anymore.
  3. Disable Flash but not completely. Flash animations seldom carry useful information but most often are used for ads. I installed Adblock and added .swf to filter list. If some site doesn’t work without Flash I add it to white list.
  4. Some sites use JavaScript to display animation. For example: xe.com. In these cases NoScript extension might help but more and more sites now rely heavily on Ajax and hence on JavaScript so it’s too much trouble to white-list sites as you surf the Web.

How I configure Windows XP

Here’s how I configure Windows XP:

  1. Remove Internet and E-mail from Start menu. Right click on Start menu, select Properties | Start Menu tab | click Customize button, uncheck Internet and E-mail. I use keyboard to start web browser and email client.
  2. In Customize Start Menu dialog select Advanced tab. Turn off My Music, My Network Places, My Pictures, Set Program Access and Defaults. I use Far Manager for file navigation so these items just clutter start menu.
  3. Add Administrator to Welcome screen. In Registry Editor, open
    HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\UserList. Create DWORD entry Administrator, set value 1. Normally I’m running as normal user; to install new programs I log in as Administrator.
  4. Turn off search with the dog. Open Explorer, click Search button. Select Turn off animated character. Whee! The dog is gone.
    dog.jpg
    Click Change Preferences, then Change files and folders search behavior. Select Advanced and click OK.
  5. Use Windows classic folders. Common tasks pane is too fancy for me.
  6. Set List view as default mode in Explorer. Select View | List menu. Then go to Tools | Folder Options | View tab and click “Apply to All Folders” button.
  7. Set advanced Explorer settings:
    • Display the contents of system folders – on
    • Hide extensions for known file types – off
    • Use simple file sharing (Recommended) – off. I know how to share folders, thank you very much.

How I configure Far Manager

far.gif

Far Manager is console-based file manager. I like it very much. Here’s how I configure it to get the maximum out of it:

  1. Set raster font, 10 x 18. Set window size 80 x 26. Turn off selection with mouse (QuickEdit mode).
  2. Turn on “Clear R/O attribute from CD files”: go to Options | System Settings. I never need files to be read-only when I copy them from CD or DVD to hard drive.
  3. Turn on displaying hidden ($) shares: Options | Plugins configuration | Network browser | Show hidden shares. Now I can type net:computername and see C$, D$, etc.
  4. Options | Confirmations. Turn off confirmations for:
    • Delete non-empty folders
    • Exit
  5. Copy these command line archivers to C:\Program Files\Far folder:
    • pkzipc.exe
    • rar.exe
    • MsCab.exe
    • tar.exe

    Unfortunately Far Manager is not bundled with any archiver so you need to get them manually, from various web sites. Update: see below.

  6. Options | Panel Settings | turn on “Select folders”. This allows using NumPad Star to select folders.
  7. Go to Options | Interface Settings. Turn off “Clock in panels”. I already have a clock in lower right corner. There is no need for extra clock.Turn on “Show total copy progress indicator”. Otherwise I have absolutely no clue when operation is going to finish when I have lots of files to copy.
  8. Go to Options | Editor Settings. Check “Del removes blocks”. Set tab size to 3. Default 8 is way to much.
  9. Switch to Wide Mode. Press Left Ctrl + 4. I prefer this mode because I can see long file names and file sizes. Go to Options | File panel modes | Wide mode. Set Column Types to N,SC and Status line column types to NR,SC,D,T. This adds comma to file sizes:
    far-delimeters.gif
  10. Install EMenu plugin. Go to C:\Program Files\Far\Plugins\EMenu folder and execute Hotkey.reg. Now I can press Context Menu key to get Explorer menu for selected file or folder.
  11. Can you read gray text on green background? I can’t.
    far-grey.gif
    Go to Options | Colors | Dialogs | Unchanged text input. Set Foreground to black.

Update: Download pkzipc.exe, Rar.exe, MsCab.exe, gzip32.exe and tar.exe:
far_archivers.zip
Extract far_archivers.zip to C:\Program Files\Far folder.

March 2008 AusPost rates

New Post Charges Booklet is online on Australia Post web site.

Oddly enough, postage rates for parcels inside Australia didn’t change at all.

International rates have increased by about 3%. It used to cost you $58.50 to send 2 kg parcel to United Kingdom by Air Mail before. Now it costs $60.35.

Summary

Local rates didn’t change. International rates increased insignificantly.

How to automate Adobe InDesign CS3

1. Locate Resources for Visual Basic.tlb in C:\Documents and Settings\All Users\Application Data\Adobe\InDesign\Version 5.0\Scripting Support\5.0 folder.

2. Open command prompt and execute:

TlbImp.exe "Resources for Visual Basic.tlb" /out:Interop.InDesign.dll

TlbImp.exe is located in C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin folder on my machine. This will generate Interop.InDesign.dll file. This is an interop assembly.

3. Add reference to Interop.InDesign.dll to your project.

4. Use this code:

using System;
using InDesign;

namespace HelloInDesign
{
   class Program
   {
      static void Main(string[] args)
      {
         object missing = Type.Missing;
         Type type = Type.GetTypeFromProgID("InDesign.Application.CS3");
         if (type == null)
         {
            throw new Exception("Adobe InDesign CS3 is not installed");
         }
         _Application app = (_Application)Activator.CreateInstance(type);
         Document document = (Document)app.Documents.Add(true, missing);
         Page page = (Page)document.Pages[1];
         TextFrame textFrame = page.TextFrames.Add(missing,
            idLocationOptions.idUnknown, missing);
         textFrame.GeometricBounds = new string[] { "6p", "6p", "24p", "24p" };
         textFrame.Contents = "Hello from .Net!";
      }
   }
}