Starting again, and some other ideas

It’s been awhile since this blog was last really active.

I’m still getting comment spam, but that’s already become a “normal” thing for most bloggers these days.

Have been doing a bit of reflection in regards to the future direction of my blogging. For a brief moment I did consider just leaving this place to die.
But then I thought, maybe I can just focus on other things? Not just tech.

I’m also spending a lot of my time on Twitter lately. Which does get updated much more often than this blog. I’ve setup an account on Swurl to aggregate a few things that I update (twitter/flickr/del.icio.us).

Another thought that came up was to start blogging about food, or in particular, about Vegetarian foods that I eat. Admittedly i’m not much of a cook (but i’m learning bit by bit). The not much of a cook part is what’s holding that idea up, not that it’s going to stop me :)

I’ve been inspired by two Melbourne based food blogs i’ve been subscribed to over the past few months, one by Mel Bedgood the other by Cindy & Michael called “where’s the beef?”. My other inspiration to start posting about Vegetarian foods is the questions I often get asked when I tell people that i’m a Vegetarian which is “so what do you eat?” and “so do you get enough Vitamins?”

It’d probably be quite easy to just direct people to the plethora of Vegetarian recipe websites and blogs and other resources, but it’s never quite that easy to define. Different individuals will have different ways of achieving the same means.

What I eat will be vastly different to many other Vegetarian individuals out there. You’d think being an Aussie with a Chinese background most of my food at home is going to be Chinese, right? Well, no.

What I do end up eating at home is a mixture from my parents’ upbringing and mums’ penchant for the local libraries cookbook section.
My mum was actually born in Luang Prabang in Laos, and dad was born in Vietnam (but are Chinese).

An example of something I may have for dinner might be Vietnamese Rice Paper wraps (Banh Cuon) with some salads (sweet potato based vermicelli noodles, cracked sesame seeds, ground pepper) with some honey/lemon and ginger dipping sauce.

Or it could be something else during summer when the Aussie mangoes are ripe and sliced on top of freshly steamed sticky rice. Then a sprinkling of lightly fried sesame seeds which had been cracked slightly in a pestle and mortar on top. There is just something about sticky rice I can’t get enough of, but hey, I grew up eating the stuff! :)

As you can see, I think there is great variety of foods available to anyone who is a Vegetarian (or even those who aren’t but like the idea of eating less meat for whatever reason they may have). So i’m hoping I can share a bit of that here.

Fixing Visual Studio’s System.OutOfMemoryException

Over the last little while Visual Studio 2005 has been crashing seemingly “randomly”. Sometimes it would happen when just trying to open a source file, other times when trying to debug a web app. A few co-workers asked if I wanted to try ReSharper, so I installed that. After installation crashing seemed much more frequent, so I went into Add-in Manager and disabled ReSharper.

My machine at work has 4GB of memory, and is running Windows XP. So I had assumed I had more than enough memory available for VS 2005 to use.

I had almost given up on fixing the issue, but yesterday came across the following blog post by Steven Harman titled Hacking Visual Studio to Use More Than 2Gigabytes of Memory.

Basically the solution was to boost the user-mode memory from 2GB to 3GB in XP via adding the /3GB to your BOOT.ini file, then making Visual Studio “Large Address” aware using the editbin command.

Paging the DataList

A few days ago I looked at various solutions to enhance an exhisting DataList control at work.

The DataList brings back a fair bit of data from several different tables and seemed a bit bloated.

The first solution I looked at was data paging and only showing rows as needed. The DataList doesn’t come with built in Paging capabilities, so you’ll need to write your own. Scott Guthrie has a great post about Efficient Data Paging with the DataList control.

Although that is a great solution, in this current environment of Ajaxifying everything you can get your fingers upon I found a great open source product named Ajax Data Controls (or ADC for short) and their DataList Paging example. You can download the controls from their CodePlex page.

The controls are basically an Ajaxified replacement for the exhisting ASP.NET 2.0 Data Controls (GridView/DataList/Repeater), with a few minor differences.

One of the authors, Kazi Manzur Rashid has a great blog post on how to use their GridView control.

A third solution is to use the PagedDataSource, which comes with ASP.NET 2.0. Sreejith Thathanattu has posted a good example of using the PagedDataSource on CodeProject with the DataList. If you decide to go down this path, consider assigning a Cached version of your DataSource to PagedDataSource as that will help with performance (you’ll be hitting the Database less).

Blank Comment Spam

There seems to be a lot of comment spam at the moment where the content is just a pair of <a>  </a> tags with no other content.

The common point linking most of them is their email address being usually an @mail.com, and a handful with @berlin.com. Or more specifically, the following:
- heel@mail.com
- jane@mail.com
- dominic@mail.com
- bill@berlin.com

There’s been about 76 of these that I’ve found, and they’ve started appearing on Saturday March 15th. To say the least, they are quite unusual compared to the regular spam I’ve been getting. I’m sure with time they may vary those addresses, or something else is going to be launched with this being just a simple system test-run.

Doing a little quick investigation via Google indicates that these aren’t new email spam addresses.

Internet Explorer 8 Beta 1 – Changes for Devs

The IE Team have just announced the availability of Beta 1 of IE8 for developers. You can read more about that on their blog.

Obviously as a web developer, the mind immediately turns to “so, what’s in it for me?”.

Picked up the following points from an MSDN Doc on what’s new for IE8:

Oh, and IE8 Whitepapers.

And finally, for those who want to try IE8 with no risks, you can download a Virtual PC image with IE8 from here.

Using Reports locally in ASP.NET 2.0

I was asked recently to develop reports for an internal ASP.NET app, after doing some research found that the best solution was to use the ASP.NET ReportViewer control set in LocalMode.

One of my big restrictions was the inability to upgrade from SQL Server 2000 to 2005, which meant avoiding I needed to avoid MS SQL Reporting Services. After much research into third party reporting components such as the Telerik Reporting Control as well as the SharpDevelop Reports, in the end I found a CodeProject article on Using the ASP.NET 2.0 ReportViewer in Local Mode which sounded perfect for my requirements.

Another requirement was to have the reports emailed out to respective contacts within the system, with PDF being the preferred format. My initial thought was to export to a temporary file on the system and attach it to the system generated email.

Found some code on the MSDN Forums about Printing Local Reports in ASP.NET which contained a useful looking ReportPrinterHelper class. Reading the code I noticed that it called the ReportViewer’s LocalReport.Render() function, and passed “PDF” as a parameter and also returned a byte[] array. An aha! moment struck, I could create a MemoryStream from the Byte[] array and attach that to an email as a PDF file.

Here’s my new RenderToPDFBytes function:

public static byte[] RenderToPDFBytes(ReportViewer reportViewer, ExportType exportType) 
{ 
  if (exportType == ExportType.Pdf) 
  { 
    Warning[] warnings; 
    string mimeType, encoding, fileNameExtension; 
    string[] streams; 
    byte[] pdfContent = reportViewer.LocalReport.Render("PDF", null, out mimeType, out encoding, out fileNameExtension, out streams, out warnings); 
    return pdfContent; 
  } 
  else if (exportType == ExportType.Xls) 
  { 
    // Implement if needed, just change PDF to XLS 
  } 
  return new byte[0]; 
}

Just place that into your ReportPrinterHelper class and reference it in your code as follows:

// Render our ReportViewer control to PDF format as bytes 
byte[] data = ReportPrinterHelper.RenderToPDFBytes(rptViewer1, ExportType.Pdf); 
// Transform our byte[] into a format suitable for attaching to an email. 
// Eg: Either in memory, or as a file on the system. 
MemoryStream ms = new MemoryStream(data); 
// Now to email it out as an attachment 
try 
{ 
  MailMessage mm = new MailMessage(); 
  mm.From = new MailAddress("noreply@example.com", "Ex Corp"); 
  mm.To.Add(new MailAddress("toaddress@example.com", "Bob Code")); 
  mm.Subject = "Daily Random Report"; 
  mm.Body = "Please find attached your Daily Report";    

  // Add our attachment to the MailMessage 
  mm.Attachments.Add(new Attachment(ms, "random.pdf", "application/pdf"));    

  // Set smtp.example.com to your relevant SMTP Host 
  SmtpClient smtp = new SmtpClient("smtp.example.com"); 
  smtp.Send(mm); 
} 
catch (System.Exception e) 
{ 
  // catch error and do something with it. 
}

Note: The ReportViewer control is only available as part of Visual Studio 2005 and is not a part of ASP.NET. As such, you’ll need Visual Studio installed to work with it.

Random Links

Okay, I just need to unload a whole bunch of links that have been open in various tabs in IE7.

Improve your wireless network in ten different ways via LifeHacker.com
Managing The Madness: What you need to know about covering the NCAA Tournament via Strobist.
Ace your next phone interview via LifeHacker.com
How to find free eBooks for your cellphone or PDA via LifeHacker.com
Tech support with VNC reverse connections via LifeHacker.com
Speed up your hard drive defrag via LifeHacker.com
Data Encryption Toolkit for Mobile PCs via Bink.nu

And one more link, for those using IE7. It’s an add-in called IE7Pro, which has a few interesting features such as crash recovery and tab history.