Thursday 25 July 2013

For the Dan Brown lovers... Inferno... ebook

Here is the link to download the latest novel by Dan Brown: Inferno. If any of you has a better link you are free to post the link as a comment.
The only problem with this ebook is that the quality is not good although you will find the complete text.
So happy reading to fellow Dan Brown fans...



Password: banehavoc

Sunday 26 May 2013

A flex and bison program for C like variable declaration...

This time we are trying to implement the C like variable declaration in flex-bison:-

Grammar:
S->S F | epsilon
F->E '\n'
E->K V
K->KEY
V->COMMALST | ID ';'
COMMALST->ID ',' CLST
CLST->ID ',' CLST | ID ';'

Here is the flex specification file: saved as identi.l

%{
//to identify the keyword and identifier
#include<stdlib.h>
#include"identi.tab.h"
%}
%%
"int" |
"char" |
"float" |
"long" |
"double" |
"signed" {return KEY;}
[A-Za-z_]+[0-9A-Za-z_]* {return ID;}
[,;\n] {return *yytext;}
. ;
%%

Here is the bison specification file: saved as identi.y
%{
#include<stdio.h>
void yyerror(char*,...);
int yywrap(void);
%}
%token KEY ID;
%%
S:S F
 |
 ;
F:E '\n'
 ;
E:K V {printf("\nValid Declaration\n");}
 ;
K:KEY
 ;
V:COMMALST
 |ID ';'
 ;
COMMALST:ID ',' CLST
 ;
CLST:ID ',' CLST
 |ID ';'
 ;
%%
int main(void)
{
 yyparse();
 return 0;
}
int yywrap(void)
{
 return 1;
}
void yyerror(char* msg, ...)
{
 printf("\nError Occurred\n");
}

Now all you have to do is run the following commands:


flex identi.l

bison -d identi.y

gcc -o identi lex.yy.c identi.tab.c


Now you have to run the program on your linux OS as:

./identi

INPUT EXAMPLES:

int a;

float ad3,t4,e3;


Wednesday 22 May 2013

Why do we need IP addressing when we have MAC addresses already?

Why use IP address when we have the device level unique MAC address?

(Please see MultiHoming for some related info...)

IP addresses give hierarchy and order to the wildly large Internet. Order is of utmost importance when you want to search someone. Take this example:
I give you a Bane Havoc's DNA fingerprint(he has no history-sheet, believe me) and ask you, can you find him for me?
What will you do? You will ask a friend if he knows him. If he doesn't, you simply hunt for the person who might. Let's say X knows who can tell you about our target(say Y). Now, you go to Y and the process repeats for an indefinite period.

Analogy: You have the MAC address and you go from one system to another, scan the tables they maintain, to find if they have a record(Think of how unreliable this can be). Solution: Let each system maintain a record for each MAC-device, but, then, size of table becomes infinite!!

Now say, finally a certain Mr. Z give's you the address for Bane. You reach there and knock his door. What if he has changed his house, or better(actually worse) still he is dead?

Analogy: Say somehow you get some system which maintains a table that has a record for our MAC. We try to connect to it and get no response. Why? Because, the system is now not on that network path. (Earlier it was in London, now it is in New York).
Or, the system is not up anymore.

So, what we conclude is using the flat network running only on MAC addresses, the network is neither efficient nor reliable. So, we append IP Address to our network protocols.

I now give you this data: Bane Havoc works in Merc Tech as one of the sales manager. Now find him for me.
You will now go to Merc Tech. Ask them for a list of Sales Managers and from that list fetch the address for Bane. Bingo you got it.

Analogy: Networks and sub-networks. You need to reach a host. You have to simply have its IP address. Go to main network, get re-routed to subnetwork and the IP address is resolved using ARP protocol to find the MAC address of the end device and the data is transmitted. Each router in the path needs to know about the upper layer of the network hierarchy (c.f.r.: routing protocols).

Now you have efficiency and reliability in your network. MAC is still used but once you have reached the subnet of which your target is a part.

Now you can have concept of DNS.

An example. If net was MAC only; and you had to connect to google.com, you would be using MAC address of google hosts. Say one day google system is corrupted. Now they set up a new system and a new MAC address is available. Now the problem is who will update all those voluminous tables around the globe? It would be a fatal catastrophe.

But if we have IP address network, even if google changes a system only the table of google's private gateway has to be updated (the ARP table) the world still happily uses the famous IP address, further simplified by an alias.

[MUSE: if we tried a DNS with MAC network and one day DNS itself had to change the system, and one of the websites also changed system, believe me that website would be practically off the network completely!!!]


Burned-in MAC address (BIA), also known as Burned-In Address, is the last six bytes of a MAC address that are assigned by the manufacturer of a network interface card (NIC). This address sometimes can be overridden by the user, in which the second bit of the most significant byte of the Organisationally Unique Identifier (OUI) is changed to a binary 1. In this case, the NIC is said to be using as a Locally Administered Address (LAA) as its MAC address. If the NIC is not configured to use an LAA as its BIA, then the second bit of the most significant byte of the OUI is changed to a binary 0. In this case, the NIC is said to be using a Universally Administered Address (UAA) as its MAC address.

Monday 13 May 2013

Second package of flex and bison usage... another grammar implementation...

This is my second attempt at using flex and bison... you might find it useful...

Grammar:
E->E+E
E->(E)
E->T
T->id


Here is the flex specification file: saved as clexer2.l

%{
//family cparser2.y - clang2
#include<stdlib.h>
#include"cparser2.tab.h"
int yylval;
%}
%%
[0-9]+ {yylval=atoi(yytext);return id;}
[+()] return *yytext;
\n |
. ;
%%


Here is the bison specification file: saved as cparser2.y

%{
//family clexer2.l clang2
#include<stdio.h>
int yywrap(void);
void yyerror(char*);
%}
%left '+'
%left '('
%left ')'
%token id;
%%
S:S E {$$=$2;}
|
;
E:E'+'E {$$=$1+$3; printf("Ans: %d\n",$$);}
|'('E')' {$$=$2;}
|T {$$=$1;}
;
T:id {$$=$1;}
;
%%
int main(void)
{
yyparse();
return 0;
}
int yywrap(void)
{
return 1;
}
void yyerror(char* msg)
{
printf("%s",msg);
}


Now all you have to do is run the following commands:



flex clexer2.l

bison -d cparser2.y

gcc -o clang2 lex.yy.c cparser2.tab.c


Now you have to run the program on your linux OS as:

./clang2

Flex Bison Beginning.... baby steps....

I have been trying to learn lex and yacc of late. Well the tools that I actually use are flex and bison.
Anyways, here is a small program to demonstrate the use of both in conjunction...

Grammar:
E->E+T
E->T
T->id


Here is the flex specification file: saved as clexer1.l

%{
//This lexer is for cparser1.y together they make clang1
#include<stdio.h>
#include"cparser1.tab.h"
int yylval;
%}
%%
[0-9]+ {yylval=atoi(yytext);return id;}
[+] return *yytext;
\n |
. ;
%%


Here is the bison specification file: saved as cparser1.y

%{
//this is the parser for the grammar E->E+T; E->T; T->id used in conjunction with clexer1.l
#include<stdio.h>
#include<stdlib.h>
void yyerror(char*);
int yywrap(void);
%}
%token id
%%
S:S E {$$=$2;}      //merely to augment the grammar
|       //represents epsilon
;
E:E'+'T {$$=$1+$3; printf("Ans: %d\n",$$);}
|T {$$=$1;}
;
T:id {$$=$1;}
;
%%
int main(void)
{
yyparse();
return 0;
}
void yyerror(char *msg)
{
printf("%s\n",msg);
}
int yywrap(void)
{
return 1;
}


Now all you have to do is run the following commands:



flex clexer1.l

bison -d cparser1.y

gcc -o clang1 lex.yy.c cparser1.tab.c


Now you have to run the program on your linux OS as:

./clang1

Sunday 7 April 2013

Compiler Design Tools installation in windows....

To install compiler design tools like flex, bison and gcc in your Windows platform follow the following steps:

1. Install Flex:


a.  After you've downloaded the setup from the link above double click to     install.

b. Make sure you DO NOT install in the default folder "C:\Program Files\...." but, to some some other folder which doesn't have a space in the name: "C:\compiler\".

2. Install Bison:


a.  After you've downloaded the setup from the link above double click to install.

b. Make sure you DO NOT install in the default folder "C:\Program Files\...." but, to some some other folder which doesn't have a space in the name: "C:\compiler\".

3. Install gcc setup:


a.  After you've downloaded the setup from the link above double click to install.

b. Make sure you DO NOT install in the default folder "C:\Program Files\...." but, to some some other folder which doesn't have a space in the name: "C:\compiler\".


or you may download the entire setup package from here: Compiler Tools


4. How to set the PATH variable in Windows: 

a.  First obtain the path for each of the tool's bin directory as follows  

for XP: (indicative)



for 7: (again indicative)



do the above for each tool separately save them in a notepad file.

b.  Now open the properties of your computer, by right clicking the icon:

for XP:




for Win 7:






c.  Now add the paths you previously obtained in the PATH variable separated by semicolons ";" and then logout and login again.



This should make your tools usable as they did in my case. Now you may work from any directory and create your programs.

In case of query or problem feel free to comment... I will definitely respond...

Enjoy...!!!
 

Thursday 17 January 2013

IDM extensions for Chrome, firefox and mozilla based browsers

<<8 Nov 2013...Updated>>
Often enough you watch a video online and wonder how to download it to your computer or download a file and think as to how can you increase the download speeds?

Yes? Are you one among them? Then your answer is invariably Internet Download Manager. With the IDM guys rolling out version 6.14 with blazing fast speeds, you must all the more be excited to lay your hands on it.

Now I hear: "Ok dude I got it, but, it doesn't work for me. My IDM wouldn't catch the video I play or the downloads I try to start."

Here is Bane's solution:

Symptom:

IDM is not able to catch the downloads when I click on download links and also just wouldn't recognize the videos that I play.

Cause:

If there is no problem with your IDM installation then in the most probable case your IDM integration extensions for your Browsers are either outdated or absent.

Solution:

Simple. Download the IDM integration extensions from the links provided below and add them to your browsers. Voila ! after you restart your browsers you are done ! Now download as much as you wish.

For Mozilla Firefox and Mozilla based browsers:

Click on the link below to download the .xpi file to your computer.


After you have downloaded the file, simply drag and drop it in your mozilla based browser and it will ask you to allow installation. Once the installation is complete restart your mozilla based browser and you have configured your browser properly.

For Chrome and chromium based browsers:

Click on the link below to download the .crx file to your computer.

>>>http://www.mediafire.com/download/k57kya7xu3yycem/IDMGCExt.crx<<<

Drag and drop this file into your chrome browser's settings->extensions page and the browser will ask if you want to add it. Allow the installation and restart the browser. And you have configured the browser correctly.


I sincerely believe that your problem with IDM and your browser is solved. Keep reading my blog for more solutions or mail me your problem at my mailing address.

Wednesday 16 January 2013

Restore shortcut file association: Desktop shortcuts not working

 Well if you are one of those who are the facing the problem that your Desktop shortcuts have suddenly become unusable and when you try to open them some other application is launched than what you expect then this article is for you.

Symptom:

1. Shortcuts on my Desktop in Windows are either not having any icon or have the icon of some common application.
2. When I try to launch any shortcut, say, firefox, application 'x' tries to open the file or windows pops up the open with dialog box.

Cause:

Your registry entry for .lnk filetype association has become corrupt by either your own mistake or by the action of some malware.

Solution:

The solution to the above mentioned problem is quite easy.
First of all calm down.
Your personal data is safe.
You need NOT format your computer.

Now the technical specifications as to what must be done in order to restore the ".lnk" filetype association in your Windows.

1. Press the "Window key + R"
2. Now type in the 'Run' dialog box: "regedit" (without quotes or this bracketed text)
3. In the new window that opens up, go to FILE ---> IMPORT menu
4. Hope fully you have already downloaded the .zip file provided below? Unzip it to find the lnk.reg file.
5. Back in step 3, when you select import, it asks for path of file, give the path of the "lnk.reg" file you obtained in step 4.
6. Accept and press oks  for all changes or questions windows asks.
7. Now the tedious part: Goto the following path within "regedit" from the left side pane:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.lnk

In the left pane itself, under the .lnk, see if there is a sub entry called "UserChoice". If there is such an entry, delete it outrightly.

8. Now you are done, restart your computer.
9. In 99% cases this has solved the problem. Hopefully it works for you as well. In case it doesn't place a comment I will definitely respond. 

 DOWN LOAD THE ZIP FILE FROM THE FOLLOWING LINK: