Browsing the archives for the cli tag.

Ohcount and Count Lines of code

Coding

Ohcount and Count Lines of Code (CLOC) counts size of code project. Mostly these aren’t very useful applications, but it is fun to see that I have written 300 lines of code in couple of days.

Ohcount is used Ohloh to generate source code reports. I was disappointed to found that i can’t use Ohcount to scan whole history of my repository, it only scans current status of code.

CLOC is written in Perl and Ohcount in Ruby. It maybe little annoying to compile Ohcount from source, but it is much faster than CLOC. If you want something that is easy to install, take CLOC. But if you are going to analysis more often than once, try Ohcount.

Here is example output from CLOC:


96 text files.
83 unique files.
33 files ignored.
http://cloc.sourceforge.net v 1.08 T=7.0 s (8.9 files/s, 547.4 lines/s)
-------------------------------------------------------------------------------
Language files blank comment code scale 3rd gen. equiv
-------------------------------------------------------------------------------
PHP      49    588   172     1950 x 3.50    = 6825.00
SQL      1     58    87      277  x 2.29     = 634.33
BASH     10    54    133     261  x 3.81     = 994.41
CSS      1     46    5       192  x 1.00     = 192.00
Python   1     2     1       6    x 4.20       = 25.20
-------------------------------------------------------------------------------
SUM: 62 748 398 2686 x 3.23 = 8670.94
-------------------------------------------------------------------------------

And here is Ohcounts output from same file:

Examining 555 file(s)......

Ohloh Line Count Summary

Language Files Code Comment Comment % Blank Total
---------------- ----- --------- --------- --------- --------- ---------
php      58    2146 219     9.3%      716  3081
sql      1     277  87      23.9%     58   422
html     60    242  1       0.4%      38   281
css      1     192  5       2.5%      46   243
python   1     6    1       14.3%     2    9
---------------- ----- --------- --------- --------- --------- ---------
Total 121      2863 313     9.9%      860  4036

- Gestalts -------------------------------------------------------------------
Platforms: PHP, SQL, Scripting

Yep. There is some difference on results. I don’t know which one is more accurate.

I haven’t posted for a while because I have coded my main project. It isn’t public, but I will blog about it when it is ready. :) I try to blog more often.

No Comments

How to do a quick backup at console

Linux, Tutorial

So, you are coding your project and you realize that you haven’t done any backups! What is the easiest and fastest way to do backup (I don’t know about speed and difficult of this method, but it works and I like this.)

Dump your databases! (if you have any)

Mysqldump --databases dbname > dump.SQL

Then move to parent directory

cd ..

And do a tar archive

tar cvvf project.tar project/

And voilà! Local backup is ready, let’s move it to safe place in your ftp server…

ftp ftp.example.com

Use ls and cd to find right folder on your server, then move local file with:

put project.tar

Whee! Now you have backups safely on your server! It is possible to write a cron script that backups and uploads your project every hour.

No Comments