Thursday, December 29, 2011

Removing mutlitple spaces in a file with single space in Linux

Folks, it is time for some Linux commands.

Ok. Here is the one that I have used, to remove lot of spaces between words with a single space in a file.

cat MoreSpaces.txt | tr -s ' ' ' ' > OneSpace.txt

For example the "MoreSpaces.txt file is having the following text.

"Hello          This is      having      more spaces        between words..."

So, once you execute the above command the output file "OneSpace.txt" will be created and it's contents will be like as given below.

"Hello This is having more spaces between words..."

Sweet isn't it ???





Saturday, December 24, 2011

Passing more than 10 arugumets to Windows Batch script

Last week came across an interesting scenario while working a batch script with my friend.
That is, we need to pass more than 10 arguments to a batch script. There will be no problem to pass 9 arguments. I will just try to explain the normal way we use to get up to 9 arguments and way to get more than 10 arguments.

Up to 9 arguments

Consider a script test.bat being called with arguments, a b c  as given below.

c:\> test.bat a b c
Inside test.bat we will getting the arguments as given below.
@echo off
           set arg_1=%1
set arg_2=%2
set arg_3=%3
For more than 10 arguments

We can not use %10 to get the 10th argument. Well, here is the solution we have found.

---------------------------------------------------------------------------------------
@echo ON

setlocal EnableDelayedExpansion

set arg_1=
set arg_2=
set arg_3=
set arg_4=
set arg_5=
set arg_6=
set arg_7=
set arg_8=
set arg_9=
set arg_10=
 //Tricky part
set /a m=0
FOR  %%i IN (%*) DO ( 
   set /a m+=1 
set arg_!m!=%%i
)

---------------------------------------------------------------------------------------

-Krishna








Friday, December 23, 2011

Apple wax peeler

I love eating apples, but I am very much worried about the wax on the apple skin. Even if we try to wash it, the wax will not go off very easily and the apple will be looking as shiny as ever after that.

I normally use knife to take it off, but I lose considerable amount of apple as well with the skin. At the end I will be eating only 70% apple alone. Considering the cost of the apple(Rs 25 /apple) this loss bothered me as well.

Accidentally seen a wax peeler tool when I was in a shop near my house. The cost is just Rs 25. 
Interestingly I found it very useful as it is taking skin of the apple alone and leaving much for me to eat. Hmm Yummy !!!!! ..

So if you go to shop next time, get one and enjoy. Will post some images if possible.

-Krishna.





Wednesday, December 7, 2011

show create table tablename - useful SQL query

Hello,

This is a very useful query in I used in MySQL to find out the "create statement" that was used to create a table.

It helped me to copy and paste the table.

Syntax and sample output,

mysql> show create table User\G;

*************************** 1. row ***************************
       Table: User
Create Table: CREATE TABLE User (
  ID INT(11) default NULL auto_increment,
  NAME char(60) default NOT NULL,
  EMAIL char(100) default NULL,
  PRIMARY KEY (ID)
) ENGINE=MyISAM


Unlike the query "desc tablename", which will give you the table definition,

we can get the table definition and the create statement from the

"show create table  tablename" query.


Guys, post your cases where you find this query useful.


-Krishna.

Friday, August 19, 2011

java.net.SocketException: No buffer space available (maximum connections reached?): JVM_Bind

Came across the exception in subject when starting a java application via wrapper. The java app never started. Found the below article as a solution in lot of forums.



http://support.microsoft.com/kb/196271

This article suggests to set the MaxUserPort in Windows  registry to 65534. This setting may solve the problem, however I have couple of questions here.
  1. The exception is occurring because of no TCP ports available at that point of time, so if you do a Server reboot, all the TCP port will be cleared up and java app can be started. 
  2. Is there any way to check (Windows Event log/ application log ) in Windows level when the java app trying to open the TCP socket it is failing. So that I can justify that the cause.
-Krishna.








Sunday, January 30, 2011

Bat bite -Interesting info

Hello,

Yesterday happen to see the bats biting humans in Discovery channel.

The interesting info is that, the saliva of the bats have anticoagulant( a substance which stops blood clotting) and analgesic. So when they bite mostly it will not be felt by the person.

I guess, similar is the case with Leech bite as well.

Did you guys know any other bird, insects like this.

-Beginner



Saturday, January 29, 2011

Electricity Bill & BSNL land line bill online payment links

Hello,

I have been using the below links for a while to pay my BSNL and EB bills. If you are not using, use the below links to create your account to pay the bills.

If you are tenant, the good news for you is you can ADD the new EB connection to your existing online account when shifted a new house.

  1. http://billchn.bsnl.co.in/index.html
  2. https://www.tnebnet.org/awp/TNEB/index.php
 -Beginner








Friday, January 28, 2011

SMS Modem connection - Test using Hyperterminal

Hello,

I have been looking at the possible ways to check the connection of a SMS modem in my machine. Googled a bit and able to find out some useful links which actually helped me. Thought of sharing this with you guys.

  1. http://help.expedient.com/dialup/hyperterminal.shtml
  2. http://www.developershome.com/sms/howToUseHyperTerminal.asp
  3. http://www.multitech.com/en_us/documents/collateral/manuals/s000444c.pdf (Specifically for Multitech Modem)  
- Beginner

Wednesday, January 26, 2011

Beginning

This is a beginning of my long lasted wish.

I always wondered, day by day we are learning lot of things either professionally or personally. So how about having those learning  recorded some where. Yes, I am going to use this blog to have those things recorded.

Please bear with my writing, if you happen to read my blog. Will try my best to have some thing in this space everyday.