Search This Blog

Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Wednesday, March 3, 2010

Counting lines of code



$ find . -name *.java |xargs wc -l


But this counts blank lines and comments as well! Better ideas, anyone?

Monday, November 16, 2009

How to mount NTFS partition in Linux

Well, these days, NTFS partitions do get auto-mounted. But it may get a little irritating when you are asked for the admin password every time you boot your comp and click on the partition.

So, to make the mounting "truly" automated, you have to add an entry to the file /etc/fstab.

In my case, I had to add
/dev/sda3  /media/cdrive  ntfs-3g defaults

So, the first thing you have to do is - create a directory /media/cdrive. Then, to find out which device your ntfs partition is listed as, run

# fdisk -l
Disk /dev/sda: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x01238b30

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1          26      208813+  83  Linux
/dev/sda3           29447       38913    76043677+   7  HPFS/NTFS
/dev/sda4              27       22978   184361940    f  W95 Ext'd (LBA)
/dev/sda5              27       20914   167782828+  83  Linux
/dev/sda6           20915       22873    15735636   83  Linux
/dev/sda7           22874       22978      843381   82  Linux swap / Solaris

From what I can see, my NTFS partition is /dev/sda3. This is how my /etc/fstab looks after making the entry.

# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
# / was on /dev/sda6 during installation
UUID=295dd122-7bd3-49e3-8e94-e192bd48e741 /               ext4    errors=remount-ro 0       1
# /boot was on /dev/sda1 during installation
UUID=31640fe8-bd0a-409f-b09e-f340e31b87ce /boot           ext4    defaults        0       2
# /home was on /dev/sda5 during installation
UUID=88e313d9-2537-466d-9856-4ae03bf75f81 /home           ext4    defaults        0       2
# /media/cdrive was on /dev/sda3 during installation
UUID=286841F96841C672 /media/cdrive   ntfs    defaults,umask=007,gid=46 0       0
# swap was on /dev/sda7 during installation
UUID=872f1854-af38-48ee-807d-b46ec1db6a75 none            swap    sw              0       0
/dev/scd0       /media/cdrom0   udf,iso9660 user,noauto,exec,utf8 0       0
/dev/sda3 /media/cdrive ntfs-3g defaults



--------------------------------------------
Reboot. You'll find your partition mounted :)

Friday, September 18, 2009

Scilab 5.1.1 on Linux




Well, if you have landed on this page, you must have got something like this when you ran Scilab 5.1.1 on linux
bin/scilab: line 132:  8184 Segmentation fault      "$SCILABBIN" $*

The easiest way to get around this is to run it as
$ bin/scilab -nogui

You obviously will have to sacrifice the "improved" GUI features of Scilab 5.1.1. But it really shouldn't matter much as gedit/kwrite are perfectly fine as text editors. And I think the terminal version is much much easier to use than the GUI version.

Update:
  1. Well, no GUI is a problem when you want to plot graphs :( I haven't yet figured out a way to get around this.
  2. Ubuntu has a deb package to install scilab 5.1. Fedora users, bad luck.

Wednesday, July 15, 2009

How to set up SVN

I wanted to set up an SVN server for my project recently. Here is the small script that I wrote for configuring SVN. Just copy-paste it in a file and run it. It'll guide you through the configuration process.
-------------------------------------------
#!/usr/bin/bash

svnadmin create svnrepos  #creates a directory called svnrepos 
#in the current directory, and 
#creates the config files

printf "[general]\nanon-access = none\nauth-access = write\npassword-db = passwd\n" > svnrepos/conf/svnserve.conf
printf "[users]\n" > svnrepos/conf/passwd

while [ 1 -gt 0 ]
do
    printf "Username: "      #create username,password for 
    read user                #whom access is required  
    if [ $user == "q" ]      #press "q" to stop accepting username, passwords
    then
       break
    fi
    printf "Password: "
    read pass
    printf "$user"" = ""$pass\n" >> svnrepos/conf/passwd
done

-------------------------------------------------
To start svnserver,
svnserve -r /users/proj/prashanth.kamle/svnrepos -d

/users/proj/prashanth.kamle/svnrepos is the path of the directory in which the SVN repository would reside (/users/proj/prashanth.kamle is the current directory).

To stop the SVN server, just kill the process (or use the script below)
#!/bin/bash
pid=`ps -A|grep svnserve| cut -d" " -f1`
kill $pid

In my next post, I'll explain how to access SVN from eclipse. Till then, happy subversioning :)

Wednesday, June 17, 2009

Resizing images

Pictures accumulate. The treks, trips, parties and the infinite fun that we've had in the past one year of college has resulted in me filling up half my hard disk with photos. My dear friends have fancy cameras which produce 8 mega pixel images, each occupying almost 2.5MB of my precious hard disk space.

Since an 8 mega pix image is serious overkill, I decided to resize them all to 1600x1200 (2 mega pix, around 1MB). Now that I've turned all linuxy, I was looking for a 'Microsoft Office Picture Manager'-like application for linux when Sriram Kashyap suggested that it'd be way easier to write a shell script to do the job.

So friends, here it is :)
#!/bin/bash
pics=`ls $1 | grep JPG`
for pic in $pics
do
   echo "Converting $1$pic ..."
   convert -size 1600x1200 $1$pic -resize 1600x1200 $1$pic
done
Pass the folder containing your pics as an argument to the script, or just put the script in your folder and double-click :)