প্রথম বাংলা post!

এইটা আমার প্রথম বাংলা পোস্ট (post এর বাংলা যেন কি!).. anyway.. কোপা শামসু!!!

Posted: April 25th, 2010
at 10:23pm by Kayes


Categories: Uncategorized

Comments: No comments


Sorting a string array in lexicographical order using LINQ and Lambda expression

I think I wrote a function in C for this purpose back in school days. I needed this again in one of my projects recently and for a couple of seconds I thought of a C# – port of that code before I’d realized that LINQ and Lambda expression could come to my rescue. And all it took is mere 4 lines of code (if you count the string array declaration line in the sole purpose ;) )

Oh, and you must add the System.Linq namespace.

string[] strArr = new string[] { "Gibbs", "Ntini", "Pollock", "Cronje", "Smith", "Kirsten", "Steyn", };
List list = strArr.ToList();
list.Sort((str1, str2) => str1.CompareTo(str2));
strArr = list.ToArray();

After the sort the array looks like this:

{ "Cronje", "Gibbs", "Kirsten", "Ntini", "Pollock", "Smith", "Steyn" }

Posted: April 19th, 2010
at 2:42am by Kayes

Tagged with , , , , ,


Categories: C#

Comments: No comments


Using Enumeration types in switch-case block and ComboBox in C#

Here’s a code snippet that demonstrates how to use enum types in a switch-case block in combination with the ComboBox control. Just wanted to share ’cause I had to look it up on the web. Hope it helps somebody.

using System;
using System.Windows.Forms;
using System.Diagnostics;

namespace EnumWithCombo
{
    public partial class PlayerSelectionForm : Form
    {
        private enum Players
        {
            Gibbs, Richards, Cronje, Kirsten, Kallis, Smith, Villiers, Pollock, Ntini, Klusener, Steyn, Rhodes, Bosman, Kemp, Botha, Harris, Roelof
        }
        private string url = "http://www.cricinfo.com/ci/content/player/45224.html";

        public PlayerSelectionForm()
        {
            InitializeComponent();
            playersComboBox.DataSource = Enum.GetValues(typeof(Players));
        }

        private void submitButton_Click(object sender, EventArgs e)
        {
            switch ((Players) playersComboBox.SelectedItem)
            {
                case Players.Gibbs:
                    Process.Start(new ProcessStartInfo("iexplore", url));
                    break;
                default:
                    MessageBox.Show(((Players) playersComboBox.SelectedItem).ToString());
                    break;
            }
        }
    }
}

Posted: June 17th, 2009
at 5:08am by Kayes

Tagged with , , ,


Categories: C#

Comments: 1 comment


Jigsaw Puzzle

I created the very basic engine back in 2007. That was only to make the puzzle pieces from an image. But never really felt like completing the game (I’m too lazy)! Anyway, I decided to have a go at it and following is the result of my past couple of days’ work. There’s a lot to be done/ fixed though. The puzzle pieces are generated programmatically. There are no fixed/ static masks/ shapes. So there’s actually no limitation of the image size. And the images can be broken into any number of pieces. The larger the image and the more the puzzle pieces, the higher the pieces generation time. Currently I used a 400×400 image and broke it into 64 (8×8) pieces.
Of course, there are some scope of optimization in the code. But all I wanted is getting a playable demo ready in as little time as possible. And the end result is not quite bad I guess ;)

Anyway, the to-dos are:
1. Allow uploading custom image
2. Logging player scores

(Click to launch the demo)

Image Hosted by ImageShack.us

Posted: May 4th, 2009
at 9:08pm by Kayes

Tagged with , , , ,


Categories: Games

Comments: 7 comments


Firefox memory usage: 1.7 GB!

For the second time when I was getting into the mood of writing something on my blog I got bogged down with another nasty Firefox mess-up. This time around, it was using up almost all of my RAM (1.7 GB). My PC got awfully slow as soon as I started Firefox and instantly knew it was my favorite browser as I heard of such huge memory usage from other FF users. But the funniest part was after restarting, I was notified that update 3.0.9 is available!

Huge memory usage by Firefox

Posted: April 23rd, 2009
at 1:45am by Kayes

Tagged with ,


Categories: Uncategorized

Comments: 1 comment


Lost my Firefox profile

I can’t believe I have to start my real blogging career with this post. I’ve just lost my Firefox profile! And that in a strange way! I usually put my Firefox profile folder in a separate directory instead of the default location. I keep a primary folder in my non-OS D: drive which contains all the different profile folders. The structure looks like this: “D:\firefox_profiles\kayes\”.

browse

‘kayes’ was the only profile I had at that time. Anyway, I was creating another profile and I mistakenly selected “D:\firefox_profiles\” as the location to save the profile files whereas I should have created a new folder under ‘firefox_profiles’ and selected that. As soon as I finished creating the profile, I noticed what I did wrong and wanted to start over. So I deleted the newly created profile ‘Default User’ and that’s when I made another, this time bigger, mistake.

delete

I deleted the profile with all the contents and since the newly created profile files were to be saved under “D:\firefox_profiles\”, the whole ‘firefox_profiles’ folder got deleted with my regular profile ‘kayes’. It took me a moment to realize that and I just kept sitting like a dumb. All my bookmarks, saved passwords, plugins, opened tabs… all gone! But fortunately I could recover the bookmarks which I periodically took backup of as HTML files for another purpose. So all is not lost I guess. Happy blogging!

Posted: March 6th, 2009
at 11:47pm by Kayes

Tagged with


Categories: Uncategorized

Comments: No comments


TestPost

This is another test post!

Posted: August 6th, 2008
at 1:13am by Kayes

Tagged with


Categories: Uncategorized

Comments: 4 comments