Using SCLC (Source Code Line Counter)

Well, it is really very simple. Here you go:

  1. Download the file. You can get it from here.
  2. Double click it. It should open as any other normal application.
    1. If it doesn’t open as expected or opens WinRAR/WinZIP/7-Zip or any other archiving software, follow here:
      1. Right click the file and point to Open With.
      2. Click on Select Default Program.
      3. Java should be here in the list of programs. If it isn’t then click browse and locate your java installation. It should be in C:Program FilesJavajre7binjava.exe
        1. If you dont have any folder called Java in Program files, then go to and download and install it first.
        2. Once Java is installed, follow step 2.
      4. Click OK. Follow step 2.
  3. Click on ‘Add File’ button to add files to it. A dialog box will be presented.
  4. Locate your source code files. You can select more than one file by selecting one file and then holding the ‘Ctrl’ key and selecting other files. Alternatively, if you wish to select all files, you can press ‘Ctrl + A’ to select all files in the directory you are in.
    1. Make sure that you do not select any executable files. This may cause an error.
  5. Click OK/Open.
  6. You should see list of files in the list above ‘Add File’ button. If you wish to add more files, follow step 3.
  7. Once you are done, click Start. It will start counting lines in the files you have selected.
  8. You’re done! The table will display number of code lines in each file and below the table you’ll find total line count and line density.

I hope you like it. Feel free to shout out any suggestions/feedback you have regarding this small application. Have fun!

If statements in Linux Shell Script

If statements are important in any programming language. I had a bit of hard time while doing if statements in linux since they are different than those in a conventional programming language. First of all, an if statement to compare whether a value in a variable val1 is equal to 5 is like:
if [ $val1 -eq 5 ]
     Code here to do some stuff
     If above condition is false, then code here gets executed

Note that spaces are important when defining condition. $val1 refers to the variable and -eq simply implies equal to operator to compare if the $val1 is equal to 5.

Seems pretty easy? It is. Other conditional operators are:

Conditional Operator Linux Equivalent
Greater than -gt
Less than -lt
Equal to -eq
Not equal to -ne

Now, if I want to compare strings, for instance, if variable answer is equal to “yes” then the code will be as follows:
if [ "$val" = "yes" ]
     Code here to do some stuff

Again, spaces are important here.
In here, ‘=’ can easily be replaced by conventional conditional operators like ‘>’ or ‘<‘ or ‘!=’ etc.

Variables in Linux Shell

Well, this has been a bit tricky for me so I decided to put it on my blog so that it can be helpful to you guys.

First of all, How to define a variable?


There! I’ve just defined a variable count with 0 as its initial value.
Now, How do you print value of a variable?

echo "$count"


echo $count

Next. How do you perform calculations on a variable?
Okay. So assume that you have two variables called val1 and val2 with values 3 and 4 respectively. Now, you want val3 to have the addition of val1 and val2. So,

val3=expr $val1 + $val2

Similarly, to do subtraction:

val4=expr $val1 - $val2

Note that spaces are very important here.

Now, if you wish to assign value returned by a command to a variable, then it works by doing:

wcount=wc -w myfile.txt

anything between and will be executed as linux command and the value returned by that command will be assigned back to the variable to left.

How to extract words from a string in C# (Split string)

This is incredibly easy in C#. First of all, you need to have a string from which you want to extract words. A word is a string separated by spaces. To do that, just say:

string s = "Welcome to my blog!";

Now, when I use the Split command, it will return an array of individual strings. So, the implementation will be:

string[] words = s.Split(" ",StringSplitOptions.RemoveEmptyEntries);

As a result, words array will contain “Welcome”, “to”, “my”, “blog!”.

Google Chrome vs Mozilla Firefox

Well, they said that Mozilla firefox is the most efficient browser. I wasn’t satisfied. Hence, I went to check. I am a big fan of Google Chrome. However, I recently learnt that chrome collects browsing information. That didn’t sound good to me and hence I switched to Mozilla Firefox. On the download page, it said that it is the most efficient browser. I downloaded it, but initially I had some issues. It lagged a bit when I used it on my laptop. However, when I used it on my university’s mac (with Windows 7 installed) it was smooth. Hence I was suspicious. I had to check. I closed all applications, refreshed the page few times and fired up Mozilla Firefox and Google Chrome.

I opened up in both the browsers. I fired up Task Manager only to find that Google chrome had three simultaneous processes and firefox had one. This probably means that it is doing multi-threading a lot and has a lot of external handlers. It is a good practice though when you are programming something like a web browser. However, I counted the memory allocated and firefox had like 88,000 and Google Chrome had in total something like 50,000. I was surprised.

Then, to satisfy myself that Firefox is better, I opened two tabs in both chrome and firefox. In one tab, I opened the google home page and in another I opened up This time, I hoped chrome to jump up. The task manager showed that chrome had four processes, one more than last time I had seen and firefox still had one process. In terms of memory, firefox allocated something like 120,000 and chrome took something like 90,000. I was even more surprised. My quick analysis at that point was that the memory print of chrome increases rapidly with increase in number of tabs while in same conditions, that of firefox increases at relatively slower rate.

In the third test, in which I seriously hoped firefox to win, I opened up four tabs as follows:
1. Tab 1:
2. Tab 2:
3. Tab 3:
4. Tab 4:

This time, firefox really won. Its memory print was around 143,000 while at the same time, that of chrome was around 150,000. Yayy! Victory at last!

So, well, what does this tell to average computer user? I will still be using firefox. However, if I quickly want to check something like a definition or address, I’d use chrome. However, for tab intensive stuff like research and like that, I will be using firefox.

Chrome: 12.0.742.122
Firefox: 5.0

%d bloggers like this: