Saturday, January 21, 2012

Fix! Pythonwin (2.x) Windows 2008 Event Log Text Get Empty String

Symptom:

You used to be able to get the Event Viewer text under Windows 2003 using the following call in Pythonwin. After switching to Windows 2008 or Windows 7 the strings are all empty!

events=win32evtlog.ReadEventLog(hEvent,flags,0)

for ev_obj in events :      
   msg=str(win32evtlogutil.SafeFormatMessage(ev_obj, logType))

Now the majority of "msg" comes out blank. Oddly enough any newer programs the msg come out fine.

Fix:

The string messages logged can also be found as tuples in (using above code example) ev_obj.StringInserts as UNICODE strings.

Therefore, for example, to grab the strings as one msg string, you could write a quick loop like this to get you the full string.

                               msg = ''
             for si in ev_obj.StringInserts :
                   msg = msg + si + ' '                               
             print msg

Monday, December 26, 2011

VoIP "Can't Hear Me, Can Hear Them" Issue

Symptom:

You have (deployed) a SIP VoIP telephone set (can also be a software SIP phone) at home. Your phone rings and you can even dial out but the recipient of a call cannot hear you, though you can hear the recipient's voice.

Issue:

This means that the SIP protocol is going though but the RTP protocol is not going through. This happens in a typical home WiFi "router" scenario connected to cable or DSL service.

Possible Fixes:

If you cannot make a call at all or if you cannot receive any calls at all: Check UDP 5060-5063 ports.

If the sound is an issue then try opening UDP Port 16384 - 16482, or 10000 - 20000. This depends on the phone implementation.


Note: If you are an Astound customer, try connecting the phone directly to the DMZ port provided by Astound.








Sunday, December 11, 2011

Mac Lion Windows Remote Desktop Freezes - Alternate Solution

Symptom

When you "log out" from a Remote Desktop session using the Windows Remote Desktop client, it either freezes or hangs. If it is in full-screen mode, it would not even allow you to open the Apple Menu to force quit the application.

As of December 2011, there is no updated version of RDP Client from Microsoft.

Workaround/Alternate Solution


Try using CoRD from SourceForge. It actually provides better user experience than the RDP client from Microsoft. It works on all recent versions of MacOS X including the Tiger version. I especially like the fact that the user/password management is built in to the software. (for me the Keychain with MS DRP goes out of Sync very quickly if you are connecting to multiple hosts frequently, usually ending up typing user and password every time.)






Monday, December 05, 2011

LINQ To XML Tips


Use XElement instead of XDocument

I misunderstood that it is usually the XElement that is all needed and not XDocument to work with LINQ to XML.

XElement has just about everything you need and also LINQ works mainly with XElement.

For example,

  • Do "var x = XElement.Load("file") instead of XDocument.Load()
  • You can also do x.Save("file") as well.
And you can query against element directly.

var rows = from y in x.Elements where f.Name == "book" select y;


















Sunday, November 20, 2011

Taking Advantage of the Microsoft XPS "Virtual Printer" Even on Macs and iPADs

Symptom:

I was using an application and the result of which is only output via a Print interface. To make the matter worse, this was on a remote site so I could not print to my printer either. To make it even worse, I don't feel like adding any PDF printing driver to this machine as it belonged to a customer.

Fix:

I have been aware that Microsoft XPS driver is installed on just about any modern Microsoft OS machines, and it is even often annoying that it comes up as a default driver to my mothers-in-law PC and she cannot print to actual paper.

As it turns out, you can consider this XPS as the pre-installed "PDF" driver that works on Windows. And since .NET Framework 3.0 a "free" viewer comes "pre-installed"; all you need to do is to activate it! Like just about anything Microsoft (Apple) does, XPS is designed to kill  other company's product, in this case the PDF.

Whether XPS is superior to PDF or not, I don't care, I am not in printing business, but, this means that we can print at most computers without any physical printer, and take or email the XPS file back home and print at your leisure (or just view them to save the tree) or re-print them in PDF once you get it back on a PDF enabled computer.

To "install" or actually "activate" the XPS viewer, see this MS article. What is XPS Viwer

Other platform users do not need to dismay. You can try uploading the XPS file to your Google Docs account and view it online!

Note that the article is a bit obsolete, in systems with .NET framework 3.5 (probably) or later the XPS viewer enable is not within the .NET Framework feature but are listed in the top level list.


SQL Server 2008: Cannot Detach The Database

Symptom:

You have a dead file for a database that was active. For example, you have lost a disk drive or if you have lost file MDF file. Now you try to detach it from the SQL Server Management Studio, it won't let you do it.

Fix:

Try manually firing the query then

use master
drop database

The key above is that you are going to the master and not any other databases.


Saturday, November 19, 2011

Tortoise Git Tips: How To Use It Behind an HTTP Proxy

Problem:

You want to connect to the Git Server via HTTPS (say GitHub.com), but you are behind a proxy. You know the proxy information.

Fix:

Issue the following Git command from the Git Bash. In this example my proxy is at DaProxy... port 8123

config --global http.proxy http://DaProxy.myhospital.edu:8123




Monday, November 14, 2011

Where is The DLL for System.Windows.Media.Imaging Namespace?

Symptom:

You wanted to use classes from System.Windows.Media.Imaging Namespace, but there is no such class when you try to Add Reference from your Visual Studio.

Fix:

Add PresentationCore, which you should find under the .NET tab of Add Reference dialog box.