Monthly Archives: September 2008

Foggy Day in Seattle

I was having lunch at Cisco’s cafeteria and noticed how the fog engulfed the top of the buildings, so I capture that image using my trusty Sony Ericsson w810i phone, fixed it up with iPhoto and voila! Instant vintage.

 

Foggy Day in Seattle

Foggy Day in Seattle

Advertisements

Morning Moon

I took this photo using my good old Sony Ericsson w801i phone while waiting for the bus at the Ash Way Park & Ride in Lynnwood, WA.

 

Morning Moon at the Ash Way Park & Ride

Morning Moon at the Ash Way Park & Ride

Irrelevant and Annoying Popus




irrelevant_popup.jpg

Originally uploaded by haivu_ed

The internet is full of ads these days, to the point that they even invade your writing. I was reading a blog about a luggage scale and when I hover my mouse over the word luggage, a popup jumped to my face with ads that so irrelevant, that I wish I can strangle the person responsible for placing it there.

Since the text was double-underlined, I know that it was not the original poster who posted it there, but the blog hosting company who did so. I wonder what they come up next.

Please share your story as I am sure I am not alone.

Reduce Distraction While Reading of Web Pages

Have you been to a web page full of ads that leave no room for contents? I bet you have. Here is an example:

Just to experiment, I printed the web page above to a PDF file, then view that file using Tofu, an OS X file viewing utility and the result is like day and night:

 

I got fed up with this high noise-to-contents ratio and have been seeking for ways to  bring sanity back to reading web pages. One of the way to deal with this situation is to use the print view. Many web sites has a print view, normally a text link that says something along the lines of “print,” “print this article,” or “printer-friendly view.” These are your friends.

The print views offer a few advantages:

  • They often pack more contents into the same screen area.
  • They are free of ads, or carry only a minimal amount
  • Some websites show white text on black background, which makes it a little hard to read for me. The print view usually show black text on white background–much easier to read in my opinion.
The following two pictures show an example of print view. While the print view might not pack more contents, it is less distracted. Here is the normal view:

white text on black background

And here is the print view:

Print view

 Here is another example, the normal view:
Normal view
And here is the print view:
print view

Have a way to reduce distractions from the web pages? I would like to hear from you.

Removing Elements from a List with the TclX intersect3 Command

Recently, I needed a quick way to remove an element from a list. For example, given the following list:

set li [list a b c d e f]

How do I remove item d from it? I can use list replace, but that would be messy because I need to know the index location of the element, and the replace syntax is not easy to remember. A few minutes after I posted my question to comp.lang.tcl, someone posted a simple solution of using the TclX’s intersect3 command. Let’s take a look at the step-by-step process:
remove element from a list
Discussion:

  • Line 61: Create the list
  • Line 62: Import the Tclx package
  • Line 63: The intersect3 command takes two lists (say, listA and listB) and returns a list of three items.
    • The first is a list of items that are unique to the first list (listA)
    • the second is a list of items that are common to both
    • Finally, the third contains a list of items that are unique to the second list (listB)
  • We are interested in the first list in this case.

  • Line 64: We use lindex to retrieve the the list first list
  • Line 65: Assign that to the original list

Of course, we can use intersect3 not only to remove one element, but several from a list.

Passing Parameters between Tcl Scripts

Problem

I have two Tcl scripts running under Linux: script1.tcl launches script2.tcl. I like to pass all command-line parameters (that is, $argv) from script1.tcl to script2.tcl and then some. However, the $argv parameter arrives to script2.tcl were groupped into one token instead of separate tokens. An example will make it clearer:

Let say, I invoked script1.tcl like this:

tclsh script1.tcl –file config.txt –userCount 5

Then in script1.tcl, I see that $argv is broken into the following tokens:

–file
config.txt
–userCount
5

This is the behavior I want. Now, in script1.tcl, I spawn the second script, I pass along $argv along with some other parameters, like this:

exec tclsh script1.tcl $argv –userIndex 0

Then in script2.tcl, $argv’s token are broken down as shown:

–file config.txt –userCount 5
–userIndex
0

Notice that the first token is everything that I passed into script1.tcl and Tcl group them together as one token instead of separate ones. This is not the behavior I am looking for so I set out to solve it.

Solution

After a bit of searching around, I found a solution from the Tickler Wiki. Basically, instead of one exec line, I have to do this:

set cmd [list exec tclsh script2.tcl]; # Construct the command line
set cmd [concat $cmd $argv –userIndex 0]; # append the arguments
if {[catch $cmd result]} {
puts “Exec failed with error: $result”
} else {
puts “Exec passed, output:”
puts $result
}

This solution works because the concat command in the second line broke $argv into pieces and concatenate it to $cmd. While this solution works, it is a bit of a hack. Without detailed comments, I will not know what to do with it six months from now. If you have a different (or better) solution, please post your comments here.

Fix for Interactive Login Problem


cannot_login

Originally uploaded by haivu_ed

The problem
I have a Windows 2003 Server which for some reason does not let me log in interactively (that is, locally). The machine issue the following error message when I tried logging in: “The local policy of this system does not permit you to logon interactively.”

The solution
From another machine in the network, I downloaded the Windows Server 2003 Resource Kit Tools (what a mouthful), then issue the following commands:

net use \\mymachine\c$
ntrights.exe -m \\mymachine -u username -r SeDenyInteractiveLogonRight

Where mymachine is the machine name for your stuck machine, and username is the user name you use to log in. When the net use command asks for credentials, I use mymachine\username and the corresponding password. This command is essential to allow ntrights.exe to gain access to your stuck machine.

References

Microsoft knowledge base article that deals with this problem.

Windows Server 2003 Resource Kit Tools Download 

A discussion about the use of net use to gain permission