tag:blogger.com,1999:blog-38784558535265433962024-03-13T20:41:55.843-07:00fat0ssAman Agarwalhttp://www.blogger.com/profile/02147925974133273726noreply@blogger.comBlogger14125tag:blogger.com,1999:blog-3878455853526543396.post-10832407865250751642013-02-03T08:53:00.000-08:002013-02-03T08:53:27.155-08:00कर्म (Work)<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div style="background-color: white; color: #444444; font-family: arial, sans-serif; font-size: 16px; line-height: 24px;">
<br /></div>
<div style="background-color: white; color: #444444; font-family: arial, sans-serif; font-size: 16px; line-height: 24px;">
<span style="color: #333333; font-family: arial, helvetica, clean, sans-serif; font-size: 13px; line-height: 16px;">Karmanyevadi Karaste Maphaleshu Kadhachana</span><br style="color: #333333; font-family: arial, helvetica, clean, sans-serif; font-size: 13px; line-height: 16px;" /><span style="color: #333333; font-family: arial, helvetica, clean, sans-serif; font-size: 13px; line-height: 16px;">Ma Karma Phalahe Durbo Matesangatsvali Karmani" Bagavad Gita( 2- 48)</span><br style="color: #333333; font-family: arial, helvetica, clean, sans-serif; font-size: 13px; line-height: 16px;" /><br style="color: #333333; font-family: arial, helvetica, clean, sans-serif; font-size: 13px; line-height: 16px;" /><span style="color: #333333; font-family: arial, helvetica, clean, sans-serif; font-size: 13px; line-height: 16px;">asks us to do our karma ( Work) and says that the benefits of the work will be rewarded.</span></div>
<div style="background-color: white; color: #444444; font-family: arial, sans-serif; font-size: 16px; line-height: 24px;">
<br /></div>
<div style="background-color: white; color: #444444; font-family: arial, sans-serif; font-size: 16px; line-height: 24px;">
<br /></div>
<div style="background-color: white; color: #444444; font-family: arial, sans-serif; font-size: 16px; line-height: 24px;">
तीरथ पर जाये, बार बार प्रभू को मनाये, <span style="line-height: 1.54;">सोचे की शायद रूठा खुद मुझ से मान जाये </span></div>
<div style="background-color: white; color: #444444; font-family: arial, sans-serif; font-size: 16px; line-height: 24px;">
फल, फूल <span style="line-height: 1.54;">चढ़ाये प्रभू को चप्पन भोग का प्रलोभ दिखाए, </span><span style="line-height: 1.54;">नंगे पाऊँ मंदिर, मस्जिद के सेकड़ो चक्कर लगाये </span></div>
<div style="background-color: white; color: #444444; font-family: arial, sans-serif; font-size: 16px; line-height: 24px;">
पर ए बुद्धिहीन प्राणी, कर्म करे जा ये है प्रभू की गीता मैं वाणी </div>
<div style="background-color: white; color: #444444; font-family: arial, sans-serif; font-size: 16px; line-height: 24px;">
- </div>
<div style="background-color: white; color: #444444; font-family: arial, sans-serif; font-size: 16px; line-height: 24px;">
Aman</div>
<div style="background-color: white; color: #444444; font-family: arial, sans-serif; font-size: 16px; line-height: 24px;">
<br /></div>
<div style="background-color: white; color: #444444; font-family: arial, sans-serif; font-size: 16px; line-height: 24px;">
<br /></div>
</div>
Aman Agarwalhttp://www.blogger.com/profile/02147925974133273726noreply@blogger.com0tag:blogger.com,1999:blog-3878455853526543396.post-32566058138559964922013-01-19T05:39:00.003-08:002013-01-19T05:43:10.046-08:00Mr. X on train Part-1<div dir="ltr" style="text-align: left;" trbidi="on">
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.<br />
<br />
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://www.colourbox.com/preview/1202435-587870-view-people-inside-the-train.jpg" imageanchor="1" style="clear: right; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" src="http://www.colourbox.com/preview/1202435-587870-view-people-inside-the-train.jpg" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Image from Google.com</td></tr>
</tbody></table>
</div>
Aman Agarwalhttp://www.blogger.com/profile/02147925974133273726noreply@blogger.com0tag:blogger.com,1999:blog-3878455853526543396.post-2929608675779853132012-12-23T08:50:00.000-08:002012-12-23T08:52:37.882-08:00Do I know ? <div dir="ltr" style="text-align: left;" trbidi="on">
Do I know about the river system of India ?<br />
Do I know about the palmistry ?<br />
Do I know about the reincarnations ?<br />
Do I know about the History of India ?<br />
Do I know about the Literature ?<br />
Do I know about the facts ?<br />
Do I have the knowledge of the maths ?<br />
Do I know the path to attain knowledge?<br />
Do I know the God?<br />
Do I know the Satan ?<br />
Do I know myself ??<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhk-x7oQTvo6ZOzbP3NM8vOi-sZg3RXaLS02T9nW-WUVHPXavBNnN4jnz8hZW0enim2XAfDoOxp6An8r0mgVVs1mj_9wrYwHIHbNK1xelGKH00YJg8mN08K6UbF-iR-BlcsHRJ8n1QGP8M/s1600/30e_puzzle_wideweb__470x298,2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="202" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhk-x7oQTvo6ZOzbP3NM8vOi-sZg3RXaLS02T9nW-WUVHPXavBNnN4jnz8hZW0enim2XAfDoOxp6An8r0mgVVs1mj_9wrYwHIHbNK1xelGKH00YJg8mN08K6UbF-iR-BlcsHRJ8n1QGP8M/s320/30e_puzzle_wideweb__470x298,2.jpg" width="320" /></a></div>
<br />
from where do I learn this knowledge, there is only one answer for the question.<br />
<br />
For me whole world is my teacher.<br />
<br />
-Aman</div>
Aman Agarwalhttp://www.blogger.com/profile/02147925974133273726noreply@blogger.com0tag:blogger.com,1999:blog-3878455853526543396.post-85660841899751683612012-10-14T12:54:00.002-07:002012-10-14T13:06:30.227-07:00Jumbled Sundays<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbPkRa9jHvoIPECJCDjaqjXDWv-4T6FZpcMP016jhdmcYy50Gcwmh3iEVq2Vxk8nT9bSwM5p5gshVaczvnSeoorhpTI1WHpWSEAHh5Z9svGjAgBLXVtiAs_j6GNfMRZrp6-6SrRhB0opE/s1600/life1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="216" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbPkRa9jHvoIPECJCDjaqjXDWv-4T6FZpcMP016jhdmcYy50Gcwmh3iEVq2Vxk8nT9bSwM5p5gshVaczvnSeoorhpTI1WHpWSEAHh5Z9svGjAgBLXVtiAs_j6GNfMRZrp6-6SrRhB0opE/s320/life1.jpg" width="320" /></a></div>
<br />
<br />
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 ;)<br />
<br />
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.<br />
<br />
Still these are my mixed Sundays. Hope for the change from next time.<br />
<br />
<br />
<br /></div>
Aman Agarwalhttp://www.blogger.com/profile/02147925974133273726noreply@blogger.com2tag:blogger.com,1999:blog-3878455853526543396.post-71274702226026357622012-10-03T13:47:00.000-07:002012-10-03T13:47:34.693-07:00शुरआत<div dir="ltr" style="text-align: left;" trbidi="on">
पीर है मेरी बड़ी,<br />
इस का कोई इन्साफ तो हो<br />
<br />
रोज मेरे जख्मों का <br />
जर्जर सही कुछ इलाज तो हो <br />
<br />
राज़ बहूत ही गंभीर हैं <br />
मगर मेरे सपनो का आगाज़ तो हो <br />
<br />
इन पंखों के पैर नहीं<br />
लेकिन इन मैं कुछ उड़ान तो हो<br />
<br />
इस मन को कुछ लाभ नहीं,<br />
पर मेरा कुछ नुकसान न हो <br />
<br />
आज नहीं तो कल सही,<br />
कहीं से मेरी भी शुरआत तो हो <br />
<br />
<br /></div>
Aman Agarwalhttp://www.blogger.com/profile/02147925974133273726noreply@blogger.com4tag:blogger.com,1999:blog-3878455853526543396.post-33037998478619246982011-06-13T12:22:00.000-07:002011-06-13T13:52:54.352-07:00Scripts of the weekHi, blogging again after a long time. feeling lots of ups and down during the period..hell leave it for now..<br />I dedicate last week to writing the scripts, I wrote <a href="http://www.vim.org/scripts/script.php?script_id=3622">vim plugin</a> for <a href="http://pastebin.com/">uploading and downloading the code to/from pastebin </a> and also created an API using <a href="http://wurfl.sourceforge.net/">wurfl</a> to detect the mobile device config and provide the run time support to it.<br /><br /><span style="color: rgb(255, 255, 0);">Vim Plugin Story :</span><br />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.<br />Plugin basically parse the HTML code using the <a href="http://www.crummy.com/software/BeautifulSoup/">beautiful soup</a> python module. After getting the branch of the code text, I removed the additional HTML tags and copied it to the vim editor.<br /><br /><br /><pre class="brush: python">import urllib2<br />from BeautifulSoup import BeautifulSoup<br />import sys<br />data=urllib2.urlopen(sys.argv[1]).read();<br />soup = BeautifulSoup(''.join(data))<br />code=soup('div', {'id' : 'code_frame'})<br />soup = BeautifulSoup(''.join(str(code[0]).strip()))<br />code_text = soup.div.div<br /><br />text=''.join(BeautifulSoup(str(code_text).strip()).findAll(text=True))<br />code_for_vim = BeautifulSoup(str(text).strip(), convertEntities=BeautifulSoup.HTML_ENTITIES)<br />print code_for_vim<br /></pre><br /><br />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<br /><span style="color: rgb(51, 255, 51);"><span style="color: rgb(255, 255, 51);">function</span> command! <span style="color: rgb(255, 255, 255);">-nargs=0 PasteBin</span> :call </span><sid><span style="color: rgb(255, 255, 255);">pasteCodeFromPasteBin() </span><br />which could be called by user from vim editor by typing :Pastebin.<br /><br /><pre class="brush: python">fun! <sid>pasteCodeFromPasteBin()<br />let g:binLink = input("Enter valid pastebin link : ")<br />let g:data=system('python ~/.vim/plugin/beautiful.py '.g:binLink)<br />set paste<br />exec "normal O".g:data<br />startinsert<br />endfun<br /></sid></pre><br />and for uploading the code directly from vim editor, I used pastebin api <a href="http://pastebin.com/api_public.php">http://pastebin.com/api_public.php</a> 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<br /><br /><pre class="brush: python">let g:data=system('cat '.bufname("%").'| perl -p -e ''s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg''')<br />let g:query='paste_private=0&paste_code='.theg:data.'&paste_name='.g:name.'&paste_email='.g:pastebin_emailid.'&paste_format='.g:pastebin_language<br />let g:out=system('curl -d -s"'.g:query.'" http://pastebin.com/api_public.php ')<br /></pre><br /><br /><span style="color: rgb(255, 255, 0);">WURFL Story:</span><br />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.<br /><br /><br /><pre class="brush: php"><br /><?php<br />// Include the WURFL/Application.php file<br />require_once "WURFL_Installation_Dir/WURFL/Application.php";<br /> <br />// Provide the absolute or relative path to your wurfl-config.xml<br />$wurflConfigFile = "wurfl-config.xml";<br /> <br />// Create WURFL Configuration from an XML config file<br />$wurflConfig = new WURFL_Configuration_XmlConfig($wurflConfigFile);<br /> <br />// Create a WURFL Manager Factory from the WURFL Configuration<br />$wurflManagerFactory = new WURFL_WURFLManagerFactory($wurflConfig);<br /> <br />// Create a WURFL Manager<br />$wurflManager = $wurflManagerFactory->create();<br />?><br /></pre><br />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. <a href="http://wurfl.sourceforge.net/help_doc.php#product_info">http://wurfl.sourceforge.net/help_doc.php#product_info</a> online doc available for getting different capability sets of the device.<br /><br />:-)<br />fat0ss</sid>Aman Agarwalhttp://www.blogger.com/profile/02147925974133273726noreply@blogger.com0tag:blogger.com,1999:blog-3878455853526543396.post-68195440104760446672010-11-16T02:03:00.000-08:002010-11-20T04:27:26.604-08:00Linux magical commands<font style="font-family: courier new;" face="webdings">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.</font><br style="font-family: courier new;"><hr style="font-family: courier new;"><a style="font-family: courier new;" href="http://unixhelp.ed.ac.uk/CGI/man-cgi?cat"><font style="font-weight: bold; color: rgb(102, 102, 204);">cat</font> :</a><br style="font-family: courier new;"><font style="font-family: courier new;" face="webdings">concatenate files and print on the standard output</font><br style="font-family: courier new;"><font style="color: rgb(0, 153, 0); font-family: courier new;" face="webdings">$> cat file.txt <font style="color: rgb(255, 255, 0);">gt; cat file.txt <font style="color: rgb(255, 255, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(255, 255, 0);">##print the content of the file on terminal</font></font><br /><font style="color: rgb(0, 153, 0);"> $> cat -n file.txt <font style="color: rgb(255, 255, 0);">gt; cat -n file.txt <font style="color: rgb(255, 255, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(255, 255, 0);">##print the content of file with line number</font></font><br /><br /></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font><hr style="font-family: courier new;" face="courier new"><font style="color: rgb(0, 153, 0); font-family: courier new;" face="webdings"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(0, 153, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(0, 153, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(0, 153, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(0, 153, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(0, 153, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(0, 153, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(0, 153, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(0, 153, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(0, 153, 0);"><font style="color: rgb(0, 153, 0);"><a href="http://unixhelp.ed.ac.uk/CGI/man-cgi?grep"><font style="font-weight: bold; color: rgb(102, 102, 204);">grep</font></a> :<br /><font style="color: rgb(255, 255, 255);">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.</font><br /><font style="color: rgb(0, 153, 0);">$</font><font style="color: rgb(0, 153, 0);" class="kw2">>grep</font><font style="color: rgb(0, 153, 0);"> apple fruitlist.txt</font><font style="color: rgb(0, 153, 0);"> </font><font style="color: rgb(255, 255, 0);">##</font><font style="color: rgb(255, 255, 0);">grep prints all lines containing </font><i style="color: rgb(0, 153, 0);"><font style="color: rgb(255, 255, 0);">apple</font><br /><font style="color: rgb(0, 153, 0);">$></font></i><font style="color: rgb(0, 153, 0);" class="kw2">grep</font><font style="color: rgb(0, 153, 0);"> </font><font style="color: rgb(0, 153, 0);" class="re5">-w</font><font style="color: rgb(0, 153, 0);"> apple fruitlist.txt <font style="color: rgb(255, 255, 0);">##grep prints all lines containing </font></font><i style="color: rgb(255, 255, 0);">apple</i><font style="color: rgb(255, 255, 0);"> as a word<br /></font>You can also use grep with <a href="http://en.wikipedia.org/wiki/Regular_expression">regular expressions</a><font style="color: rgb(255, 255, 0);"><br /></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font><hr style="font-family: courier new;" face="courier new"><font style="color: rgb(0, 153, 0); font-family: courier new;" face="webdings"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(0, 153, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(0, 153, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(0, 153, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(0, 153, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(0, 153, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(0, 153, 0);"><font style="color: rgb(255, 255, 0);"><a style="color: rgb(102, 51, 255); font-weight: bold;" href="http://unixhelp.ed.ac.uk/CGI/man-cgi?sed">sed</a><br /><font style="color: rgb(255, 255, 255);">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.</font><br /><br /><font style="color: rgb(0, 153, 0);">$>sed -e 's/oldstuff/newstuff/g' inputFileName > outputFileName$></font><br />##<font style="color: rgb(255, 255, 0);">s Substitute command</font><br />##<font style="color: rgb(255, 255, 0);">g global</font><br />##<font style="color: rgb(255, 255, 0);">/../../ Delimiterday </font><br />##(<font style="color: rgb(0, 153, 0);">oldstuff</font>)<font style="color: rgb(255, 255, 0);">Regular Expression Pattern Search Pattern</font><br />##(<font style="color: rgb(0, 153, 0);">newstuff</font>)<font style="color: rgb(255, 255, 0);">night Replacement string<br /><br /></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font><hr style="font-family: courier new;" face="courier new"><font style="color: rgb(0, 153, 0); font-family: courier new;" face="webdings"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(0, 153, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(0, 153, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(0, 153, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(0, 153, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(0, 153, 0);"><font style="color: rgb(255, 255, 0);"><a style="color: rgb(102, 51, 255); font-weight: bold;" href="http://unixhelp.ed.ac.uk/CGI/man-cgi?awk">awk :</a><br /><font style="color: rgb(255, 255, 255);">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.</font><br /><font style="color: rgb(0, 153, 0);">$>awk [ -F<ch> ] {pgm} | { -f <pgm_file> } [ <vars> ] [ - | <data_file> ]</data_file></vars></pgm_file></ch></font><br />##<font style="color: rgb(255, 255, 0);">ch: Field-separator character.</font><br />##<font style="color: rgb(255, 255, 0);">pgm: Awk command-line program</font><br />##<font style="color: rgb(255, 255, 0);">pgm file: File containing an Awk program.</font><br />##<font style="color: rgb(255, 255, 0);">vars: Awk variable initializations.</font><br />##<font style="color: rgb(255, 255, 0);">data file: Input data file.</font><br /><br /></font></font></font></font></font></font></font></font></font></font></font></font><hr style="font-family: courier new;" face="courier new"><font style="color: rgb(0, 153, 0); font-family: courier new;" face="webdings"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(0, 153, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(0, 153, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(0, 153, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(0, 153, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(0, 153, 0);"><font style="color: rgb(255, 255, 0);"><a style="color: rgb(102, 51, 255);" href="http://unixhelp.ed.ac.uk/CGI/man-cgi?tr"><font style="font-weight: bold;">tr :</font></a><br /><font style="color: rgb(255, 255, 255);">Translate, squeeze, and/or delete characters from standard input, writing to standard output.</font><br /><font style="color: rgb(0, 153, 0);"> </font><font style="color: rgb(0, 153, 0);">$></font></font></font><font style="color: rgb(51, 204, 0);"><font style="color: rgb(0, 153, 0);">tr 'abcd' 'jkmn'</font> </font> <font style="color: rgb(255, 255, 0);"><font style="color: rgb(255, 255, 0);">##</font></font><font style="color: rgb(255, 255, 0);">maps 'a' to 'j', 'b' to 'k', 'c' to 'm', and 'd' to 'n'.</font><br /><font style="color: rgb(0, 153, 0);">$>cat file.txt | tr -d '\n' </font><font style="color: rgb(255, 255, 0);">##delete new line character from file</font><br /></font></font></font></font></font></font></font></font></font></font><hr style="font-family: courier new;" face="courier new"><font style="color: rgb(0, 153, 0); font-family: courier new;" face="webdings"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(0, 153, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(0, 153, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(0, 153, 0);"><font style="color: rgb(255, 255, 0);"><font style="color: rgb(0, 153, 0);"><font style="color: rgb(255, 255, 0);"><a style="color: rgb(102, 51, 255);" href="http://curl.haxx.se/docs/manual.html"><font style="font-weight: bold;">curl : </font></a></font></font><br /><font style="color: rgb(255, 255, 255);">Curl is a computer software project providing a library and command-line tool for transferring data using various Protocols.</font><br /><font size="3"><font style="color: rgb(0, 153, 0);">$></font><code><font style="color: rgb(51, 204, 0);"><font style="color: rgb(0, 153, 0);">curl -o example.html www.example.co</font>m</font> </code></font><code></code><font style="color: rgb(255, 255, 0);">##cURL can write the output it retrieves to a file with the -o flag</font><br /><font size="3"><code></code><font style="color: rgb(0, 153, 0);">$></font></font><code style="color: rgb(0, 153, 0);"><font style="color: rgb(51, 204, 0);">curl www.example.com</font> </code><font style="color: rgb(255, 255, 0);"></font></font></font></font></font></font></font></font></font><hr style="color: rgb(255, 255, 0); font-family: courier new;">Aman Agarwalhttp://www.blogger.com/profile/02147925974133273726noreply@blogger.com1tag:blogger.com,1999:blog-3878455853526543396.post-26588209937564971302010-10-27T23:27:00.000-07:002010-10-28T01:37:07.500-07:00A small grep ToolYesterday, 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.<br /><br /><br /><pre class="brush: c"> <br />int grep (char *regexp, char *text)<br />{<br />if (*regexp == '$' ){ /*End of regular expression*/<br />if ( *(regexp+1) == '\0' ){<br />return 1;<br />} else {<br />return 0;<br />}<br />} else if ( *regexp == '.' ) { /*Single character presence*/<br />return grep ( regexp + 1, text + 1 );<br />} else if ( *regexp == '*') { /*multi character presence*/<br />return matchstar(regexp+1, text);<br />} else if ( *regexp == *text ) { <br />return grep ( regexp + 1, text + 1 );<br />} else {<br />return 0;<br />}<br />}<br /></pre><br /><br />The above code has the four important regions and will detect the expressions for <span style="font-weight:bold;">*</span>,<span style="font-weight:bold;">.</span>,<span style="font-weight:bold;">$</span> code will return 1 on success.<br /><br /><pre class="brush: c"> <br />int matchstar(char *regexp, char *text)<br />{<br />if ( grep (regexp, text ) ){ /*end of multi character match*/<br />return 1;<br />} else {<br />matchstar(regexp, text+1);<br />}<br />}<br /></pre><br /><br />The code is matching multi character presence and checking it's end recursively.<br /><br /><pre class="brush: c"> <br />int main(int argc, char **argv)<br />{<br /> FILE *file;<br /> char text[200]; <br /> char c;<br /> size_t size = 0;<br /><br /> if (argc >= 3) {<br /> file = fopen(argv[1], "r");<br /> <br /> while(EOF != (c = getc(file))){<br /> if (c=='\n'){<br /> text[size] = '\0';<br /> int i = 0;<br /> for ( i = 0; i < size; i++){<br /> if (grep(argv[2], text + i)) {<br /> printf("%s\n", text);<br /> break;<br /> }<br /> }<br /> size = 0;<br /> } else {<br /> text[size] = c;<br /> size++;<br /> }<br /> }<br /> }<br /> return 0;<br />}<br /><br /></pre><br /><br />Compilation Instruction <br /><code><br />[~/CODE]<br />13:04:24 $ gcc -o grep grep.c <br /><br />[~/CODE]<br />13:04:36 $ gedit grep.c <br /></code><br /><br />./grep file_name regular_expression$<br /><code><br />[~/CODE]<br />13:37:32 $ cat test<br />my<br />myname is <br />my name is khan<br />dog<br />cat is my pet<br />peterson is an awesome player<br /><br />[~/CODE]<br />13:37:35 $ ./grep test m*k$<br />my<br />myname is <br />my name is khan<br />cat is my pet<br />peterson is an awesome player<br /><br />[~/CODE]<br />13:37:39 $ ./grep test dog$<br />dog<br /><br />[~/CODE]<br />13:37:43 $ ./grep test awsome$<br /><br />[~/CODE]<br />13:37:49 $ ./grep test aw.some$<br />peterson is an awesome player<br /></code><br /><br /><br />:-fat0ssAman Agarwalhttp://www.blogger.com/profile/02147925974133273726noreply@blogger.com0tag:blogger.com,1999:blog-3878455853526543396.post-26830744004225496782010-10-20T11:13:00.000-07:002010-10-20T11:30:01.968-07:00nmap scans : some basics over LAN<span style="color: rgb(204, 204, 255); font-weight: bold;">nmap</span> : nmap(network mapper) is a network scanning tool written by Gordon Lyon and used to scan port, IP, operating systems,services on computer network<br /><br />Here, I List some useful set of nmap scans over LAN :<br /><br /><span style="color: rgb(204, 204, 255);">1)</span><span style="font-weight: bold; color: rgb(204, 204, 255);">ping a range of IP addresses</span><br />nmap -sP 192.168.1.100-254<br /><br />-sP: Ping Scan<br /><br /><span style="color: rgb(204, 204, 255);">2)</span><span style="font-weight: bold; color: rgb(204, 204, 255);">list all opened ports on host</span><br />nmap -p 1-65535 --open IP<br /><br />-p : port range<br />--open: Only show open<br />Where IP may be a single IP, a hostname or a subnet<br /><br /><span style="color: rgb(204, 204, 255);">3)</span><span style="font-weight: bold; color: rgb(204, 204, 255);">Get info about remote host ports and OS detection</span><br />nmap -sS -P0 -sV -O IP<br /><br />Where IP may be a single IP, a hostname or a subnet<br />-sS TCP SYN scanning (also known as half-open, or stealth scanning)<br />-P0 option allows you to switch off ICMP pings.<br />-sV option enables version detection<br />-O flag attempt to identify the remote operating system<br />Other option:<br />-A option enables both OS fingerprinting and version detection<br />-v use -v twice for more verbosity.<br /><br />Useful Links:<br /><br />* <a href="http://nmap.org/book/install.html">Installation Guide</a><br />* <a href="http://nmap.org/docs.html">Document of Nmap</a><br />* <a href="http://nmap.org/book/">Books on Nmap</a><br /><br /><br />:-fat0ssAman Agarwalhttp://www.blogger.com/profile/02147925974133273726noreply@blogger.com0tag:blogger.com,1999:blog-3878455853526543396.post-64583991132316538742010-10-20T11:10:00.001-07:002010-10-20T11:27:58.994-07:00freopen() : change Mode backYesterday, I found a particular problem with the C function freopen(), so I decide to share it with you<br /><br />Problem is with the function freopen(); the function change the role of the usual stdin, stdout for the file operation.<br /><br /><span style="font-weight: bold; color: rgb(204, 204, 255);">Problem : if I use freopen, how can I get the original stdout (or stdin) back?</span><br />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.<br /><br /><span style="font-weight: bold; color: rgb(204, 204, 255);">Solution</span> : 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.<br /><br />Reference:<br /><a href="http://c-faq.com/stdio/undofreopen.html">http://c-faq.com/stdio/undofreopen.html</a><br /><a href="http://c-faq.com/stdio/rd.kirby.c">http://c-faq.com/stdio/rd.kirby.c</a><br /><br />:-fat0ssAman Agarwalhttp://www.blogger.com/profile/02147925974133273726noreply@blogger.com0tag:blogger.com,1999:blog-3878455853526543396.post-80119284139779004242009-11-04T09:47:00.000-08:002009-11-04T23:01:17.371-08:00Image DifferenceFollowing Images show the difference of two images in mainwin1<br /><div style="text-align: left;"> </div><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEib96z5-cemy9TiEI0IU6GCLwB1FOaw_LhoxfpWBdrWTXH1gFe_Mwlt8zy3WcfRXd2q0NiFXegu5QekMYOJEzN-nnfdE8uZ_T4vlPJcrNyDqiGG8ZZ1ivIHtV2BCiJg7TI_47HX432ZMW4/s1600-h/x.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 139px; height: 120px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEib96z5-cemy9TiEI0IU6GCLwB1FOaw_LhoxfpWBdrWTXH1gFe_Mwlt8zy3WcfRXd2q0NiFXegu5QekMYOJEzN-nnfdE8uZ_T4vlPJcrNyDqiGG8ZZ1ivIHtV2BCiJg7TI_47HX432ZMW4/s320/x.jpg" alt="" id="BLOGGER_PHOTO_ID_5400308918961060354" border="0" /></a><div style="text-align: left;"><div style="text-align: center;"> </div><div style="text-align: left;"><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJyZcAiFUnLMjZUJ9ntqnciil8BPQvPXLetmXIxjbNogFrr3tKfi8AgiT573EE_Qzyl-a7ik-xv0toAR-WtcTmlrXgdMFsPyphLS2aiPHH9HqdS0qtqPlsiFG-0TVgXi-slJd58BpGhno/s1600-h/y.jpg"><img style="margin: 0pt 0pt 10px 10px; float: left; cursor: pointer; width: 145px; height: 120px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJyZcAiFUnLMjZUJ9ntqnciil8BPQvPXLetmXIxjbNogFrr3tKfi8AgiT573EE_Qzyl-a7ik-xv0toAR-WtcTmlrXgdMFsPyphLS2aiPHH9HqdS0qtqPlsiFG-0TVgXi-slJd58BpGhno/s320/y.jpg" alt="" id="BLOGGER_PHOTO_ID_5400309126280743090" border="0" /></a></div><br /><br /><br /><br /><br /><br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipblt9V947XQceJyiHmvhx5lbb_IAlUDYQMymCYsg5XzNnkeEAYkp0wIBBnLRYUhWzOBeod49s0g7cnc4fLXqqo_6NmJvUIkhoO2UK8wdVdoVlSN3H6g0brIIncaTDRXaD-eWVWXJuUR8/s1600-h/11.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 320px; height: 113px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipblt9V947XQceJyiHmvhx5lbb_IAlUDYQMymCYsg5XzNnkeEAYkp0wIBBnLRYUhWzOBeod49s0g7cnc4fLXqqo_6NmJvUIkhoO2UK8wdVdoVlSN3H6g0brIIncaTDRXaD-eWVWXJuUR8/s320/11.jpg" alt="" id="BLOGGER_PHOTO_ID_5400494249274439202" border="0" /></a><br /><br /><br /><br /><br /><br /><br />mainwin show the edges of the second image<br /><br />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 .<br /><br />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<br /><br />1)convert both images in to Gray scale, you can use this formula for this <pre><blockquote> Y = 0.3*R + 0.59*G + 0.11*B</blockquote></pre>2)after that subtract two images I(Final)= I(Reference) -I(Real-time)<br />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<br /> <blockquote> I=RsterScan(I(Final))<br /> if [value > 100]<br /> I = 255<br /> else<br /> I = 0</blockquote><br />4) finally further smoothness will be provided on the basic of neighbour hood<br />5) Filter the shadow<br /><br />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<br /><br /><br /><br /></div> <div style="text-align: left;"> </div> <div style="text-align: left;"> </div> <div style="text-align: left;"> </div>Aman Agarwalhttp://www.blogger.com/profile/02147925974133273726noreply@blogger.com0tag:blogger.com,1999:blog-3878455853526543396.post-6917605015332501572009-09-29T07:53:00.000-07:002009-11-01T02:05:44.792-08:00OpenCV Webcamlaziness 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 <a href="http://www.blogger.com/en.wikipedia.org/wiki/Repetitive_strain_injury">RSI</a> , <a href="http://www.nlm.nih.gov/medlineplus/ency/article/000436.htm">cervical spondylosis</a> .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<br /><br />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<br /><br /><span style="font-weight: bold;">what is OpenCV ?</span><br />Very simple Question and well answered by <a href="http://en.wikipedia.org/wiki/OpenCV">wikipedia</a> :P<br /><br /><span style="font-weight: bold;">How to Install OpenCV ?</span><br />for fedora<br /><div style="text-align: left;">$>yum install opencv<br /></div>and for other <a href="http://opencv.willowgarage.com/wiki/InstallGuide_Linux">distro </a><br /><br />after following the above instructions now try this code with appropriate compiler option<br /><blockquote><br />#include "cv.h"<br />#include "highgui.h"<br />#include <stdio.h><br /><br />// A Simple Camera Capture Framework<br />int main() {<br /><br />CvCapture* capture = cvCaptureFromCAM( CV_CAP_ANY );<br /><br /> if( !capture ) {<br /> fprintf( stderr, "ERROR: capture is NULL \n" );<br /> getchar();<br /> return -1;<br />}<br /><br />// Create a window in which the captured images will be presented<br />cvNamedWindow( "mywindow", CV_WINDOW_AUTOSIZE );<br /><br />// Show the image captured from the camera in the window and repeat<br />while( 1 ) {<br /> // Get one frame<br /> IplImage* frame = cvQueryFrame( capture );<br />/* if( !frame ) {<br /> fprintf( stderr, "ERROR: frame is null...\n" );<br /> getchar();<br /> break;<br /> }*/<br /><br /> cvShowImage( "mywindow", frame );<br /> // Do not release the frame!<br /><br /> //If ESC key pressed, Key=0x10001B under OpenCV 0.9.7(linux version),<br /> //remove higher bits using AND operator<br /> if( (cvWaitKey(10) & 255) == 27 ) break;<br />}<br /><br />// Release the capture device housekeeping<br />cvReleaseCapture( &capture );<br />cvDestroyWindow( "mywindow" );<br />return 0;<br />}<br /></stdio.h><br /></blockquote>if output is<span style="font-weight: bold;"> ERROR: capture is NULL </span>than it might be possible your camera is incompatible with OpenCV<br /><br />enjoy :) with OpenCV<br /><h3 style="margin-left: 3px;"><br /></h3><span class="med"><b></b></span>Aman Agarwalhttp://www.blogger.com/profile/02147925974133273726noreply@blogger.com0tag:blogger.com,1999:blog-3878455853526543396.post-416779338791791362009-06-23T02:45:00.000-07:002009-06-23T03:05:51.304-07:00Change GRUB splash screenWow !! 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<br /><br />for Changing the grub splash screen you have to follow these steps<br /><br />1)Download the splash. screen from <a href="http://schragehome.de/splash/">http://schragehome.de/splash/</a><br />2)$ su -<br />3)Edit the grub file # vi /boot/grub/menu.lst<br />4)give the proper link for the splash.xpm.gz<br />5)reboot<br /><br />now check that your splash screen has changed<br /><br />:-fat0ssAman Agarwalhttp://www.blogger.com/profile/02147925974133273726noreply@blogger.com0tag:blogger.com,1999:blog-3878455853526543396.post-17390158439751104302009-05-13T11:24:00.000-07:002009-05-13T12:26:14.292-07:00Kill BUG using patch<p>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.</p><p><strong><span style="font-family:georgia;">create a patch</span></strong></p><p><span style="font-family:arial;">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,</span></p><p align="center"><span style="font-family:arial;"><strong><em>$>diff original updated > patchfile.patch </em></strong></span></p><p align="left"><span style="font-family:arial;">now patchfile.patch conatin a difference of both files</span></p><p align="center"><span style="font-family:arial;"><strong>$>cat <span class="blsp-spelling-error" id="SPELLING_ERROR_0">patchfile</span>.patch<span style="font-family:arial;"><span style="font-family:arial;"><br /></span></span></strong><span style="font-family:arial;"></p><p align="center"><span style="font-family:arial;"><span class="blsp-spelling-error" id="SPELLING_ERROR_0"><span class="blsp-spelling-error" id="SPELLING_ERROR_0"></p><p align="left"><span style="font-family:arial;">1c1<br />< </span><span style="font-family:arial;">my name is aman</p></span><p align="left"><span style="font-family:arial;">---</span></p><p align="left"><span style="font-family:arial;">>my name is <span class="blsp-spelling-error" id="SPELLING_ERROR_1">neshu</span></span></p><span style="font-family:arial;"><span class="blsp-spelling-error" id="SPELLING_ERROR_0"><span class="blsp-spelling-error" id="SPELLING_ERROR_0"><p align="left"><span style="font-family:arial;">1c1 denotes that there is some thing to change at 1st line</span><span style="font-family:arial;"><br />similarly 'd' is for delete and 'a' is for add<br /></span></p></span><p align="left"><span style="font-family:arial;">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.</span></p><p align="left"><span style="font-family:arial;">Applying a patch</span></p><p align="left"><span style="font-family:arial;">Applying a patch is a very simple task , after applying a patch on original file it will convert it in to updated file ,</span></p><p align="center"><em><strong><span style="font-family:arial;">$>patch <span class="blsp-spelling-error" id="SPELLING_ERROR_1">original</span> <span class="blsp-spelling-error" id="SPELLING_ERROR_2">patchfile</span>.patch</span></strong></em></p><p align="left"><span style="font-family:arial;">patching file <span class="blsp-spelling-error" id="SPELLING_ERROR_3">original</span> </p></span><p></p><p align="left"><span style="font-family:arial;"> original file is now converted in to updated </span></p><p align="left"><span style="font-family:arial;">--</span></p><p align="center"><span style="font-family:arial;"><span style="font-family:arial;"></p><p align="center"><p align="left"><span style="font-family:arial;">Happy Patching :)</span></p><p align="left"><span style="font-family:arial;">:-fat0ss</span><span style="font-family:arial;"><br /><br /><br /></span></p><p></p>Aman Agarwalhttp://www.blogger.com/profile/02147925974133273726noreply@blogger.com0