Sunday, February 3, 2013

कर्म (Work)



Karmanyevadi Karaste Maphaleshu Kadhachana
Ma Karma Phalahe Durbo Matesangatsvali Karmani" Bagavad Gita( 2- 48)

asks us to do our karma ( Work) and says that the benefits of the work will be rewarded.


तीरथ  पर जाये, बार बार प्रभू को मनाये, सोचे की शायद रूठा खुद मुझ से मान जाये 
फल, फूल चढ़ाये प्रभू को चप्पन भोग का प्रलोभ दिखाए, नंगे पाऊँ मंदिर, मस्जिद के सेकड़ो चक्कर लगाये 
पर ए बुद्धिहीन प्राणी, कर्म करे जा ये है प्रभू की गीता मैं वाणी 
- 
Aman


Saturday, January 19, 2013

Mr. X on train Part-1

We generally used to board same train every day, he always comes in formal clothing, by his attires he looks like some kind of financial escort or some bank employee. He usually travel with black suitcase and smile on his face, But today I am sensing some worry on his face, may be some kind of meeting tension ? or some client is refusing to give money on stocks loss ? But no this tension don't look like that, something wrong with him.

Image from Google.com

Sunday, December 23, 2012

Do I know ?

Do I know about the river system of India ?
Do I know about the palmistry ?
Do I know about the reincarnations ?
Do I know about the History of India ?
Do I know about the Literature ?
Do I know about the facts ?
Do I have the knowledge of the maths ?
Do I know the path to attain knowledge?
Do I know the God?
Do I know the Satan ?
Do I know myself ??

from where do I learn this knowledge, there is only one answer for the question.

For me whole world is my teacher.

-Aman

Sunday, October 14, 2012

Jumbled Sundays





What is Sunday ? The day with no work, no challenge or the day with lots of thought with full of imagination. Actually Sunday is the day in which you can explore tons of good options. Options to do something good with your life ? Or to make your lifestyle better than ever ? Or just lay in your bed  ? third one is more intuitive actually ;)

This question is keep bugging me from past few months. Actually my conscious mind wants to do something, something innovative or something different from my daily routine like playing guitar or like watching some thoughtful documentaries or reading some good books. But my subconscious mind wants totally different thing, actually it wants to be lazy after work of 5 days, my subconscious mind force me to do nothing, it just want to go in hibernate mode and try to be less thoughtful.

Still these are my mixed  Sundays. Hope for the change from next time.



Wednesday, October 3, 2012

शुरआत

पीर है मेरी बड़ी,
इस का कोई इन्साफ तो हो

रोज मेरे जख्मों का
जर्जर सही कुछ इलाज तो हो

राज़ बहूत ही गंभीर हैं
मगर मेरे सपनो का आगाज़ तो हो

इन पंखों के पैर नहीं
लेकिन इन मैं कुछ उड़ान तो हो

इस मन को कुछ लाभ नहीं,
पर मेरा कुछ नुकसान न हो

आज नहीं तो कल सही,
कहीं से  मेरी भी  शुरआत तो हो


Monday, June 13, 2011

Scripts of the week

Hi, blogging again after a long time. feeling lots of ups and down during the period..hell leave it for now..
I dedicate last week to writing the scripts, I wrote vim plugin for uploading and downloading the code to/from pastebin and also created an API using wurfl to detect the mobile device config and provide the run time support to it.

Vim Plugin Story :
Finally I wrote my own vim plugin, I had an idea long time ago, but never get the time to implement it, during this weekend I have nothing much to do so, I decide to go with the plugin and give rest to other tasks, I spend two days on writing plugin.
Plugin basically parse the HTML code using the beautiful soup python module. After getting the branch of the code text, I removed the additional HTML tags and copied it to the vim editor.


import urllib2
from BeautifulSoup import BeautifulSoup
import sys
data=urllib2.urlopen(sys.argv[1]).read();
soup = BeautifulSoup(''.join(data))
code=soup('div', {'id' : 'code_frame'})
soup = BeautifulSoup(''.join(str(code[0]).strip()))
code_text = soup.div.div

text=''.join(BeautifulSoup(str(code_text).strip()).findAll(text=True))
code_for_vim = BeautifulSoup(str(text).strip(), convertEntities=BeautifulSoup.HTML_ENTITIES)
print code_for_vim


above code print the code pasted on the valid link of the pastebin, this involves parsing of the HTML source and beautiful soup does it beautifully ;). I called above python script from the vim
function command! -nargs=0 PasteBin :call pasteCodeFromPasteBin()
which could be called by user from vim editor by typing :Pastebin.

fun! pasteCodeFromPasteBin()
let g:binLink = input("Enter valid pastebin link : ")
let g:data=system('python ~/.vim/plugin/beautiful.py '.g:binLink)
set paste
exec "normal O".g:data
startinsert
endfun

and for uploading the code directly from vim editor, I used pastebin api http://pastebin.com/api_public.php which require code to be pasted, language preference, email ID, title etc details passed as a post argument with an api, for this I used 'curl -d' and perl

let g:data=system('cat '.bufname("%").'| perl -p -e ''s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg''')
let g:query='paste_private=0&paste_code='.theg:data.'&paste_name='.g:name.'&paste_email='.g:pastebin_emailid.'&paste_format='.g:pastebin_language
let g:out=system('curl -d -s"'.g:query.'" http://pastebin.com/api_public.php ')


WURFL Story:
WURFL is a Device Description Repository (DDR), i.e. a software component which contains the descriptions of thousands of mobile devices with the help of WURFL I create an API which can detect not only the device but can also find the nearest match from the available configs and provide the run time support to it.



// Include the WURFL/Application.php file
require_once "WURFL_Installation_Dir/WURFL/Application.php";

// Provide the absolute or relative path to your wurfl-config.xml
$wurflConfigFile = "wurfl-config.xml";

// Create WURFL Configuration from an XML config file
$wurflConfig = new WURFL_Configuration_XmlConfig($wurflConfigFile);

// Create a WURFL Manager Factory from the WURFL Configuration
$wurflManagerFactory = new WURFL_WURFLManagerFactory($wurflConfig);

// Create a WURFL Manager
$wurflManager = $wurflManagerFactory->create();
?>

WURFL maintains the database in wurfl-config.xml file and which is created on the basis of the user agent of the different devices, by passing the argument of $_SERVER array to the WURFL API we can get the exact model, brand, device OS, resolution and other additional details. http://wurfl.sourceforge.net/help_doc.php#product_info online doc available for getting different capability sets of the device.

:-)
fat0ss

Tuesday, November 16, 2010

Linux magical commands

Linux command like a magic stick in the hand of wizard, more you practice more you find scope of learning. I am playing with it from few years and still I find myself n00b in this context, although today I planed to share my n00b experience with you regards to few basic Linux commands . This POST is totally belongs to the beginners.

cat :
concatenate files and print on the standard output
$> cat file.txt gt; cat file.txt ##print the content of the file on terminal
$> cat -n file.txt gt; cat -n file.txt ##print the content of file with line number


grep :
grep searches the named input FILEs (or standard input if no files are named, or if a single hyphen-minus (-) is given as file name) for lines containing a match to the given PATTERN. By default, grep prints the matching lines.
$>grep apple fruitlist.txt ##grep prints all lines containing apple
$>
grep -w apple fruitlist.txt ##grep prints all lines containing apple as a word
You can also use grep with regular expressions

sed
is a stream editor. A stream editor is used to perform basic text transformations on an input stream. While in some ways similar to an editor which permits scripted edits (such as ed), sed works by making only one pass over the input(s), and is consequently more efficient. But it is sed's ability to filter text in a pipeline which particularly distinguishes it from other types of editors.

$>sed -e 's/oldstuff/newstuff/g' inputFileName > outputFileName$>
##s Substitute command
##g global
##/../../ Delimiterday
##(oldstuff)Regular Expression Pattern Search Pattern
##(newstuff)night Replacement string


awk :
An AWK program is a sequence of pattern {action} pairs and function definitions. Short programs are entered on the command line usually enclosed in ' ' to avoid shell interpretation. Longer programs can be read in from a file with the -f option. Data input is read from the list of files on the command line or from standard input when the list is empty.
$>awk [ -F ] {pgm} | { -f } [ ] [ - | ]
##ch: Field-separator character.
##pgm: Awk command-line program
##pgm file: File containing an Awk program.
##vars: Awk variable initializations.
##data file: Input data file.


tr :
Translate, squeeze, and/or delete characters from standard input, writing to standard output.
$>
tr 'abcd' 'jkmn' ##maps 'a' to 'j', 'b' to 'k', 'c' to 'm', and 'd' to 'n'.
$>cat file.txt | tr -d '\n' ##delete new line character from file

curl :
Curl is a computer software project providing a library and command-line tool for transferring data using various Protocols.
$>curl -o example.html www.example.com ##cURL can write the output it retrieves to a file with the -o flag
$>curl www.example.com

Wednesday, October 27, 2010

A small grep Tool

Yesterday, I was reading about the regular expressions design that how first developer wrote the complex code with minimal complexity, Since now I know the design of the minimal version of regular expression code I decided to share it. code in itself is quite simple and self explanatory..although I marked the complex part with appropriate comments.


 
int grep (char *regexp, char *text)
{
if (*regexp == '$' ){ /*End of regular expression*/
if ( *(regexp+1) == '\0' ){
return 1;
} else {
return 0;
}
} else if ( *regexp == '.' ) { /*Single character presence*/
return grep ( regexp + 1, text + 1 );
} else if ( *regexp == '*') { /*multi character presence*/
return matchstar(regexp+1, text);
} else if ( *regexp == *text ) {
return grep ( regexp + 1, text + 1 );
} else {
return 0;
}
}


The above code has the four important regions and will detect the expressions for *,.,$ code will return 1 on success.

 
int matchstar(char *regexp, char *text)
{
if ( grep (regexp, text ) ){ /*end of multi character match*/
return 1;
} else {
matchstar(regexp, text+1);
}
}


The code is matching multi character presence and checking it's end recursively.

 
int main(int argc, char **argv)
{
FILE *file;
char text[200];
char c;
size_t size = 0;

if (argc >= 3) {
file = fopen(argv[1], "r");

while(EOF != (c = getc(file))){
if (c=='\n'){
text[size] = '\0';
int i = 0;
for ( i = 0; i < size; i++){
if (grep(argv[2], text + i)) {
printf("%s\n", text);
break;
}
}
size = 0;
} else {
text[size] = c;
size++;
}
}
}
return 0;
}



Compilation Instruction

[~/CODE]
13:04:24 $ gcc -o grep grep.c

[~/CODE]
13:04:36 $ gedit grep.c


./grep file_name regular_expression$

[~/CODE]
13:37:32 $ cat test
my
myname is
my name is khan
dog
cat is my pet
peterson is an awesome player

[~/CODE]
13:37:35 $ ./grep test m*k$
my
myname is
my name is khan
cat is my pet
peterson is an awesome player

[~/CODE]
13:37:39 $ ./grep test dog$
dog

[~/CODE]
13:37:43 $ ./grep test awsome$

[~/CODE]
13:37:49 $ ./grep test aw.some$
peterson is an awesome player



:-fat0ss

Wednesday, October 20, 2010

nmap scans : some basics over LAN

nmap : nmap(network mapper) is a network scanning tool written by Gordon Lyon and used to scan port, IP, operating systems,services on computer network

Here, I List some useful set of nmap scans over LAN :

1)ping a range of IP addresses
nmap -sP 192.168.1.100-254

-sP: Ping Scan

2)list all opened ports on host
nmap -p 1-65535 --open IP

-p : port range
--open: Only show open
Where IP may be a single IP, a hostname or a subnet

3)Get info about remote host ports and OS detection
nmap -sS -P0 -sV -O IP

Where IP may be a single IP, a hostname or a subnet
-sS TCP SYN scanning (also known as half-open, or stealth scanning)
-P0 option allows you to switch off ICMP pings.
-sV option enables version detection
-O flag attempt to identify the remote operating system
Other option:
-A option enables both OS fingerprinting and version detection
-v use -v twice for more verbosity.

Useful Links:

* Installation Guide
* Document of Nmap
* Books on Nmap


:-fat0ss

freopen() : change Mode back

Yesterday, I found a particular problem with the C function freopen(), so I decide to share it with you

Problem is with the function freopen(); the function change the role of the usual stdin, stdout for the file operation.

Problem : if I use freopen, how can I get the original stdout (or stdin) back?
FOF, this is not a good way to doing the file handling and my suggestion is always use your own explicit output (or input) stream variable, for the file operation.

Solution : solution of this particular problem is given by using dup, dup2 , dup and dup2 are the system call for duplicating underling file descriptor, which are present in UNIX/LINUX but not necessary any where else.

Reference:
http://c-faq.com/stdio/undofreopen.html
http://c-faq.com/stdio/rd.kirby.c

:-fat0ss

Wednesday, November 4, 2009

Image Difference

Following Images show the difference of two images in mainwin1














mainwin show the edges of the second image

One of the most common and frequent problem in front of us is to extract the information from the real time data because of real time data is dynamic in nature, so for that there is a need of efficient algorithm which can intelligently interact with your real time data and solve your problem , rather I can say that there is need to train your algorithm by taking the data from the well defined data set and train your system for every possible input for this we can use the different training techniques like ANN but for this post my concern is not about ANN but to solve a problem of detecting the object from the real time data .

in this Post I discuss about to detect the object from the real time data ,for example you want to detect the model of car running on the road so first you click the snap from a particular location without shaking or shivering click another snap of the road from same position without a car .so finally you have two snap one is of road with car and another is of only road now follow the procedure

1)convert both images in to Gray scale, you can use this formula for this
Y = 0.3*R + 0.59*G + 0.11*B
2)after that subtract two images I(Final)= I(Reference) -I(Real-time)
3)classify the pixels in two black or white ,for 8 bit gray scale value > 100 is a white color else it should be black
I=RsterScan(I(Final))
if [value > 100]
I = 255
else
I = 0

4) finally further smoothness will be provided on the basic of neighbour hood
5) Filter the shadow

now after that much thing , now you can extract information like height of car width of car, radius of wheel from the final image and providing this information to ANN and you will come up with a model of car



Tuesday, September 29, 2009

OpenCV Webcam

laziness one of the most common property of IT geeks like me ;) ,who spend 10-12 hrs in front of PC , which leads to problem like RSI , cervical spondylosis .There is some alternative or preventive present to avoid problem accord due to this , but preventive will be taken at the verge :P this is a simple human tendency ,in actually we need a newly designed systems which give's us a comfort at maximum level

for the same problem some project's are going on like handVU,ehci library (google codes) and on the same foot step I start working on gesture recognition ,actually I designed application like simple calculator which is controlled by the particular color(blue) detection .I share my code with you in my upcoming post in this post I give you just a glim's about OpenCV and how to display video from web cam using OpenCV

what is OpenCV ?
Very simple Question and well answered by wikipedia :P

How to Install OpenCV ?
for fedora
$>yum install opencv
and for other distro

after following the above instructions now try this code with appropriate compiler option

#include "cv.h"
#include "highgui.h"
#include

// A Simple Camera Capture Framework
int main() {

CvCapture* capture = cvCaptureFromCAM( CV_CAP_ANY );

if( !capture ) {
fprintf( stderr, "ERROR: capture is NULL \n" );
getchar();
return -1;
}

// Create a window in which the captured images will be presented
cvNamedWindow( "mywindow", CV_WINDOW_AUTOSIZE );

// Show the image captured from the camera in the window and repeat
while( 1 ) {
// Get one frame
IplImage* frame = cvQueryFrame( capture );
/* if( !frame ) {
fprintf( stderr, "ERROR: frame is null...\n" );
getchar();
break;
}*/

cvShowImage( "mywindow", frame );
// Do not release the frame!

//If ESC key pressed, Key=0x10001B under OpenCV 0.9.7(linux version),
//remove higher bits using AND operator
if( (cvWaitKey(10) & 255) == 27 ) break;
}

// Release the capture device housekeeping
cvReleaseCapture( &capture );
cvDestroyWindow( "mywindow" );
return 0;
}

if output is ERROR: capture is NULL than it might be possible your camera is incompatible with OpenCV

enjoy :) with OpenCV


Tuesday, June 23, 2009

Change GRUB splash screen

Wow !! itz a amazing experience to change my grub splash screen , for those who don't know about it, I write the procedure to change the grub splash screen

for Changing the grub splash screen you have to follow these steps

1)Download the splash. screen from http://schragehome.de/splash/
2)$ su -
3)Edit the grub file # vi /boot/grub/menu.lst
4)give the proper link for the splash.xpm.gz
5)reboot

now check that your splash screen has changed

:-fat0ss

Wednesday, May 13, 2009

Kill BUG using patch

so, finally i know that how to create a patch :D,this is a beautiful concept to remove a bug by using simple Linux commands . The command 'diff' and 'patch' create a powerful combination and hit the bug from the program :) ,diff command is widely used to get a difference between original file and updated file and this difference is stored in a patch file and through this way other people who have only a original file can change it in to a update file by applying a patch using a patch file.

create  a patch

we create a patch by using diff command , suppose we have to file 'original' and 'updated' the content of original file is "my name is aman" and the content of updated file is "my name is neshu",and we have to conver the original file in to the updated file by applying a patch and patch would be created as,

$>diff original updated > patchfile.patch 

now patchfile.patch conatin a difference of both files

$>cat patchfile.patch

1c1
<
my name is aman

---

>my name is neshu

1c1 denotes that there is some thing to  change at 1st line
similarly 'd' is for delete and 'a' is for add

As you may have noticed, I omitted explaining what the 3 -'s are for. They indicate the end of the lines that should be replaced and the beginning of the lines that should replace them. They separate the old and the new lines.

Applying a patch

Applying a patch is a very simple task , after applying a patch on original file it will convert it in to updated file ,

$>patch original patchfile.patch

patching file original

 original file is now converted in to updated  

--

Happy Patching :)

:-fat0ss