skip to Main Content

WBR HTML Tag

The little known WBR tag is great for formatting HTML tables. Add it to specific places in your table cell values to give the browser the option to add a line break there. This is very useful when displaying tables with long strings that would otherwise cause horizontal scrolling.

Here’s a sample table, displaying some info. Since the values in the tables do not have spaces or tabs, the browser is forced to display the values on one line:

Key Value
ChinhDo.TestApp.TestClass.ExampleKey1 this.is.an.example.of.a.very.long.string

Here’s the same table, with <wbr/> tags inserted where periods are:

Key Value
ChinhDo.TestApp.TestClass.ExampleKey1 this.is.an.example.of.a.very.long.string

Getting the Starting Day of the Week for Any Date

From my code snippets, here’s a function that will return the starting day of the week for any date:

/// <summary>
/// Gets the start of the week that contains the specified date.
/// </summary>
/// <param name="date">The date.</param>
/// <param name="weekStartsOn">The day that each week starts on.</param>
/// <returns>The start date of the week.</returns>
public static DateTime GetStartOfWeek(DateTime date, DayOfWeek weekStartsOn)
{
    int days = date.DayOfWeek - weekStartsOn;
    DateTime startOfWeek = days>=0 ? date.AddDays(-days) : date.AddDays(-7 - days);
    return startOfWeek;
}

If anyone is looking for the original name in English/Spanish of the song “Ngày Vui Đêm Nay” (í ô à)

The original version is Cuentame (The Speak Up Mambo) by The Manhattan Transfer.

Knowing only the Vietnamese version, I had a hard time finding the original song. I hate that most “foreign” songs translated to Vietnamese simply have this in the credit line: “Nhạc Ngoại” (foreign song). If you are going to translate/record the song in Vietnamese, at least give proper credit to the original performer/composer.

Here’s the vietnamese lyrics to this song to help you googlers out there:

Í o à, í o a ê …
Í o à, í o a ề …

Chiều lắng xuống, rừng vang tiếng ca mừng
Lửa bốc cháy rực lên nhg tiếng ân tình,
Thiết tha ôi ngàn lời ca đắm say ngập trời ngất ngây

Này má thắm, này môi mắt đa tình
Làm say mê, làm ngây ngất ân tình
Trái tim theo nhịp vang vang đắm say triền miên thiết tha

Hãy vui đêm nay, nét môi thơm nồng ái ân !

( nhạc….. )

Hãy cho tim non đắm say mơ mộng vòng tay ân ái,
Hát lên muôn ngàn câu hát ngất ngây tình yêu đắm say !

Í o a, í o a ê …
Í o a, í o a ề …
Í o a, í o a ê …
Í o a, í o a ề …
u u u u u ….

Này má thắm, này môi mắt đa tình
Làm say mê, làm ngây ngất ân tình
Trái tim theo nhịp vang vang đắm say triền miên thiết tha

Hãy vui đêm nay, nét môi thơm nồng ái ân

Transactional File Manager Is Now On CodePlex

It’s my first open source project! I’ve gone open source with my Transactional File Manager. Check out the CodePlex link here.

Use any file system as a transactional file system! Transactional File Manager is a .NET API that supports including file system operations such as file copy, move, delete in a transaction. It’s an implementation of System.Transaction.IEnlistmentNotification (works with System.Transactions.TransactionScope).

image

More on Transactional File Manager in my original blog post on it. If you are interested in contributing to the project, let me know.

MSMQ Installation on Windows Server 2008 Fail with 0x80070643

If you get one of these errors starting MSMQ Server or installing MSMQ on Windows (Server 2008), this article describes a potential solution:

  • You cannot start MSMQ Service with the following entry in the Application Event Log: The Message Queuing service cannot start. The internal private queue ‘admin_queue$’ cannot be initialized. If the problem persists, reinstall Message Queuing. Error 0xc00e0001.
  • You cannot install MSMQ with the following error: Attempt to install Message Queuing Server failed with error code 0x80070643. Fatal error during installation. The following features were not installed: Message Queuing Services/Message Queuing Server.

    MSMQ Installation Result

 

For me, the solution was to delete the Registry key KEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSMQ, then try the installation again.

See also:

Don’t hire ghost hunters who are afraid of ghosts

Your house is haunted. You can’t stand living with the ghosts anymore and decide to call in the professional, a ghost hunter. The ghost hunter comes, nicely equipped with all kinds of shiny ghost hunting equipment, and proceeds to immediately pass out and fall to to the floor with a loud thud at first sight of the ghosts.

Well, in a nutshell, that is the story of the new Event Viewer in Windows Vista and Windows Server 2008. The new Event Viewer looks very nice and all. Trouble is, it now won’t work when there is a syntax error in machine.config or other .NET Framework problems. Apparently, in Windows Vista and Windows 2008, someone at Microsoft decided to rewrite the Event Viewer utility (a perfectly usable and solid utility in previous versions of Windows) in .NET.

MMC could not create the snap-in. The snap-in might not have been installed correctly. Name: Event Viewer.

So, the lesson I learned from this is: don’t hire ghost hunters who are afraid of ghosts. Or, don’t write a utility designed to view monitoring and troubleshooting messages that can fail due to unnecessary dependencies. A critical system troubleshooting utility such as Event Viewer should be the last thing that fails.

What to do when you cannot run Event Viewer in Windows Vista/Windows Server 2008/or Windows 7?

If you get the following error:

MMC could not create the snap-in. The snap-in might now have been installed correctly. Name: Event Viewer. CLSID: FX:{b05566ad-fe9c-4363-be05-7a4cbb7cb510}

Try the following:

  • Fix any syntax errors in machine.config. Restore to a previously known working copy.
  • Rename EventVwr.exe.config in %WINDIR%\System32.

SQL Server Implicit String Conversion/Concatenation (XML parsing: line <x>, character <y>, unexpected end of input)

If you are getting this error in your SQL Server T-SQL script:, you may be running into an issue with implicit string conversion in SQL Server:

declare @xml varchar(max), @doc XML, @stringVariable varchar(256)
set @stringVariable = 'a string value'

-- @doc is set by concatenating multiple string literals
-- and string variables, with all the variables having less than
-- or equal to 8000 characters
set @xml = '<root>' +
... + @stringVariable +
...
'</root>'

print len(@xml)

set @doc = @xml

Output

8000
Msg 9400, Level 16, State 1, Line 4
XML parsing: line 64, character 74, unexpected end of input

As you can see in the output, the @xml variable was truncated to 8000 characters, resulting in an invalid XML. This is due to the way SQL Server performs implicit string conversions when concatenating strings. When all the string literals/variables involved in the concatenation are 8000 characters or less, the resulting string will be exactly 8000 characters.

The same issue occurs with NVARCHAR data type. Instead of the 8000-character limit, it’s 4000 characters.

A simple fix is to make sure at least one of the string variables is of type VARCHAR(MAX):

declare @xml varchar(max), @doc XML, @stringVariable varchar(256)
declare @x varchar(max)

set @stringVariable = 'a string value'
set @x = ''

set @xml = @x + '<root>' +
... + @stringVariable +
...
'</root>'

print len(@xml)

set @doc = @xml

More Info

Instant Messaging Etiquette for the Workplace

The use of instant messaging at the workplace is very prevalent these days. While instant messaging is very convenient for everyday communication, don’t treat it the same as email, face-to-face meetings, or phone calls. There are several significant differences between instant messaging and traditional forms of communications:

  • Instant messaging is not necessarily one-one-one. At any given moment, one person may be engaged in several simultaneous instant messaging conversations.
  • Even though your messages will be displayed on the recipient’s screen immediately, the recipient may not be able to read the messages and respond immediately.
  • With most instant messaging applications, the recipient cannot read your messages until you press the Enter key to send it. This limitation inherently makes instant messaging significantly slower than voice conversations.
  • Most people can speak faster than they can type.

Here are some guidelines on basic/everyday instant messaging etiquette that will help you and your co-workers make the most out of this communication medium.

Instant Messaging apps - AIM, MSN Messenger, Windows Live Messenger, Yahoo Messenger, Google Talk, ICQ 

Include Relevant Info/Questions in The First Message

Avoid typing greetings or non-essential messages separately first. Include the question or relevant information in your first message.

Not-so-good examples (avoid this)

Conversation 1

  • Jane (10:54:50 AM): Hi
  • Mike (10:55:01 AM): Hello
  • Jane (10:55:06 AM): The test server will be restarted in 1 minute.
  • Mike (10:56:11 AM): Thanks for the info

Conversation 2

  • Jane (2:15:08 PM): Good afternoon
  • Mike (2:15:13 PM): Good afternoon
  • Jane (2:15:13 PM): Do you have a few minutes to talk on the phone re project A?
  • Mike (2:15:18 PM): Sure, let me call you.

Conversation 3

  • Jane (4:03:30 PM): You there?
  • Mike (4:03:35 PM): Yes
  • Jane (4:03:42 PM): Can we have a short team meeting in conf room A
  • Mike (4:03:50 PM): Sure. Be there in 5.

Good examples

Conversation 1

  • Jane (10:54:50 AM): Hi, the test server will be restarted in 1 minute.
  • Mike (10:54:55 AM): Thanks for the info

Conversation 2

  • Jane (2:15:08 PM): Good afternoon, do you have a few minutes to talk on the phone re project A?
  • Mike (2:15:13 PM): Sure I will call you.

Conversation 3

  • Jane (4:03:30 PM): Can we have a short team meeting in conf room A?
  • Mike (4:03:35 PM): Sure, be right there.

Every time you send a message, the recipient is disrupted from whatever he/she is doing. The more you can delay this disruption the better, even if it’s only seconds. It’s also not necessary to ask the recipient if he/she is there. That’s what the online status (away/available) is for. You can just type your message or ask your question. One exception to this would be if your message contains sensitive information.

Send Complete Messages

Good:

  • Jane (9:15:23 AM): Hi, all integration tests are failing in the integration environment for the admin user group. Can you take a look?”

No so good:

  • Jane (9:15:23 AM): Hi, all integration tests are failing…
  • Jane (9:15:27 AM): the integration environment…
  • Jane (9:15:32 AM): for the admin user group…”
  • Jane (9:15:38 AM): Can you take a look?

If you have to send several sentences in sequence, compose them in a separate editor first (notepad would do), then type them out quickly in succession. That way the recipient does not have to wait for you while you type your next message, make editing corrections, etc.

Do Not Expect Responses Immediately

Unless the recipient reports to you, do not expect a response immediately after you type a message. The recipient may be in the middle of five other instant message conversations, on the phone, or working on something else more important. If the recipient’s status is not set to “Away”, and you have not received a response after a few minutes, it’s ok to ping him/her again. Maybe they forgot about your message.

Update Your Status and Respect Others’ Status

If you need to step out, change your status to “Away”, or “In a Meeting”, or “Back in an Hour”, or whatever is appropriate for the situation. This tells everyone else that you are not available to respond to messages immediately and save them from having to wait for your responses.

Pick Up the Phone

If the instant messaging conversation starts to go into lots of details and may make take longer than a few minutes, consider picking up the phone and continue the conversation there.

Using a Different Configured Binding in WCF Client

To programmatically switch bindings on the fly, you can do it via the constructor of the generated client:

var client = new WeatherClient(“MyEndpoint”);

“MyEndpoint” is the name of the endpoint defined in your config file:

<client>
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="http1" contract="MyContract" name="MyEndpoint" />
</client>
Back To Top