Archive for August, 2008

Write PDF files using .Net

This item was filled under [ .Net ]

“iText is a library that allows you to generate PDF files on the fly” – using this library, one can easily write PDFs in .Net. To get started, download the library from http://www.lowagie.com/iText/ (or SourceForge.net).
After downloading the .dll file, add it as a reference in your application.
Sample code (C#.Net):

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;

namespace [...]

Continue reading...

Calculate time difference in hh:mm

This item was filled under [ SQL Server ]

A simple query that computes time difference between two dates and displays the result in “hh:mm” format.

– 2008-08-10 00:00:04 < Start_Time
– 2008-08-10 08:32:17 < End_Time
– 8:32 << Output (HHMM_Duration)

SELECT Start_Time, End_Time,
CONVERT(VARCHAR, DATEDIFF(hour, Start_Time, End_Time)) + ':' + CONVERT(VARCHAR, DATEDIFF(minute, Start_Time, End_Time)%60) as HHMM_Duration
FROM Events

*The above query was executed on Microsoft SQL Server 2000.

Continue reading...

Manage hostnames on local PC

This item was filled under [ Uncategorized ]

Every OS has a ‘hosts’ file that defines mapping of hostnames to IP address. The computer file is used to store information on where to find a node on a computer network, and is under the control of local computer’s administrator.
‘Hosts’ file can be helpful for blocking/redirecting hostnames and accelerating DNS resolution. It is used [...]

Continue reading...

Wordpress: ‘Recent Comments’ snippet

This item was filled under [ PHP, WordPress ]

A little piece of code that I found on BlogOhBlog.com. However, the code wasn’t doing proper formatting since all comments exceeding the sidebar width ended like the normal ones, so I simply added “..” at the end of lengthy comments. Also modified the display format to:
<Author> (on <PostTitle>):
<Comment text>
The code snippet can be used to [...]

Continue reading...

List of Google bots

This item was filled under [ SEO/Adsense ]

Google uses several user-agents. Using the bot name, you can block access or track any user-agent easily.

Googlebot: crawl pages from web index and news index
Googlebot-Mobile: crawls pages for mobile index
Googlebot-Image: crawls pages for image index
Mediapartners-Google: crawls pages to determine AdSense content. Only used to crawl your site if AdSense ads are displayed on your site
Adsbot-Google: [...]

Continue reading...

Sending email through .Net

This item was filled under [ .Net ]

In .Net, you can easily send an email through MailMessage() class. Below is a little ConsoleApplication that shows how to send a simple email in .Net:
using System;
using System.Collections.Generic;
using System.Text;
using System.Net.Mail;

namespace ConsoleEmailApp
{
class Program
{
static void Main(string[] args)
{
MailMessage objMail = new MailMessage("<a href="mailto:from-email@domain.com">from-email@domain.com</a>", "<a href="mailto:to-email@domain.com">to-email@domain.com</a>");
SmtpClient objSMTP = new SmtpClient("smtp.host.com", 25);

objMail.Subject = "Sending email through .Net";
objMail.Body = "Hello World!";

objSMTP.Credentials = new [...]

Continue reading...