Sunday, April 19, 2009

Pirate Bay founders sentenced in copyright case

Earlier this month, in the case of The Pirate Bay versus Universal, MGM, Sony et al, the Stockholm court convicted Peter Sunde, Carl Lundstrom, Frederik Neij and Gottfrid Svartholm Ward of acting as an accessory to breaching copyright laws.

The Pirate Bay founders are optimistic and have appealed the decision. In either case, I'd go grab all the torrents off The Pirate Bay while I still can.

WordPress Mod: Authenticate via ASP.NET


I hooked up a WordPress blog to authenticate via ASP.NET. It's wicked, I tell you! After hacking through the WordPress source code, the integration was quick and easy from both the PHP and ASP.NET sides. The purpose of the integration was to deal with differences in hash algorithms, so we wouldn't have to create user accounts with completely different passwords.

We still would have to build a component on the ASP.NET side to push profile changes and new user accounts into WordPress. I'm wondering if MS SQL Server can connect to MySQL and update the data from within a trigger.

Monday, April 13, 2009

Virus Sweeper

You shouldn't believe everything you read on the Internet. Most people simply just ignore that advice and that's how Virus Sweeper gets into computers. Virus Sweeper is advertised as a warning indicating that you should use it to disinfect your computer. When users do download and run it, that's when Virus Sweeper takes over.

They even have a very convincing user interface that makes Virus Sweeper seem like an actual anti-malware program:


You can find removal instructions and a utility here.

Source: 2-spyware.com

HttpResponse.Close instead of HttpResponse.End

When profiling my application, I noticed that Response.End takes more time to execute than Response.Close. I'm guessing this is because Response.End causes a ThreadAbortException and .NET's handling of the exception causes the overhead.

Twitter Worm

A worm has been running amok on Twitter. It changes profile info, posts tweets, and resets the password. You can get the source code of the worm at:
http://gist.github.com/93782

All it requires is an active Twitter session to take effect.

Saturday, April 11, 2009

Bury The DiggBar

If you've been using Digg for finding websites to visit or bookmarking, you've no doubt come across the DiggBar. It is an annoying bit that takes up screen space. Having to close the DiggBar each time is a pain.

Digg, bury the DiggBar. Make a browser toolbar instead.

Wednesday, April 8, 2009

A Start In Joomla

I've been trying out Joomla, the free and open-source CMS developed in PHP. I set it up on XAMPP and the first thing I can tell is that it's not very intuitive. The features provided on Joomla make it worth the effort to learn it all though - advertising banner management, contact lists, news feeds, polls, search and more.

Twitter Hands Over Registration Details of "Skype"

Twitter handed over the registration details of the user "Skype" to Skype Inc. It definitely raises privacy concerns, but what makes this extreme is that they do not notify the user when they do reveal private data.

Monday, April 6, 2009

Manual Sliding Expiration

When using ASP.NET Forms Authentication, ASP.NET sets a timeout of 30 minutes by default for which a user is logged in. If the user does make a request within the 30 minutes, the authentication ticket is renewed for a another period. This normally happens behind the scenes and the developer is often not aware of this process, known as sliding expiration.

However, if you've got some pages on your web application that should be viewable by the user without the authentication ticket being renewed (such as a ticker to display new messages within an IFrame), you can disable slidingExpiration by making the following change in the web.config file:

<authentication mode="Forms">
<forms slidingExpiration="false"></forms>
</authentication>

You then have to programatically perform sliding expiration within your code, which can be done with the following code snippet posted at:
http://forums.asp.net/p/1083581/1607975.aspx

// Acquire Auth Ticket from the FormsIdentity object
FormsAuthenticationTicket objOrigTicket = ((FormsIdentity)Context.User.Identity).Ticket;

if (!Request.Url.AbsolutePath.ToLower().EndsWith(".ashx"))
{
// Manually slide the expiration
FormsAuthenticationTicket objNewTicket = FormsAuthentication.RenewTicketIfOld(objOrigTicket);

if (objNewTicket.Expiration > objOrigTicket.Expiration)
{
// Create the (encrypted) cookie.
HttpCookie objCookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(objNewTicket));
// Add the cookie to the list for outbound response.
Response.Cookies.Add(objCookie);
// Update original
objOrigTicket = objNewTicket;
}
}

In the code snippet above, you would have to change the condition within the IF statement that checks Request.Url to exclude the pages for which you do not want slidingExpiration to occur. The example above excludes all requests to ASP.NET Generic Handlers (files ending in .ashx).

Sunday, April 5, 2009

Aspose Library for Creating Excel and Word Files


If you want to generate Excel and Word files using .NET or Java code, then the Aspose.Cells and Aspose.Words libraries are just what you are looking for. The Aspose.Cells library costs roughly $600 while the Aspose.Words library costs about $900, but you can get a discount of about $200 for purchasing both libraries in a single transaction. You might want to buy Aspose.Total, which is a package containing both Aspose.Cells and Aspose.Words along with several other useful libraries.

How to use Aspose.Cells for creating Excel files in .NET

Using Aspose.Cells is quite simple. You need to add a reference to the Aspose.Cells.dll, create an instance of the Workbook class, get a Worksheet instance (either use the existing sheet or create a new one) and use the Cells indexer to access a cell. Set the value of cells using the PutValue method. Finally, generate the Excel file using the Save method of the Workbook class. Here's an example:

//using Aspose.Cells; //add this to the top of your file
Workbook wb = new Workbook();
Worksheet ws = wb.Worksheets[0];
ws.Cells[0,0].PutValue("Nitin");
ws.Cells[1,0].PutValue("Reddy");
wb.Save("File1.xls", FileFormatType.Excel2003);

If you are using Aspose.Cells in an ASP.NET application, you can simply save the document for the user to download by replacing the above wb.save statement with the one below:
wb.Save("File1.xls", FileFormatType.Excel2003, SaveType.OpenInExcel, Response);
Respose.End();

You can also use Aspose.Cells to directly save a DataTable (System.Data.DataTable) to an Excel file by inserting values into the worksheet like this:
ws.Cells.ImportDataTable(myDataTable, true, "B2");
The "true" value indicates that the column names of the data table will also be written to the worksheet and the "B2" indicates the cell from which the copy will begin.

How to use Aspose.Words for creating Word files in .NET

Using Aspose.Words was a little challenging for me to get started as the demos provided on the Aspose website do not provide examples of creating MS Word files from scratch, but rather focus on demonstrating the ability to load an existing Word file as a template and building upon it. As is the case with the Workbook object in Aspose.Cells, you have to begin by creating a Document object and creating a DocumentBuilder. You can then use the Write, Writeln, and InsertHtml methods of the DocumentBuilder class to create the document and the Save method of the Document class to write to a file or a Respose stream.

Here's an example:
//using Aspose.Words; //add this to the top of your file
Document doc = new Document();
DocumentBuilder bld = new DocumentBuilder(doc);
bld.Writeln("Nitin Reddy");
bld.InsertHtml("<b>Location:</b> Dubai<br />");
bld.Write("-----");
doc.Save("File1.doc", SaveFormat.Doc);

When using this in an ASP.NET application to serve files to client browsers, simply replace the above doc.Save method call with the following:
doc.Save("File1.doc", SaveFormat.Doc, SaveType.OpenInWord, Respose);
Respose.End();

W3C Geolocation API

ASP.NET MVC 1.0 Source Code

For those of you who are still in the dark, the ASP.NET MVC 1.0 source code is available for download at:
http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=24471

Twitter Comic Strips

Saturday, April 4, 2009

Windows 7 To Minimize OEM Software Performance Hit

Microsoft aims to deliver a better user experience for Windows 7 users by going as far as keeping a check on the performance hit and impact on startup time due to pre-installed OEM software. After the failure of Windows Vista, Microsoft is taking every measure to ensure that it doesn't repeat the same mistakes with Windows 7. A lot of effort goes into improving UI elements that we use everyday, such as the Start button and the taskbar.

Friday, April 3, 2009

New Path For .NET 4 Certification

It's quite likely that the certification path for .NET 4 may be significantly different from the ones for .NET 2.0 and .NET 3.5. The certification path for .NET 2/3.5 requires test-takers to take a foundation exam that covers various topics.

The change would be welcomed by many professionals. After all, how many ASP.NET and Silverlight developers want to spend time learning COM interop instead of focusing on their core competencies?

Tiobe Index For Programming Languages

The Tiobe Programming Community Index, indicative of a programming language's popularity, can be found here .

According to the index, Java, C, C++, PHP and BASIC are the top 5 languages, with Python, C# and JavaScript following closely behind. Over the last year, there's been a sharp decline in the popularity of BASIC and Perl, and a moderate decline in the popularity of Java. On the other hand, C, C++ and JavaScript have been gaining popularity.

You can also look at a long-term trend chart for the top 10 languages here.

Thursday, April 2, 2009

Cross-Domain Policy Files

A Cross-domain policy file or crossdomain.xml is used by Adobe Flash in determining whether it is allowed to access resources from a domain other than that of the currently running Flash object.

The master cross domain policy file has to be located at the root of the server Eg. http://api.flickr.com/crossdomain.xml .

The root element of the crossdomain.xml file is the cross-domain-policy tag which can contain one of the following:

allow-access-from
The allow-access-from element allows other domains to access resources. Attributes used with this element are domain (to specify a domain name; wildcards are supported), to-ports (to specify a comma-separated list or hyphenated-range of ports), secure (set to false for an HTTPS policy file to be used for allowing an HTTP request).

site-control
The site-control element is valid only within the master policy file (policy file located at the domain root). It is used to determine if other policy files other than the master policy file are permitted. The permitted-cross-domain-policies attribute is used in this tag with a value of: none, master-only, by-content-type, by-ftp-filename, and all. Using none prevents the user of any cross domain policy files for this domain, master-only specifies that only the policy file located at the root is permitted, by-content-type indicates that any file served via HTTP or HTTPS with a content type of text/x-cross-domain-policy is permitted, by-ftp-filename indicates that any file with the name crossdomain.xml is permitted, and all indicates that any policy file on the domain is allowed.

allow-http-request-headers-from
The allow-http-request-headers-from element allows a request from another domain to include custom headers. Attributes used within this element are domain (to specify a domain name), headers (to specify list of comma-separated headers, an asterisk or a header with a wildcard suffix), and secure (set to false for an HTTPS policy file to be used for allowing an HTTP request).


The following is an example of a cross domain policy file:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="www.company.com" />
</cross-domain-policy>

The cross domain policy file should be served with the MIME type of text/*, application/xml, or application/xhtml+xml, but the preferred content type is text/x-cross-domain-policy.

Wednesday, April 1, 2009

On A Pentium-II

I'm making this blog post from my old IBM Thinkpad 600E, which is powered by a Pentium-II 366MHz processor and 64MB RAM. It runs Opera 9.64 on Windows 98 and can send/receive email and post to my blog without breaking a sweat. It makes you wonder how newer machines have lots and lots of processing power but you only need so much to get the job done.

I must admit though that for the amount of processing power I get, I do spend an awful lot of electricity. With the same number of electrons it takes to power an old computer, I can run a brand new shiny Thinkpad. My newer Thinkpad T60 also generates lesser heat, so I'm guessing the cooling fan uses lesser electricity and I'm less likely to turn on the air conditioning.

Anyway, I do my part by shutting down the 600E when it's not in use so let's all just take pride in knowing that an old Thinkpad 600E is still alive and in service on the frontlines.

PS: I would install Linux on it but I can't find a driver for the USB interface of my SpeedStream ADSL modem.

Flash Game: Darts

Check out this really cool game of darts:
http://www.gamesolo.com/flash-game/darts.html

It's fun to play - you use the mouse to aim left/right and hold the mouse button down to set the force at which you throw the dart. It's pretty much impossible to beat the computer-opponent at the game though.

Tuesday, March 31, 2009

Will Users Switch Over To Windows 7?

After Windows Vista was released, some users decided to take the leap and stayed on in the Vista camp while others were forced there as it was pre-installed on their computers. In either case, the most popular OS running on PCs today is Windows XP which according to NetApplications Market Share is 63.5%.