Monday, December 20, 2010

ASP:Menu SkipLink

For those who landed here looking for a solution together with the cristal clear explanation, sorry, no, I do not have one :-(

Symptom.
We have migrated our internet facing site from SharePoint 2007 to 2010. We (needed to) have redone our custom master page. We did so having the 2010 minimal masterpage http://code.msdn.microsoft.com/odcSP14StarterMaster as the basis.
Then we found the Global Navigation menu, which uses the SharePoint:AspMenu control (I think it behaves pretty much the same as ASP:Menu), appears a little lower than it used to.
It does so to me everywhere. I have IE8 and FF3.5 on my PC. But later realized that it is OK on their old versions; IE7 and FF1.5.

The only difference is with the so-called "skip navigation link". It is visible (and thus takes some space) with the new master.





It was invisible with the old master.





The above screenshots are from FireBug. But up to now, I do not know what makes it "visible" or "ïnvisible".

My solution for the time being is to set DOCTYPE of the masterpage back to XHTML 1.0 Transitional. Do not ask me why...

The above mentioned minimal masterpage comes as XHTML 1.0 Strict. It is pity that I had to go back "Transitional". But this is the only workaround that I so far found.

Tuesday, December 14, 2010

Install Perl Modules

This is really my personal memo.
I have installed a perl module for the first time in my life and actually learned a lot, so just like to keep what I did here for future reference.

The command is as simple as this. There is a switch -MCPAN for the executable itself to add a module. I log the output. Again this is just for my reference.
# perl -MCPAN -e "install Time::Period" >install.perl.time.period.log 2>&1

Actually, this failed.
It was unable to find the package, Period-1.20.tar.gz, at (in our environment)
http://cpan.mirror.fr/.
I found the file at
http://search.cpan.org/CPAN/authors/id/P/PR/PRYAN/Period-1.20.tar.gz. So how can I change the host (that perl goes to get packages)? You do as follows.

# perl -MCPAN -e shell <- go into the shell mode

cpan shell -- CPAN exploration and modules installation (v1.61)
ReadLine support available (try 'install Bundle::CPAN')

cpan> o conf urllist <- show the currect host list

urllist
http://cpan.mirror.fr
http://cpan.mirror.fr/
Type 'o conf' to view configuration edit options

cpan> o conf urllist pop
cpan> o conf urllist pop <- do this twice to remove the unwanted hosts


cpan> o conf urllist push http://search.cpan.org/CPAN/
cpan> o conf urllist push http://cpan.mirror.fr <- not really care but just liked to keep what were there
cpan> o conf urllist push http://cpan.mirror.fr/

cpan> o conf urllist
urllist
http://search.cpan.org/CPAN/ <- now perl tries this site first
http://cpan.mirror.fr
http://cpan.mirror.fr/
Type 'o conf' to view configuration edit options

cpan> o conf commit
commit: wrote /usr/lib/perl5/5.8.0/CPAN/Config.pm

cpan> quit

Try the first command again, and GOTCHA!

Wednesday, October 27, 2010

EventLog.WriteEntry from a ASP.NET page

The page is run as NETWORK SERVICE. I would not ask you to either change it to LOCAL SYSTEM, or put NETWORK SERVICE to the administrator group.
The later sounds quite stupid. But a colleague of mine did find somebody proposing it as a solution on the net.

The simplest code fragment that you would find at many places on the net should look like the following. I too found it on the net.
protected void Page_Load(object sender, EventArgs e)
{
// Create the source, if it does not already exist.
if (!EventLog.SourceExists("hoge"))
{
//An event log source should not be created and immediately used.
//There is a latency time to enable the source, it should be created
//prior to executing the application that uses the source.
//Execute this sample a second time to use the new source.
EventLog.CreateEventSource("hoge", "Application");
// The source is created. Exit the application to allow it to be registered.
return;
}

// Create an EventLog instance and assign its source.
EventLog myLog = new EventLog();
myLog.Source = "hoge";

// Write an informational entry to the event log.
myLog.WriteEntry("hello world.");
return;
}

This would not run as NETWORK SERVICE. However, there is actually only one instruction that cannot be performed with NETWORK SERVICE privilege. It is the “CreateEventSource()”. The instruction to actually write an event, WriteEntry(), runs with no problem.
Since CreateEventSource() needs to run only once, you either take it out and run in a separate console app, or runs the above code only once as LOCAL SYSTEM then change it back to NETWORK SERVICE immediately after that.

Wednesday, April 28, 2010

[MOSS 2007 public facing site] access to MS Office documents in Document Library

I am less and less certain if this is a right product…
This is THE most incredible and discouraging experience that I ever had with this product, which I have been working on to maintain our public internet site.

First of all, MANY MANY MANY thanks to the author of this blog post.
http://www.theblackknightsings.com/RemoveLoginBoxWhenAnonymousUsersDownloadOfficeDocumentFromSharePointSite.aspx
# BTW, the design is very funny. I thought it was a genuine error screen at the beginning.

The explanation is very clear, and so is the code. So I went straight plugging it in to our production site.
# I have at least compiled the DLL myself, and did a bit of test though.

We know that this product i.e. SharePoint is now widely used, especially with intranets, sites for collaboration and so on, where you know the users, they are all authenticated. However, for public facing internet sites such as ours where majority of users are anonymous, there are points overlooked, including ones as obvious as this one. And we users by ourselves need to apply workarounds… Hope with the coming 2010, it comes as a WCM product fully ready for public sites.

Tuesday, April 6, 2010

A day with video files


Nothing to do with work. Some video stuff.


Many probably knows about .fll (FLV Flash Video) file. I have got some movie files where there are some annoying discrepancy between image and sound.


I was bored today so tried to do something with it.


There is this famous Avidemux freeware with which you could fix this discrepancy. The latest is 5.2. It appears not yet nicely support the H264 video format.


When it finds that your file is in the format, it popups:

H.264 detected. If the file is using B-frames as reference it can lead to a crash or stuttering. Avidemux can use another mode which is safe but YOU WILL LOSE FRAME ACCURACY. Do you want to use that mode?


I am not at all an expert in this area, do not know what this means exactly, so went on accepting use of the "safe" mode. That appears fine. However, if you do not do what you want at this first time you open the file and close it. The popup would never come again and as the consequence, you can not open the file, unless you go to its conf file (in XML) and manually clear the history. This was the first difficulty that I encountered.


The second thing is the sound. To adjust the sound so it goes nicely, side-by-side with the video, of course you want to see the video together with the sound in its preview mode. I use a mac at home by the way. And the latest mac version of the freeware does not seem to allow me to listen to the sound.


I went back to a previous version, 4.4. Its handling of the sound device seems ok. Good! But then it does not yet support the audio format of my files!!!


So finally what I did was the following. I open each of those files with the latest, 5.2, change the audio data format to mp3, then turn to the 4.4 and shift the starting point of the sound.


A nice holiday activity.

Thursday, April 1, 2010

media="print" and proxy


Really strange thing happened.


One of our developer tried to do a print-friendly rendering of a page. That is, when you print the page, logo is removed, hyperlinks is followed by their URLs written etc. A usual stuff.


He did so using media="print" trick with CSS.


He made it work nicely with FireFox but not on IE. Still needs some improvement, to support various browsers. That's OK. Not my business.


The weird thing is that it behaves differently when you get the page, css everything via a proxy.

The simplest example. If I start Fiddler to see if all come from where they are supposed to, you see it already different in the print preview...


You would normally suspect that some element of the page such as a css file fails to come, due to some authentication/authorization issue for instance, when you go thru the proxy. But Fiddler reports none. The key, linked as media="print", css seems downloaded OK. If the elements are the same, whether or not via proxy, it should behave in the same way...


After almost one day of fruitless investigation, given up... Asked him to revise it, so it works OK with IE as well, and with or without a proxy.


Mmmm...


Thursday, February 11, 2010

ASP.NET Menu for Arabic i.e. right-to-left pages


Just to share, or for myself to remember this small piece of info.

http://www.microsoft.com/middleeast/msdn/Asp2_menu.aspx

It is becoming more and more that the key to be a good programmer is the ability to come up with a good set of keywords for the problem in hand, to type into a search engine...

In this case... what did I type?
At first, I typed something like "ASP.NET Menu right to left", whcih did not give me any useful pages.
Then tried (already started thinking of moving to CSS adapter. No, do not want to do that. Would be quite a work...)
"ASP.NET Menu Arabic". Then, Voila! I found the above.

For those who speak Arabic, it must be a well-known trick. But for us...