Just sharing some of my inconsequential lunch conversations with you... RSS  

Saturday, April 12, 2008

Choosing compression options

I'm still spending some time managing my development servers. Backing up virtual machine images is a CPU intensive operation, so I'd imagine my 8 core server wouldn't have a problem with it. I was wrong, for some strange reason, 7Zip was using only one core. After some tests, I've found out the relevance of the compression method:

method #cores used
zip 1
7z 2
bzip2 8

I've yet to measure the core usage efficiency, but until otherwise proven bzip2 will be my default compression method on this servers.

PS: I'd expect 7z to have a better compression rate than bzip2, but the time frame to compress images is crucial on these servers.

Old technology over shiny new 64 bits OS

I've been upgrading some development environments from 32 to 64 bits when I found out my old VB scripts stopped instantiating COM objects. The problem was solved when I've updated cscript references to:

%windir%\SysWOW64\cscript.exe

Mental note to self: get some time out to port this scripts to PowerShell.

Friday, April 11, 2008

Another great tool

Here's a great tool to help you configure your CruiseControl.Net: ccnetconfig. A must. At least for lazy developers like me, definitely not for those of you who would rather edit ccnet.config with good old vi over bourne shell.

Thursday, April 10, 2008

The future of Virtual Machines

Now that virtual machines are everywhere and that my dream of lightweighted hypervisors monitoring virtual machines on every laptop is get closer, here's another great concept: www.mokafive.com. MokaFive delivers "virtual desktops as a service" to help customers manage thousands of virtual desktops running a variety of operating systems and resolve key security issues remotely. Here a nice demo.

I'm not the only lunatic to believe on virtual machines on personal computing. According to eWeek:

Natalie Lambert, an analyst at Forrester Research, predicts that in five years or so virtual machine software will be how most personal computing is done.

But Natalie goes further:

"It can be hosted in a data-center cloud, running on a desktop or some combination of the two. Personally, I think the greatest potential is for virtual desktop computing hosted in a data center. Imagine Google owning your desktop, and it’s available to you wherever you are.”

Makes sense. We came a long way since CP/CMS...

Tuesday, April 08, 2008

Silverlight Essential Training with: Mike Harsh

Here's a great training kit from Mike Harsh, the program manager on the Silverlight team at Microsoft. It comes with with exercise files!

[Update]

I've forgot to mention, here are the labs from Microsoft.

Monday, April 07, 2008

How to Serve an Excel File from a Web Application

When I need to serve an Excel file from a Web Application I usually serve them through HTML. But when you have to serve a 220MB excel, you may think again! On my desktop, it took ages and lots of memory to open.

The obvious alternative is Spreadsheet XML. It is fast, light, powerful and you still don't need an installed runtime at your server. Here is a great reference link from MSDN.

PS: watch out for ss:MergeAcross, his count excludes the current cell. So, if a cell is not merged, the MergeDown="0" and MergeAcross="0".

 

[Update]

MergeAcross is the HTML colspan equivalent. Couldn't get MergeDown  to work in my scenario.

Sunday, April 06, 2008

No comments

As promised, I stopped commenting over the Microhoo business, so you won't ear any angry comments from me about Microsoft Forcing Yahoo’s Hand.

Free opensource GIS tool

I recently had the need for some GIS features on a project. As the project's budget didn't anticipate a commercial GIS tool, I asked for an advice to the GIS experts: the answer was MapWindow GIS.

I was impressed by the quality and integration ease. We used the shapes and DBF databases from a well known (and costly) commercial tool and customized some interactive GIS views in a couple of days.

Unfortunately I can't show you the views, so here's a map from MapWindows GIS:

StringReader sharing issue

I was using my LINQ log retriever collecting some data from a live server when I got an IOException for file sharing. Probably not what I would expect, but it makes sense: by default, FileShare is set to None.

So if all you want to do is just read the damned file, and you're not interested on the fact that this file may be written by another process, all you have to do is:

        StreamReader reader = new StreamReader(
new FileStream(
filename,
FileMode.Open,
FileAccess.Read,
FileShare.ReadWrite
)
)

For log collecting retrieval, this is now my default mode :)

Friday, April 04, 2008

Yet another LINQ success story

I tend to overuse new technology just for fun. But here's a great real reason to use LINQ: I have a huge log file (EL logger) with some profiling data (among other logging). LINQ is a great way to solve this class of problems:

// sample: "Message: [00:00:34.2389312] Initialize "
var regex = new Regex(@"Message: \[(?<hour>\d\d):(?<minute>\d\d):(?<second>\d\d).(?<milisecond>\d\d\d\d)\d+\] (?<message>\w+)");

var groupedMessages =
from message in
from line in ReadLinesFromFile(@"D:\Logs\Link.MetaHeuristics.Business.log")
let match = regex.Match(line)
where match.Success
select new
{
Message = match.Groups["message"].Value,
Time = new TimeSpan(
0,
Convert.ToInt32(match.Groups["hour"].Value),
Convert.ToInt32(match.Groups["minute"].Value),
Convert.ToInt32(match.Groups["second"].Value),
Convert.ToInt32(match.Groups["milisecond"].Value)
)
}
group message by message.Message into g
select new {
Message = g.Key,
AverageTime = new TimeSpan((long)g.Average(x => x.Time.Ticks)),
MaxTime = new TimeSpan((long)g.Max(x => x.Time.Ticks)),
MinTime = new TimeSpan((long)g.Min(x => x.Time.Ticks)),
SumTime = new TimeSpan((long)g.Sum(x => x.Time.Ticks)),
CountOf = g.Count()
};

Console.WriteLine("");
Console.WriteLine("{0,38} {1,5} {2,14} {3,14}", "Message", "Count", "SumTime", "AverageTime");
foreach (var item in groupedMessages.OrderBy(p => -p.SumTime.Ticks))
{
Console.WriteLine("{0,38} {1,5} {2,14} {3,14}", item.Message, item.CountOf, item.SumTime, item.AverageTime);
}

I'm using Don Box's ReadLinesFromFile helper - yes, the WideFinder C# naive implementation:

// LINQ-compatible streaming I/O helper
// taken from: http://www.pluralsight.com/blogs/dbox/archive/2007/10/09/48719.aspx

public static IEnumerable<string> ReadLinesFromFile(string filename)
{
using (StreamReader reader = new StreamReader(filename))
{
while (true)
{
string s = reader.ReadLine();

if (s == null)
{
break;
}

yield return s;
}
}
}

It took about 11s to consolidate a 500MB log file on an old Pentium D. Not impressive, I know, but highly readable and easy to write. And last but not least: declarative enough to allow future PLINQ optimizations :)


PS: PLINQ tests will need some refactoring, as IO is probably the current bottleneck (CPU doesn't get to 40%...).

Thursday, April 03, 2008

Redirecting stdin and stdout

We've been working on probabilistic meta-algorithms for the global optimization problem. I'm afraid I can't talk much about the project for the time being except for details. Here's a one of those details.

As strange as it may seem today I had the need to redirect stdin and stdout from within .NET. On one of the alternative solution branches we've decided to use lp_solve to optimize some variables so we could benchmark an alternative way for solving our algorithm.

The problem has so many variables and restrictions that we couldn't use lp_solve as a lib, we had to create the input file, execute lp_solve.exe and recover the outputted data.

Here's where stdin and stdout redirection came in. Here's how we did it:

	Process process = new Process();

process.StartInfo.FileName = "cmd.exe";
process.StartInfo.Arguments = String.Format(
"/c {0} < \"{1}\" > \"{2}\"",
System.Configuration.ConfigurationSettings.AppSettings["LPSOLVE_PATH"] + @"\lp_solve.exe",
inputFilename,
outputFilename
);
process.Start();
process.WaitForExit();
And there you go. Not much, but it works. And it sure brings back memories... :)

Tuesday, April 01, 2008

Accessibility in Silverlight 2

Accessibility and Silverlight in the same post? And not to say it just doesn't support it? It seems like the accessible options in Silverlight 2 is heading the right way. Here's a mix webcast about it.

Great news, this was probably the question that troubled us the most when adopting Silverlight. Clearly a great advantage over Flash, right?

read about it at: http://blogs.msdn.com/publicsector/archive/2008/04/01/silverlight-2-accessibility-section-508-etc.aspx

Development Catharsis :: Copyright 2006 Mário Romano