Thursday, 19 April 2012

Food honour :P

Mongolian traditional food called "Huushuur"




Indian Food "Butter Chicken & Butter Nun"

Korean food "Takturitan"


Saturday, 14 April 2012

C#: Multilingual application

This is all about developing an application which supports multiple languages.
So that, you need two or more resource files as you need. These files hold the translations corresponding to languages.
As shown bellow figure, you can add resource files to your application. (C#.NET 2005).

Wednesday, 11 April 2012

C# :Count the total number of lines in RichTextBox

All you have to use is RichTextBox.GetLineFromCharIndex method.

int lineNumber = richTextBox1.GetLineFromCharIndex(richTextBox1.TextLength) + 1;
MessageBox.Show(lineNumber.ToString());
This 2 lines of code will give you number of lines in RichTextBox

You will find more detailed explanation here:
GetLineFromCharIndex[^]

Here is complete example of counting total number of lines in RTB

Saturday, 7 April 2012

C#: Read from excel file

I used .NET 2.0 framework. Reading from excel file is depends on excel's version, not entirely but it will affect your source code little bit.

Here is little tip about reading excel file.
string mFileName; // file name which you will read from.
System.Data.OleDb.OleDbConnection connection;
string mSheetName; // excel file consists of many sheets / pages.
System.Data.OleDb.OleDbDataAdapter dtAdapter;
Reading from excel file is as same as reading from database, so that you will need connection string which helps you to connect your program to excel sheets, as well as dataAdapter which will retrieve data from excel sheet.

This function accepts 2 arguments which are describe excel file's name, and it's version.
If you are using excel 2007 then send true as a second argument, or else send false when you call this function.

C#: Read from command Prompt

I've been trying to read from Command prompt using c#. My application supposed to read lines from cmd whatever it shows. My Purpose was developing code editor and using external compiler.
 You need to use  System.Diagnostics.Process(System.Diagnostics.ProcessStartInfo).

System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo("file.exe", "command");
startInfo.RedirectStandardError = true;
startInfo.RedirectStandardOutput = true;
startInfo.StandardOutputEncoding = //change if you need, you might need it
startInfo.StandardErrorEncoding = //change if you need, you might need it
//...

Using this example, file.exe could be any executable file and command, it should be related to exe file. In this example, file.exe is "cmd.exe" and "command" is "RUNCOB"

PHP: How To Create Thumbnail image.

Someone may wonder that when we have Photoshop, why do we bother to create thumbnail images using Php? Well answer is quite easy, whenever you upload photos to your web site to attract your readers or someone, every time you will have to cut or crop or do something on your photos by manually. Is not it annoying?
Once you completed your few lines of code you will no longer suffer from editing photos.
Here is your source code.

// Path of photo.
$img_name="Gear2nd.sized.jpg";
//In this case thumbnail image size will be twice smaller than its original.
//based on original photo's size this size can be changed.
$thm_size=2;
// Type
header('Content-type: image/jpeg');
// Generating Thumbnail's size.
list($width, $height)=getimagesize($img_name);
$new_width=$width / $thm_size;
$new_height =$height / $thm_size;
// Generating thumbnail image
$thm_img=imagecreatetruecolor($new_width, $new_height);
$img=imagecreatefromjpeg($img_name);
imagecopyresampled($thm_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
// show off the thumbnail
imagejpeg($thm_img, null,100);

Result :
Good luck