Sunday, December 20, 2009

xargs

It was only today that I probably recognized the power of this command. For the first time in my life I combined this with "find" to play songs from a folder. Why is it interesting? Because, mostly the song name will contain spaces.

find ./ | grep mp3 | ls -Q | xargs mplayer

The above command will play all the mp3 songs in the current directory tree!

Wednesday, November 18, 2009

fedora 12

Fedora 12 is out. Grab it from here: http://fedoraproject.org/en/get-fedora

I am downloading it. Will take a while before I get it. More after I get it and install it.

Monday, November 16, 2009

gPXE

It was only today I noticed this. I was using etherboot in 1998 for remote boot. Well, I think I must have written about it somewhere. But, it was only today I went back to their site. A lot has changed. They now have a complete TCP stack on those boot roms and they support various protocols including HTTP and iSCSI. Well, one day I will go back to all these and enjoy doing the IE lab once again :)

http://etherboot.org/wiki/index.php

Sunday, November 15, 2009

Redoing the world: The google way

Google has been a pioneer in many areas. Be it search, mail or any other web related technology they have been treading paths which were/are avoided by many. Android, Chrome, Gears... the list is endless. About an year back they disclosed the hardware secret of their servers and the power supply used by them. There is something special about this company. They don't stop at getting their business done. But, they go far beyond and make everything they touch (or everything which touches them) their business.

Here are two new things they have disclosed recently. The first one is a programming language. It is called "Go". The more details can be found from this site:

http://golang.org/

What makes go special? For me these are the things which makes go special
  • Open source
  • Systems language with features from high level languages
  • Created by Rob Pike, Ken Thompson and Robert Griesemer
  • Compilation of code written in GO is much faster
Well, Rob mentioned this is to be used for web servers etc. So, I see a direct business interest for Google. However, many claim that it will take at least an year for this language to mature. Well, we lived with C, Java and C# for decades. who is in a hurry? :)



The second one that I wanted to mention here is the SPDY protocol. The link is below

http://blog.chromium.org/2009/11/2x-faster-web.html

SPeeDY is the HTTP replacement/enhancement from Google. They claim that page loading times can be improved as much as 55% with the help of this new protocol. They use multiplexed streams, HTTP header compression etc for achieving this. Well, you think this is all trivial and you can do it better? Feel free make suggestions and even modification to code :)

rsyslog

Today I had to get the logs of a machine on another. The simple reason was that the first machine was crashing and its log file was not on persistent storage. This was what I did.

On the client machine, edit /etc/rsyslog.conf. Add an entry like the one shown below


*.*                                                   @10.0.0.2


*.* says that any message of any priority comes under this rule. 10.0.0.2 is the address of the server where the log daemon is running. (Note the @ sign). After making this change, I restarted rsyslog on the client.

On the server, again edit /etc/rsyslog.conf. Look for lines shown below

# Provides UDP syslog reception
#$ModLoad imudp.so
#$UDPServerRun 514

# Provides TCP syslog reception
#$ModLoad imtcp.so
#$InputTCPServerRun 514

Uncomment (remove the #) the module and port number to allow receiving of log messages from the remote client. Restart the rsyslog here again. You will start receiving the messages from the client on your server.

How to test it?

The testing can be done very easily. Use logger on the client to log a message. For example, run,

logger "Test message from the client"


You will then see the message appear on the /var/log/messages of the server!

Sunday, November 8, 2009

Tech Trends

I am looking at new trends in technology which I would like to closely follow. Of course, I am going to be biased by what I do in real life.

Here is a quick list of items that I want to skim through and then short list a few. I will then deep dive into few of them to find the possibilities.

1. DLNA
http://www.dlna.org/home

They say that there will be more than 300M+ which are DLNA enabled by the year 2012. The seamless interaction of these devices are going to be a really new experience. Well, certain things need to be experienced before they are being judged.

I recently moved from 256kbps internet connection to 512kbps. The differences are dramatic. I am sure I could have never thought about these possibilities and experience when I was on 256kbps. The entire thought process would have been crippled by my experience so far. I believe its going to be the same for DLNA. You think of DLNA as something, and you will experience it as something else when you have 300M+ devices using it tomorrow.

2. Cloud computing

This has to somehow happen. It is happening. The likes of Google, Amazon, HP, Microsoft are pushing it. The day is not far when you move your applications to internet along with your data. The interoperability between various cloud apps and their desktop counterparts are aiming and promoting exactly this. As part of this, there will be higher synergy between various www sites.

Another offshoot of this will be tremendous growth in mobile computing and related technologies such as wireless technologies such as 3G, WiFi and WIMAX.

3. Augmented Reality

I need to pay more attention to this. This is still a fantasy for many. But not for all. http://www.hindu.com/2009/11/08/stories/2009110851251100.htm. I will study this further in coming days and then form my opinion on this.



These are also

Remember the milk

I went back to that site today. They have improved a lot and they got lot number of 3rd party services to link RTM with gmail, google calender etc. I am planning to try this for a few days. Most of the technology stuff will be done here as I have put a link to labels on this blog to many of the tasks.

Wednesday, October 7, 2009

Threads in GDB

I was recently facing some issue with a multi threaded program. The program was getting terminated because one thread was dying and it was causing a broken pipe in other threads. Now, there were multiple threads that are opening a pipe. The program had quite a few number of threads. Hence I could not find out which thread was misbehaving and causing the entire application to fail. However, this made me to look into threads support in GDB.

I found the following interesting articles on the net on debugging threads using gdb.

http://www.redhat.com/docs/manuals/enterprise/RHEL-4-Manual/gdb/threads.html

Here is a summary of commands

1. info threads
Shows information on threads

2. thread
Allows you to switch to that thread. Then you can do a bt or something similar

3. break file.c:lineno thread if condition
Allows to set a break point conditionally for a specific thread

4. set print thread-events on
Turns on printing entry and exit of a thread

5. thread apply args
Applies a command to a thread/all threads

I still don't know how to tackle my issue of dying thread. However, I expect a combo of 3,4 might shed some light. I will post the details tomorrow after trying.

Sunday, October 4, 2009

Picasa name tags

Well, I noticed this only recently. Today while adding a few photos to Picasa, I experienced the power of this feature myself. It could,

1. Detect almost all faces present in the images
2. Relate a number of detected photos and recognize they are photos of same person
3. Suggest close matches for most of the photos from already tagged photos.

The below image is a screenshot of google detecting almost all occurrences of my face from an album and suggesting that it is me! It has made a single mistake but that is the picture of one of my paternal uncle.



There was one more amazing factor. For every picture it was making some suggestions. The suggestions were mainly either a correct match or a person who is of close blood relation!

Well, I am not an expert in this field. But, I can see Google coming up with real image search in near future. Well done Google.

Saturday, September 26, 2009

Back home

http://www.olpcnews.com/laptops/xo15/video_xo-15_laptop_dual_boot.html
http://www.olpcnews.com/laptops/xo15/olpc_news_exclusive_xo-15_laptop.html

OLPC guys are back to basics. Though many claim that this is a undoing the all the research and innovation done in the initial stages of OLPC, I look at it as a journey towards real feasible commercial solution. VIA C7 was in market for many years now. So? It was after the death of many great personalities that we recognised their contribution to mankind. 5-6 years is nothing. Lets not get into it. However, my personal opinion is, if ARM is to be chosen, the sole basis should be the benefits of ARM over x86. It should not be for creating a lock-in for Linux.

Anyway, this is good news. Hope to see Linux on XO-2.0 too.

Saturday, September 19, 2009

clearcase find

Today I had to merge main branch files to a private branch. The reason was that people was updating the main branch and private branch was having many issues. However, when it came to updating files in private branch, I could not find which are the files that were branched out. This forced me to refresh some old commands of clearcase. I used a simple find to get a list of all files which were on a private branch.

cleartool find ./ -element "brtype(Private_branch)" -print

Let me also post some sites from where you can get some good information on clearcase commands.

1. http://www.yolinux.com/TUTORIALS/ClearcaseCommands.html (Has some simple examples)

2. http://publib.boulder.ibm.com/infocenter/cchelp/v7r0m0/index.jsp?topic=/com.ibm.rational.clearcase.hlp.doc/cc_main/c_hood_cleartool_cli.htm

3. Last but not least, use cleartool man to get offline help. (I goes without saying that you should have cc installation if you have to use it)

Sunday, August 23, 2009

mysql-embedded

Well, I was looking at sqlite last week. But while doing a yum update I found this rpm package. "mysql-embedded". On doing a rpm -qi, it told me that this is a C interface to mysql that can directly be embedded in your application. I haven't tried it yet. But I am sure its going to be interesting. The package has only one shared library. However the size is ~7.5M. If I happen to use it, will post again here.

Sunday, August 9, 2009

Presentation database

My wife asked me for this simple application which will store and display the details of daily presentations that they do at their department. Well, I can create a simple text interface in C and it will not even take me an hour to complete. But, there are constraints.

1. This has to be a graphical application
2. This has to be usable by non-geeks
3. This has to run on MS Windows!
4. This has to be searchable

I was thinking of many things. Till requirement 3, I can manage with some vague wiki/CMS software. (Say twiki with table plugin). However, that is surely not going to be user friendly. I have been recently been working on Java. But, my Java skills are not that good. Besides Java will be a overkill for such a simple application.

It is at this point I noticed sqlite. (Well, this has pained me through firefox cookie database once before this). When I read about it, I found that it has a good tcl API. So, thats it! sqlite+tcl/tk!

I have just started. Will keep updating this space as and when I progress.

Saturday, August 8, 2009

__VA__ARGS__

How to create a macro which takes variable number of arguments?

I had to do this as I wanted to replace a printf with a common debug function that can be turned on or off in the runtime. Besides, I wanted to print local variables from that function. The simplest way was to define a macro that will replace the printf.

However, printf takes variable number of arguments. How do I handle that in a macro? The answer was __VA_ARGS__. Using this, you can replace (more or less) any printf with something like what is shown below.


#define DBG_PRN(x,...) do {\
if ( is_debug_on() )\
{\
printf(x,__VA_ARGS__);\
}\
}while(0);


The downside is, you need to have minimum of two arguments for printfs. If you do not have minimum two arguments, you will get a compilation error.I solve this by providing a dummy variable.

The gcc way of doing this is different. That depends on the the pre-processor operator ## to achieve this. This method will help you solve the empty argument issue.

Saturday, July 18, 2009

Quick popup

Today I was downloading a file using bittorrent. I was using my laptop. I kept it on my lap and started working on a document when download was going on. After a while I noticed that the download has stopped. When I checked, I found that the network cable had come out. This repeated for a while and I found that how much ever I try, the cable will come out slowly as it was not really fitting in the socket. By the time I notice this, 10-15 minutes would have elapsed without network.

How do I know just when it gets disconnected? I was running XFCE. I knew that XFCE allowed to create widgets that can do this for me. But, reading and understanding them and again writing one will take time. Also, I cannot use any built in one as I want a real popup. (My panel auto hides. Can't waste height on a wide screen monitor).

This is what I did.

while sleep 1 ;
do
ping -c 3 www.google.com ;
[ $? == "1" ] && xterm -e "wall trouble && sleep 10";
done

Thats all! When my network went down, xterm just screamed on my face that there is trouble. Then I will push the cable a bit and press ctrl-c to dismiss the message. I love xterm... :)

/dev/port

This is something that I had known for years but never had a chance to try out. Recently I had to write a program to control parallel ports. I decided to do with iopl and in/outb. However, they did not work for me. Then I tried this. Just open the file, seek till where your parallel port is, write the data! It worked like a charm. Below is a small code snippet to do it.


#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/stat.h>
#include <fcntl.h>

int main(int argc, char *argv[])
{
    int fd1=-1;
    unsigned char data=0xaa;

    fd1=open("/dev/port",O_RDWR|O_NDELAY);
    if ( fd1 < 0 ) return fd1;

    lseek(fd1,(0x378+0x00),SEEK_SET);
    write(fd1,&data,1);


    return 0;
}



You will have to change 0x378 to your parallel port base address. Also data is at offset 0, status is at offset 1 and control is at offset 2.

Saturday, July 11, 2009

MAXNS

We recently had a requirement to have about 8 entries in /etc/resolv.conf. This was because the machine was to be used in various networks where the NS entry will be different. However, the default value of MAXNS in resolv.h is only 3 (There might be distros that might have set this to another value. But most of them have it at 3). That means, if I add a 4th or 5th name server to /etc/resolv.conf, all of them (starting from 4th entry) will get ignored.

What is the workaround? There are two ways to solve this. The first solution is to change MAXNS to some other value in resolv.h and recompile the stuff. Now, what is this 'stuff'? This stuff is glibc. Replacing glibc on a working machine can be disastrous. Hence I decided to recompile glibc on a new machine. Again, what if the machine did not accept a newly compiled glibc? I might not lose any data, but the effort spent will be wasted. Hence, I decided to make an lfs.

I downloaded an lfs live CD from here . Its been ages since I had done it last. This time, however, I decided to use jhalfs. LFS live CD has a user with the same name and the tool is present there. The glibc source tar ball was replaced by a modified one where the MAXNS was set to 8. It took one whole night. But it worked. I was able to set 8 entries in resolv.conf and they were all used.

What is the second solution? It is much simpler. Just install your own DNS server software and configure it in proxy mode. I did not try this. But, I am almost sure that it should work. Alas, its just a small piece of software. You can change it in anyway to accept any number of i/p and if you want you can write one overnight. We are evaluating both the solutions. They both have some common issues.

1. Resolution will take a long time if the address need to be retrieved from name server at the bottom of the list
2. If any one of the top servers decides to respond for the query with an address not found, then even if we have a correct answer from the bottom server, we will not get it.

However, the second solution has some workarounds for these two issues. The above two problems can be solved with the help of domain specific forwarders (named supports this AFAIK).

Sunday, June 28, 2009

Soft realtime

Recently we wanted to try out some hard real time stuff. When we attempted it, the results were not satisfactory. Today, I just tried a program to see how a soft real time program performs against a normal program.
(Notice the use of SCHED_FIFO and a priority


#include <stdio.h>
#include <sched.h>
#include <sys/time.h>

int main()
{

int retval=-1;
struct sched_param sp;
struct timeval tv;
int old=0;


#if defined(SFT_RLT)

sp.sched_priority=20;
retval=sched_setscheduler(0,SCHED_FIFO,&sp);
printf("Ret= %d\n",retval);

#endif

while(1)
{

gettimeofday(&tv,NULL);
old=(tv.tv_usec-old)<0?1000*1000+tv.tv_usec-old:tv.tv_usec-old;
printf("%u %u %u \n",tv.tv_sec, tv.tv_usec,old);
old=tv.tv_usec;
usleep(1000*200);

}

return 0;
}


I compiled two binaries from this

gcc -DSFT_RLT rt.c -o rt
gcc rt.c -o nrt

As one can easily see, the first one is a soft realtime program and the second is a normal program. I ran these programs under two scenarios. One, when the system was relatively free; two, when the system was loaded. This is what I did and observed.

Normal scenario (X, FVWM, Terminal, bittorrent and Firefox)



./rt./nrt

1246142672 137029 200069
1246142672 337101 200072
1246142672 537171 200070
1246142672 737242 200071
1246142672 937312 200070
1246142673 137344 200032
1246142673 337413 200069
1246142673 537486 200073
1246142673 737557 200071
1246142673 937627 200070

1246142672 004983 200072
1246142672 205055 200072
1246142672 405127 200072
1246142672 605199 200072
1246142672 805265 200066
1246142673 005331 200066
1246142673 205402 200071
1246142673 405538 200136
1246142673 605604 200066
1246142673 805668 200064

Then I tried running the same under loaded condition. (Just played a movie using mplayer. The other processes which were earlier running were running now also)



./rt./nrt

1246146025 832916 200046
1246146026 032951 200035
1246146026 233010 200059
1246146026 433064 200054
1246146026 633097 200033
1246146026 833150 200053
1246146027 033203 200053
1246146027 233255 200052
1246146027 433286 200031
1246146027 633317 200031
1246146027 833368 200051

1246146025 803540 200145
1246146026 003647 200107
1246146026 203734 200087
1246146026 403823 200089
1246146026 603918 200095
1246146026 804006 200088
1246146027 004127 200121
1246146027 204204 200077
1246146027 404257 200053
1246146027 604314 200057
1246146027 804368 200054

I guess the difference in result is noticeable.This is easier to achieve compared to hard rt, since there is no kernel patches needed. When we make a break through with hard rt, I will post again

Saturday, June 13, 2009

Migrating phpBB2.0.13 on RH9 to phpBB3 on F11

I am doing this for my division in SISO. I am typing in stuff as I do it.

1. Tar the old BB directory
tar cvjf bb.tbz phpBB2
(Replace phpBB2 with the name of the folder containing your earlier phpBB2 installation)
2. Get the data from the mysql table
mysqldump -u root -p --databases div_dbase > div.sql
(replace 'root' with any other admin name who has full permission and 'div_dbase' with the name of database used by your old installation)
3. Scp these files to your new machine.
(It is expected that you have mysql, php-mysql, apache etc are installed and turned on in the new machine)
4. re-insert the sql data
mysql -u root -p < div.sql
Note 1: If you are a mysql pro and want to take some trouble configuring a new user at your old machine who can access mysql db on the old machine from the new one, this step might not be needed
Note 2: The mysql that comes with F11 does not consider --- as a comment. However the old sql dump will have a line like -------------. Just edit it and make it -- --------------- (Note the space after two hyphens).
5. Untar the old BB2 installation folder into /var/www/html. Rename if necessary (You may want to use the same folder name for BB3)
6. Download and install BB3
7. Make the directories of BB3 owned by apache user
chown -R apache.apache forum
(Where 'forum' is the folder containing the BB3 installation)
8. Click on the convert tab. Enter necessary information. Assuming you followed step 4, you will have to enter: new root password, location of old BB2 wrt to new BB3 (If you were strictly sticking to these instructions, it will be ../) and the table prefix for the old db (phpbb_ is the default)

Thats it. Just click the convert button and you will have the new BB ready in a few minutes!

Thursday, June 11, 2009

Fedora 11

Downloaded at office for creating a website. Installed on an old machine. Did not use it much. On startup itself smart came and told that my disk is failing (Nice feature. Don't know if it was part of F10). I am downloading this at my house. But that will arrive only tomorrow. The most noticeable thing was bootup. Though, it did not happen with in 20 sec on my machine (mostly because of dhcp, I guess), the way the boot screen was transformed to initial login screen was really nice. More and screenshots after I get it installed at home.

Friday, May 8, 2009

Analysing a file (brute force method)

Recently I came across a page where someone was asking about finding the offset of a file system in a disk image. I am trying the following. Will update this post if I succeed.

for k in `count 0 1 100` ; do for d in `count ${k}000 1 `; do dd if=working.img of=ram/test.img skip=$d bs=1 count=512 &> /dev/null; file ram/test.img | grep ram/test.img | grep -v data; [ $? == "0" ] && echo $d;done ;done

count : this is a small program that I wrote. It take 2 or 3 parameters. "count 0 1 100" will print "0 1 2 3 4... 100". "count n 1" will print "n n+1 n+2.... n+1000"

The directory ram was mount point for a ram disk. It was created as follows

mkfs -t ext2 /dev/ram4
mount -o loop /dev/ram4 ram

Still its taking a lot of time and its eating a lot of cpu. Next, I will move the working.img also to ramdisk!

Thursday, April 30, 2009

Why not a decent NAS? (1)

There were a few things that I was reading/doing recently which led me think in this way.

1. http://tech.slashdot.org/article.pl?sid=09/04/27/2310234

MS researchers published a paper where they explains how a torrent session can be transferred from a Vista to a NIC on the same machine. This NIC runs Linux on ARM.

2. http://www.freenas.org/

A FreeBSD flavour that has only storage related functionalities. I downloaded the image for x86 and ran it under qemu. Checked the page on a browser. Except for a few, it was running almost the same functions that my laptop/TC was running.

3. EDMS

We currently provide support for EDMS in a few organisations. However, their requirements are simpler. Alfresco is really an overkill. This can be simplified.

4. The High power - Low power boards

Yes. There is a bunch of such boards which consume very low power yet have reasonably powerful processors and fast NICs. I recently setup an always on home server using a VIA board and cheap USB drives. The system is running for days together without any complaint. No cooling, no maintenance!

FreeNAS is a nice solution. But I am little too old to learn FreeBSD now (Might correct this statement in future :) ). I am planning to make a Linux NAS server. Got a call from someone. Rest later.

Sunday, April 26, 2009

Friday, April 24, 2009

mysql commands (2)

This is perhaps the most useful command in mysql that I have come across till now.

describe table_name;
This command will describe the contents of the table. Then it is very easy to insert the contents into the table.
insert into table_name ( var1,var2,var3) values (val1,val2,val3);
Next post after my current experiment :)

Saturday, March 28, 2009

2html.vim

Ever wanted to post your c code on your web page just as colorful as it looks in your vi editor? Well, I used to do this very often in the past. But then one fine day my (free) web hosting provider vanished and I lost all that. Then I stopped it for a long time. Recently I wanted to post some C codes that way, but could not remember how to do that. It took me 15-20 minutes of google search to get that command. Well its simple:

source $VIMRUNTIME/syntax/2html.vim
When you do this from vi, the window will split into two and one will show the corresponding html code generated (Ok, I hope its understood that this needs to be done when syntax highlighting is enabled). The new file generated will have the name . Save this new html file and you are ready to publish your code in its colorful glory.

Wednesday, March 25, 2009

Linux worms!

I was always with the group which argued that the Linux does not have worms and virus since it is not popular. Someone who is bent on paining the maximum number of people can easily do it on Windows OS family since it is the most widely used desktop OS. If tomorrow Linux replaces Windows, I feel, the same fate awaits Linux also.

http://dronebl.org/blog/8

I feel, it is a clear indication that if economy of volumes justifies, black hat hackers will find a way into your Linux system. All that talk about weak passwords etc is impractical since when you reach masses, a number of them will still have vulnerable passwords. In a way Linux has an advantage over windows since the people are more knowledgeable today than in the past as many of them have learned their lessons the hard way using Windows. Even today, I usually find many a edge device with default password. All I can say is, I see a good market for SELinux and related technologies.

Tuesday, March 24, 2009

Qt-4

I started learning this on Fedora 10 machine. The first thing that I noticed is qmake is named qmake-qt4. The following are my learnings yesterday.

1. Qt uses concepts of widgets (Which is very common and hence it was easily understandable)
2. Qt has built in layout classes which can be used to decide how you place your widgets in parent window
3. Qt has an assistant called assistant-qt4. This is used for searching and displaying Qt reference documents.
On F10, I found that assistant-qt4 is not able to search any docs as the docs were not installed. I have started installing them. This rpm is 85MB!
4. Qt works on "signals" and "slots"
5. Signals are the events such as mouse clicks
6. Slots are the functions that will be executed when a signal is received

Monday, March 23, 2009

Qt

For a while I was thinking about making some GUI programs. I have been looking at Java for that. But, for some reason I was not able to get into the details. May be because Java is still a mystery for me. It is only recently I looked at Qt. Since it is cpp, I feel closer to Qt :) I am going to try my luck with Qt. Will keep posting my progress here.

Compiling a Qt app:

0. Ensure that you have qt and qt-devel (yum -y install qt qt-devel)
1. Create a Qt source file first.cpp
2. Create a project with the command
qmake -project
3. Create a makefile
qmake first.pro
4. Make the app
make

Saturday, March 21, 2009

Remote console monitoring using screen

I wanted something like VNC for console. Had no clue whether such software did exist at all. In fact I did not expect to find any. I made a post at LQ and found not just one, but a bunch of them

http://www.linuxquestions.org/questions/linux-software-2/looking-for-console-monitoring-application-713280/

It was really shocking to discover that such a common application like screen had this feature and I never knew. I did help my client. Now I found a better use. I am running rtorrent session on one of my computer. Usually, I go upstairs and check the status. Now, I can run it in a screen session, ssh to the machine, connect to the running screen session using screen -x and view the status. Just makes me think how many such unexplored features will be there in each of the programs that we use daily!

Intel Vs. AMD

Recently I had an argument with my friend about Intel Vs. AMD. Who has the best processor?

I remember the time when the AMD was pushing its processors very hard in India. They had some numbers like 1600 and 2000 etc to claim their processors are as powerful as intel 1.6GHz or 2.0GHz. Though I don't remember the details, I do remember working on one of them. The experience was worse compared to working on a 800MHz celeron in our labs. Whatever it may be, the argument is that they were only trying to make the people understand that the processors are not to be judged by clock frequency alone. But, I feel, AMD eventually confused some poor customers who were not that tech savy and AMD made money out of it.

My friend was of the opinion that AMD has processors that are comparable to intels. The following site contains some data which says otherwise.

http://techreport.com/articles.x/16570

Let me just look at two ends of the spectrum. I will take the high end first. Intel's Core i7 is sitting there unchallenged. AMD is yet to produce a comparable chip. But they are a bit costly and work with DDR3 only (I recently checked DDR3 price in market. It was about Rs. 2700 (~$54) for 2GB). But, its simply the best.

Now come to the lowest end of the spectrum. I am just looking at Core 2 Duo 8400 and Athlon X2 6400+. Just look at the amount of L2 Cache. You can also see the cinebench graph there. Again Intel processor simple out performs the counterpart from AMD. Now the price. Intel is about $75 more than AMD. Is this a real difference?

The answer to the above question is a simple 'No'. Why? Assume that you use the computer for 3 hours a day (I use it for hours together and I don't know what is the average home usage. But, I am assuming it will be close to ~3 hours/day on a normal shared home computer.) The power consumed by AMD processor is 60W more than the Intel processor. Result? 60 * 3 * 30 = 5400 Wh. In my state, excess power usage causes electricity board to levy you a charge of Rs. 7 per unit (1 unit = 1kWh). This is about Rs. 450 ($9) per year loss. Eventually, if a home user sticks to his computer for 3 years, he will spent extra $30 on this processor through the power bill. In an office, the computers run from 8-9 in the morning till 6 in the evening. And, thanks to our enlighted employees, some of them run 24 hours. If you assume only 9 hour usage per day, you will lose ~$90 in three years.

So, my humble conclusion is to stick to Intel for the time being :)

Wednesday, March 18, 2009

Write only space in Alfresco

Ok, I needed a write-only space for the Alfresco that we were managing for a client. This is what I did. Before you read further, read this http://forums.alfresco.com/en/viewtopic.php?f=4&t=7156

Go to your Alfresco install folder
1. Edit tomcat/webapps/alfresco/WEB-INF/classes/alfresco/model/permissionDefinitions.xml
2. Look for permission group Contributor
3. Remove Consumer and ReadPermissions
4. Save file and quit
5. Restart Alfresco (I did this. May be not needed)
6. Create two users: user1 and user2
7. Create a folder in user1 and remove inheriting access. Make user2 a contributor to it and user1 a collaborator
8. Create another folder in user2 and add a workflow to move content to the folder created in last step

Thats it. Done!

Wednesday, March 4, 2009

mysql commands (1)

Following are some useful mysql commands that I learned today

1. Reset mysql root password

1.1 Stop mysql service

service mysqld stop
1.2 Start mysql in safe mode by skipping grant table

mysqld_safe --skip-grant-table
1.3 Enter as root user

mysql -u root
1.4 Change the root password

UPDATE mysql.user SET Password=PASSWORD('new_password') WHERE User='root';
1.5 Flush mysql privileges
flush privileges;
1.6 Kill mysqld_safe and mysqld

2. Add a database (Login to mysql as root for all the below operations)

create database ;
3. Add a new user

The command below will add a user. But there is a catch here. The 'password' should be the hash value of the password. To get the hash of a password, use

select PASSWORD('MyPlainTextPassword');
It will output a value like "1b25e4042f3f780d". Use this in the next command.
grant all privileges on db_name.* to 'user'@'localhost' identified by password '1b25e4042f3f780d';
4. Drop a user
use mysql;
drop user;

installing ikiwiki

Well, I have a machine running from a 2gb pen drive. When I wanted to install a wiki, all I saw was the size needed. (Ok, I was also interested in this when I saw it can use git -- one of my new fascination -- ). This one runs fedora 10. I followed the following steps to install it. Since it took me a while to get it working, I thought I will add it here

1. Install ikiwiki using yum (Don't remember which repo was used. I have fedora, updates and rpmfusion configured and enabled)
yum install ikiwiki

2. Add a user for this wiki
useradd wiki

3. Login as that user
su - wiki

4. Setup wiki (Catch: You need gcc for this. yum install gcc if you don't have one yet). This will ask you the folder to setup your wiki and also a user to edit wiki. Answer them with whatever folder name and username that you choose. (Rest of the article assumes that you installed it in "wiki" folder)
ikiwiki -setup /etc/ikiwiki/auto.setup
5. Configure your apache (Not needed if you have already allowed user directories and permitted executable scripts in them). This will have to be done as root

5.1 Allow user directories
Look for public_html in /etc/httpd/conf/httpd.conf. Comment "UserDir disabled" and uncomment "UserDir public_html"
5.2 Allow executable files in them

Add the following to your httpd.conf


Options ExecCGI
AddHandler cgi-script cgi pl


Do not use a SetHandler. It will result in errors from httpd (When you open the directory, it will try to execute the directory itself and fail)
5.3 Save your configuration and restart httpd

service httpd restart
6. Make changes to your wiki directories (Access control changes). This will have to be done as wiki user

6.1 Make your public_html accessible to other

chmod 711 ~
chmod 755 public_html


6.2 ikiwiki does not set certain permissions correctly and it leaves the cgi file suid. Take care of them

chmod g-w public_html/wiki
chmod a-s public_html/wiki/ikiwiki.cgi


6.3 You can also use some basic http authentication if you need.

Now your wiki should be ready to be used. Go to http://localhost/wiki/wiki to start using it

7. Last but not least, if you run into trouble, keep watching the httpd logs and then perform the action that caused the problem

tail -f /var/log/httpd/*


These logs are very useful and you can use them for debugging any issues regarding apache in general.

Sunday, March 1, 2009

git

I was using svn for version control. However, when you are travelling, svn is not the greatest VCS you can have. After having my share of server crashes, bad networks and places without networks, I decided to move to git, a distributed version control system.

Tuesday, January 27, 2009

Horde on F10

I wanted to install horde-webmail version on my Fedora 10. First and foremost, (my?) F10 seems to have weird problems with yum. So far my upgrade has failed 2-3 times for dependencies not satisfied. I had to get a few F9 rpms for satisfying these deps. With horde, I faced the following two issues.

1. When I installed horde-webmail, the installation script complained about DOM not being support by PHP. I had to manually install php-xml.
2. After installation, it complained about imap extension not being supported. I tried a "yum install php-imap"
Result...

Loaded plugins: refresh-packagekit
Setting up Install Process
Parsing package install arguments
No package php-imap available.
Nothing to do

yum repolist
Loaded plugins: refresh-packagekit
repo id repo name status
fedora Fedora 10 - i386 enabled : 2,220
rpmfusion-free RPM Fusion for Fedora 10 - Free enabled : 324
rpmfusion-free-updat RPM Fusion for Fedora 10 - Free - Update enabled : 262
rpmfusion-nonfree RPM Fusion for Fedora 10 - Nonfree enabled : 142
rpmfusion-nonfree-up RPM Fusion for Fedora 10 - Nonfree - Upd enabled : 163
updates Fedora 10 - i386 - Updates enabled : 2,850

Then I had to download this package from F10's site.
http://download.fedora.redhat.com/pub/fedora/linux/releases/10/Everything/i386/os/Packages/php-imap-5.2.6-5.i386.rpm

Yes. It was there. But yum did not recognize it. After downloading, I did a "yum localinstall php-imap-5.2.6-5.i386.rpm"
With this, and a restart of httpd, I was able to remove the imap extension error.

These are the points that I noticed.

1. Horde's installation is not user friendly.
2. F10's yum is screwed beyond any help
3. Horde has a bug that does an endless loop when php-imap extension is not found.
4. Firefox gracefully handles this situation
5. Konqueror fails miserably to handle above situation.

I am still fighting with Horde. More updates later.