Blog

During the course of the day I encounter lots of challenges, some of which take minutes to solve and others that take much longer. My goal for this section is to keep track of these challenges and their solutions. I will turn the longer ones into articles, while the shorter ones will stay as blog entries. You can expect topics to range from very specific programming challenges to broader topics like life.

Below is a list of the recent blog entries. You can also browse the blog by using the tags on the right side, or if you know what you are looking for then you can use the search box at the top right.

RFS Explorer 0.9 Released

Finally I got around to finishing up RFS Explorer. New features include, among others, actual sorting icons for the listview (before I was using "v" and "^" :D), fixed sorting on the listview, trimmed paths in labels for easy visuals. Check it out here.

End of Another Year

Last night was the end of another year in my life. This was an interesting year but from the past three/four months I can see that the future will be even more interesting, exciting, and adventurous! 😀 Wish me luck 🙂 My achievements for last year included becoming an MCP, getting a new job at Epic Systems Corporation (where I have gotten three certifications so far), starting an almost regular exercise schedule and tons of other things (unfortunately/fortunately (?) this does not include mastering wheelie on the bike yet :(). Hmmm…. thinking about it, maybe I will post my career ambitions for this year.

Truncating Paths to Fit a Label

A new language’s success massively depends on how good the initial set of classes are. Microsoft has done a good job with the base classes for C# (a.k.a. .Net framework) which I think is one of the reasons C# is doing so good (plus the facts that Microsoft is behind it and the familiar C++/Java syntax). Anyways tonight while working on RFS Explorer I had a need for truncating the file path to fit the width of a label (by replacing the extra characters with ellipses). I remember doing this before for another program that I was working on so I started by searching online and after a minute I ended up at this page. The fourth comment is exactly what I was looking for. Below is the C# version in form of a function so it can be easily called or added to a code library.

COULD NOT FIND A LEXER FOR LANGUAGE ‘C#’

///

/// Makes the text in the passed label fit it's width by trimming in the middle and replacing with ellipses.
/// This should be called from the 'Paint' event of the label.
///

/// Label with the text and the size. /// System.Drawing.Graphics provided in the paint call (e.Graphics). public void MakePathElliptical_OnPaint(Label lbl, Graphics graphics) {
graphics.Clear(lbl.BackColor, ');
RectangleF rect = new RectangleF(0, 0, lbl.Width, lbl.Height, ');
Brush br = new SolidBrush(lbl.ForeColor, ');
StringFormat sf = new StringFormat(StringFormatFlags.NoWrap, ');
sf.Trimming = StringTrimming.EllipsisPath;
graphics.DrawString(lbl.Text, lbl.Font, br, rect, sf, ');
}

To use this you just have to override the Paint event of the label (this might also work in a textbox with slight modifications) and call this function like below:

COULD NOT FIND A LEXER FOR LANGUAGE ‘C#’

private void lblName_Paint(object sender, System.Windows.Forms.PaintEventArgs e) {
winFormUtils.MakePathElliptical_OnPaint(lblName, e.Graphics, ');
}

Below is a screenshot of what label will look like after going through this function.

Example

ArchLinux on VMware 3.2

ArchLinux on VMware 3.2

Here is an image of the error that I am getting when running ArchLinux on VMware version 3.2.

Quick Update

Just a quick update on what’s going on. Basically as usual I have a million things going on at once. Last weekend I replaced the debian installation on the "be all" machine, called exhilarator, with ArchLinux because I wanted to install most of the new stuff (now called "dreamer"! :)). Other than that I have I have been thinking of finalizing RFS Explorer but my brother’s laptop has started giving him problems so he stole mine. Actually I let him take it because I have been spending most of my time on dreamer and configuring it as a MythTV box (after all it is the "be all" box, right? :D).

Anyways, I just learned about the ‘screen’ program in linux. It is a very cool utility and you should definitely check it out! Basically it is the "visual" version of the "jobs" command that is part of most of the shells. You start a new ‘screen’ by running ‘screen’ and once you have started a long task, or just something that you want to keep running but would like to get back to at a later time (e.g. irssi 🙂 ), you can deactivate the screen by pressing CTRL-A,D. Once deactivated you can go back to it by typing ‘screen -r ‘ if you have just one screen, or ‘screen -r <PID>’ if you have multiple screens. You can use ‘screen -list’ to get a list of screens. It’s awesome, check it out!

2005-06-20: Below are some more useful ‘screen’ links:

VIM’s Command-Line Editing Window

VIM command-line editing window

I was thinking I knew quite a lot about VIM but guess what? I do not! 🙂

A few days ago I was doing a few repetitive steps on multiple files and at times I exited VIM (oh, who knows why!) and lost the history. So knowing the awesome power of VIM I knew there had to be some way… I ended up going to #vim for some help and up comes the topic of the command-line editing window. You can add, edit, or delete commands using the normal VIM editing power and re-run the sequence of commands. Here is a tip on vim.org with a little more information and below is a screenshot.

Debian 3.1 Released!

The long awaited Debian 3.1 release (Sarge push to stable) is finally uploaded to the FTP servers. I was kind of curious on whether the Debian team will make the Monday release date and they did. You can find more about it here. The Debian homepage hasn’t been updated yet…

RFS Explorer Beta

You can download the beta here.

Last few days I have been working on a GUI for the rfstool which allows you to browse ReiserFS filesystems on Microsoft Windows. The only thing is that after I started working on the project I found out that there were already two GUIs for it! So I went and checked out the more friendly looking one and realized that the GUI would freeze up as rfstool was copying large files in the background. This made me think that this would be a good time to learn some multithreading in Windows Forms and make my version large-file-friendly :). Anyways now you can download the first beta of the application. In addition to multithreading I added irregularly shaped "About" form just for fun 😀

In addition to a few things I still to need add the credits for the icons. Below a screenshot of the main form and I will posting the source once I clean it up a little and add some more comments 🙂

COULD NOT FIND ATTACHMENT AT POSITION ([inline:1], ‘1’)
Screenshot of the main form

Bash Prompt Reference

“Here”:http://www-106.ibm.com/developerworks/library/l-tip-prompt/ is a nice reference for customizing the bash prompt. Below is the PS1 that I use for bash under cygwin on my XP machine. A little color and it sets the title bar to the complete path of the current directory.

PS1="\[\e]2;\w\a\e[32;1m\]\u@\h \[\e[33;1m\]\W\[\e[0m\] $ "

Nice C# Multithreading Article

Want to learn multithreading in C# in System.Windows.Forms’ context? Check out this awesome article by Ian Griffiths at MSDN. I am working on a GUI for the ReiserFS command line tool (rfstool) and wanted to implement multithreading. After reading this article I am very confident about multithreading in C# 🙂 Thanks Ian!

As far as the application is concerned: I will be uploading the first version in the next few days.