Saturday, January 31, 2009

The FANTASTIC FOUR

Hi all.... it's Jan 31 and quite a dramatic day.... i wont use the word dramatic but rather eventual, where you just love the flow of events!!

The Fantastic Four must have struck to u as the famed TV series and the comic basher. Though i don't have slightest of hint what's it all about... i'll try to weave my own in here :-D!!

Fantastic four.... hmmmm..... so what is this fantastic four all about!! Hey, hey do you know that i know four Neha's :D, hehe.....

1. She's the old school friend -- and she's hot by all means :P
2. She's my maternal sis.... mamaji ko namaste :D
3. This is one neha i've talked only twice and met once.... but sometimes singleton == ton!! :P
4. She's the latest entry.... but it feels like me, her and gtalk are made for each other :P

Now the thing with Neha's in my life is this.... whenever they do something i have to cry a lot, the third Neha that i met was not a consious effort! I referred the first Neha and she advised me so.... i know, i know it's damn amazing :P. Btw i had to cry because i came all wet in rain and the meet was almost futile.

Then I got this Birthday Card from the fourth Neha... she's a State of Art intellect from BITS Pilani( no pun intended ), and what was written in the card made me almost hysteric, it's such a pleasure to have all you neha's!! But again the fact that all neha's make me cry though in different modes.... makes me laugh a lot.

Haha.....

Well there's another FAN 4 that u need to look out for... the last 4 days have been the most fantastic of my life. Ok have a look at this....

There's a video given to u, there are cars passing through it and your job is to identify the fastest car... get a suitable frame out of the car, extract the number plate and mark it with a box. Not had enof... u'll have to identify the number scribbled in the plate.

Now that's some heck of a statement. But the sorta extreme programming i have been going through, it's been amazing to see how an individual lifts himself in time of crisis AND fervour. Of course here it's fervour :P

FYI, i with my worthy intellect Rohit Hiwale worked in Matlab. Now matlab is one heck of monolithic marvel. You just cannot get out of the box once you enter Matlab. The best, no where do you need to reinvent the wheel. We used Image Processing and my job was Video Processing.

Feels geeky, FYI again.... i had no knowledge of Processing Images or Videos, but MATLAB makes it so very abstract that you just need the programming skill.... the algorithm part is blown apart from your head.

Not only processing.... my other job was to prepare a Arificial Neural Network( ANN ), wow wow wow, ANN sounds super hot and cool, right!!

Well it is that way.... and again matlab keeps the complexity on it's shoulders :D. I refer Matlab to everybody who's interested in ne sort of coding relaed abstract job. Do visit matlab and see if things can be achieved from there on... things generally happen intuitively in matlab :P

Hats off to the MathWorks team and these Fantastic 4 dayz.......

Chao

Sunday, January 25, 2009

The HECTIC few dayz!! CASE STUDY

Well it has almost been 10 days since i have even thought of posting a blog. Let's talk through what all happened,

Starting from Jan 17th it was the old mundane life but with an Inter Hall event Case Study round the corner, 19th Jan, life became super duper hectic ;-)!!

I had, wth help of my Gen Sec, arranged a Xavier Mangmnt Insti, Bangalore professor, Prof. Subhasis Ray. Well the event was at Vikramshila halls, and no doubt i had to toil my sweat out to arrange it, but as always is... it's fun to see when things start rollin'.

The event started in time( a rarity in Kgp ), and to the utter surprise ended 1.5 hrs before we estimated( for Kgp it's a miracle ), now thats precision and wonderful execution. :D

All was well, but congratulation for such a marvellous event DIDNT actually come :(. Well u must be surprised at it. The thing with the General Championship is that the marks of the event are more important to the Halls then the event itself.

I didnt see any hall stay back after their presentation to actually have views of others, rather they had made their hall representatives have an eye over me so that i may do my job unbiased! U know this feeling that pple really dont believe u, only because they dont want to, is really sinking.

Newayz i am the organizer and critics are my Bosses :P.

The worst part guys, yeah again Kgpians might have guessed it. Have them one big chunk of scrap at a time, Chaoses:

1. The rule says u cannot metion the hall name, member's name or reveal any hall identity BECAUSE it might influence the Judje. Well technically speaking this is all for internal judjes who might be themselves had some hall biasness.

The chaos ovr the rule: A team member summoned ovr a member of his team by name, just to give the mike. And u know what after the event the CHAOS bell.

The remedies: Rule should have been for inhouse judjes. WTFFFFF!!!!

2. One team member was in full steam... rather overheaded with steam :D. When time was called he exceeded the limit by 5 sec in order to complete the statement. But as u might have guessed.... CHAOS!!!!

Plz Halls be sensible... i know that cannot happen, but atleast try to change this dirty trend! The mud slinging and no-interest-in-event and all-chaos-and-points thingy is really not cool. I alwayz mention in my posts to all hall General Secy's, use common sense.

But as another part of this distorted coin, i am thankful to GSec's for being supportive and flexible before events. This helps us a lot to organize stuff where we can actually do somethin', where we actually have the liberty to think, where we feel like we have the authority!!!

Thank u all

Saturday, January 17, 2009

C Up your skills!!

Well this is the second part of C Up your skills. And lemme tell u it's real time obfuscation.....

The code is working but it aims to solve the tower of hanoi!

And some changes need to be made in order to make it work. The changes are per character and maximum 10 such changes are available:

#include
#include
static signed char a[] = {'i','n','v','a','l','i','d','\0','b','y','e','\0','r','e','m','o','v','e',' ','%','d',' ','f','r','o','m',' ','%','s',' ','t','o',' ','%','s','\n','\0'}, *b = a+8, *c = a+14, *w, *x, *u, *y, *z; int main(int d, char *e[]) {int r, n;return r=(d==6?0*(*(y=e[2]),*(u=e[3]),*(z=e[4])):0*puts(a) +1)||(((w = e[1]) && w[0] == 's')?0:0*puts(b) + 1)||((w[1] == 'o')?0:0*puts(b) + 1)||((w[2] == 'l')?0:0*puts(b) + 1)||((w[3] == 'v')?0:0*puts(b) + 1)||((w[4] != 'e')?0*puts(b) + 1:((n=atoi(x=e[5])),(n ==1)?0*printf(c, n, e[2], e[3]):(sprintf(x, "%d", n-1),e[3]=z,e[4]=u, main(6,e),printf(c,n, e[2], e[4]),e[2] = z,e[3] = u, e[4] = y, main(6, e), e[2]=y,e[3] = u, e[4] = z,sprintf(x, "%d", n))));}


I know it's real ugly maybe i might help in a bit of indentation:

#include
#include
static signed char a[] = {'i','n','v','a','l','i','d','\0','b','y','e','\0','r','e','m','o','v','e',' ','%','d',' ','f','r','o','m',' ','%','s',' ','t','o',' ','%','s','\n','\0'}, *b = a+8, *c = a+14, *w, *x, *u, *y, *z;

int main(int d, char *e[])
{

int r, n;
return r=(d==6?0*(*(y=e[2]),*(u=e[3]),*(z=e[4])):0*puts(a) +1)||(((w = e[1]) && w[0] == 's')?0:0*puts(b) + 1)||((w[1] == 'o')?0:0*puts(b) + 1)||((w[2] == 'l')?0:0*puts(b) + 1)||((w[3] == 'v')?0:0*puts(b) + 1)||((w[4] != 'e')?0*puts(b) + 1:((n=atoi(x=e[5])),(n ==1)?0*printf(c, n, e[2], e[3]):(sprintf(x, "%d", n-1),e[3]=z,e[4]=u,e[5]=x, main(6,e),printf(c,n, e[2], e[4]),e[2] = z,e[3] = u, e[4] = y, main(6, e), e[2]=y,e[3] = u, e[4] = z,sprintf(x, "%d", n))));

}

Well refer to the original code of tower of hanoi. Here's a snapshot of it:

#include
int towerOfHanoi(int noOfDisc,
char source,
char destination,
char third
) // towerHanoi.c
{
if(noOfDisc == 0) { return 0; } // Basis
{
int noOfMoves ;
& %
noOfMoves = towerOfHanoi(noOfDisc-1,
source, third, destination);
printf("%c -> %c ", source, destination);
++ noOfMoves ;
noOfMoves += towerOfHanoi(noOfDisc-1,
third, destination, source);
return noOfMoves ;
}
}


So this is a generic code.... u might run the buggy code by:

./a.out solve s d t 10

Here s is source
d-destination
t-third pole
10 is the value to solve


Help me guys...

Friday, January 16, 2009

Unix...... the funny side ;-)

Well guys.... had enof of the black screen!! Got bored off the repeated commands, cat, echo, ls, man, apt-get huha and foobar..... then let's see the funny side of it:

Well i didnt write it... but still considering it's open source i copy it under GNU GPL v 1.2 :P

Funny Unix csh/sh commands:

% cat "food in cans"
cat: can't open food in cans

% nice man woman
No manual entry for woman.

% rm God
rm: God nonexistent

% ar t God
ar: God does not exist

% ar r God
ar: creating God

% "How would you rate Quayle's incompetence?
Unmatched ".

% Unmatched ".
Unmatched ".

% [Where is Jimmy Hoffa?
Missing ].

% ^How did the sex change operation go?^
Modifier failed.

% If I had a ( for every $ the Congress spent, what would I have?
Too many ('s.

% make love
Make: Don't know how to make love. Stop.

% sleep with me
bad character

% got a light?
No match.

% man: why did you get a divorce?
man:: Too many arguments.

% !:say, what is saccharine?
Bad substitute.

% %blow
%blow: No such job.

% \(-
(-: Command not found.

$ PATH=pretending! /usr/ucb/which sense
no sense in pretending!

$ drink matter
matter: cannot create



All coutesy David G Wiseman............ hahaha!!!!

Thursday, January 15, 2009

C Up your skills!!

Debug the following program. What does the debugged program do?

#include
#define REP(t,n) for(t=n;t;t--,t&=n)
typedef int *abc(int a);
int func(int n)
{
int t;
REP(t,n)
printf("%3d",t);
return 0;
}
int main()
{
int n=9;
abc f1;
f1=func;
f1(n);
return 0;
}


Well this is one of the best questions i have ever came across( in terms of trick they have :P )!

First part first: the error.


Well u wud not notice but it is sorta syntactical error... and such codes are sometimes called obfuscated codes!!

Well for the first part the error lies in typedef.... statement:

Correct form: typedef int (*abc)(int a);

because else the precedence will say somethin else, it'll take int * and typedef to abc(int a) which is weird, i dont know how the code for this line even compiled.... by the way it's C, so u expect obfuscation a lot :P!!

But the next intersting part..... how shall u guess what the program is doin.

First the macro can be put directly in int func(...), to get:

nt func(int n)
{
int t;
for(t=n;t;t--,t&=n)
printf("%3d",t);
return 0;
}


so we actually get a for loop... interesting hmmmmm.

But thats the simpler part.... take this.... the output: n=9
o/p: 9 8 1

Now u really dont get much hints from here.... if u do.... then why the heck u DONT participate in the event :P

And now some more outputs for the interest!

n:88
0/p: 88 80 72 64 24 16 8

in:31
o/p: 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

in:45
o/p: 45 44 41 40 37 36 33 32 13 12 9 8 5 4 1

Now let's notice the similarity: count the total num of terms,

n=9 t=3
n=88 t=7
n=31 t=31
n=45 t=15

Whats so intersting, all are of the form 2^k-1

Hmmm so whats boiling.... let's take binary of 9
9==1001

Now if i take all combination of 0's and 1's in the place of 1's of the bin number, we get:
0000(redundant)
0001
1000
1001

Voila it's the series..... didnt get it... just convert them to decimals!

Similarly let's take: 31

31==11111

Now if u'll take all ppossible combination of 0's and 1's in place of 1's in 31( actually all are one's ), u'll get all numbers from 0-31( 0, is excluded by defualt ), and thats the answer actually!

Hence the result

Hope u njoyed the question.........

Wednesday, January 14, 2009

It tasted like success.......

Well people really don't realize the raw power of linux..... but to their amaze it's damn true that Linux in any form is just GREAT!!!!

Well this shall not be one of the long post that i put up... but rather a short one, for some of linux buffs it might be interesting ;-)

To start with my dear friend Rohit Ramesh Hiwale, messed up with his Ubuntu 8.10 in this way---> He was playin with some installation package, maybe OpenGL( a graphics library ), and he issued a command:

$>sudo rm -R /usr/lib/GL

But i really believe he entered some equivalent of:

$>sudo rm -R /usr/lib/

So what does that do, it's nothin less then a cold blooded suicide :-D
It removes everything( rm ) recursively, including sub dir's( -f ) and giving sudo( root privellages ), makes it all the less painful for Ubuntu to do it :-D. And it's the library directory, well u cant even compile a C program after that.... so the seriousness is inherent :-)

And now he's up against the wall.... ahhhh!!!!

No worries.... i got his technically dead OS workin up and fine as Follows:

1. I first ran the computer on a Ubuntu 8.10 Live Cd.
2. Set up internet( LAN ) connectivity. ssh'ed into my computer( somthing like connecting to my computer )!
3. Copied all the files for /usr/lib... though many may be incompatible or rather useless so to say,....
4. To our utter surprise it worked.... voila!!!!!


Hmmm it tasted like success.... specifically when u analyze the problem and come up with a drastcally innovative solution......

What we learn: Respect the privellages while working in Linux.... if u dont u r doomed to be destroyed :-D, just like Rohit just did.... :-D

Friday, January 9, 2009

Servlets: Java and me..... maybe we'll rock :-D

Well one thing's for sure. Our SoftEE( it's Software Engeneering ), Professor got it right, at the outset.....

"Softwares are lagging behing Hardware due to lack of Standard Interfaces"

It's damn true........ mind my verdict. Because the maximum time even an experienced and professional takes is to get used to interface and installation procedure. Take for example our Java assignment.... well it's no cakewalk to do it in 3 weeks while learning JavaCore/Swings/MySql/Servlets!!!!

Quite a voila of work........ ;-)

My latest tryst..... to get the hang of servlets! And it was damn tough and took almost 3-4 hrs. I mean u just cant get hang of this stuff.

Well for a briefing this is what I did:

1. Install a Tomcat Server
2. Install an Apache( optional ) for better efficiency.
3. Run it to see some sample java servlets on job :-D
4. Making one of my own.

If u are on one of the Kgp Lan's, might want to have a go on this link:

http://10.110.9.200:8080/servlets-examples/servlet/MyHelloWorld
http://10.110.9.200:8080/servlets-examples/servlet/LotteryNumbers

Well thats just for fun..... not a big deal.... but it's gr8 to see ur code work out of the block.... an amazing site :-D :-D!!!!

But I really think Java lags badly in speed.

Well here's some facts that tell why java is so slow....

Once upon a time( dont sleep mates ) Java was developed to be Platform Independent and so they introduced their own ByteCode and JVM that we all know. The fact is that JVM was always an not so efficient out of blocks.... infact Java thought they would directly include JVM in Hardware.

Amazing right??!! thats why they never thought of keeping it the way it is today.... but being too ambitous can be harmful. Guys guys, that in no way tells if Java is a faliure.... It's a big success given the facilities and library support and blablazigzaggujhdfskjdh....... ( try doin my SoftEE course... they teach that stuff ) ;-).

I never thought i would get that much addicted( 4/10 ) on Java... but for a person like me who's still obsessed wth Kerningham( read it C ), paradigm it's pretty refreshing. For a thought i had hands on Python....

Python is one of the language that attracts but u can't really get in serious programming wth it...... i mean too abstract, but no offences i am developing some gud for nothin Dbus scripts for my favourite client Pidgin/Libpurple.

But Java has got this quality of Java+MySql+Apache+Tomcat+Servlets... i mean u just can't get enof.

Hats off to the marketing strategy..... the products are newayz not that gud....

Sunday, January 4, 2009

Techie Talk: Java MySql Connection!!

Well this semeser we have a course called Software Engeneering( pretty obvious for comp. sc students :-D ). But what's amazing is we have to learn the whole of Core Java, yes my frnzz WHOLE of it in 3 weeks. Including MySql, JDBC, Swings. Dont worry i just know the names!!

For all those who are stuck up with the Java Sql Connection problem here's a post u might be helped with:

First the steps which actually make the connnection:

1. Install a MySql server on the computer. It will run on 127.0.0.1 port:3306.
2. You need the Java Class corresponding to MySql for connection via JDBC( Java Data Base Connection ).
3. Make a Data Base with MySql.
4. Connect to the server with the code.
5. And Access the Data Base with the username password.

I will let u in with a example so hang on!

First of all the OS i am talkin is Debian( Ubuntu as an example ).

So the following are the steps!

1. Considering you have APT packaging toolkit installed, or Synaptic. Issue this command on the command line:

sudo apt-get install mysql-common

I take that it might be already installed.

2. Next install the server,

sudo apt-get install mysql-server

Dont try fancy options. Until you need a specific version. The above will install the most stable and recent version automatically!!

3. The server shall be starting automatically. So do this to check if it really is:

ps -e | grep mysqld

this will give u an o/p like:

sanket@sanket-laptop:~$ ps -e | grep mysql
5480 ? 00:00:00 mysqld_safe
5522 ? 00:00:00 mysqld

Thats what my OS shows. A mysqld is enough for now.

4. Confirm the port on which the server is running. Issue

sudo nmap -sS -sV -O -PI -PT 127.0.0.1 2> /dev/null | grep mysql

and u shall obtain something like this:

3306/tcp open mysql MySQL 5.0.51a-3ubuntu5.4

Which tells u that mysql running on 3306. Rest info can be helpful but not now.

5. Now we shall create a mysql database. We shall be using the root privellages only. They may be changed whenever required.

6. So start the mysql app by: mysql -p -u root
Enter the password.

7. For fun view the Databases already present, issue: show databases

My o/p:

mysql> show databases;
+--------------------+
| Database
+--------------------+
| information_schema
| mysql
| sanket
+--------------------+
3 rows in set (0.01 sec)

8. But we will be making a brand new database, so do this:

mysql> create database jdbc_test; ( mysql> is the prompt dont input it!! )

9. Now let's see if it's there:

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| jdbc_test |
| mysql |
| sanket |
+--------------------+
4 rows in set (0.00 sec)

I think u r pretty familiar with how i am entering the commands.
10. Change the working database:

mysql> use jdbc_test
Database changed

10. Now lets create a Table:

mysql> show tables;
Empty set (0.00 sec)

mysql> create table colm1 ( name VARCHAR(100));
Query OK, 0 rows affected (0.00 sec)

mysql> show tables;
+---------------------+
| Tables_in_jdbc_test |
+---------------------+
| colm1 |
+---------------------+
1 row in set (0.00 sec)

11. Enter some names.

mysql> insert into colm1 values ("sanket") , ("huha"), ("is.the.best"), ("windows_sux");
Query OK, 4 rows affected (0.00 sec)
Records: 4 Duplicates: 0 Warnings: 0

12. Let's see what we have done:

mysql> select * from colm1;
+-------------+
| name |
+-------------+
| sanket |
| huha |
| is.the.best |
| windows_sux |
+-------------+
4 rows in set (0.00 sec)

So we're bang on.

13. Now let's get the connector: download it from
http://dev.mysql.com/downloads/connector/j/5.1.html

There shall be a Jar file in the archive named: mysql-connector-java-5.1.7-bin.jar

First extract and then unjar it.
On the command line u could do: java -jar

Newayz get hold of it, it will do with the GUI too :-/

Now where you xtracted the contents paste this to a Java file above the com folder that came with Jar file.

import java.sql.*;

public class AllTableName{
public static void main(String[] args) {
System.out.println("Listing all table name in Database!");
Connection con = null;
String url = "jdbc:mysql://localhost:3306/";
String db = "jdbc_test";
String driver = "com.mysql.jdbc.Driver";
String user = "root";
String pass = ""; //your password here
Statement stmt = null;
ResultSet rs = null;
try{
Class.forName(driver);
con = DriverManager.getConnection(url+db, user, pass);
try{
DatabaseMetaData dbm = con.getMetaData();
String[] types = {"TABLE"};
rs = dbm.getTables(null,null,"%",types);
System.out.println("Table name:");
while (rs.next()){
String table = rs.getString("TABLE_NAME");
System.out.println(table);
con.close();
}
}
catch (SQLException s){
System.out.println("No any table in the database");
}
}
catch (Exception e){
e.printStackTrace();
}
}
}

Put the root password in place!!

14. Now first compile the program using:

javac AllTableName.java
java AllTableName

Now if u see the following o/p u r done:

Listing all table name in Database!
Table name:
colm1

Voila ne doubts or Exceptions thrown please post in the comments i'll see to them!!

Friday, January 2, 2009

Voila the Email and Girly connection :P

So how many of you have noticed the email and sex( no pun intended ) relation!

Wtf!! Sanket are you insane??

Maybe not!!

Ok let's purge into the world where even movie makers have given up.... well in despair they made "What women want" and it was a disaster.... HAHAHA! Good joke.

Enof playing with gal emotions.. they might get hurt. Like we even care :-D :-D

So whats this email-konnection..... let's explore ;-).

Well the email can be all the more expressive than the name itself. Obviously, ur name was kept by bunch of pple who cudnt even identify that the tiny creature u wud have been was a boy or a girl :P.

And emails are all kept by us.... so they express more. You can see Raghu( Roadies one ) takin' pple for a ride when they keep id's like "raajisalwaysright@raghukickedinhisass.com" -------- hahahahaha

So let's have a look at plethora of mail id's and browse them in order of pecularity.

Disclosure: all names have been jumbled to respect privacy!!

1. roopal24agarwal@gmail.com

Thats seems to be fine.... 24 inserted in there to get a possible namespace!

2. talari.nitisha.jyothsana@gmail.com

Hmm thats a sensible name.... btw the name's changed so dont try to bug her up :P

3. neha.blossoms@gmail.com

4. audacious.palak@gmail.com

5. deep.is.the.best@gmail.com

Wow..... yupzz that certainly makes u the best darling :P

6. misdolonjain@gmail.com

Maybe she'll change it when she get married :P

7. aridcoolest@ymail.com

Well i have no idea what that means.... but might be she's living somewhere in Antarctica..... coolest arid place i can think of :P

8. coolbreeze16@ymail.com

Voila.... why do we say boyz are cool.... and girls hot!! They all seem to be soooo cool abt them!! Pple leave the 16 stuff.... i know i know ;-)

9. diptihereicome@ymail.com

Hope she's not bulky( pun intented :P )!!

Well enof of leg pulling. But dear frnzz this does reflect some intersting points abt the gals around think abt themselves. Well they certainly are pretty confident abt how they feel and try to make a feel good factor around themselves. But on the same hand they make naming id's meaningless.... they are meant to identify you not dipict if u r cool.... or for that matter mis or missed :P!!

I think id's shuld be names seperated by periods( dots ) and to avoid clash you can add school/clg name to it!!

Well my suggestion, go through each gal's id, i guarantee atleast 50% will turn u down to splits :-D :-D

Happy mailing :-D