tag:blogger.com,1999:blog-60052470069493846912024-03-19T02:18:29.629-07:00IDITAROD-Adventerous journey of being tough, sharing my experiments with technology and blogging. Discuss, share and learn.TShttp://www.blogger.com/profile/02381204600694943595noreply@blogger.comBlogger46125tag:blogger.com,1999:blog-6005247006949384691.post-81262279803943999852016-03-11T03:33:00.002-08:002016-03-11T03:44:59.245-08:00Xiaomi redmi note 3 wifi connectivity issue<div dir="ltr" style="text-align: left;" trbidi="on">
Issue observed:-<br />
<br />
Faced Xiaomi redmi note 3 wifi connectivity issue.<br />
<br />
It properly connect to wifi hotspot but fails to connect home wifi device.<br />
Enabling/Disabling the router and mobile wifi does not helped much.<br />
<br />
What worked for me is the MIUI version upgrade.<br />
Upgraded it to MIUI Global 7.1 (7.1.7.0).<br />
After upgrade, it properly detects and connects to home wifi.<br />
<br />
Hope this will help.<br />
<br />
<br />
<br />
<br />
<br /></div>
TShttp://www.blogger.com/profile/02381204600694943595noreply@blogger.com11tag:blogger.com,1999:blog-6005247006949384691.post-52609977717117455872013-10-01T01:48:00.000-07:002013-10-24T01:50:15.936-07:00Running bat file from the C++ source code<div dir="ltr" style="text-align: left;" trbidi="on">
What to do when one has to execute batch script from the c++ source code ?<br />
<br />
System command can solve the purpose in this context.<br />
Here is the syntax details :-<br />
<br />
<pre style="font-family: Consolas, Courier, monospace; font-size: 12.800000190734863px; line-height: 13.600000381469727px; overflow: auto; padding: 5px; word-wrap: normal;"><span style="background-color: white; color: #cc0000;">int system( const char *command );
int _wsystem( const wchar_t *command );</span></pre>
<br />
<br />
Example :-<br />
Suppose if some one want to restart a service named "TestService" form the batch file.<br />
Then c:\\sample.bat file would look like as:-<br />
<br />
<blockquote class="tr_bq">
net stop TestService<br />net start TestService</blockquote>
<br />
calling it from source code:-<br />
<blockquote class="tr_bq">
system ("c:\\sample.bat");</blockquote>
<br />
<br />
<br />
For API refrenece<br />
<a href="http://msdn.microsoft.com/en-us/library/277bwbdz(v=vs.90).aspx">http://msdn.microsoft.com/en-us/library/277bwbdz(v=vs.90).aspx</a><br />
<br />
<br /></div>
TShttp://www.blogger.com/profile/02381204600694943595noreply@blogger.com12tag:blogger.com,1999:blog-6005247006949384691.post-50892468734960848262011-12-13T03:55:00.001-08:002011-12-15T03:48:51.938-08:00How to increase service start/stop timeout ?<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="margin-bottom: 7.5pt;">
<span style="color: #2a2a2a; font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: "Times New Roman";">Windows provide <b>SetServiceStatus</b> function by which one can manage service time out
period. It’s a very straight forward API here are its details:-<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; word-break: break-all;">
<span style="font-family: Consolas; font-size: 10pt;"> BOOL WINAPI
SetServiceStatus(<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; word-break: break-all;">
<span style="font-family: Consolas; font-size: 10pt;"> __in SERVICE_STATUS_HANDLE
hServiceStatus,<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; word-break: break-all;">
<span style="font-family: Consolas; font-size: 10pt;"> __in LPSERVICE_STATUS
lpServiceStatus<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; word-break: break-all;">
<span style="font-family: Consolas; font-size: 10pt;"> );<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 7.5pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 7.5pt;">
<span style="color: #2a2a2a; font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: "Times New Roman";">To manage timeout one need to inform SCM
periodically about the current status of service. So if one have pending
operations same information can be conveyed with this interface to SCM.<o:p></o:p></span></div>
<blockquote class="tr_bq">
<span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><span class="apple-style-span"><i>A
common bug is for the service to have the main thread perform the
initialization while a separate thread continues to call</i></span><span class="apple-converted-space"><i> </i></span><strong><i>SetServiceStatus</i></strong><span class="apple-converted-space"><i><span style="float: none;"> </span></i></span><span class="apple-style-span"><i>to
prevent the service control manager from marking it as hung. However, if the
main thread hangs, then the service start ends up in an infinite loop because
the worker thread continues to report that the main thread is making progress.</i></span></span></blockquote>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: 'Segoe UI', sans-serif;">Here are the details of structure<o:p></o:p></span></b></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<pre style="word-break: break-all;"><span style="font-family: Consolas; font-size: 9pt;">typedef struct _SERVICE_STATUS {<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas; font-size: 9pt;"> DWORD dwServiceType;<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas; font-size: 9pt;"> DWORD dwCurrentState;<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas; font-size: 9pt;"> DWORD dwControlsAccepted;<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas; font-size: 9pt;"> DWORD dwWin32ExitCode;<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas; font-size: 9pt;"> DWORD dwServiceSpecificExitCode;<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas; font-size: 9pt;"> DWORD dwCheckPoint;<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas; font-size: 9pt;"> DWORD dwWaitHint;<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas; font-size: 9pt;">} SERVICE_STAT<o:p></o:p></span></pre>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: 'Segoe UI', sans-serif;">And following are the main parameters to be used
while managing service time out duration in the structure<o:p></o:p></span></b></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: 'Segoe UI', sans-serif;">dwCheckPoint</span></b><span style="font-family: 'Segoe UI', sans-serif;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 13.5pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in;">
<span style="color: #2a2a2a; font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: "Times New Roman";">The check-point value the service increments periodically to
report its progress during a lengthy start, stop, pause, or continue operation.
For example, the service should increment this value as it completes each step
of its initialization when it is starting up. The user interface program that
invoked the operation on the service uses this value to track the progress of
the service during a lengthy operation. This value is not valid and should be
zero when the service does not have a start, stop, pause, or continue operation
pending.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 13.5pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: 'Segoe UI', sans-serif;">dwWaitHint</span></b><span style="font-family: 'Segoe UI', sans-serif;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 13.5pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in;">
<span style="color: #2a2a2a; font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: "Times New Roman";">The estimated time required for a pending start, stop, pause, or
continue operation, in milliseconds. Before the specified amount of time has
elapsed, the service should make its next call to the </span><b><span style="color: red; font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: "Times New Roman";">SetServiceStatus</span></b><span style="color: #2a2a2a; font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: "Times New Roman";">function<span style="color: #2a2a2a;"> with either an incremented <b>dwCheckPoint</b> value
or a change in <b>dwCurrentState</b>. If the amount of time specified by <b>dwWaitHint</b> passes,
and <b>dwCheckPoint</b> has not been incremented or<b>dwCurrentState</b> has
not changed, the service control manager or service control program can assume
that an error has occurred and the service should be stopped. However, if the
service shares a process with other services, the service control manager
cannot terminate the service application because it would have to terminate the
other services sharing the process as well.<o:p></o:p></span></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="color: #2a2a2a; font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: "Times New Roman";">A sample code showing the use of above
discussed variable :-<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="color: #2a2a2a; font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: "Times New Roman";"><br /></span></div>
<pre style="word-break: break-all;"><span style="font-family: Consolas;">//<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;">// Purpose: <o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;">// It will set the current service status and reports it to the SCM.<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;">//<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;">// Parameters:<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;">// </span><span style="color: red; font-family: Consolas;">dwCurrentState</span><span style="font-family: Consolas;"> - The current state (see SERVICE_STATUS)<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;">// </span><span style="color: red; font-family: Consolas;">dwWin32ExitCode</span><span style="font-family: Consolas;"> - The system error code<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;">// </span><span style="color: red; font-family: Consolas;">dwWaitHint</span><span style="font-family: Consolas;"> - Estimated time for pending operation, <o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;">// in milliseconds<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;">// <o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span class="Apple-style-span" style="font-family: Consolas;">VOID ReportServiceStatus( DWORD dwCurrentState,</span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;"> DWORD dwWin32ExitCode,<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;"> DWORD dwWaitHint)<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;">{<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;"> static DWORD dwCheckPoint = 1;<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;"><o:p> </o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;"> // Fill in the SERVICE_STATUS structure.<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;"><o:p> </o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;"> gSvcStatus.dwCurrentState = dwCurrentState;<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;"> gSvcStatus.dwWin32ExitCode = dwWin32ExitCode;<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;"> gSvcStatus.dwWaitHint = dwWaitHint;<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;"><o:p> </o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;"> if (dwCurrentState == SERVICE_START_PENDING)<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;"> gSvcStatus.dwControlsAccepted = 0;<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;"> else gSvcStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP;<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;"><o:p> </o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;"> if ( (dwCurrentState == SERVICE_RUNNING) ||<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;"> (dwCurrentState == SERVICE_STOPPED) )<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;"> gSvcStatus.dwCheckPoint = 0;<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;"> else gSvcStatus.dwCheckPoint = </span><span style="color: red; font-family: Consolas;">dwCheckPoint</span><span style="font-family: Consolas;">++;<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;"><o:p> </o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;"> // Report the status of the service to the SCM.<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;"> SetServiceStatus( gSvcStatusHandle, &gSvcStatus );<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;">}<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;">
</span></pre>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="color: #2a2a2a; font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: "Times New Roman";"><b>One more important thing to remember :</b><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="color: #2a2a2a; font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: "Times New Roman";"><br /></span></div>
<pre style="margin-left: .5in; mso-list: l0 level1 lfo1; text-indent: -.25in; word-break: break-all;"><!--[if !supportLists]--><span style="color: #2a2a2a; font-family: Wingdings; font-size: 11.0pt; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings;">Ø<span style="font: 7.0pt "Times New Roman";"> </span></span><!--[endif]--><span style="color: #2a2a2a; font-family: "Segoe UI","sans-serif"; font-size: 11.0pt;"> Do not wait longer than the wait hint. A good interval is one-tenth of the wait hint but not less than 1 second and not more than 10 seconds. </span><span class="Apple-style-span" style="font-family: Consolas; font-size: 12px;"> </span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas; font-size: 9pt;"><o:p> </o:p></span><span style="font-family: Consolas; font-size: 9pt;"> </span><span style="font-family: Consolas;"> Example:- </span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;"><o:p> </o:p></span></pre>
<pre style="word-break: break-all;"><span style="background-color: white; font-family: Consolas;"> dwWaitTime = ssStatus.dwWaitHint / 10;<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="background-color: white; font-family: Consolas;"><o:p> </o:p></span></pre>
<pre style="word-break: break-all;"><span style="background-color: white; font-family: Consolas;"> if( dwWaitTime < 1000 )<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="background-color: white; font-family: Consolas;"> dwWaitTime = 1000;<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="background-color: white; font-family: Consolas;"> else if ( dwWaitTime > 10000 )<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="background-color: white; font-family: Consolas;"> dwWaitTime = 10000;<o:p></o:p></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;"><span class="Apple-style-span" style="background-color: #eeeeee;">
</span></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;"><span class="Apple-style-span" style="background-color: #eeeeee;">
</span></span></pre>
<pre style="word-break: break-all;"><span style="font-family: Consolas;"><span class="Apple-style-span" style="background-color: #eeeeee;"><b>
</b></span></span></pre>
<div class="MsoNormal">
</div>
<div class="MsoNormal">
<span style="color: #2a2a2a; font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: "Times New Roman";"><b>The following are some
of the best practices when calling SetServiceStatus function:</b><o:p></o:p></span></div>
<ul type="disc">
<li class="MsoNormal" style="color: #2a2a2a;"><span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: "Times New Roman";">Initialize
all fields in the <b><span style="color: #2a2a2a; text-decoration: none; text-underline: none;">SERVICE_STATUS</span></b> structure,
ensuring that there are valid check-point and wait hint values for pending
states. Use reasonable wait hints.<o:p></o:p></span></li>
<li class="MsoNormal" style="color: #2a2a2a;"><span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: "Times New Roman";">Do
not register to accept controls while the status is <b>SERVICE_START_PENDING</b> or the service can crash. After
initialization is completed, accept the <b>SERVICE_CONTROL_STOP</b> code.<o:p></o:p></span></li>
<li class="MsoNormal" style="color: #2a2a2a;"><span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: "Times New Roman";">Call
this function with checkpoint and wait-hint values only if the service is
making progress on the tasks related to the pending start, stop, pause, or
continue operation. Otherwise, SCM cannot detect if your service is hung.<o:p></o:p></span></li>
<li class="MsoNormal" style="color: #2a2a2a;"><span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: "Times New Roman";">Enter
the stopped state with an appropriate exit code if <b><span style="color: #2a2a2a; text-decoration: none; text-underline: none;">ServiceMain</span></b> fails.<o:p></o:p></span></li>
<li class="MsoNormal" style="color: #2a2a2a;"><span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: "Times New Roman";">If
the status is <b>SERVICE</b>_<b>STOPPED</b>, perform all necessary
cleanup and call <b>SetServiceStatus</b> one
time only. This function makes an LRPC call to the SCM. The first call to
the function in the <b>SERVICE_STOPPED</b>
state closes the RPC context handle and any subsequent calls can cause the
process to crash.<o:p></o:p></span></li>
<li class="MsoNormal" style="color: #2a2a2a;"><span style="font-family: "Segoe UI","sans-serif"; mso-fareast-font-family: "Times New Roman";">Do
not attempt to perform any additional work after calling <b>SetServiceStatus</b> with <b>SERVICE_STOPPED</b>, because the
service process can be terminated at any time.</span></li>
</ul>
<br />
</div>TShttp://www.blogger.com/profile/02381204600694943595noreply@blogger.com9tag:blogger.com,1999:blog-6005247006949384691.post-1268418879918705362011-12-03T10:07:00.001-08:002012-02-20T02:15:59.676-08:00Inline function example, a sample program c++<div dir="ltr" style="text-align: left;" trbidi="on">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; font-size: large;">Inline function </span>examples :-<br />
recommended article :- <a href="http://tajendrasengar.blogspot.com/2010/03/what-is-inline-function-in-cc.html" target="_blank">Inline Function</a><br />
<br />
Lets look out one of the simple example :-<br />
<pre style="font-family: Consolas, Courier, monospace; font-size: 13px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"><span class="Apple-style-span" style="background-color: white;">-------------------------------------------------------------------</span></pre>
<pre style="font-size: 13px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><span class="Apple-style-span" style="background-color: white;">// inline_functions_inline.cpp
#include <stdio.h>
#include <conio.h>
</conio.h></stdio.h></span><span class="Apple-style-span" style="background-color: #9fc5e8;">inline </span><span class="Apple-style-span" style="background-color: white;">char toupper( char a ) {
return ((a >= 'a' && a <= 'z') ? a-('a'-'A') : a );
}
int main() {
printf_s("Enter a character: ");
char ch = toupper( getc(stdin) );
printf_s( "%c", ch );
}</span></span></pre>
<pre style="font-size: 13px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"><pre style="overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"><span class="Apple-style-span" style="background-color: white;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">--</span><span class="Apple-style-span" style="font-family: Consolas, Courier, monospace;">-----------------------------------------------------------------</span></span></pre>
</pre>
<pre style="font-family: Consolas, Courier, monospace; font-size: 13px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"><span class="Apple-style-span" style="font-family: 'Times New Roman'; font-size: small; white-space: normal;">Now </span><span class="Apple-style-span" style="font-family: 'Times New Roman'; font-size: small; white-space: normal;"> moving to example of using inline function inside a class :-</span></pre>
<pre style="font-family: Consolas, Courier, monospace; font-size: 13px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"><pre style="font-family: Consolas, Courier, monospace; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"><span class="Apple-style-span" style="background-color: white;">-------------------------------------------------------------------</span></pre>
</pre>
<pre style="overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"><span class="Apple-style-span" style="background-color: #9fc5e8; font-family: 'Courier New', Courier, monospace; font-size: x-small;">// Inline_Member Function example</span></pre>
<pre style="overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"><span class="Apple-style-span" style="background-color: white;">class CBankAccount
{
public:
CBankAccount(double initial_balance) { balance = initial_balance; }
double GetBalance();
double Deposit( double Amount );
double Withdraw( double Amount );
private:
double balance;
};
</span><span class="Apple-style-span" style="background-color: #9fc5e8;">inline </span><span class="Apple-style-span" style="background-color: white;">double CBankAccount::GetBalance()
{
return balance;
}
</span><span class="Apple-style-span" style="background-color: #9fc5e8;">inline </span><span class="Apple-style-span" style="background-color: white;">double CBankAccount::Deposit( double Amount )
{
return ( balance += Amount );
}
</span><span class="Apple-style-span" style="background-color: #9fc5e8;">inline </span><span class="Apple-style-span" style="background-color: white;">double CBankAccount::Withdraw( double Amount )
{
return ( balance -= Amount );
}
int main()
{
CBankAccount objAccount;
objAccount.Deposit(1000);
}</span></span></pre>
<pre style="font-family: Consolas, Courier, monospace; font-size: 13px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"><span class="Apple-style-span" style="background-color: white;">-------------------------------------------------------------------</span></pre>
<pre style="overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"><pre style="overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"><span class="Apple-style-span" style="font-family: 'Times New Roman'; font-size: small; white-space: normal;">Just as you can ask the compiler to make a regular function inline, you can make class methods inline. The keyword </span><tt style="font-family: Consolas, Courier, monospace; font-size: 13px; white-space: normal;">inline</tt><span class="Apple-style-span" style="font-family: 'Times New Roman'; font-size: small; white-space: normal;"> appears before the return value. In the class declaration, the functions were declared without the inline keyword. The inline keyword can be specified in the class declaration; the result is the same.</span></pre>
<blockquote class="tr_bq">
<span class="Apple-style-span" style="font-family: 'Times New Roman'; font-size: small; white-space: normal;"> </span><span class="Apple-style-span" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px; white-space: normal;">Inline functions are best used for small functions such as accessing private data members. The main purpose of these one- or two-line "accessor" functions is to return state information about objects; short functions are sensitive to the overhead of function calls. Longer functions spend proportionately less time in the calling/returning sequence and benefit less from inlining.</span></blockquote>
Read More :- <a href="http://tajendrasengar.blogspot.com/2010/03/what-is-inline-function-in-cc.html" target="_blank">Guidelines for using Inline function</a>. </pre>
<pre style="overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;">
</pre>
<pre style="overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;">Check this out</pre>
<pre style="overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;">----------------------------------------------------</pre>
<pre style="overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"><a href="http://www.ticketamerica.com/harvard_crimson_tickets.html">harvard crimson tickets</a></pre>
<pre style="overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"><a href="http://www.ticketamerica.com/hofstra_pride_tickets.html">hofstra pride tickets</a></pre>
<pre style="overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"><a href="http://www.ticketamerica.com/houston_baptist_huskies_tickets.html">houston baptist huskies tickets</a></pre>
<pre style="overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;"><pre style="overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;">----------------------------------------------------</pre>
</pre>
<pre style="overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; word-break: break-all; word-wrap: break-word;">
</pre>
</div>TShttp://www.blogger.com/profile/02381204600694943595noreply@blogger.com2tag:blogger.com,1999:blog-6005247006949384691.post-51664085688776165102011-11-22T23:21:00.001-08:002011-11-22T23:27:57.771-08:00How to start , stop perfmon from the command line in Windows ?<div dir="ltr" style="text-align: left;" trbidi="on">
<span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif; font-size: large;">Logman </span>command is the solution for it.<br />
let's have a look at the command syntax<br />
<br />
<blockquote class="tr_bq">
Syntax Verbs<br /><b>Logman</b> [<b>create</b> {<i>counter</i> | <i>trace</i>} <i>collection_name</i> ] [<b>start</b> <i>collection_name</i>] [<b>stop</b> <i>collection_name</i>] [<b>delete</b> <i>collection_name</i>] [<b>query</b> {<i>collection_name</i>|<b>providers</b>}] [<b>update</b> <i>collection_name</i>]</blockquote>
<br />
<h2 style="background-color: white; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 15px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 4px; padding-left: 0px; padding-right: 0px; padding-top: 8px; text-align: -webkit-auto;">
Parameter details:-</h2>
<div style="background-color: white; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 15px; padding-bottom: 1em; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;">
<b>create</b><b> {</b><b><i>counter</i></b><b> | </b><b><i>trace</i></b><b>} </b><b><i>collection_name</i></b><b> </b><b>: </b>Creates collection queries for either counter or trace collections. You can use command line options to specify settings.</div>
<div style="background-color: white; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 15px; padding-bottom: 1em; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;">
<b>start</b><b> </b><b><i>collection_name</i></b><b> </b><b>: </b>Starts the data collection query <i>collection_name</i>. Use this option to change from scheduled collections to manual ones. Use the <b>update</b> parameter in the command line with begin-time (-b), end-time (-e), or repeat-time (-rt) to reschedule collections.</div>
<div style="background-color: white; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 15px; padding-bottom: 1em; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;">
<b>stop</b><b> </b><b><i>collection_name</i></b><b> </b><b>: </b>Stops the data collection query <i>collection_name</i>. Use this option to change from scheduled collections to manual ones. Use the <b>update</b> parameter in the command line with begin-time (-b), end-time (-e), or repeat-time (-rt) to reschedule collections.</div>
<div style="background-color: white; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 15px; padding-bottom: 1em; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;">
<b>delete</b><b> </b><b><i>collection_name</i></b><b> </b><b>: </b>Deletes the data collection query <i>collection_name</i>. If the <i>collection_name</i> does not exist, you will receive an error.</div>
<div style="background-color: white; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 15px; padding-bottom: 1em; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;">
<b>query</b><b> {</b><b><i>collection_name</i></b><b>|</b><b>providers</b><b>} </b><b>: </b>If no <i>collection_name</i> or <b>providers</b> are given, the status of all existing collection queries are displayed. Use <i>collection_name</i> to display the properties of a specific collection. To display the properties on remote computers, use the <b>-s</b> <i>remote computer</i> option in the command line. Use <b>providers</b> as your keyword in place of <i>collection_name</i> to display the registered providers installed on your local system. To list registered providers installed on the remote system, use the <b>-s</b>option in the command line.</div>
<div style="background-color: white; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 15px; padding-bottom: 1em; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;">
<b>update</b><b> </b><b><i>collection_name</i></b><b> </b><b>: </b>Updates collection queries for counter and trace collections. For counter collections, modifications to the query will stop, and then restart the collections. For trace collections, use the following parameters in the command line to query without stopping the collection: <b>-p</b> <i>provider</i> [<b>(</b><i>flags</i>[<b>,</b><i>flags ...</i>]<b>)</b>] <i>Level</i>, <b>- max</b> <i>n</i>, <b>- o</b> <i>PathName</i>, <b>-ft</b> <i>mm:ss</i>, or <b>-fd</b>.</div>
<br />
<br />
This command is very helpful in performance automation scenario.<br />
If performance monitoring counter name is test_perf_log<br />
then start command will go as :-<br />
<span class="Apple-style-span" style="background-color: black;"><span class="Apple-style-span" style="color: white;"> logman start test_perf_log</span></span><br />
on similar line stop command will go as:-<br />
<span class="Apple-style-span" style="background-color: black; color: white;"> logman stop test_perf_log</span><br />
<span class="Apple-style-span" style="background-color: black; color: white;"><br /></span><br />
<span class="Apple-style-span" style="background-color: white;">For more detail jump to page :- </span><a href="http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/nt_command_typeperf.mspx?mfr=true">http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/nt_command_typeperf.mspx?mfr=true</a><br />
</div>TShttp://www.blogger.com/profile/02381204600694943595noreply@blogger.com101tag:blogger.com,1999:blog-6005247006949384691.post-32997561949580408392011-11-01T22:57:00.000-07:002011-11-29T00:01:15.887-08:00Google MAP APIs to charge for usage, heavy traffic cost more<div dir="ltr" style="text-align: left;" trbidi="on">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><b><span class="Apple-style-span" style="font-size: large;">Google MAP</span></b> server with their increased traffic has given a new dimension of earning to Google. </span><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">With its success now Google is planning to charge for its usage.</span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">Now one has to pay according to their usage.</span><br />
<br />
Following is the cost estimation as per BBC<br />
<i style="background-color: white; border-left-color: rgb(221, 221, 221); border-left-style: solid; border-left-width: 3px; color: #363636; display: block; font-family: Arial, sans-serif; font-size: 13px; font-style: normal; line-height: 19px; margin-bottom: 0.5em; margin-left: 0.5em; margin-right: 0.5em; margin-top: 0.5em; outline-color: initial; outline-style: none; outline-width: initial; padding-bottom: 0px; padding-left: 1em; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto; vertical-align: baseline;">"The BBC is reporting that from 1 January 2012, Google <span class="Apple-style-span" style="color: #006666; font-family: inherit;"><span class="Apple-style-span" style="cursor: pointer; font-style: inherit; outline-color: initial; outline-width: initial;">will charge for the Google Maps API service</span></span> when more than the limit of 25,000 map "hits" are made in a day. Google is rumoured to be charging $4 per 1,000 views in excess of the limit. Google maintains the high limit of 25,000 free hits before charging 'will only affect 0.35% of users.'"</i><br />
<br />
<a href="http://upload.wikimedia.org/wikipedia/en/thumb/3/30/Google_Maps_directions.png/250px-Google_Maps_directions.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="172" src="http://upload.wikimedia.org/wikipedia/en/thumb/3/30/Google_Maps_directions.png/250px-Google_Maps_directions.png" width="320" /></a><a href="http://www.blogger.com/"></a><br />
<blockquote class="tr_bq">
<span class="Apple-style-span" style="background-color: white; color: #494949; font-family: Verdana, sans-serif; font-size: 12px; line-height: 20px;"><b>In the Google announcement:</b> </span><em style="background-color: white; color: #494949; line-height: 20px; text-align: -webkit-auto;"><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-style-span" style="font-size: x-small;">"</span>We understand that the introduction of these limits may be concerning. However with the continued growth in adoption of the Maps API we need to secure its long term future by ensuring that even when used by the highest volume for-profit sites, the service remains viable. By introducing these limits we are ensuring that Google can continue to offer the Maps API for free to the vast majority of developers for many years to come."</span></em></blockquote>
<br />
<h2 style="background-color: white; font-family: Helvetica, Arial, sans-serif; font-size: 18px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-top: 1em; text-align: -webkit-auto;">
About Google Maps API</h2>
<div style="background-color: white; font-family: Helvetica, Arial, sans-serif; line-height: 16px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 1em; text-align: -webkit-auto;">
The Maps API is a free service, available for any web site that is free to consumers. Please see the <a href="http://code.google.com/apis/maps/terms.html" style="color: #0000cc;">terms of service</a> for more information.</div>
<span class="Apple-style-span" style="background-color: white; font-family: Helvetica, Arial, sans-serif; line-height: 16px;">Businesses that charge fees for access, track assets or build internal applications must use </span><a href="http://code.google.com/apis/maps/documentation/premier/" style="background-color: white; color: #0000cc; font-family: Helvetica, Arial, sans-serif; line-height: 16px; text-align: -webkit-auto;">Google Maps API Premier</a><span class="Apple-style-span" style="background-color: white; font-family: Helvetica, Arial, sans-serif; line-height: 16px; text-align: -webkit-auto;">, which provides enhanced features, technical support and a service-level agreement.</span><br />
<span class="Apple-style-span" style="background-color: white; font-family: Helvetica, Arial, sans-serif; line-height: 16px; text-align: -webkit-auto;"><br /></span><br />
<span class="Apple-style-span" style="background-color: white; font-family: Helvetica, Arial, sans-serif; line-height: 16px; text-align: -webkit-auto;"><br /></span><br />
<blockquote class="tr_bq">
<span class="Apple-style-span" style="background-color: white; font-family: Helvetica, Arial, sans-serif; font-size: large; line-height: 16px; text-align: -webkit-auto;"><b><a href="http://www.ticketamerica.com/indiana_pacers_tickets.html" target="_blank"><span class="Apple-style-span" style="color: blue;">indiana pacers tickets</span></a></b></span><span class="Apple-style-span" style="background-color: #f1f1f1; color: #797979; font-family: Arial, sans-serif; font-size: 13px;">Ticketamerica.com has all of you're basketball NBA ticketing needs for teams like the indiana pacers and the milwaukee bucks as well as the atlanta hawks games, maps and seating charts.</span><span class="Apple-style-span" style="color: #797979; font-family: Arial, sans-serif; font-size: x-small;">Links to follow :- </span><ul style="text-align: left;">
<li><a href="http://www.ticketamerica.com/atlanta_hawks_tickets.html" style="font-family: Arial, sans-serif; font-size: small;" target="_blank">atlanta hawks tickets</a></li>
</ul>
<ul style="text-align: left;">
<li><a href="http://www.ticketamerica.com/milwaukee_bucks_tickets.html" style="font-family: Arial, sans-serif; font-size: small;" target="_blank">milwaukee bucks tickets</a></li>
</ul>
<b style="background-color: #f1f1f1; color: #999999; font-family: Arial, sans-serif; font-size: 13px; text-align: -webkit-auto;">Disclosure :</b><span class="Apple-style-span" style="background-color: #f1f1f1; color: #797979; font-family: Arial, sans-serif; font-size: 13px;">Pay Per Post Ad </span></blockquote>
<span class="Apple-style-span" style="color: #797979; font-family: Arial, sans-serif; font-size: x-small;"><br /></span></div>TShttp://www.blogger.com/profile/02381204600694943595noreply@blogger.com96tag:blogger.com,1999:blog-6005247006949384691.post-49735188797615038802011-10-20T03:02:00.001-07:002011-12-03T10:44:03.325-08:00How to stop function inlining ?<div dir="ltr" style="text-align: left;" trbidi="on">
<span class="Apple-style-span" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px;"></span><br />
<div xmlns="http://www.w3.org/1999/xhtml">
<b>__declspec(noinline)</b> tells the compiler to never inline a particular member function (function in a class).</div>
<div style="margin-top: -6px;" xmlns="http://www.w3.org/1999/xhtml">
It may be worthwhile to not inline a function if it is small and not critical to the performance of your code.<br />
<br />
That is, if the function is small and not likely to be called often, such as a function that handles an error condition.<br />
<br /></div>
<div style="margin-top: -6px;" xmlns="http://www.w3.org/1999/xhtml">
Keep in mind that if a function is marked <b>noinline</b>, the calling function will be smaller and thus, itself a candidate for compiler inlining.<br />
<br />
More about inlining :-<br />
<br />
<ul style="text-align: left;">
<li><a href="http://tajendrasengar.blogspot.com/2010/03/what-is-inline-function-in-cc.html" target="_blank">Inline Function Advantage , Disadvantage , Performance Impact</a></li>
<li><a href="http://tajendrasengar.blogspot.com/2011/12/inline-function-example-sample-program.html" target="_blank">Inline Function examples</a></li>
</ul>
<br />
<br /></div>
</div>TShttp://www.blogger.com/profile/02381204600694943595noreply@blogger.com71tag:blogger.com,1999:blog-6005247006949384691.post-26165299072001218682011-10-16T06:58:00.000-07:002011-10-17T02:18:31.877-07:00Distance Calculation from Latitude/Longitude using Google MAP APIs between two locations<div dir="ltr" style="text-align: left;" trbidi="on">
Here is a sample application which i have developed to get the direction, distance and duration between two location/places using <span class="Apple-style-span" style="color: #b45f06; font-size: large;">Latitude/Longitude</span> with the help of <b>Google MAP APIs.</b><br />
<div>
This application will also reveals that how can we retrieve place/city name from the Latitude/Longitude.</div>
<div>
<br /></div>
<div>
Let's look at the input of application :-</div>
<img style="border:2px solid black" src="http://2.bp.blogspot.com/-JT5C2169jVQ/TprfCGcRIXI/AAAAAAAAAeg/H4GD-KlLc5c/s640/Distance+calculator+Latitude-Longitude.jpg" />
<div>
Just input Lat/Lng and press "get Directions with Distance/Duration!" and get the updated direction MAP with Distance and Duration.<br />
Place A and Place B will displays the Lat/Lng resolved location.</div>
<div>
<br /></div>
<div>
<b>Check out its demo :-</b></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<!--
You are free to copy and use this sample in accordance with the terms of the
Apache license (http://www.apache.org/licenses/LICENSE-2.0.html)
-->
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps API Sample, Distance from Latitude and Longitude between two locations</title>
<script src="http://maps.google.com/maps?file=api&v=2&sensor=false&
key=ABQIAAAAeUlgz5ZezwUbH47hW-nEohQCA9e3Snamcn8o65dAybaGLWFLfRR88VjEEw1CS7bsSs9P0Srig2eL-g" type="text/javascript"></script>
<style type="text/css">
body {
font-family: Verdana, Arial, sans serif;
font-size: 11px;
margin: 2px;
}
table.directions th {
background-color:#EEEEEE;
}
img {
color: #000000;
}
</style>
<script type="text/javascript">
var map;
var gdir;
var geocoder = null;
var addressMarker;
var fromAddress ;
var toAddress;
var strAddress1 = null;
var strAddress2 = null;
var count = 0;
var oGLatLngTo;
var glocale;
function initialize() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
gdir = new GDirections(map, document.getElementById("directions"));
geocoder = new GClientGeocoder();
GEvent.addListener(gdir, "load", onGDirectionsLoad);
GEvent.addListener(gdir, "error", handleErrors);
//setDirections("40.7384918","-74.0022663", "41.707521", "-74.0022663", "en_US");
setDirections("40.7384918","-74.0022663", "41.707521", "-74.0022663", "en_US");
/*setDirections( document.getElementById("fromC1").value,
document.getElementById("fromC2").value,
document.getElementById("toC1").value,
document.getElementById("toC2").value,
document.getElementById("locale").value);*/
}
}
function GetStringAddress1(response) {
map.clearOverlays();
if (!response || response.Status.code != 200) {
alert("Status Code: " + response.Status.code + " , Check Lat and Lng");
} else {
var place = response.Placemark[0];
var point = new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);
var marker = new GMarker(point);
//map.addOverlay(marker);
strAddress1 = place.address;
fromAddress = strAddress1;
//alert("fromAddress :" + fromAddress );
var gc2 = new GClientGeocoder();
gc2.getLocations(oGLatLngTo , GetStringAddress2);
}
}
function GetStringAddress2(response) {
map.clearOverlays();
if (!response || response.Status.code != 200) {
alert("Status Code: " + response.Status.code + " , Check Lat and Lng");
} else {
var place = response.Placemark[0];
var point = new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);
var marker = new GMarker(point);
strAddress2 = place.address;
toAddress = strAddress2;
//alert("toAddress:" + toAddress );
document.getElementById("fromAddressP1").value = fromAddress ;
document.getElementById("toAddressP2").value = toAddress;
gdir.load("from: " + fromAddress + " to: " + toAddress,
{ "locale": glocale });
}
}
function setDirections(gLatLngFromC1, gLatLngFromC2, gLatLngToC1, gLatLngToC2, locale) {
var oGLatLngFrom = new GLatLng(gLatLngFromC1,gLatLngFromC2);
oGLatLngTo = new GLatLng(gLatLngToC1, gLatLngToC2);
count = 0;
glocale = locale;
var gc1 = new GClientGeocoder();
gc1.getLocations(oGLatLngFrom , GetStringAddress1);
}
function handleErrors(){
if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);
// else if (gdir.getStatus().code == G_UNAVAILABLE_ADDRESS) <--- Doc bug... this is either not defined, or Doc is wrong
// alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_BAD_KEY)
alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
else alert("An unknown error occurred.");
}
function onGDirectionsLoad(){
// Use this function to access information about the latest load()
// results.
var distance = gdir.getDistance().meters;
//alert("Distance is : " + gdir.getDistance().meters + " and Duration Is: " + gdir.getDuration().seconds/60);
document.getElementById("DistanceKM").value = gdir.getDistance().meters/1000;
document.getElementById("DurationMin").value = gdir.getDuration().seconds/60;
}
</script>
<body onload="initialize()" onunload="GUnload()" style="font-family: Arial;border:1px solid black;">
<h2>Maps API Directions Illustrated with Latitude and Longitude</h2>
<form action="#" onsubmit="setDirections(this.fromC1.value, this.fromC2.value, this.toC1.value, this.toC2.value, this.locale.value); return false">
<table>
<tr>
<th align="right">From: </th>
<td>
<input type="text" size="15" id="fromAddressC1" name="fromC1" value="40.7384918"/>
<input type="text" size="15" id="fromAddressC2" name="fromC2" value="-74.0022663"/>
<td>
<th align="right"> To: </th>
<td>
<input type="text" size="15" id="toAddressC1" name="toC1" value="41.707521" />
<input type="text" size="15" id="toAddressC2" name="toC2" value="-74.0022663" />
<td>
</tr>
<tr>
<th align="right">Place A: </th>
<td >
<input type="text" size="40" id="fromAddressP1" name="fromP1" value="NA"
"/>
<td>
<th align="right"> Place B: </th>
<td align="right">
<input type="text" size="40" id="toAddressP2" name="toP2" value="NA"
" />
<td>
</tr>
<tr>
<th align="right"><span lang="en-us">Distance </span></th>
<td>
<input id="DistanceKM" type="text"
/><span lang="en-us"> KM</span><td>
<th align="right"><span lang="en-us">Duration</span></th>
<td align="left">
<input id="DurationMin" align="left" type="text" /><span lang="en-us"> Minutes</span><td>
</tr>
<tr>
<th>Language: </th>
<td colspan="3">
<select id="locale" name="locale">
<option value="en" selected>English</option>
<option value="fr">French</option>
<option value="de">German</option>
<option value="ja">Japanese</option>
<option value="es">Spanish</option>
</select>
<input name="submit" type="submit" value="Get Directions with Distance/Duration!"
style="border: thick ridge #FFFFFF" />
<td>
</tr>
</table>
</form>
<br/>
<br />
<br />
<div style="float: left; padding-right: 5px;">
<script type="text/javascript">
<!--
google_ad_client = "ca-pub-9274462217825187";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text";
google_ad_channel ="";
google_color_border = "E8E7D0";
google_color_bg = "FFFFFF";
google_color_link = "B96F17";
google_color_url = "B96F17";
google_color_text = "000000";
//-->
</script>
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script>
</div>
<table class="directions">
<tr>
<th>Formatted Directions</th><th>Map</th>
</tr>
<tr>
<td valign="top">
<div id="directions" style="width: 275px"></div>
<td>
<td valign="top"">
<div id="map_canvas" style="height: 600px; width: 400px;"></div>
<td>
</tr>
</table>
</body>
</div>
TShttp://www.blogger.com/profile/02381204600694943595noreply@blogger.com309tag:blogger.com,1999:blog-6005247006949384691.post-80071716347447281862011-10-14T11:22:00.000-07:002011-10-14T11:24:43.864-07:00Google's new web programming language, Dart<div dir="ltr" style="text-align: left;" trbidi="on">
Google recently came up with new programming language for web application named as <b><span class="Apple-style-span" style="font-size: large;">Dart</span></b>.<br />
Let's look at its technical specification :-<br />
<br />
<blockquote>
<span class="Apple-style-span" style="background-color: white; color: #444444; font-family: 'Open Sans', sans-serif; font-size: 15px; line-height: 18px;">Dart is a new class-based programming language for creating structured web applications. Developed with the goals of simplicity, efficiency, and scalability, the Dart language combines powerful new language features with familiar language constructs into a clear, readable syntax.</span></blockquote>
<br />
In 2009, Google launched Go, a language designed for writing server software and handling other chores often handled today by C or C++. Dart, though, is "a new programming language for structured Web programming," according to the schedule for the Goto conference where Googlers plan to describe it next month.<br />
<div class="separator" style="clear: both; text-align: center;">
<img border="0" src="http://www.dartlang.org/imgs/dart-logo.png" /></div>
<br />
<br />
<br />
<div style="float: left; padding-right: 5px;">
<script type="text/javascript">
<!--
google_ad_client = "ca-pub-9274462217825187";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text";
google_ad_channel ="";
google_color_text = "000000";
google_color_link = "B96F17";
google_color_url = "B96F17";
//-->
</script>
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script>
</div>
<br />
<br />
<br />
<br />
<br />
<br />
Some Key feature mentioned by google about <b>Dart</b>.<br />
<br />
<br />
<b>Key features of the Dart language include:</b><br />
<br />
<span class="Apple-style-span" style="color: #990000;"><b>Classes</b></span><br />
Classes and interfaces provide a well understood mechanism for efficiently defining APIs. These constructs enable encapsulation and reuse of methods and data.<br />
<span class="Apple-style-span" style="color: #990000;"><b>Optional types</b></span><br />
Dart programmers can optionally add static types to their code. Depending on programmer preference and stage of application development, the code can migrate from a simple, untyped experimental prototype to a complex, modular application with typing. Because types state programmer intent, less documentation is required to explain what is happening in the code, and type-checking tools can be used for debugging.<br />
<span class="Apple-style-span" style="color: #990000;"><b>Libraries</b></span><br />
Developers can create and use libraries that are guaranteed not to change during runtime. Independently developed pieces of code can therefore rely on shared libraries.<br />
<span class="Apple-style-span" style="color: #990000;"><b>Tooling</b></span><br />
Dart will include a rich set of execution environments, libraries, and development tools built to support the language. These tools will enable productive and dynamic development, including edit-and-continue debugging and beyond—up to a style where you program an application outline, run it, and fill in the blanks as you run.<br />
<br />
More information about Dart can be found at :- <a href="http://www.dartlang.org/">http://www.dartlang.org/</a><br />
<br />
Sample "Hello World" program :-<br />
<blockquote>
main() {<br />
var name = 'World';<br />
print('Hello, ${name}!');<br />
}</blockquote>
Tutorial for Dart language :- <a href="http://www.dartlang.org/docs/getting-started/">http://www.dartlang.org/docs/getting-started/</a><br />
<br />
<b>How to use Dart with HTML ?</b><br />
Like JavaScript, Dart programs can be directly embedded on HTML pages served to the browser.<br />
Here is the example for it :-<br />
<br />
<br />
simple Hello World in HTML using Dart. The main() method is the entry point.<br />
<br />
<blockquote>
<html><br />
<body><br />
<script type='<span class="Apple-style-span" style="color: #cc0000;">application/dart</span>'><br />
void <span class="Apple-style-span" style="color: #38761d;">main</span>() {<br />
HTMLElement element = document.getElementById('<span class="Apple-style-span" style="color: #cc0000;">message</span>');<br />
element.innerHTML = 'Hello from Dart';<br />
}<br />
</script><br />
<div id='message'></div><br />
</body><br />
</html></blockquote>
<br />
The div element above is guaranteed to exist by the time the Dart code starts running.<br />
<br />
<br />
Let's see now whether in future DART will hit its target or not.<br />
<br /></div>TShttp://www.blogger.com/profile/02381204600694943595noreply@blogger.com84tag:blogger.com,1999:blog-6005247006949384691.post-83763127723133240342011-10-12T23:13:00.000-07:002012-05-31T05:55:15.728-07:00How to write HTML code inside blogger blog post ?<div dir="ltr" style="text-align: left;" trbidi="on">
Most of the time it become very messy when we try to write HTML code inside blog post.<br />
It does not appear in the same way as we want when we publish it.<br />
<br />
<b><br /></b><br />
<br />
<div style="float: left; padding-right: 5px;">
<script type="text/javascript">
<!--
google_ad_client = "ca-pub-9274462217825187";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text";
google_ad_channel ="";
google_color_text = "000000";
google_color_link = "B96F17";
google_color_url = "B96F17";
//-->
</script>
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script>
</div>
<br />
<br />
<br />
<br />
<br />
<br />
<b>Following are some tricks which one can follow to simplify this process :-</b>
<br />
<b><br /></b><br />
1) Using existing HTML editor for writing complete content, and then copy paste entire content in post HTML mode.<br />
2) Encode specific code with HTML encoder :-<br />
shared one link here for you : <a href="http://centricle.com/tools/html-entities/">http://centricle.com/tools/html-entities/</a><br />
a) Write your html code or any other code in the above site<br />
b) Press encode button. This will change all html tags with relevant encoded symbols ( e.g. < with < )<br />
c) Copy and paste encoded content into your compose post window.<br />
here is the demo of embedded code:-<br />
<br />
<br />
<blockquote>
void CLogicalTimeMarker::RegisteringFlag(int nModuleID, char* pszName)<br />
{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(NULL != pszName && nModuleID <= g_nMaxModuleSupported)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>m_stArrTimeAccounterStats[nModuleID].strName = pszName;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
}</blockquote>
Here is one more site doing same html code encode:-<br />
<a href="http://www.eblogtemplates.com/blogger-ad-code-converter/">http://www.eblogtemplates.com/blogger-ad-code-converter/</a><br />
Though one can embed any type of code like c/c++ , javascript , html with discussed approach.
<br />
<br />
<br />
<div style="float: left; padding-right: 5px;">
<script type="text/javascript">
<!--
google_ad_client = "ca-pub-9274462217825187";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text";
google_ad_channel ="";
google_color_text = "000000";
google_color_link = "B96F17";
google_color_url = "B96F17";
//-->
</script>
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script>
</div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br /></div>TShttp://www.blogger.com/profile/02381204600694943595noreply@blogger.com97tag:blogger.com,1999:blog-6005247006949384691.post-31117144811372019272011-10-12T10:45:00.000-07:002011-10-12T11:34:53.428-07:00Distance between two locations with the help of Latitude and Longitude<div dir="ltr" style="text-align: left;" trbidi="on">
<script src="http://maps.google.com/maps?file=api&v=2&sensor=false&
key=ABQIAAAAeUlgz5ZezwUbH47hW-nEohQCA9e3Snamcn8o65dAybaGLWFLfRR88VjEEw1CS7bsSs9P0Srig2eL-g" type="text/javascript">
</script>
<script type="text/javascript">
var map;
var gdir;
//var geocoder = null;
var addressMarker;
var fromAddress ;
var toAddress;
var strAddress1 = null;
var strAddress2 = null;
var count = 0;
function initialize() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
gdir = new GDirections(map, document.getElementById("directions"));
//geocoder = new GClientGeocoder();
GEvent.addListener(gdir, "load", onGDirectionsLoad);
GEvent.addListener(gdir, "error", handleErrors);
//setDirections("40.7384918","-74.0022663", "41.707521", "-74.0022663", "en_US");
//setDirections("40.7384918","-74.0022663", "41.707521", "-74.0022663", "en_US");
/*setDirections( document.getElementById("fromC1").value,
document.getElementById("fromC2").value,
document.getElementById("toC1").value,
document.getElementById("toC2").value,
document.getElementById("locale").value);*/
}
}
function GetStringAddress1(response) {
map.clearOverlays();
if (!response || response.Status.code != 200) {
alert("Status Code: " + response.Status.code + " , Check Lat and Lng");
} else {
var place = response.Placemark[0];
var point = new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);
var marker = new GMarker(point);
//map.addOverlay(marker);
strAddress1 = place.address;
}
}
function GetStringAddress2(response1) {
map.clearOverlays();
if (!response1 || response1.Status.code != 200) {
alert("Status Code: " + response1.Status.code + " , Check Lat and Lng");
} else {
var place = response1.Placemark[0];
var point = new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);
var marker = new GMarker(point);
strAddress2 = place.address;
}
}
function pausecomp(millis)
{
var date = new Date();
var curDate = null;
do { curDate = new Date(); }
while(curDate-date < millis);
}
function setDirectionsA(AgLatLngFromC1, AgLatLngFromC2, AgLatLngToC1, AgLatLngToC2, Alocale) {
//for(count = 0; count < 2; count++)
{
setDirections(AgLatLngFromC1, AgLatLngFromC2, AgLatLngToC1, AgLatLngToC2, Alocale);
//pausecomp(1000);
// setDirections(AgLatLngFromC1, AgLatLngFromC2, AgLatLngToC1, AgLatLngToC2, Alocale);
}
}
function setDirections(gLatLngFromC1, gLatLngFromC2, gLatLngToC1, gLatLngToC2, locale) {
//GUnload();
//initialize();
var oGLatLngFrom = new GLatLng(gLatLngFromC1,gLatLngFromC2);
var oGLatLngTo = new GLatLng(gLatLngToC1, gLatLngToC2);
count = 0;
// for(count = 0; count < 3; count++ )
{
// alert("gLatLngFrom:" + gLatLngFrom);
var gc1 = new GClientGeocoder();
gc1.reset();
gc1.getLocations(oGLatLngFrom , GetStringAddress1);
fromAddress = strAddress1;
//alert("fromAddress :" + fromAddress );
}
count = 0;
//for(count = 0; count < 3; count++ )
{
var gc2 = new GClientGeocoder();
gc2.reset();
gc2.getLocations(oGLatLngTo , GetStringAddress2);
toAddress = strAddress2;
//alert("toAddress:" + toAddress );
}
//alert("toAddress:" + gLatLngToC1);
document.getElementById("fromAddressP1").value = fromAddress ;
document.getElementById("toAddressP2").value = toAddress;
gdir.load("from: " + fromAddress + " to: " + toAddress,
{ "locale": locale });
}
function setDirectionsC(gLatLngFromC1, gLatLngFromC2, gLatLngToC1, gLatLngToC2, locale) {
var oGLatLngFrom = new GLatLng(gLatLngFromC1,gLatLngFromC2);
var oGLatLngTo = new GLatLng(gLatLngToC1, gLatLngToC2);
count = 0;
// for(count = 0; count < 3; count++ )
{
// alert("gLatLngFrom:" + gLatLngFrom);
var gc1 = new GClientGeocoder();
gc1.getLocations(oGLatLngFrom , GetStringAddress1);
fromAddress = strAddress1;
alert("fromAddress :" + fromAddress );
}
count = 0;
//for(count = 0; count < 3; count++ )
{
var gc2 = new GClientGeocoder();
gc2.getLocations(oGLatLngTo , GetStringAddress2);
toAddress = strAddress2;
alert("toAddress:" + toAddress );
}
//alert("toAddress:" + gLatLngToC1);
document.getElementById("fromAddressP1").value = fromAddress ;
document.getElementById("toAddressP2").value = toAddress;
gdir.load("from: " + fromAddress + " to: " + toAddress,
{ "locale": locale });
}
function handleErrors(){
if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);
// else if (gdir.getStatus().code == G_UNAVAILABLE_ADDRESS) <--- Doc bug... this is either not defined, or Doc is wrong
// alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_BAD_KEY)
alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
else alert("An unknown error occurred.");
}
function onGDirectionsLoad(){
// Use this function to access information about the latest load()
// results.
// e.g.
// document.getElementById("getStatus").innerHTML = gdir.getStatus().code;
// and yada yada yada...
// setDirections("40.7384918","-74.0022663", "41.707521", "-74.0022663", "en_US");
//alert("gdir.getStatus().code"+gdir.getStatus().code);
}
</script>
<body onload="initialize()" onunload="GUnload()">
<span class="style26" lang="en-us"><span class="style29"><span class="style6">
Finding </span><span class="style24">Distance</span><span class="style6">
between two locations with Latitude and Longitude</span></span><span
class="style25">.<br class="style16" />
<br class="style16" />
<span class="style16">Lets see how can we find out the distance and duration
between two diffrent locations,
<br />
if you have the latitude and longitude of two places.</span><br
class="style16" />
<br class="style16" />
<span class="style16">Here is the pic of the application :-</span><br
class="style16" />
<table style="width:auto;"><tr><td><a href="https://picasaweb.google.com/lh/photo/gGeyrGe7qHNTYfi-SPp-ENVZw4JXrCaleKH1Tie_fMY?feat=embedwebsite"><img src="https://lh3.googleusercontent.com/-Nl4zw3vgMDc/TpXWdnn_gpI/AAAAAAAAAeY/1jcnVCkQGpk/s800/Google%252520Map%252520Lat%252520Lng.jpg" height="621" width="678" /></a></td></tr><tr></tr></table>
<br />
<div style="float: left; padding-right: 5px;">
<script type="text/javascript">
<!--
google_ad_client = "ca-pub-9274462217825187";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text";
google_ad_channel ="";
google_color_text = "000000";
//-->
</script>
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script>
</div>
<br /><br /><br /><br /><br /><br />
<br class="style6" />
<span class="style24">Steps for finding distance with latitude/longitude</span><span
class="style16">.<b><br />
</b>1) Lets say we have latitude and longitude set P1 and P2.<br />
Google MAP comes up with the class
<a href="http://code.google.com/apis/maps/documentation/javascript/v2/reference.html#GLatLng">
GLatLng</a>. This class helps to encapsulate Latitude<br />
and Longitude.<br />
</span></span><span class="style26">GLatLng is a point in
geographical coordinates longitude and latitude. Notice that although usual map
projections associate longitude with the x-coordinate of the map, and latitude
with the y-coordinate, the latitude cooridnate is always written first, followed
by the longitude, as it is custom in cartography. </span><span class="style25">
<span class="style6"><span class="style16"
style="color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 16px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);">
</span></span><span class="Apple-style-span"
style="color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 16px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span
class="style16"><br />
<br />
</span></span></span><span class="style6"><span class="style26">2) From this
GLatLng points we need to get place name first.<br />
</span></span><span class="style26">class <b>GClientGeocoder</b>
will help us to get the place name from LatLng.</span><span class="style16"><br
class="style25" />
<span class="style25"> </span></span><span class="style26">This
class is used to communicate directly with Google servers to obtain geocodes for
user specified addresses. In addition, a geocoder maintains its own cache of
addresses, which allows repeated queries to be answered without a round trip to
the server. As a general best practice, it is not recommended to use
GClientGeocoder functions in a loop. Developers that have multiple addresses to
geocode should probably use our HTTP Geocoder instead.<br />
<br />
<span class="style9">Method</span> :- </span><span class="style8">
<span class="style26"
style="color: rgb(0, 112, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 16px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);">
getLocations(latlng:<a
href="http://code.google.com/apis/maps/documentation/javascript/v2/reference.html#GLatLng"
style="color: rgb(0, 0, 204); " title="GLatLng">GLatLng</a>,
callback:function)<br />
<br />
</span></span><span class="style16"><span class="style26"
style="border-style: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 16px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(240, 240, 240);">
This method performs reverse-geocoding, the conversion of a latitude/longitude
pair into human-readable addresses. getLocations() sends a request to the Google
geocoding service, asking it to return the address for the given latlng and pass
the response in the given callback. As this method requires a call to a Google
server, you must also pass a callback method to handle the response. This
response will contain a Status code, and if successful, one or more Placemark
objects. Note that this method may instead pass an addressable String, as
indicated above; in that case, the service will do a standard geocode. If
however, the first argument contains a GLatLng, the service will do a
reverse-geocode.</span></span><span class="style8"><span class="style26"
style="color: rgb(0, 112, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 16px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><br />
<br />
</span><span class="style28"
style="font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 16px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);">
Here is the example of function :-<br />
</span></span><span class="Apple-style-span"
style="color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); font-size: small; ">
<pre class="prettyprint"
style="font-family: monospace; color: rgb(0, 112, 0); font-size: 9pt; background-color: rgb(250, 250, 250); border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(187, 187, 187); border-right-color: rgb(187, 187, 187); border-bottom-color: rgb(187, 187, 187); border-left-color: rgb(187, 187, 187); line-height: 15px; margin-top: 1em; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.99em; padding-right: 0.99em; padding-bottom: 0.99em; padding-left: 0.99em; overflow-x: auto; overflow-y: auto; word-wrap: break-word; "><span
class="kwd" style="color: rgb(0, 0, 136); ">function</span><span
class="pln" style="color: rgb(0, 0, 0); "> showAddress</span><span
class="pun" style="color: rgb(102, 102, 0); ">(</span><span class="pln"
style="color: rgb(0, 0, 0); ">response</span><span class="pun"
style="color: rgb(102, 102, 0); ">)</span><span class="pln"
style="color: rgb(0, 0, 0); "> </span><span class="pun"
style="color: rgb(102, 102, 0); ">{</span><span class="pln"
style="color: rgb(0, 0, 0); ">
map</span><span class="pun" style="color: rgb(102, 102, 0); ">.</span><span
class="pln" style="color: rgb(0, 0, 0); ">clearOverlays</span><span
class="pun" style="color: rgb(102, 102, 0); ">();</span><span class="pln"
style="color: rgb(0, 0, 0); ">
</span><span class="kwd" style="color: rgb(0, 0, 136); ">if</span><span
class="pln" style="color: rgb(0, 0, 0); "> </span><span class="pun"
style="color: rgb(102, 102, 0); ">(!</span><span class="pln"
style="color: rgb(0, 0, 0); ">response </span><span class="pun"
style="color: rgb(102, 102, 0); ">||</span><span class="pln"
style="color: rgb(0, 0, 0); "> response</span><span class="pun"
style="color: rgb(102, 102, 0); ">.</span><span class="typ"
style="color: rgb(102, 0, 102); ">Status</span><span class="pun"
style="color: rgb(102, 102, 0); ">.</span><span class="pln"
style="color: rgb(0, 0, 0); ">code </span><span class="pun"
style="color: rgb(102, 102, 0); ">!=</span><span class="pln"
style="color: rgb(0, 0, 0); "> </span><span class="lit"
style="color: rgb(0, 102, 102); ">200</span><span class="pun"
style="color: rgb(102, 102, 0); ">)</span><span class="pln"
style="color: rgb(0, 0, 0); "> </span><span class="pun"
style="color: rgb(102, 102, 0); ">{</span><span class="pln"
style="color: rgb(0, 0, 0); ">
alert</span><span class="pun" style="color: rgb(102, 102, 0); ">(</span><span
class="str" style="color: rgb(0, 136, 0); ">"Status Code:"</span><span
class="pln" style="color: rgb(0, 0, 0); "> </span><span class="pun"
style="color: rgb(102, 102, 0); ">+</span><span class="pln"
style="color: rgb(0, 0, 0); "> response</span><span class="pun"
style="color: rgb(102, 102, 0); ">.</span><span class="typ"
style="color: rgb(102, 0, 102); ">Status</span><span class="pun"
style="color: rgb(102, 102, 0); ">.</span><span class="pln"
style="color: rgb(0, 0, 0); ">code</span><span class="pun"
style="color: rgb(102, 102, 0); ">);</span><span class="pln"
style="color: rgb(0, 0, 0); ">
</span><span class="pun" style="color: rgb(102, 102, 0); ">}</span><span
class="pln" style="color: rgb(0, 0, 0); "> </span><span class="kwd"
style="color: rgb(0, 0, 136); ">else</span><span class="pln"
style="color: rgb(0, 0, 0); "> </span><span class="pun"
style="color: rgb(102, 102, 0); ">{</span><span class="pln"
style="color: rgb(0, 0, 0); ">
place </span><span class="pun" style="color: rgb(102, 102, 0); ">=</span><span
class="pln" style="color: rgb(0, 0, 0); "> response</span><span class="pun"
style="color: rgb(102, 102, 0); ">.</span><span class="typ"
style="color: rgb(102, 0, 102); ">Placemark</span><span class="pun"
style="color: rgb(102, 102, 0); ">[</span><span class="lit"
style="color: rgb(0, 102, 102); ">0</span><span class="pun"
style="color: rgb(102, 102, 0); ">];</span><span class="pln"
style="color: rgb(0, 0, 0); ">
point </span><span class="pun" style="color: rgb(102, 102, 0); ">=</span><span
class="pln" style="color: rgb(0, 0, 0); "> </span><span class="kwd"
style="color: rgb(0, 0, 136); ">new</span><span class="pln"
style="color: rgb(0, 0, 0); "> </span><span class="typ"
style="color: rgb(102, 0, 102); ">GLatLng</span><span class="pun"
style="color: rgb(102, 102, 0); ">(</span><span class="pln"
style="color: rgb(0, 0, 0); ">place</span><span class="pun"
style="color: rgb(102, 102, 0); ">.</span><span class="typ"
style="color: rgb(102, 0, 102); ">Point</span><span class="pun"
style="color: rgb(102, 102, 0); ">.</span><span class="pln"
style="color: rgb(0, 0, 0); ">coordinates</span><span class="pun"
style="color: rgb(102, 102, 0); ">[</span><span class="lit"
style="color: rgb(0, 102, 102); ">1</span><span class="pun"
style="color: rgb(102, 102, 0); ">],</span><span class="pln"
style="color: rgb(0, 0, 0); ">place</span><span class="pun"
style="color: rgb(102, 102, 0); ">.</span><span class="typ"
style="color: rgb(102, 0, 102); ">Point</span><span class="pun"
style="color: rgb(102, 102, 0); ">.</span><span class="pln"
style="color: rgb(0, 0, 0); ">coordinates</span><span class="pun"
style="color: rgb(102, 102, 0); ">[</span><span class="lit"
style="color: rgb(0, 102, 102); ">0</span><span class="pun"
style="color: rgb(102, 102, 0); ">]);</span><span class="pln"
style="color: rgb(0, 0, 0); ">
marker </span><span class="pun" style="color: rgb(102, 102, 0); ">=</span><span
class="pln" style="color: rgb(0, 0, 0); "> </span><span class="kwd"
style="color: rgb(0, 0, 136); ">new</span><span class="pln"
style="color: rgb(0, 0, 0); "> </span><span class="typ"
style="color: rgb(102, 0, 102); ">GMarker</span><span class="pun"
style="color: rgb(102, 102, 0); ">(</span><span class="pln"
style="color: rgb(0, 0, 0); ">point</span><span class="pun"
style="color: rgb(102, 102, 0); ">);</span><span class="pln"
style="color: rgb(0, 0, 0); ">
map</span><span class="pun" style="color: rgb(102, 102, 0); ">.</span><span
class="pln" style="color: rgb(0, 0, 0); ">addOverlay</span><span
class="pun" style="color: rgb(102, 102, 0); ">(</span><span class="pln"
style="color: rgb(0, 0, 0); ">marker</span><span class="pun"
style="color: rgb(102, 102, 0); ">);</span><span class="pln"
style="color: rgb(0, 0, 0); ">
marker</span><span class="pun" style="color: rgb(102, 102, 0); ">.</span><span
class="pln" style="color: rgb(0, 0, 0); ">openInfoWindowHtml</span><span
class="pun" style="color: rgb(102, 102, 0); ">(</span><span class="pln"
style="color: rgb(0, 0, 0); ">
</span><span class="str" style="color: rgb(0, 136, 0); ">'orig latlng:'</span><span
class="pln" style="color: rgb(0, 0, 0); "> </span><span class="pun"
style="color: rgb(102, 102, 0); ">+</span><span class="pln"
style="color: rgb(0, 0, 0); "> response</span><span class="pun"
style="color: rgb(102, 102, 0); ">.</span><span class="pln"
style="color: rgb(0, 0, 0); ">name </span><span class="pun"
style="color: rgb(102, 102, 0); ">+</span><span class="pln"
style="color: rgb(0, 0, 0); "> </span><span class="str"
style="color: rgb(0, 136, 0); ">' '</span><span class="pln"
style="color: rgb(0, 0, 0); "> </span><span class="pun"
style="color: rgb(102, 102, 0); ">+</span><span class="pln"
style="color: rgb(0, 0, 0); ">
</span><span class="str" style="color: rgb(0, 136, 0); ">'latlng:'</span><span
class="pln" style="color: rgb(0, 0, 0); "> </span><span class="pun"
style="color: rgb(102, 102, 0); ">+</span><span class="pln"
style="color: rgb(0, 0, 0); "> place</span><span class="pun"
style="color: rgb(102, 102, 0); ">.</span><span class="typ"
style="color: rgb(102, 0, 102); ">Point</span><span class="pun"
style="color: rgb(102, 102, 0); ">.</span><span class="pln"
style="color: rgb(0, 0, 0); ">coordinates</span><span class="pun"
style="color: rgb(102, 102, 0); ">[</span><span class="lit"
style="color: rgb(0, 102, 102); ">1</span><span class="pun"
style="color: rgb(102, 102, 0); ">]</span><span class="pln"
style="color: rgb(0, 0, 0); "> </span><span class="pun"
style="color: rgb(102, 102, 0); ">+</span><span class="pln"
style="color: rgb(0, 0, 0); "> </span><span class="str"
style="color: rgb(0, 136, 0); ">","</span><span class="pln"
style="color: rgb(0, 0, 0); "> </span><span class="pun"
style="color: rgb(102, 102, 0); ">+</span><span class="pln"
style="color: rgb(0, 0, 0); "> place</span><span class="pun"
style="color: rgb(102, 102, 0); ">.</span><span class="typ"
style="color: rgb(102, 0, 102); ">Point</span><span class="pun"
style="color: rgb(102, 102, 0); ">.</span><span class="pln"
style="color: rgb(0, 0, 0); ">coordinates</span><span class="pun"
style="color: rgb(102, 102, 0); ">[</span><span class="lit"
style="color: rgb(0, 102, 102); ">0</span><span class="pun"
style="color: rgb(102, 102, 0); ">]</span><span class="pln"
style="color: rgb(0, 0, 0); "> </span><span class="pun"
style="color: rgb(102, 102, 0); ">+</span><span class="pln"
style="color: rgb(0, 0, 0); "> </span><span class="str"
style="color: rgb(0, 136, 0); ">' '</span><span class="pln"
style="color: rgb(0, 0, 0); "> </span><span class="pun"
style="color: rgb(102, 102, 0); ">+</span><span class="pln"
style="color: rgb(0, 0, 0); ">
</span><span class="str" style="color: rgb(0, 136, 0); ">'Status Code:'</span><span
class="pln" style="color: rgb(0, 0, 0); "> </span><span class="pun"
style="color: rgb(102, 102, 0); ">+</span><span class="pln"
style="color: rgb(0, 0, 0); "> response</span><span class="pun"
style="color: rgb(102, 102, 0); ">.</span><span class="typ"
style="color: rgb(102, 0, 102); ">Status</span><span class="pun"
style="color: rgb(102, 102, 0); ">.</span><span class="pln"
style="color: rgb(0, 0, 0); ">code </span><span class="pun"
style="color: rgb(102, 102, 0); ">+</span><span class="pln"
style="color: rgb(0, 0, 0); "> </span><span class="str"
style="color: rgb(0, 136, 0); ">' '</span><span class="pln"
style="color: rgb(0, 0, 0); "> </span><span class="pun"
style="color: rgb(102, 102, 0); ">+</span><span class="pln"
style="color: rgb(0, 0, 0); ">
</span><span class="str" style="color: rgb(0, 136, 0); ">'Status Request:'</span><span
class="pln" style="color: rgb(0, 0, 0); "> </span><span class="pun"
style="color: rgb(102, 102, 0); ">+</span><span class="pln"
style="color: rgb(0, 0, 0); "> response</span><span class="pun"
style="color: rgb(102, 102, 0); ">.</span><span class="typ"
style="color: rgb(102, 0, 102); ">Status</span><span class="pun"
style="color: rgb(102, 102, 0); ">.</span><span class="pln"
style="color: rgb(0, 0, 0); ">request </span><span class="pun"
style="color: rgb(102, 102, 0); ">+</span><span class="pln"
style="color: rgb(0, 0, 0); "> </span><span class="str"
style="color: rgb(0, 136, 0); ">' '</span><span class="pln"
style="color: rgb(0, 0, 0); "> </span><span class="pun"
style="color: rgb(102, 102, 0); ">+</span><span class="pln"
style="color: rgb(0, 0, 0); ">
</span><span class="str" style="color: rgb(0, 136, 0); ">'Address:'</span><span
class="pln" style="color: rgb(0, 0, 0); "> </span><span class="pun"
style="color: rgb(102, 102, 0); ">+</span><span class="pln"
style="color: rgb(0, 0, 0); "> place</span><span class="pun"
style="color: rgb(102, 102, 0); ">.</span><span class="pln"
style="color: rgb(0, 0, 0); ">address </span><span class="pun"
style="color: rgb(102, 102, 0); ">+</span><span class="pln"
style="color: rgb(0, 0, 0); "> </span><span class="str"
style="color: rgb(0, 136, 0); ">' '</span><span class="pln"
style="color: rgb(0, 0, 0); "> </span><span class="pun"
style="color: rgb(102, 102, 0); ">+</span><span class="pln"
style="color: rgb(0, 0, 0); ">
</span><span class="str" style="color: rgb(0, 136, 0); ">'Accuracy:'</span><span
class="pln" style="color: rgb(0, 0, 0); "> </span><span class="pun"
style="color: rgb(102, 102, 0); ">+</span><span class="pln"
style="color: rgb(0, 0, 0); "> place</span><span class="pun"
style="color: rgb(102, 102, 0); ">.</span><span class="typ"
style="color: rgb(102, 0, 102); ">AddressDetails</span><span class="pun"
style="color: rgb(102, 102, 0); ">.</span><span class="typ"
style="color: rgb(102, 0, 102); ">Accuracy</span><span class="pln"
style="color: rgb(0, 0, 0); "> </span><span class="pun"
style="color: rgb(102, 102, 0); ">+</span><span class="pln"
style="color: rgb(0, 0, 0); "> </span><span class="str"
style="color: rgb(0, 136, 0); ">' '</span><span class="pln"
style="color: rgb(0, 0, 0); "> </span><span class="pun"
style="color: rgb(102, 102, 0); ">+</span><span class="pln"
style="color: rgb(0, 0, 0); ">
</span><span class="str" style="color: rgb(0, 136, 0); ">'Country code: '</span><span
class="pln" style="color: rgb(0, 0, 0); "> </span><span class="pun"
style="color: rgb(102, 102, 0); ">+</span><span class="pln"
style="color: rgb(0, 0, 0); "> place</span><span class="pun"
style="color: rgb(102, 102, 0); ">.</span><span class="typ"
style="color: rgb(102, 0, 102); ">AddressDetails</span><span class="pun"
style="color: rgb(102, 102, 0); ">.</span><span class="typ"
style="color: rgb(102, 0, 102); ">Country</span><span class="pun"
style="color: rgb(102, 102, 0); ">.</span><span class="typ"
style="color: rgb(102, 0, 102); ">CountryNameCode</span><span class="pun"
style="color: rgb(102, 102, 0); ">);</span><span class="pln"
style="color: rgb(0, 0, 0); ">
</span><span class="pun" style="color: rgb(102, 102, 0); ">}</span><span
class="pln" style="color: rgb(0, 0, 0); ">
</span><span class="pun" style="color: rgb(102, 102, 0); ">}</span></pre>
</span><span class="style6"><span class="style18">
<br />
</span></span><span class="style16">
<br class="style25" />
<span class="style18"><span class="style25">3) With the help of place name, we
will query map for getting the distance and duration.<br />
</span></span></span><span class="style26">A sample code snippet for
displaying location with map :-</span><span class="style16"><span
class="style4"><span class="style25"> </span></span>
</span><span class="style10"><span class="Apple-style-span"
style="color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); font-size: small; ">
<pre class="prettyprint"
style="font-family: monospace; color: rgb(0, 112, 0); font-size: 9pt; background-color: rgb(250, 250, 250); border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(187, 187, 187); border-right-color: rgb(187, 187, 187); border-bottom-color: rgb(187, 187, 187); border-left-color: rgb(187, 187, 187); line-height: 15px; margin-top: 1em; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0.99em; padding-right: 0.99em; padding-bottom: 0.99em; padding-left: 0.99em; overflow-x: auto; overflow-y: auto; word-wrap: break-word; "><span
class="com" style="color: rgb(136, 0, 0); ">// Create a directions object and register a map and DIV to hold the </span><span
class="pln" style="color: rgb(0, 0, 0); ">
</span><span class="com" style="color: rgb(136, 0, 0); ">// resulting computed directions</span><span
class="pln" style="color: rgb(0, 0, 0); ">
</span><span class="kwd" style="color: rgb(0, 0, 136); ">var</span><span
class="pln" style="color: rgb(0, 0, 0); "> map</span><span class="pun"
style="color: rgb(102, 102, 0); ">;</span><span class="pln"
style="color: rgb(0, 0, 0); ">
</span><span class="kwd" style="color: rgb(0, 0, 136); ">var</span><span
class="pln" style="color: rgb(0, 0, 0); "> directionsPanel</span><span
class="pun" style="color: rgb(102, 102, 0); ">;</span><span class="pln"
style="color: rgb(0, 0, 0); ">
</span><span class="kwd" style="color: rgb(0, 0, 136); ">var</span><span
class="pln" style="color: rgb(0, 0, 0); "> directions</span><span
class="pun" style="color: rgb(102, 102, 0); ">;</span><span class="pln"
style="color: rgb(0, 0, 0); ">
</span><span class="kwd" style="color: rgb(0, 0, 136); ">function</span><span
class="pln" style="color: rgb(0, 0, 0); "> initialize</span><span
class="pun" style="color: rgb(102, 102, 0); ">()</span><span class="pln"
style="color: rgb(0, 0, 0); "> </span><span class="pun"
style="color: rgb(102, 102, 0); ">{</span><span class="pln"
style="color: rgb(0, 0, 0); ">
map </span><span class="pun" style="color: rgb(102, 102, 0); ">=</span><span
class="pln" style="color: rgb(0, 0, 0); "> </span><span class="kwd"
style="color: rgb(0, 0, 136); ">new</span><span class="pln"
style="color: rgb(0, 0, 0); "> </span><span class="typ"
style="color: rgb(102, 0, 102); ">GMap2</span><span class="pun"
style="color: rgb(102, 102, 0); ">(</span><span class="pln"
style="color: rgb(0, 0, 0); ">document</span><span class="pun"
style="color: rgb(102, 102, 0); ">.</span><span class="pln"
style="color: rgb(0, 0, 0); ">getElementById</span><span class="pun"
style="color: rgb(102, 102, 0); ">(</span><span class="str"
style="color: rgb(0, 136, 0); ">"map_canvas"</span><span class="pun"
style="color: rgb(102, 102, 0); ">));</span><span class="pln"
style="color: rgb(0, 0, 0); ">
directionsPanel </span><span class="pun" style="color: rgb(102, 102, 0); ">=</span><span
class="pln" style="color: rgb(0, 0, 0); "> document</span><span class="pun"
style="color: rgb(102, 102, 0); ">.</span><span class="pln"
style="color: rgb(0, 0, 0); ">getElementById</span><span class="pun"
style="color: rgb(102, 102, 0); ">(</span><span class="str"
style="color: rgb(0, 136, 0); ">"my_textual_div"</span><span class="pun"
style="color: rgb(102, 102, 0); ">);</span><span class="pln"
style="color: rgb(0, 0, 0); ">
directions </span><span class="pun" style="color: rgb(102, 102, 0); ">=</span><span
class="pln" style="color: rgb(0, 0, 0); "> </span><span class="kwd"
style="color: rgb(0, 0, 136); ">new</span><span class="pln"
style="color: rgb(0, 0, 0); "> </span><span class="typ"
style="color: rgb(102, 0, 102); ">GDirections</span><span class="pun"
style="color: rgb(102, 102, 0); ">(</span><span class="pln"
style="color: rgb(0, 0, 0); ">map</span><span class="pun"
style="color: rgb(102, 102, 0); ">,</span><span class="pln"
style="color: rgb(0, 0, 0); "> directionsPanel</span><span class="pun"
style="color: rgb(102, 102, 0); ">);</span><span class="pln"
style="color: rgb(0, 0, 0); ">
directions</span><span class="pun" style="color: rgb(102, 102, 0); ">.</span><span
class="pln" style="color: rgb(0, 0, 0); ">load</span><span class="pun"
style="color: rgb(102, 102, 0); ">(</span><span class="str"
style="color: rgb(0, 136, 0); ">"from:"+ </span><span class="style11">fromAddress</span><span
class="str" style="color: rgb(0, 136, 0); "> + "to: " + </span><span
class="style11">toAddress</span><span class="pun"
style="color: rgb(102, 102, 0); ">);</span><span class="pln"
style="color: rgb(0, 0, 0); ">
</span><span class="pun" style="color: rgb(102, 102, 0); ">}</span></pre>
</span></span><span class="style6"><span class="style16"
style="color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);">
<br class="style25" />
</span></span></span><span class="style20"> fromAddress</span><span
class="style26"> and <b>toAddress</b> is the same which we can retrieve
easily with as we have discussed in step 2.</span><p class="style20">
Let's see the demo in a sample application</p>
<p>
</p>
<br />
<div style="float: left; padding-right: 5px;">
<script type="text/javascript">
<!--
google_ad_client = "ca-pub-9274462217825187";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text";
google_ad_channel ="";
google_color_text = "000000";
//-->
</script>
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script>
</div>
<br /><br /><br /><br /><br /><br />
<form action="#" onsubmit="setDirectionsA(this.fromC1.value, this.fromC2.value, this.toC1.value, this.toC2.value, this.locale.value); return false">
<table>
<tr>
<th align="right">From: </th>
<td>
<input type="text" size="15" id="fromAddressC1" name="fromC1" value="40.7384918"/>
<input type="text" size="15" id="fromAddressC2" name="fromC2" value="-74.0022663"/>
<td>
<th align="right"> To: </th>
<td>
<input type="text" size="15" id="toAddressC1" name="toC1" value="41.707521" />
<input type="text" size="15" id="toAddressC2" name="toC2" value="-74.0022663" />
<td>
</tr>
<tr>
<th align="right">Place A: </th>
<td>
<input type="text" size="50" id="fromAddressP1" name="fromP1" value="NA"/>
<td>
<th align="right"> Place B: </th>
<td align="right">
<input type="text" size="50" id="toAddressP2" name="toP2" value="NA" />
<td>
</tr>
<tr>
<th>Language: </th>
<td colspan="3">
<select id="locale" name="locale">
<option value="en" selected>English</option>
<option value="fr">French</option>
<option value="de">German</option>
<option value="ja">Japanese</option>
<option value="es">Spanish</option>
</select>
<input name="submit" type="submit" value="Save Updated Values!" />
<input name="submit" type="submit" value="Show In Map!" />
<td>
</tr>
</table>
</form>
<br/>
<table class="directions">
<tr>
<th>Formatted Directions</th><th>Map</th>
</tr>
<tr>
<td valign="top">
<div id="directions" style="width: 275px"></div>
<td>
<td valign="top">
<div id="map_canvas" style="width: 350px; height: 450px"></div>
<td>
</tr>
</table>
</body>
<br /></div>TShttp://www.blogger.com/profile/02381204600694943595noreply@blogger.com58tag:blogger.com,1999:blog-6005247006949384691.post-83324033516454884072011-10-01T03:18:00.000-07:002011-10-01T03:25:34.662-07:00How to add gadget to blogger header ?<div dir="ltr" style="text-align: left;" trbidi="on">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">Recently experimenting with blogger template came across need of </span><span class="Apple-style-span" style="font-size: large;"><b>adding gadget to blogger header.</b></span>
<br />
<span class="Apple-style-span" style="font-size: large;"><b><br /></b></span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">Its very simple , just follow the steps below :-</span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">1) Go to the edit section of blogger template.</span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"> <span class="Apple-style-span" style="font-size: x-small;">Template->Edit HTML</span></span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">2) Search for following code which is about header.</span><br />
<br />
<span class="Apple-style-span" style="background-color: white;"><span class="Apple-style-span" style="color: #660000;"><b:section class='header' id='header' maxwidgets='1' showaddelement='no'></span></span><br />
<span class="Apple-style-span" style="background-color: #eeeeee; color: #335577; font-family: 'Trebuchet MS', Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"><br /></span><br />
<span class="Apple-style-span" style="background-color: #eeeeee; color: #335577; font-family: 'Trebuchet MS', Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"><br /></span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">3) Just change the <i>showaddelement </i>to yes.</span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">4) Now move back to template layout view and now one can gadget to the header.</span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><br /></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-pdWu4tG1BY4/TobncOMcS7I/AAAAAAAAAd8/NuQlYjp8l5I/s1600/Blog+Header.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="155" src="http://2.bp.blogspot.com/-pdWu4tG1BY4/TobncOMcS7I/AAAAAAAAAd8/NuQlYjp8l5I/s640/Blog+Header.jpg" width="640" /></a></div>
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><br /></span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">In addition to it one can also change <i>maxwidgets </i>count from 1 to desired number to increase widget counts.</span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><br /></span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">Extending the same concept of <i>showaddelement </i>and <i>maxwidgets,</i> one can also add and increase the gadget count to any other part of your blog. For example to body, footer or side column.</span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><br /></span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">Try this out to customize.</span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><br /></span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
TShttp://www.blogger.com/profile/02381204600694943595noreply@blogger.com65tag:blogger.com,1999:blog-6005247006949384691.post-25005324532297482132011-09-23T22:50:00.000-07:002011-09-23T22:55:28.943-07:00Google In Page Analytics<div dir="ltr" style="text-align: left;" trbidi="on">
<span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;">Yet another awesome innovation from Google.</span><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;">A very<b><span class="Apple-style-span" style="color: #660000;"> <span class="Apple-style-span" style="font-size: large;">important SEO tool</span></span></b>, it actually helps one to visualize click views performed on a web page. Google recently launched In Page Analytic for this which can be found under Content section of Google analytic.</span><br />
<br />
<span class="Apple-style-span" style="background-color: white; color: #222222; line-height: 19px;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"></span></span><br />
<span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"> It enables you to visually analyze your website pages in order to assess how users interact with those pages, and helps you understand the answers to questions as per Google Analytics such as:</span><br />
<br />
<div style="float: left; padding-right: 5px;">
<script type="text/javascript">
<!--
google_ad_client = "ca-pub-9274462217825187";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text";
google_ad_channel ="";
google_color_border = "E8E7D0";
google_color_bg = "dcdcdc";
google_color_link = "B96F17";
google_color_url = "B96F17";
google_color_text = "000000";
//-->
</script>
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script>
</div>
<br />
<br />
<br />
<br />
<br />
<ul>
<li><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;">Is my page layout optimal for what I want users to accomplish on the page?</span></li>
<li><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;">Are my users seeing the content I want them to see?</span></li>
<li><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;">Are my users finding what they're looking for on the page?</span></li>
<li><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;">Are my calls to action motivating or visible enough?</span></li>
<li><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;">Which links are users clicking?</span></li>
</ul>
<div>
<span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;">Here is the image for my web page:-</span></div>
<div>
<span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><a href="http://1.bp.blogspot.com/-kjZtmWiKvgI/Tn1nU75ZdNI/AAAAAAAAAdk/3uUMkwpX0es/s1600/In+Page+Analytics.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="246" src="http://1.bp.blogspot.com/-kjZtmWiKvgI/Tn1nU75ZdNI/AAAAAAAAAdk/3uUMkwpX0es/s640/In+Page+Analytics.gif" width="640" /></a></span></div>
<div>
<span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><br /></span></div>
<div>
<span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;">It's really great to see In-Page-Analytic report.</span></div>
<div>
<span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;">For more details one can refer :- </span></div>
<a href="http://www.google.com/support/analytics/bin/answer.py?answer=178902">http://www.google.com/support/analytics/bin/answer.py?answer=178902</a><br />
<br />
For SEO purpose this analysis report is very helpful, Try it out.<br />
<br /></div>
TShttp://www.blogger.com/profile/02381204600694943595noreply@blogger.com84tag:blogger.com,1999:blog-6005247006949384691.post-7592319091383189422011-09-20T01:59:00.000-07:002011-09-20T04:15:06.522-07:00How to add adsense to blog using javascript<div dir="ltr" style="text-align: left;" trbidi="on">
<title>Untitled Page</title>
<style type="text/css">
p.MsoNormal
{margin-top:0cm;
margin-right:0cm;
margin-bottom:10.0pt;
margin-left:0cm;
line-height:115%;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
}
</style>
<script language="javascript" type="text/javascript">
// <!CDATA[
function IMG1_onclick() {
}
// ]]>
</script>
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: 'Courier New'; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<b><span class="Apple-style-span" style="font-size: large;">Google Adsense </span></b>can be easily added with the help of <b>javascript </b>in any poart of post.</div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
Lets look at the simple steps for doing it :-
</div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;">
1) Go to the edit post of your blog.
</div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;">
2) Select HTML edit mode.
</div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;">
3) Insert following javascript to your HTML.</div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;">
<strong><em>
Below is the example of leader board Adsense :- </em></strong>
</div>
<div id=""javascript">
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
-------------------------------------------------------------------------------------------------------------------------</div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: 'Courier New'; font-size: 10pt;"><o:p> </o:p>
</span> </div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span class="Apple-style-span" style="color: blue; font-family: 'Courier New'; font-size: x-small;"><br /></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: 'Courier New'; font-size: 10pt;"><</span><span style="color: maroon; font-family: 'Courier New'; font-size: 10pt;">script</span><span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: red;">type</span><span style="color: blue;">="text/javascript"><</span>!--<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: 'Courier New'; font-size: 10pt;">
google_ad_client = <span style="color: maroon;">"ca-pub-9274462217825187"</span>;<o:p>
//change your pusblisher id</o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: 'Courier New'; font-size: 10pt;">
google_ad_width = 728;<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: 'Courier New'; font-size: 10pt;">
google_ad_height = 90;<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: 'Courier New'; font-size: 10pt;">
google_ad_format = <span style="color: maroon;">"728x90_as"</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: 'Courier New'; font-size: 10pt;">
google_ad_type = <span style="color: maroon;">"text"</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: 'Courier New'; font-size: 10pt;">
google_ad_channel =<span style="color: maroon;">""</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: 'Courier New'; font-size: 10pt;">
google_color_border = <span style="color: maroon;">"E8E7D0"</span>;<o:p> //change
background color from here</o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: 'Courier New'; font-size: 10pt;">
google_color_bg = <span style="color: maroon;">"dcdcdc"</span>;<o:p> //change back
ground coloe from here </o:p>
</span>
</div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: 'Courier New'; font-size: 10pt;">
google_color_link = <span style="color: maroon;">"B96F17"</span>;<o:p> //change
link color from here</o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: 'Courier New'; font-size: 10pt;">
google_color_url = <span style="color: maroon;">"B96F17"</span>;<o:p> //change url
color from here</o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: 'Courier New'; font-size: 10pt;">
google_color_text = <span style="color: maroon;">"000000"</span>;<o:p> //change
text color from here</o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: green; font-family: 'Courier New'; font-size: 10pt;">//--><</span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">/</span><span style="color: maroon; font-family: 'Courier New'; font-size: 10pt;">script</span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: 'Courier New'; font-size: 10pt;"><</span><span style="color: maroon; font-family: 'Courier New'; font-size: 10pt;">script</span><span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: red;">type</span><span style="color: blue;">="text/javascript"<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: red; font-family: 'Courier New'; font-size: 10pt;">src</span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">="http://pagead2.googlesyndication.com/pagead/show_ads.js"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: 'Courier New'; font-size: 10pt;"><!--</font--><span style="color: maroon; font-family: 'Courier New'; font-size: 10pt;">script</span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
</div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
-------------------------------------------------------------------------------------------------------------------------</div>
</div>
</div>
<div class="MsoNormal">
4) Save your post and you done with Adsense emebed into your post.
</div>
<div class="MsoNormal">
Above adsense javascript code will return some thing like below in your blog post
:-</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-mkJ-mki-8bo/TnhUR9SQqeI/AAAAAAAAAdM/K5REV_KGMR4/s1600/Blog_Adsense_JavaScript_LeaderBoard.JPG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="236" src="http://2.bp.blogspot.com/-mkJ-mki-8bo/TnhUR9SQqeI/AAAAAAAAAdM/K5REV_KGMR4/s640/Blog_Adsense_JavaScript_LeaderBoard.JPG" width="640" /></a></span></div>
<br />
<div class="MsoNormal">
<br /></div>
<br />
<div style="float: left; padding-right: 5px;">
<script type="text/javascript">
<!--
google_ad_client = "ca-pub-9274462217825187";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text";
google_ad_channel ="";
google_color_border = "E8E7D0";
google_color_bg = "dcdcdc";
google_color_link = "B96F17";
google_color_url = "B96F17";
google_color_text = "000000";
//-->
</script>
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script>
</div>
<br /><br /><br /><br /><br /><br />
<h1>
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<span >
How to change the Adsense Unit Size ?</span></h1>
<div class="MsoNormal">
<span>Next important point is to change the adsense layout using javascript.</span></div>
<div class="MsoNormal">
<span >Follow below step to change the :-
</span></div>
<div class="MsoNormal">
<span>1) Go to the adsense javascript.</span></div>
<div class="MsoNormal">
<span >2) Change the hieght and width field , get the value of hieght and width from the
image shown below:-</span></div>
<div class="MsoNormal">
<span ><img height="640" id="IMG1" onclick="return IMG1_onclick()" src="http://4.bp.blogspot.com/-sT1JfIzKFwk/TnhDnmDz6_I/AAAAAAAAAdE/QNsvBslBkbQ/s640/AdUnit_Size_type.JPG" width="512" />:</span></div>
<div class="MsoNormal">
<span >3) After changing the hieght and width, change the "<span class="MsoNormal"><span style="color: #cc3300;">google_ad_format</span>" value in "width_height_as" format,
example :-</span></span></div>
<span ><span class="MsoNormal"></span><span style="font-family: 'Courier New'; font-size: 10pt;">
google_ad_width = 336; </span><span class="MsoNormal"></span>
</span><br />
<span ><span style="font-family: 'Courier New'; font-size: 10pt;"> google_ad_height = 280;</span></span><br />
<span ><span style="font-family: 'Courier New';">
<span style="font-size: 10pt;"></span></span><span style="font-family: 'Courier New'; font-size: 10pt;">
google_ad_format = <span style="color: maroon;">"336x280_as"</span>;</span></span><br />
<span ><span style="font-family: 'Courier New'; font-size: 10pt;"><br /></span></span><br />
<div class="MsoNormal">
<span ><span class="MsoNormal">4) Just save it after changing the value, and you are
ready with new Adsense unit size. Choose unit size according to your website/blog.</span></span></div>
<span><span class="MsoNormal">
</span></span><br />
<br />
<span><span class="MsoNormal">
<br />
</span>
<br />
<br />
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
</span></div>
TShttp://www.blogger.com/profile/02381204600694943595noreply@blogger.com96tag:blogger.com,1999:blog-6005247006949384691.post-24416606710883310342011-09-18T10:37:00.000-07:002011-09-19T23:51:37.795-07:00List of Blog Post Gadget for blogger using javascript<div dir="ltr" style="text-align: left;" trbidi="on">
<title>Blogger Data API Sample</title>
<style type="text/css">
.style1
{
font-family: Arial, Helvetica, sans-serif;
}
.style2
{
font-family: Arial, Helvetica, sans-serif;
font-size: small;
}
.style3
{
font-size: small;
}
.style4
{
font-family: Modern;
background-color: #FFFFFF;
}
</style>
<p class="style2">
Following post will help in retrieving the information related to <b>list of
post from</b> a blog. One can use this to display the list of blogs by following
easy step mentioned below</p>
<p class="style2">
1) Add one html/javascript gadget to your blog.
</p>
<p class="style2">
2) Copy paste below code to your gadget.
</p>
<p class="style2">
3) Replace feeduri with your blog feed uri.
</p>
<p class="style1">
<span class="style3">
var feedUri = '</span><a
href="http://www.blogger.com/feeds/10861780/posts/default"><span
class="style3">http://www.blogger.com/feeds/10861780/posts/default</span></a><span
class="style3">';</span></p>
<p class="style2">
4) just save the gadget and its ready to use. Here goes the code for list of post
for a blog :-
</p>
<br />
<div style="float:left; padding-right:5px;">
<script type="text/javascript"><!--
google_ad_client = "ca-pub-9274462217825187";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text";
google_ad_channel ="";
google_color_border = "E8E7D0";
google_color_bg = "dcdcdc";
google_color_link = "B96F17";
google_color_url = "B96F17";
google_color_text = "000000";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
</div>
<br /><br /><br /><br /><br />
<p>
-------------------------------------------------------------------------------------------</p>
<p class="style4">
<span class="Apple-style-span"
style="color: rgb(102, 102, 102); font-family: monospace; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: nowrap; widows: 2; word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
<span class="js-comment" style="color: rgb(136, 0, 0); ">/*<span
class="Apple-converted-space"> </span></span><br />
<span class="js-comment" style="color: rgb(136, 0, 0); ">* Retrieve a list of
blog posts</span><br />
<span class="js-comment" style="color: rgb(136, 0, 0); ">*/</span><br />
<br />
<span class="js-comment" style="color: rgb(136, 0, 0); ">// Obtain a reference
to the 'content' div</span><br />
<span class="js-keyword" style="color: rgb(0, 0, 136); ">var<span
class="Apple-converted-space"> </span></span><span class="js-variable"
style="color: black; ">content<span class="Apple-converted-space"> </span></span><span
class="js-operator" style="color: rgb(102, 102, 102); ">=<span
class="Apple-converted-space"> </span></span><span class="js-variable"
style="color: black; ">document</span><span class="js-punctuation"
style="color: rgb(102, 102, 102); ">.</span><span class="js-property"
style="color: black; ">getElementById</span><span class="js-punctuation"
style="color: rgb(102, 102, 102); ">(</span><span class="js-string"
style="color: rgb(0, 136, 0); ">'content'</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">);</span><br />
<br />
<span class="js-comment" style="color: rgb(136, 0, 0); ">// Create the blogger
service object</span><br />
<span class="js-keyword" style="color: rgb(0, 0, 136); ">var<span
class="Apple-converted-space"> </span></span><span class="js-variable"
style="color: black; ">bloggerService<span class="Apple-converted-space"> </span></span><span
class="js-operator" style="color: rgb(102, 102, 102); ">=</span><br />
<span class="whitespace"> </span><span class="js-keyword"
style="color: rgb(0, 0, 136); ">new<span class="Apple-converted-space"> </span></span><span
class="js-variable" style="color: black; ">google</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">.</span><span
class="js-property" style="color: black; ">gdata</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">.</span><span
class="js-property" style="color: black; ">blogger</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">.</span><span
class="js-property" style="color: black; ">BloggerService</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">(</span><span
class="js-string" style="color: rgb(0, 136, 0); ">'com.appspot.interactivesampler'</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">);</span><br />
<br />
<span class="js-comment" style="color: rgb(136, 0, 0); ">// The feed for a
single blog. (In this case, the Official Google Blog.)</span><br />
<span class="js-comment" style="color: rgb(136, 0, 0); ">//</span><br />
<span class="js-comment" style="color: rgb(136, 0, 0); ">// The ID included in
this URI can be retrieved from the</span><br />
<span class="js-comment" style="color: rgb(136, 0, 0); ">// <link
rel="service.post"> element in the Blog's HTML source</span><br />
<span class="js-keyword" style="color: rgb(0, 0, 136); ">var<span
class="Apple-converted-space"> </span></span><span class="js-variable"
style="color: black; ">feedUri<span class="Apple-converted-space"> </span></span><span
class="js-operator" style="color: rgb(102, 102, 102); ">=<span
class="Apple-converted-space"> </span></span><span class="js-string"
style="color: rgb(0, 136, 0); ">'http://www.blogger.com/feeds/10861780/posts/default'</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">;</span><br />
<br />
<span class="js-comment" style="color: rgb(136, 0, 0); ">// A callback method
invoked getBlogPostFeed() returns data</span><br />
<span class="js-keyword" style="color: rgb(0, 0, 136); ">var<span
class="Apple-converted-space"> </span></span><span class="js-variable"
style="color: black; ">handleBlogPostFeed<span
class="Apple-converted-space"> </span></span><span class="js-operator"
style="color: rgb(102, 102, 102); ">=<span class="Apple-converted-space"> </span></span><span
class="js-keyword" style="color: rgb(0, 0, 136); ">function</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">(</span><span
class="js-variabledef" style="color: black; ">postsFeedRoot</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">)<span
class="Apple-converted-space"> </span>{</span><br />
<span class="whitespace"> </span><span class="js-keyword"
style="color: rgb(0, 0, 136); ">var<span class="Apple-converted-space"> </span></span><span
class="js-variabledef" style="color: black; ">posts<span
class="Apple-converted-space"> </span></span><span class="js-operator"
style="color: rgb(102, 102, 102); ">=<span class="Apple-converted-space"> </span></span><span
class="js-localvariable" style="color: black; ">postsFeedRoot</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">.</span><span
class="js-property" style="color: black; ">feed</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">.</span><span
class="js-property" style="color: black; ">getEntries</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">();</span><br />
<span class="whitespace"> </span><br />
<span class="whitespace"> </span><span class="js-comment"
style="color: rgb(136, 0, 0); ">// This variable will buffer HTML output
until function completes</span><br />
<span class="whitespace"> </span><span class="js-keyword"
style="color: rgb(0, 0, 136); ">var<span class="Apple-converted-space"> </span></span><span
class="js-variabledef" style="color: black; ">html<span
class="Apple-converted-space"> </span></span><span class="js-operator"
style="color: rgb(102, 102, 102); ">=<span class="Apple-converted-space"> </span></span><span
class="js-string" style="color: rgb(0, 136, 0); ">''</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">;</span><br />
<span class="whitespace"> </span><br />
<span class="whitespace"> </span><span class="js-comment"
style="color: rgb(136, 0, 0); ">// Display blog's title</span><br />
<span class="whitespace"> </span><span class="js-localvariable"
style="color: black; ">html<span class="Apple-converted-space"> </span></span><span
class="js-operator" style="color: rgb(102, 102, 102); ">+=<span
class="Apple-converted-space"> </span></span><span class="js-string"
style="color: rgb(0, 136, 0); ">'<dl>'</span><br />
<span class="whitespace"> </span><span class="js-operator"
style="color: rgb(102, 102, 102); ">+<span class="Apple-converted-space"> </span></span><span
class="js-string" style="color: rgb(0, 136, 0); ">'<dt><strong>Blog:</strong>
'</span><br />
<span class="whitespace"> </span><span class="js-operator"
style="color: rgb(102, 102, 102); ">+<span class="Apple-converted-space"> </span></span><span
class="js-string" style="color: rgb(0, 136, 0); ">'<a href="'</span><br />
<span class="whitespace"> </span><span class="js-operator"
style="color: rgb(102, 102, 102); ">+<span class="Apple-converted-space"> </span></span><span
class="js-localvariable" style="color: black; ">postsFeedRoot</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">.</span><span
class="js-property" style="color: black; ">feed</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">.</span><span
class="js-property" style="color: black; ">getLink</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">(</span><span
class="js-string" style="color: rgb(0, 136, 0); ">'alternate'</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">).</span><span
class="js-property" style="color: black; ">getHref</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">()</span><br />
<span class="whitespace"> </span><span class="js-operator"
style="color: rgb(102, 102, 102); ">+<span class="Apple-converted-space"> </span></span><span
class="js-string" style="color: rgb(0, 136, 0); ">'">'</span><br />
<span class="whitespace"> </span><span class="js-operator"
style="color: rgb(102, 102, 102); ">+<span class="Apple-converted-space"> </span></span><span
class="js-localvariable" style="color: black; ">postsFeedRoot</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">.</span><span
class="js-property" style="color: black; ">feed</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">.</span><span
class="js-property" style="color: black; ">getTitle</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">().</span><span
class="js-property" style="color: black; ">getText</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">()</span><br />
<span class="whitespace"> </span><span class="js-operator"
style="color: rgb(102, 102, 102); ">+<span class="Apple-converted-space"> </span></span><span
class="js-string" style="color: rgb(0, 136, 0); ">'</a></dt>'</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">;</span><br />
<span class="whitespace"> </span><br />
<span class="whitespace"> </span><span class="js-comment"
style="color: rgb(136, 0, 0); ">// Display blog posts</span><br />
<span class="whitespace"> </span><span class="js-localvariable"
style="color: black; ">html<span class="Apple-converted-space"> </span></span><span
class="js-operator" style="color: rgb(102, 102, 102); ">+=<span
class="Apple-converted-space"> </span></span><span class="js-string"
style="color: rgb(0, 136, 0); ">'<dd><ul>'</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">;</span><br />
<span class="whitespace"> </span><span class="js-keyword"
style="color: rgb(0, 0, 136); ">for<span class="Apple-converted-space"> </span></span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">(</span><span
class="js-keyword" style="color: rgb(0, 0, 136); ">var<span
class="Apple-converted-space"> </span></span><span class="js-variabledef"
style="color: black; ">i<span class="Apple-converted-space"> </span></span><span
class="js-operator" style="color: rgb(102, 102, 102); ">=<span
class="Apple-converted-space"> </span></span><span class="js-atom"
style="color: rgb(34, 136, 17); ">0</span><span class="js-punctuation"
style="color: rgb(102, 102, 102); ">,<span class="Apple-converted-space"> </span></span><span
class="js-variabledef" style="color: black; ">post</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">;<span
class="Apple-converted-space"> </span></span><span class="js-localvariable"
style="color: black; ">post<span class="Apple-converted-space"> </span></span><span
class="js-operator" style="color: rgb(102, 102, 102); ">=<span
class="Apple-converted-space"> </span></span><span class="js-localvariable"
style="color: black; ">posts</span><span class="js-punctuation"
style="color: rgb(102, 102, 102); ">[</span><span class="js-localvariable"
style="color: black; ">i</span><span class="js-punctuation"
style="color: rgb(102, 102, 102); ">];<span class="Apple-converted-space"> </span></span><span
class="js-localvariable" style="color: black; ">i</span><span
class="js-operator" style="color: rgb(102, 102, 102); ">++</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">)<span
class="Apple-converted-space"> </span>{</span><br />
<span class="whitespace"> </span><span class="js-keyword"
style="color: rgb(0, 0, 136); ">var<span class="Apple-converted-space"> </span></span><span
class="js-variabledef" style="color: black; ">postTitle<span
class="Apple-converted-space"> </span></span><span class="js-operator"
style="color: rgb(102, 102, 102); ">=<span class="Apple-converted-space"> </span></span><span
class="js-localvariable" style="color: black; ">post</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">.</span><span
class="js-property" style="color: black; ">getTitle</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">().</span><span
class="js-property" style="color: black; ">getText</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">();</span><br />
<span class="whitespace"> </span><span class="js-keyword"
style="color: rgb(0, 0, 136); ">var<span class="Apple-converted-space"> </span></span><span
class="js-variabledef" style="color: black; ">postURL<span
class="Apple-converted-space"> </span></span><span class="js-operator"
style="color: rgb(102, 102, 102); ">=<span class="Apple-converted-space"> </span></span><span
class="js-localvariable" style="color: black; ">post</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">.</span><span
class="js-property" style="color: black; ">getHtmlLink</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">().</span><span
class="js-property" style="color: black; ">getHref</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">();</span><br />
<span class="whitespace"> </span><span class="js-localvariable"
style="color: black; ">html<span class="Apple-converted-space"> </span></span><span
class="js-operator" style="color: rgb(102, 102, 102); ">+=<span
class="Apple-converted-space"> </span></span><span class="js-string"
style="color: rgb(0, 136, 0); ">'<li><a href="'<span
class="Apple-converted-space"> </span></span><span class="js-operator"
style="color: rgb(102, 102, 102); ">+<span class="Apple-converted-space"> </span></span><span
class="js-localvariable" style="color: black; ">postURL<span
class="Apple-converted-space"> </span></span><span class="js-operator"
style="color: rgb(102, 102, 102); ">+<span class="Apple-converted-space"> </span></span><span
class="js-string" style="color: rgb(0, 136, 0); ">'" target="_blank">'</span><br />
<span class="whitespace"> </span><span class="js-operator"
style="color: rgb(102, 102, 102); ">+<span class="Apple-converted-space"> </span></span><span
class="js-localvariable" style="color: black; ">postTitle</span><br />
<span class="whitespace"> </span><span class="js-operator"
style="color: rgb(102, 102, 102); ">+<span class="Apple-converted-space"> </span></span><span
class="js-string" style="color: rgb(0, 136, 0); ">'</a></li>'</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">;</span><br />
<span class="whitespace"> </span><span class="js-punctuation"
style="color: rgb(102, 102, 102); ">}</span><br />
<span class="whitespace"> </span><span class="js-localvariable"
style="color: black; ">html<span class="Apple-converted-space"> </span></span><span
class="js-operator" style="color: rgb(102, 102, 102); ">+=<span
class="Apple-converted-space"> </span></span><span class="js-string"
style="color: rgb(0, 136, 0); ">'</ul></dd>'</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">;</span><br />
<span class="whitespace"> </span><br />
<span class="whitespace"> </span><span class="js-comment"
style="color: rgb(136, 0, 0); ">// Write out buffered HTML, and clear the
"Loading..." message</span><br />
<span class="whitespace"> </span><span class="js-variable"
style="color: black; ">content</span><span class="js-punctuation"
style="color: rgb(102, 102, 102); ">.</span><span class="js-property"
style="color: black; ">innerHTML<span class="Apple-converted-space"> </span></span><span
class="js-operator" style="color: rgb(102, 102, 102); ">=<span
class="Apple-converted-space"> </span></span><span class="js-localvariable"
style="color: black; ">html</span><span class="js-punctuation"
style="color: rgb(102, 102, 102); ">;</span><br />
<span class="js-punctuation" style="color: rgb(102, 102, 102); ">};</span><br />
<br />
<span class="js-keyword" style="color: rgb(0, 0, 136); ">var<span
class="Apple-converted-space"> </span></span><span class="js-variable"
style="color: black; ">handleError<span class="Apple-converted-space"> </span></span><span
class="js-operator" style="color: rgb(102, 102, 102); ">=<span
class="Apple-converted-space"> </span></span><span class="js-keyword"
style="color: rgb(0, 0, 136); ">function</span><span class="js-punctuation"
style="color: rgb(102, 102, 102); ">(</span><span class="js-variabledef"
style="color: black; ">error</span><span class="js-punctuation"
style="color: rgb(102, 102, 102); ">)<span class="Apple-converted-space"> </span>{</span><br />
<span class="whitespace"> </span><span class="js-variable"
style="color: black; ">content</span><span class="js-punctuation"
style="color: rgb(102, 102, 102); ">.</span><span class="js-property"
style="color: black; ">innerHTML<span class="Apple-converted-space"> </span></span><span
class="js-operator" style="color: rgb(102, 102, 102); ">=<span
class="Apple-converted-space"> </span></span><span class="js-string"
style="color: rgb(0, 136, 0); ">'<pre>'<span class="Apple-converted-space"> </span></span><span
class="js-operator" style="color: rgb(102, 102, 102); ">+<span
class="Apple-converted-space"> </span></span><span class="js-localvariable"
style="color: black; ">error<span class="Apple-converted-space"> </span></span><span
class="js-operator" style="color: rgb(102, 102, 102); ">+<span
class="Apple-converted-space"> </span></span><span class="js-string"
style="color: rgb(0, 136, 0); ">'</pre>'</span><span class="js-punctuation"
style="color: rgb(102, 102, 102); ">;</span><br />
<span class="js-punctuation" style="color: rgb(102, 102, 102); ">};</span><br />
<br />
<span class="js-variable" style="color: black; ">bloggerService</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">.</span><span
class="js-property" style="color: black; ">getBlogPostFeed</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">(</span><span
class="js-variable" style="color: black; ">feedUri</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">,<span
class="Apple-converted-space"> </span></span><span class="js-variable"
style="color: black; ">handleBlogPostFeed</span><span
class="js-punctuation" style="color: rgb(102, 102, 102); ">,<span
class="Apple-converted-space"> </span></span><span class="js-variable"
style="color: black; ">handleError</span><span class="js-punctuation"
style="color: rgb(102, 102, 102); ">);</span></span></p>
<p>
------------------------------------------------------------------------------------------------------</p>
<p>
</p>
<p class="style2">
<b> Below is the demo of above code for my blog :- </b></p>
<p>
</p>
<script src="http://www.google.com/jsapi" type="text/javascript">
</script>
<script type="text/javascript">
google.load("gdata", "1.x", { packages : ["blogger"] });
</script>
<script type="text/javascript">
function _run() {
/*
* Retrieve a list of blog posts
*/
// Obtain a reference to the 'content' div
var content = document.getElementById('content');
// Create the blogger service object
var bloggerService =
new google.gdata.blogger.BloggerService('com.appspot.interactivesampler');
// The feed for a single blog. (In this case, the Official Google Blog.)
//
// The ID included in this URI can be retrieved from the
// <link rel="service.post"> element in the Blog's HTML source
var feedUri = 'http://tajendrasengar.blogspot.com/feeds/posts/default';
// A callback method invoked getBlogPostFeed() returns data
var handleBlogPostFeed = function(postsFeedRoot) {
var posts = postsFeedRoot.feed.getEntries();
// This variable will buffer HTML output until function completes
var html = '';
// Display blog's title
html += '<dl>'
+ '<dt><strong>Blog:</strong> '
+ '<a href="'
+ postsFeedRoot.feed.getLink('alternate').getHref()
+ '">'
+ postsFeedRoot.feed.getTitle().getText()
+ '</a></dt>';
// Display blog posts
html += '<dd><ul>';
for (var i = 0, post; post = posts[i]; i++) {
var postTitle = post.getTitle().getText();
var postURL = post.getHtmlLink().getHref();
html += '<li><a href="' + postURL + '" target="_blank">'
+ postTitle
+ '</a></li>';
}
html += '</ul></dd>';
// Write out buffered HTML, and clear the "Loading..." message
content.innerHTML = html;
};
var handleError = function(error) {
content.innerHTML = '<pre>' + error + '</pre>';
};
bloggerService.getBlogPostFeed(feedUri, handleBlogPostFeed, handleError);
}
google.setOnLoadCallback(_run);
</script>
<br />
<div id="content" style="width: 100%;">
<br />
<br />
<br />
Loading...</div>
<br /></div>
TShttp://www.blogger.com/profile/02381204600694943595noreply@blogger.com233tag:blogger.com,1999:blog-6005247006949384691.post-61702696716108523052011-09-15T10:50:00.000-07:002011-10-13T00:52:24.619-07:00Postfix to Infix Algorithm<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: black; font-family: Arial, sans-serif;">I have come across one
very interesting query about<span class="apple-converted-space"><b> </b></span><b>Postfix
to Infix<span class="apple-converted-space"> </span></b>conversion.<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<span style="color: black; font-family: Arial, sans-serif;">Let’s understand first the importance
of having Postfix notation:-<o:p></o:p></span></div>
<br />
<div style="float: left; padding-right: 5px;">
<script type="text/javascript">
<!--
google_ad_client = "ca-pub-9274462217825187";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text";
google_ad_channel ="";
google_color_border = "E8E7D0";
google_color_bg = "dcdcdc";
google_color_link = "B96F17";
google_color_url = "B96F17";
google_color_text = "000000";
//-->
</script>
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script>
</div>
<br />
<div style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; text-indent: -18.0pt;">
<span style="font-family: Symbol;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';">
</span></span><span style="font-family: Arial, sans-serif;">To
reduce computer memory access.<o:p></o:p></span></div>
The automatic stack permits the automatic storage of intermediate results for use later: this key<br />
feature is what permits RPN calculators to easily evaluate expressions of arbitrary complexity: they<br />
do not have limits on the complexity of expression they can evaluate.
<br />
<div style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; text-indent: -18.0pt;">
<span style="color: black; font-family: Symbol;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';">
</span></span><span style="font-family: Arial, sans-serif;">To
utilize the stack to evaluate expressions.<span style="color: black;"><o:p></o:p></span></span></div>
<div style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; text-indent: -18.0pt;">
<span style="color: black; font-family: Symbol;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';">
</span></span><span style="font-family: Arial, sans-serif;">To reduce the complexity of expression while evaluation.<span style="color: black;"><o:p></o:p></span></span></div>
<div style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; text-indent: -18.0pt;">
<span style="font-family: Symbol;">·<span style="font: normal normal normal 7pt/normal 'Times New Roman';">
</span></span><span style="font-family: Arial, sans-serif;">Postfix notation is often used in <span style="text-decoration: none;">stack-based</span> and concatenative programming languages.<span class="Apple-style-span" style="font-size: 9pt;"><o:p></o:p></span></span></div>
<div style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 0cm; margin-top: 0cm;">
<br /></div>
<table border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="background: white; border-collapse: collapse; border: none; margin-left: 36.0pt; mso-background-themecolor: background1; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-yfti-tbllook: 1184;">
<tbody>
<tr>
<td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0cm 5.4pt 0cm 5.4pt; width: 462.1pt;" valign="top" width="616"><div style="border-bottom: solid #AAAAAA 1.0pt; border: none; mso-border-bottom-alt: solid #AAAAAA .75pt; mso-element: para-border-div; padding: 0cm 0cm 2.0pt 0cm;">
<div class="MsoNormal" style="border: none; margin-bottom: 7.2pt; mso-border-bottom-alt: solid #AAAAAA .75pt; mso-line-height-alt: 12.9pt; mso-outline-level: 2; mso-padding-alt: 0cm 0cm 2.0pt 0cm; padding: 0cm;">
<span style="color: black; font-family: Arial, sans-serif; font-size: 13pt;">Postfix to Infix Algorithm</span><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black; font-family: Arial, sans-serif; font-size: 13pt;"><o:p></o:p></span></div>
</div>
<div class="MsoNormal" style="line-height: 18.0pt; margin-bottom: 6.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 4.8pt;">
<span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black; font-family: Arial, sans-serif; font-size: 9pt;">Let’s look out for
the algorithm for converting postfix to infix expression:-<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 19.2pt; mso-list: l1 level1 lfo2; mso-margin-top-alt: auto; tab-stops: list 36.0pt; text-indent: -17.85pt;">
<span style="color: black; font-family: Wingdings; font-size: 10pt;">§<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black; font-family: Arial, sans-serif; font-size: 9pt;">While
there are input symbol left<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 38.4pt; mso-list: l1 level2 lfo2; mso-margin-top-alt: auto; tab-stops: list 72.0pt; text-indent: -17.85pt;">
<span style="color: black; font-family: Wingdings; font-size: 10pt;">§<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black; font-family: Arial, sans-serif; font-size: 9pt;">Read
the next symbol from input.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 38.4pt; mso-list: l1 level2 lfo2; mso-margin-top-alt: auto; tab-stops: list 72.0pt; text-indent: -17.85pt;">
<span style="color: black; font-family: Wingdings; font-size: 10pt;">§<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black; font-family: Arial, sans-serif; font-size: 9pt;">If
the symbol is an operand (i.e. value)<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 57.6pt; mso-list: l1 level3 lfo2; mso-margin-top-alt: auto; tab-stops: list 108.0pt; text-indent: -17.85pt;">
<span style="color: black; font-family: Wingdings; font-size: 10pt;">§<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black; font-family: Arial, sans-serif; font-size: 9pt;">Push
it onto the stack.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 38.4pt; mso-list: l1 level2 lfo2; mso-margin-top-alt: auto; tab-stops: list 72.0pt; text-indent: -17.85pt;">
<span style="color: black; font-family: Wingdings; font-size: 10pt;">§<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black; font-family: Arial, sans-serif; font-size: 9pt;">Otherwise,
the symbol is an operator.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 57.6pt; mso-list: l1 level3 lfo2; mso-margin-top-alt: auto; tab-stops: list 108.0pt; text-indent: -17.85pt;">
<span style="color: black; font-family: Wingdings; font-size: 10pt;">§<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black; font-family: Arial, sans-serif; font-size: 9pt;">If
there are fewer than</span><span style="color: black; font-family: Arial, sans-serif; font-size: 9pt;"> <b>2</b> </span><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black; font-family: Arial, sans-serif; font-size: 9pt;">values on the stack<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 76.8pt; mso-list: l1 level4 lfo2; mso-margin-top-alt: auto; tab-stops: list 144.0pt; text-indent: -17.85pt;">
<span style="color: black; font-family: Wingdings; font-size: 10pt;">§<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><b><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black; font-family: Arial, sans-serif; font-size: 9pt;">(</span></b><b><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #c00000; font-family: Arial, sans-serif; font-size: 9pt;">Error</span></b><b><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black; font-family: Arial, sans-serif; font-size: 9pt;">)</span></b><span style="color: black; font-family: Arial, sans-serif; font-size: 9pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black; font-family: Arial, sans-serif; font-size: 9pt;">The user has not input sufficient values in the
expression.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 57.6pt; mso-list: l1 level3 lfo2; mso-margin-top-alt: auto; tab-stops: list 108.0pt; text-indent: -17.85pt;">
<span style="color: black; font-family: Wingdings; font-size: 10pt;">§<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black; font-family: Arial, sans-serif; font-size: 9pt;">Else,
Pop the top</span><span style="color: black; font-family: Arial, sans-serif; font-size: 9pt;"> <b>2</b> </span><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black; font-family: Arial, sans-serif; font-size: 9pt;">values from the stack (operand1 & operand 2).<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 57.6pt; mso-list: l1 level3 lfo2; mso-margin-top-alt: auto; tab-stops: list 108.0pt; text-indent: -17.85pt;">
<span style="color: black; font-family: Wingdings; font-size: 10pt;">§<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black; font-family: Arial, sans-serif; font-size: 9pt;">Put
the operator, with the values as arguments and form a string (like : operand1
operator operand2).<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 57.6pt; mso-list: l1 level3 lfo2; mso-margin-top-alt: auto; tab-stops: list 108.0pt; text-indent: -17.85pt;">
<span style="color: black; font-family: Wingdings; font-size: 10pt;">§<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black; font-family: Arial, sans-serif; font-size: 9pt;">Encapsulate
the resulted string with parenthesis. (like: (a+b) if operand1 =’a’, operand2 =’b’, operator =
‘+’ )<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 57.6pt; mso-list: l1 level3 lfo2; mso-margin-top-alt: auto; tab-stops: list 108.0pt; text-indent: -17.85pt;">
<span style="color: black; font-family: Wingdings; font-size: 10pt;">§<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black; font-family: Arial, sans-serif; font-size: 9pt;">Push
the resulted string back to stack.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 19.2pt; mso-list: l1 level1 lfo2; mso-margin-top-alt: auto; tab-stops: list 36.0pt; text-indent: -17.85pt;">
<span style="color: black; font-family: Wingdings; font-size: 10pt;">§<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black; font-family: Arial, sans-serif; font-size: 9pt;">If
there is only one value in the stack<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 38.4pt; mso-list: l1 level2 lfo2; mso-margin-top-alt: auto; tab-stops: list 72.0pt; text-indent: -17.85pt;">
<span style="color: #365f91; font-family: Wingdings; font-size: 10pt;">§<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #365f91; font-family: Arial, sans-serif; font-size: 9pt;">That value in the stack is the desired
infix string.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 19.2pt; mso-list: l1 level1 lfo2; mso-margin-top-alt: auto; tab-stops: list 36.0pt; text-indent: -17.85pt;">
<span style="color: black; font-family: Wingdings; font-size: 10pt;">§<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black; font-family: Arial, sans-serif; font-size: 9pt;">If
there are more values in the stack<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 38.4pt; mso-list: l1 level2 lfo2; mso-margin-top-alt: auto; tab-stops: list 72.0pt; text-indent: -17.85pt;">
<span style="color: black; font-family: Wingdings; font-size: 10pt;">§<span style="font: normal normal normal 7pt/normal 'Times New Roman';"> </span></span><b><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black; font-family: Arial, sans-serif; font-size: 9pt;">(</span></b><b><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #c00000; font-family: Arial, sans-serif; font-size: 9pt;">Error</span></b><b><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black; font-family: Arial, sans-serif; font-size: 9pt;">)</span></b><span style="color: black; font-family: Arial, sans-serif; font-size: 9pt;"> </span><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black; font-family: Arial, sans-serif; font-size: 9pt;">The user input has too many values.<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
</td>
</tr>
</tbody></table>
<div style="margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 36.0pt; margin-right: 0cm; margin-top: 0cm;">
<br /></div>
<br />
Postfix to infix will not give you exact expression in terms of parenthesis, though it will give you same result on evaluation.<br />
<br />
e.g. (a+b+c)*2<br />
Postfix will be :- ab+c+2*<br />
And postfix to infix will give :- (((a+b)+c)*2)<br />
<br />
<br />
<br /></div>TShttp://www.blogger.com/profile/02381204600694943595noreply@blogger.com92tag:blogger.com,1999:blog-6005247006949384691.post-6556470465922799282011-09-15T00:19:00.000-07:002011-09-19T23:41:54.006-07:00Distance Google MAP API demo<div dir="ltr" style="text-align: left;" trbidi="on">
<title>Google Maps API Sample</title> <script src="http://maps.google.com/maps?file=api&v=2&sensor=false&
key=ABQIAAAAeUlgz5ZezwUbH47hW-nEohQCA9e3Snamcn8o65dAybaGLWFLfRR88VjEEw1CS7bsSs9P0Srig2eL-g" type="text/javascript">
</script> <br />
<style type="text/css">
body {
font-family: Verdana, Arial, sans serif;
font-size: 11px;
margin: 2px;
}
table.directions th {
background-color:#EEEEEE;
}
img {
color: #000000;
}
</style> <br />
<script type="text/javascript">
var map;
var gdir;
var geocoder = null;
var addressMarker;
var distance;
function initialize() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
gdir = new GDirections(map, document.getElementById("directions"));
GEvent.addListener(gdir, "load", onGDirectionsLoad);
GEvent.addListener(gdir, "error", handleErrors);
setDirections("San Francisco", "Mountain View", "en_US");
}
}
function setDirections(fromAddress, toAddress, locale) {
gdir.load("from: " + fromAddress + " to: " + toAddress,
{ "locale": locale });
}
function handleErrors(){
if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);
// else if (gdir.getStatus().code == G_UNAVAILABLE_ADDRESS) <--- Doc bug... this is either not defined, or Doc is wrong
// alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_BAD_KEY)
alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
else alert("An unknown error occurred.");
}
function onGDirectionsLoad(){
// Use this function to access information about the latest load()
// results.
// e.g.
distance = gdir.getDistance().meters;
//alert("Distance is : " + gdir.getDistance().meters + " and Duration Is: " + gdir.getDuration().seconds/60);
document.getElementById("DistanceMeter").value = gdir.getDistance().meters/1000;
document.getElementById("DurationMin").value = gdir.getDuration().seconds/60;
}
</script>
<br />
<h1>
<span class="Apple-style-span" style="color: #cc0000;">Google</span> <span class="Apple-style-span" style="font-size: small;">Maps </span><span class="Apple-style-span" style="font-size: small; font-weight: normal;">API Directions Illustrated</span></h1>
<h1>
<span class="Apple-style-span" style="font-size: small; font-weight: normal;">Enter Location in format #place,#city </span></h1>
<h1>
<span class="Apple-style-span" style="font-size: small; font-weight: normal;">Experimenting with google maps api, i have developed this quick utility to show the distance and duration between locations. TRY IT OUT</span></h1>
<form action="#" onsubmit="setDirections(this.from.value, this.to.value, this.locale.value); return false">
<body onload="initialize()" onunload="GUnload()" style="font-family: Arial;border: 0 none;">
<table>
<tbody>
<tr>
<th align="right">From: </th>
<td><input id="fromAddress" name="from" size="25" type="text" value="San Francisco" />
</td><td></td><th align="right"> To: </th>
<td align="right"><input id="toAddress" name="to" size="25" type="text" value="Mountain View" />
</td><td></td></tr>
<tr>
<th>Language: </th>
<td colspan="3"><select id="locale" name="locale">
<option selected="" value="en">English</option>
<option value="fr">French</option>
<option value="de">German</option>
<option value="ja">Japanese</option>
<option value="es">Spanish</option>
</select>
<input name="submit" type="submit" value="Get Directions!" />
</td><td></td></tr>
<tr>
<th align="right">Distance:
</th>
<td align="right"><input id="DistanceMeter" name="distMeter" size="22" type="text" value="0" />KMs
</td>
<td></td>
</tr>
<tr>
<th align="right">Duration:
</th>
<td align="right"><input id="DurationMin" name="durationMin" size="20" type="text" value="0" />Minutes
</td>
<td></td>
</tr>
</tbody></table>
</form>
<br />
<br />
<div style="float:left; padding-right:5px;">
<script type="text/javascript"><!--
google_ad_client = "ca-pub-9274462217825187";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text";
google_ad_channel ="";
google_color_border = "E8E7D0";
google_color_bg = "FFFFFF";
google_color_link = "B96F17";
google_color_url = "B96F17";
google_color_text = "000000";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
</div>
<table class="directions">
<tbody>
<tr>
<th>Formatted Directions</th><th>Map</th>
</tr>
<tr>
<td valign="top"><div id="directions" style="width: 275px;">
</div>
</td><td></td><td valign="top"><div id="map_canvas" style="height: 600px; width: 510px;">
</div>
</td><td></td></tr>
</tbody></table>
</body>
</div>
TShttp://www.blogger.com/profile/02381204600694943595noreply@blogger.com85tag:blogger.com,1999:blog-6005247006949384691.post-26566966647885626912011-09-14T06:52:00.000-07:002011-09-19T22:42:53.849-07:00Distance between two locations with Google Map API<div dir="ltr" style="text-align: left;" trbidi="on">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">One can easily calculate distance between two location with the help of Google Map APIs. Google Map APIs comes with a set of classes which helps in doing such tasks.<br />class <b><span class="Apple-style-span" style="font-size: large;">GDirection</span></b>, helps in getting the travel distance between the two different location.<br />So example shown below targets following features :-</span><br />
<ul style="text-align: left;">
<li><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"> Getting distance between two location. </span></li>
<li><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"> Getting duration between two location. </span></li>
</ul>
<div style="background-color: white; border-bottom-style: none; border-bottom-width: 0px; border-color: initial; border-color: initial; border-left-style: none; border-left-width: 0px; border-right-style: none; border-right-width: 0px; border-top-style: none; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">
<span class="Apple-style-span" style="color: #880000;">Here goes the complete java script code for it</span></div>
<div style="background-color: white; border-bottom-style: none; border-bottom-width: 0px; border-color: initial; border-color: initial; border-left-style: none; border-left-width: 0px; border-right-style: none; border-right-width: 0px; border-top-style: none; border-top-width: 0px; font-family: monospace; font-size: 10pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; white-space: nowrap;">
<span class="Apple-style-span" style="color: #880000;">-------------------------------------------------------------------------------</span></div>
<div style="background-color: white; border-bottom-style: none; border-bottom-width: 0px; border-color: initial; border-color: initial; border-left-style: none; border-left-width: 0px; border-right-style: none; border-right-width: 0px; border-top-style: none; border-top-width: 0px; font-family: monospace; font-size: 10pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; white-space: nowrap;">
<span class="whitespace" style="color: #666666;"> </span><span class="xml-punctuation" style="color: #666600;"><</span><span class="xml-tagname" style="color: #000088;">script </span><span class="xml-attname" style="color: #660066;">type</span><span class="xml-punctuation" style="color: #666600;">=</span><span class="xml-attribute" style="color: #008800;">"text/javascript"</span><span class="xml-punctuation" style="color: #666600;">></span><br />
<span class="whitespace" style="color: #666666;"> </span><span class="js-keyword" style="color: #000088;">var </span><span class="js-variable" style="color: black;">map</span><span class="js-punctuation" style="color: #666666;">;</span><br />
<span class="whitespace" style="color: #666666;"> </span><span class="js-keyword" style="color: #000088;">var </span><span class="js-variable" style="color: black;">gdir</span><span class="js-punctuation" style="color: #666666;">;</span><br />
<span class="whitespace" style="color: #666666;"> </span><span class="js-keyword" style="color: #000088;">var </span><span class="js-variable" style="color: black;">geocoder </span><span class="js-operator" style="color: #666666;">= </span><span class="js-atom" style="color: #228811;">null</span><span class="js-punctuation" style="color: #666666;">;</span><br />
<span class="whitespace" style="color: #666666;"> </span><span class="js-keyword" style="color: #000088;">var </span><span class="js-variable" style="color: black;">addressMarker</span><span class="js-punctuation" style="color: #666666;">;</span><br />
<span class="whitespace" style="color: #666666;"> </span><span class="js-keyword" style="color: #000088;">var </span><span class="js-variable" style="color: black;">distance</span><span class="js-punctuation" style="color: #666666;">;</span><br />
<span class="whitespace" style="color: #666666;"> </span><br />
<span class="whitespace" style="color: #666666;"> </span><span class="js-keyword" style="color: #000088;">function </span><span class="js-variable" style="color: black;">initialize</span><span class="js-punctuation" style="color: #666666;">(</span><span class="js-punctuation" style="color: #666666;">) </span><span class="js-punctuation" style="color: #666666;">{</span><br />
<span class="whitespace" style="color: #666666;"> </span><span class="js-keyword" style="color: #000088;">if </span><span class="js-punctuation" style="color: #666666;">(</span><span class="js-variable" style="color: black;">GBrowserIsCompatible</span><span class="js-punctuation" style="color: #666666;">(</span><span class="js-punctuation" style="color: #666666;">)</span><span class="js-punctuation" style="color: #666666;">) </span><span class="js-punctuation" style="color: #666666;">{ </span><br />
<span class="whitespace" style="color: #666666;"> </span><span class="js-variable" style="color: black;">map </span><span class="js-operator" style="color: #666666;">= </span><span class="js-keyword" style="color: #000088;">new </span><span class="js-variable" style="color: black;">GMap2</span><span class="js-punctuation" style="color: #666666;">(</span><span class="js-variable" style="color: black;">document</span><span class="js-punctuation" style="color: #666666;">.</span><span class="js-property" style="color: black;">getElementById</span><span class="js-punctuation" style="color: #666666;">(</span><span class="js-string" style="color: #008800;">"map_canvas"</span><span class="js-punctuation" style="color: #666666;">)</span><span class="js-punctuation" style="color: #666666;">)</span><span class="js-punctuation" style="color: #666666;">;</span></div>
<div style="background-color: white; border-bottom-style: none; border-bottom-width: 0px; border-color: initial; border-color: initial; border-left-style: none; border-left-width: 0px; border-right-style: none; border-right-width: 0px; border-top-style: none; border-top-width: 0px; font-family: monospace; font-size: 10pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; white-space: nowrap;">
<span class="js-punctuation" style="color: #666666;"><br /></span></div>
<div style="background-color: white; border-bottom-style: none; border-bottom-width: 0px; border-color: initial; border-color: initial; border-left-style: none; border-left-width: 0px; border-right-style: none; border-right-width: 0px; border-top-style: none; border-top-width: 0px; font-family: monospace; font-size: 10pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; white-space: nowrap;">
<span class="whitespace" style="color: #666666;"> </span><span class="js-variable" style="color: black;">gdir </span><span class="js-operator" style="color: #666666;">= </span><span class="js-keyword" style="color: #000088;">new </span><span class="js-variable" style="color: black;">GDirections</span><span class="js-punctuation" style="color: #666666;">(</span><span class="js-atom" style="color: #228811;">map</span><span class="js-punctuation" style="color: #666666;">, </span><span class="js-variable" style="color: black;">document</span><span class="js-punctuation" style="color: #666666;">.</span><span class="js-property" style="color: black;">getElementById</span><span class="js-punctuation" style="color: #666666;">(</span><span class="js-string" style="color: #008800;">"directions"</span><span class="js-punctuation" style="color: #666666;">)</span><span class="js-punctuation" style="color: #666666;">)</span><span class="js-punctuation" style="color: #666666;">;</span><br />
<span class="whitespace" style="color: #666666;"> </span><br />
<span class="whitespace" style="color: #666666;"> </span><span class="js-variable" style="color: black;">GEvent</span><span class="js-punctuation" style="color: #666666;">.</span><span class="js-property" style="color: black;">addListener</span><span class="js-punctuation" style="color: #666666;">(</span><span class="js-variable" style="color: black;">gdir</span><span class="js-punctuation" style="color: #666666;">, </span><span class="js-string" style="color: #008800;">"load"</span><span class="js-punctuation" style="color: #666666;">, </span><span class="js-variable" style="color: black;">onGDirectionsLoad</span><span class="js-punctuation" style="color: #666666;">)</span><span class="js-punctuation" style="color: #666666;">;</span><br />
<span class="whitespace" style="color: #666666;"> </span><span class="js-variable" style="color: black;">GEvent</span><span class="js-punctuation" style="color: #666666;">.</span><span class="js-property" style="color: black;">addListener</span><span class="js-punctuation" style="color: #666666;">(</span><span class="js-variable" style="color: black;">gdir</span><span class="js-punctuation" style="color: #666666;">, </span><span class="js-string" style="color: #008800;">"error"</span><span class="js-punctuation" style="color: #666666;">, </span><span class="js-variable" style="color: black;">handleErrors</span><span class="js-punctuation" style="color: #666666;">)</span><span class="js-punctuation" style="color: #666666;">;</span><br />
<span class="whitespace" style="color: #666666;"> </span><br />
<span class="whitespace" style="color: #666666;"> </span><span class="js-variable" style="color: black;">setDirections</span><span class="js-punctuation" style="color: #666666;">(</span><span class="js-string" style="color: #008800;">"San Francisco"</span><span class="js-punctuation" style="color: #666666;">, </span><span class="js-string" style="color: #008800;">"Mountain View"</span><span class="js-punctuation" style="color: #666666;">, </span><span class="js-string" style="color: #008800;">"en_US"</span><span class="js-punctuation" style="color: #666666;">)</span><span class="js-punctuation" style="color: #666666;">;</span><br />
<span class="whitespace" style="color: #666666;"> </span><span class="js-punctuation" style="color: #666666;">}</span><br />
<span class="whitespace" style="color: #666666;"> </span><span class="js-punctuation" style="color: #666666;">}</span><br />
<span class="whitespace" style="color: #666666;"> </span><br />
<span class="whitespace" style="color: #666666;"> </span><span class="js-keyword" style="color: #000088;">function </span><span class="js-variable" style="color: black;">setDirections</span><span class="js-punctuation" style="color: #666666;">(</span><span class="js-variabledef" style="color: black;">fromAddress</span><span class="js-punctuation" style="color: #666666;">, </span><span class="js-variabledef" style="color: black;">toAddress</span><span class="js-punctuation" style="color: #666666;">, </span><span class="js-variabledef" style="color: black;">locale</span><span class="js-punctuation" style="color: #666666;">) </span><span class="js-punctuation" style="color: #666666;">{</span><br />
<span class="whitespace" style="color: #666666;"> </span><span class="js-variable" style="color: black;">gdir</span><span class="js-punctuation" style="color: #666666;">.</span><span class="js-property" style="color: black;">load</span><span class="js-punctuation" style="color: #666666;">(</span><span class="js-string" style="color: #008800;">"from: " </span><span class="js-operator" style="color: #666666;">+ </span><span class="js-localvariable" style="color: black;">fromAddress </span><span class="js-operator" style="color: #666666;">+ </span><span class="js-string" style="color: #008800;">" to: " </span><span class="js-operator" style="color: #666666;">+ </span><span class="js-localvariable" style="color: black;">toAddress</span><span class="js-punctuation" style="color: #666666;">,</span><br />
<span class="whitespace" style="color: #666666;"> </span><span class="js-punctuation" style="color: #666666;">{ </span><span class="js-string" style="color: #008800;">"locale"</span><span class="js-punctuation" style="color: #666666;">: </span><span class="js-localvariable" style="color: black;">locale </span><span class="js-punctuation" style="color: #666666;">}</span><span class="js-punctuation" style="color: #666666;">)</span><span class="js-punctuation" style="color: #666666;">;</span><br />
<span class="whitespace" style="color: #666666;"> </span><span class="js-punctuation" style="color: #666666;">}</span><br />
<span class="whitespace" style="color: #666666;"> </span><br />
<span class="Apple-style-span" style="color: #666666;"></span><span class="whitespace" style="color: #666666;"> </span><span class="js-keyword" style="color: #000088;">function </span><span class="js-variable" style="color: black;">onGDirectionsLoad</span><span class="js-punctuation" style="color: #666666;">(</span><span class="js-punctuation" style="color: #666666;">)</span><span class="js-punctuation" style="color: #666666;">{ </span><br />
<span class="whitespace" style="color: #666666;"> </span><span class="js-comment" style="color: #880000;">// Use this function to access information about the latest load()</span><br />
<span class="whitespace" style="color: #666666;"> </span><span class="js-comment" style="color: #880000;">// results.</span><br />
<span class="whitespace" style="color: #666666;"> </span><span class="whitespace" style="color: #666666;"> </span><span class="js-comment" style="color: #880000;">// e.g.</span><br />
<span class="whitespace" style="color: #666666;"> </span><span class="js-variable" style="color: black;">distance </span><span class="js-operator" style="color: #666666;">= </span><span class="js-variable" style="color: black;">gdir</span><span class="js-punctuation" style="color: #666666;">.</span><span class="js-property" style="color: black;">getDistance</span><span class="js-punctuation" style="color: #666666;">(</span><span class="js-punctuation" style="color: #666666;">)</span><span class="js-punctuation" style="color: #666666;">.</span><span class="js-property" style="color: black;">meters</span><span class="js-punctuation" style="color: #666666;">;</span><br />
<span class="whitespace" style="color: #666666;"> </span><br />
<span class="whitespace" style="color: #666666;"> </span><span class="js-variable" style="color: black;">alert</span><span class="js-punctuation" style="color: #666666;">(</span><span class="js-string" style="color: #008800;">"Distance is : " </span><span class="js-operator" style="color: #666666;">+ </span><span class="js-variable" style="color: black;">gdir</span><span class="js-punctuation" style="color: #666666;">.</span><span class="js-property" style="color: black;">getDistance</span><span class="js-punctuation" style="color: #666666;">(</span><span class="js-punctuation" style="color: #666666;">)</span><span class="js-punctuation" style="color: #666666;">.</span><span class="js-property" style="color: black;">meters </span><span class="js-operator" style="color: #666666;">+ </span><span class="js-string" style="color: #008800;">"and Duration Is: " </span><span class="js-operator" style="color: #666666;">+</span></div>
<div style="background-color: white; border-bottom-style: none; border-bottom-width: 0px; border-color: initial; border-color: initial; border-left-style: none; border-left-width: 0px; border-right-style: none; border-right-width: 0px; border-top-style: none; border-top-width: 0px; font-family: monospace; font-size: 10pt; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; white-space: nowrap;">
<span class="js-operator" style="color: #666666;"> </span><span class="js-variable" style="color: black;">gdir</span><span class="js-punctuation" style="color: #666666;">.</span><span class="js-property" style="color: black;">getDuration</span><span class="js-punctuation" style="color: #666666;">(</span><span class="js-punctuation" style="color: #666666;">)</span><span class="js-punctuation" style="color: #666666;">.</span><span class="js-property" style="color: black;">seconds</span><span class="js-operator" style="color: #666666;">/</span><span class="js-atom" style="color: #228811;">60</span><span class="js-punctuation" style="color: #666666;">)</span><span class="js-punctuation" style="color: #666666;">;</span><br />
<span class="whitespace" style="color: #666666;"> </span><span class="whitespace" style="color: #666666;"> </span><br />
<span class="whitespace" style="color: #666666;"> </span><span class="js-variable" style="color: black;">document</span><span class="js-punctuation" style="color: #666666;">.</span><span class="js-property" style="color: black;">getElementById</span><span class="js-punctuation" style="color: #666666;">(</span><span class="js-string" style="color: #008800;">"fdistance"</span><span class="js-punctuation" style="color: #666666;">)</span><span class="js-punctuation" style="color: #666666;">.</span><span class="js-property" style="color: black;">innerHTML </span><span class="js-operator" style="color: #666666;">= </span><span class="js-variable" style="color: black;">gdir</span><span class="js-punctuation" style="color: #666666;">.</span><span class="js-property" style="color: black;">getDistance</span><span class="js-punctuation" style="color: #666666;">(</span><span class="js-punctuation" style="color: #666666;">)</span><span class="js-punctuation" style="color: #666666;">.</span><span class="js-property" style="color: black;">meters</span><span class="js-punctuation" style="color: #666666;">;</span><br />
<span class="whitespace" style="color: #666666;"> </span><span class="js-variable" style="color: black;">document</span><span class="js-punctuation" style="color: #666666;">.</span><span class="js-property" style="color: black;">getElementById</span><span class="js-punctuation" style="color: #666666;">(</span><span class="js-string" style="color: #008800;">"fduration"</span><span class="js-punctuation" style="color: #666666;">)</span><span class="js-punctuation" style="color: #666666;">.</span><span class="js-property" style="color: black;">innerHTML </span><span class="js-operator" style="color: #666666;">= </span><span class="js-punctuation" style="color: #666666;"><span class="Apple-style-span" style="color: black;"><span class="js-variable" style="color: black;">gdir</span><span class="js-punctuation" style="color: #666666;">.</span><span class="js-property" style="color: black;">getDuration</span><span class="js-punctuation" style="color: #666666;">(</span><span class="js-punctuation" style="color: #666666;">)</span><span class="js-punctuation" style="color: #666666;">.</span><span class="js-property" style="color: black;">seconds</span><span class="js-operator" style="color: #666666;">/</span><span class="js-atom" style="color: #228811;">60</span></span>;</span><br />
<span class="whitespace" style="color: #666666;"> </span><br />
<span class="Apple-style-span" style="color: #666666;"></span><span class="whitespace" style="color: #666666;"> </span><span class="js-punctuation" style="color: #666666;">}</span><br />
<span class="whitespace" style="color: #666666;"> </span><span class="xml-punctuation" style="color: #666600;"><span class="xml-tagname" style="color: #000088;">script</span><span class="xml-punctuation" style="color: #666600;">></span><br /><span class="whitespace" style="color: #666666;"> -------------------------------------------------------------------------------</span></span></div>
<div>
<br /></div>
<br />
<div style="float:left; padding-right:5px;">
<script type="text/javascript"><!--
google_ad_client = "ca-pub-9274462217825187";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text";
google_ad_channel ="";
google_color_border = "E8E7D0";
google_color_bg = "dcdcdc";
google_color_link = "B96F17";
google_color_url = "B96F17";
google_color_text = "000000";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
</div>
<br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; font-size: large;"><b>Can we call GDirection without creating GMap ?</b></span><br />
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"> So the answer is yes, one can create GDirection without pasing GMap also.<br />So the output will only contain text format.<br /><i>sample code </i><br /> <span class="Apple-style-span" style="background-color: white; font-family: monospace; font-size: 13px; white-space: nowrap;"><span class="whitespace" style="color: #666666;"> </span><span class="js-variable" style="color: black;">gdir </span><span class="js-operator" style="color: #666666;">= </span><span class="js-keyword" style="color: #000088;">new </span><span class="js-variable" style="color: black;">GDirections</span><span class="js-punctuation" style="color: #666666;">(</span><span class="js-atom" style="color: #228811;">null</span><span class="js-punctuation" style="color: #666666;">, </span><span class="js-variable" style="color: black;">document</span><span class="js-punctuation" style="color: #666666;">.</span><span class="js-property" style="color: black;">getElementById</span><span class="js-punctuation" style="color: #666666;">(</span><span class="js-string" style="color: #008800;">"directions"</span><span class="js-punctuation" style="color: #666666;">)</span><span class="js-punctuation" style="color: #666666;">)</span><span class="js-punctuation" style="color: #666666;">;</span></span><br />so instead of map object <b><i>null </i></b>is passed in above code line, it will <br />display direction information in only text format.<br />One can also use above logic to design their own Google Gadgets too.</span></div>
TShttp://www.blogger.com/profile/02381204600694943595noreply@blogger.com85tag:blogger.com,1999:blog-6005247006949384691.post-16387459805426032552011-09-11T23:33:00.000-07:002015-03-22T20:55:44.055-07:00new vs malloc ?<div dir="ltr" style="text-align: left;" trbidi="on">
<span class="Apple-style-span" style="font-size: large;"><b>C++ </b></span>often confuses beginners with its multiple way to allocate and free memory. Most of them understand them that free must be used with malloc and delete with new. But still they are not clear with the differences. This article will help in understanding the concept behind new and malloc.<br />
<br />
<b>Lets see the broader level differences first :-</b><br />
<br />
<br />
<ul style="text-align: left;">
<li> 'new' helps in constructing an object (calls constructor), malloc does not. One of the most important differences between them.</li>
</ul>
e.g. Consider a<br />
<div>
Class A { </div>
<div>
public : A() { cout <<"In constructor"; }</div>
<div>
}</div>
<div>
</div>
<div>
A* pobjA = new A(); //this will call constructor and displays "In constructor"</div>
<div>
A* pa = (A*) malloc(sizeof(A)); //this will <b>not </b>call constructor</div>
<div style="text-align: left;">
<ul style="text-align: left;">
<li>new requires type of object to be allocated, malloc requires you to specify the total number of bytes to allocate.</li>
</ul>
<ul style="text-align: left;">
<li>operator new is an operator, malloc is a function.</li>
</ul>
<ul style="text-align: left;">
<li>operator new throws an exception if there is not enough memory, malloc returns a NULL. As both function help allocating memory dynamically, there are chances for run-time failure due to non availability of memory. For such cases both shows different behavior and hence need to be handled accordingly.</li>
</ul>
<div style="text-align: left;">
very important pint to be noticed over here is</div>
<div style="text-align: left;">
<blockquote class="">
When new is used to allocate memory for a C++ class object, the object's constructor is called after the memory is allocated.</blockquote>
</div>
<ul style="text-align: left;">
<li>operator new can be overloaded, malloc cannot be overloaded.</li>
</ul>
</div>
<div style="text-align: left;">
<ul style="text-align: left;">
<li>operator new/new[] must be matched with operator delete/delete[] to deallocate memory, malloc() must be matched with free() to deallocate memory.</li>
</ul>
<div>
Another big question is</div>
<div>
<br /></div>
<div>
<b><span class="Apple-style-span" style="font-size: large;">How to choose between malloc and new ?</span></b></div>
<div>
<br /></div>
<div>
While <b>working with C++, its always recommended to use "new"</b>, because it has additive advantage over malloc which are:-</div>
<div>
<ul style="text-align: left;">
<li>Its type safe.</li>
<li>It calls constructor and helps in implementing very important Object Oriented feature Inheritence (constructor chaining). </li>
</ul>
</div>
<div>
One can though use malloc while working with buffer (non class and struct base) , which they want to resize with time with the help of realloc. But still it can be achieved with the combination new/delete too.</div>
<div>
<br /></div>
<div>
<b><span class="Apple-style-span" style="font-size: large;">How much one can allocate ?</span></b></div>
<div>
<b><span class="Apple-style-span" style="font-size: large;"><br /></span></b></div>
<div>
One more query one can have now is, "How much one can allocate"? The largest possible memory block malloc can allocate depends on the host system, particularly the size of physical memory and the operating system implementation. Theoretically, the largest number should be the maximum value that can be held in a size_t type, which is an implementation-dependent unsigned integer representing the size of an area of memory. The maximum value is 2power(CHAR_BIT*sizeof(size_t) − 1), or the constant SIZE_MAX in the C99 standard.</div>
<div>
<br /></div>
<div>
More relevant article:-</div>
<div>
Read more <a href="http://tajendrasengar.blogspot.com/2010/02/how-to-allocate-memory-dynamically-on.html">about dynamically allocating memory on stack here</a></div>
<div>
<br /></div>
<div>
<br /></div>
<br /></div>
</div>
TShttp://www.blogger.com/profile/02381204600694943595noreply@blogger.com77tag:blogger.com,1999:blog-6005247006949384691.post-6692414318894767562011-09-10T21:43:00.000-07:002011-09-19T22:43:42.440-07:00Post a Suggestion/Query<div dir="ltr" style="text-align: left;" trbidi="on">
<b>Open post</b> for adding suggestions/queries to be considered for next posting.<br />
<br />
<table>
<tbody>
<tr>
<td style="height: 402px; width: 3810px;"><a href="http://2.bp.blogspot.com/-1oz1a0FASrk/TeZi_tBo3uI/AAAAAAAAA7Q/VPuWStRw25s/s1600/question-mark.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="320" src="http://2.bp.blogspot.com/-1oz1a0FASrk/TeZi_tBo3uI/AAAAAAAAA7Q/VPuWStRw25s/s320/question-mark.jpg" width="320" /></a></td>
<td style="height: 402px; width: 444px;"><div id="test_canvas" style="height: 450px; width: 850px;">
<br />
<marquee direction="down" style="color: #ffcc00; font-family: Cursive; font-size: 14pt; height: 400; left: 318; position: absolute; top: 8; z-index: 2;">Queries and Suggestions</marquee><marquee direction="down" scrollamount="2" style="color: #ffcc00; font-family: Cursive; font-size: 14pt; height: 258; left: 71; position: absolute; top: 6; z-index: 2;">Queries and Suggestions</marquee><marquee direction="down" scrollamount="3" style="color: #ffcc00; font-family: Cursive; font-size: 14pt; height: 254; left: 48; position: absolute; top: 89; z-index: 2;">Queries and Suggestions</marquee><marquee direction="down" scrollamount="2" style="color: #ffcc00; font-family: Cursive; font-size: 14pt; height: 76; left: 279; position: absolute; top: 81; z-index: 2;">Queries and Suggestions</marquee><marquee direction="down" scrollamount="2" style="color: #ffcc00; font-family: Cursive; font-size: 14pt; height: 135; left: 65; position: absolute; top: 30; z-index: 2;">Queries and Suggestions</marquee><marquee direction="down" scrollamount="1" style="color: #ffcc00; font-family: Cursive; font-size: 14pt; height: 196; left: 173; position: absolute; top: 98; z-index: 2;">Queries and Suggestions</marquee><marquee direction="down" scrollamount="7" style="color: #ffcc00; font-family: Cursive; font-size: 14pt; height: 28; left: 112; position: absolute; top: 24; z-index: 2;">Queries and Suggestions</marquee><marquee direction="down" scrollamount="4" style="color: #ffcc00; font-family: Cursive; font-size: 14pt; height: 152; left: 232; position: absolute; top: 46; z-index: 2;">Queries and Suggestions</marquee><marquee direction="down" scrollamount="4" style="color: #ffcc00; font-family: Cursive; font-size: 14pt; height: 114; left: 196; position: absolute; top: 99; z-index: 2;">Queries and Suggestions</marquee><marquee direction="down" scrollamount="5" style="color: #ffcc00; font-family: Cursive; font-size: 14pt; height: 19; left: 66; position: absolute; top: 35; z-index: 2;">Queries and Suggestions</marquee><marquee direction="down" scrollamount="5" style="color: #ffcc00; font-family: Cursive; font-size: 14pt; height: 409; left: 307; position: absolute; top: 18; z-index: 2;">Queries and Suggestions</marquee><marquee direction="down" scrollamount="3" style="color: #ffcc00; font-family: Cursive; font-size: 14pt; height: 76; left: 172; position: absolute; top: 107; z-index: 2;">Queries and Suggestions</marquee><marquee direction="down" style="color: #ffcc00; font-family: Cursive; font-size: 14pt; height: 430; left: 10; position: absolute; top: 119; z-index: 2;">Queries and Suggestions</marquee><marquee direction="down" scrollamount="1" style="color: #ffcc00; font-family: Cursive; font-size: 14pt; height: 48; left: 309; position: absolute; top: 68; z-index: 2;">Queries and Suggestions</marquee><marquee direction="down" scrollamount="6" style="color: #ffcc00; font-family: Cursive; font-size: 14pt; height: 470; left: 175; position: absolute; top: 105; z-index: 2;">Queries and Suggestions</marquee><marquee direction="down" scrollamount="3" style="color: #ffcc00; font-family: Cursive; font-size: 14pt; height: 87; left: 122; position: absolute; top: 4; z-index: 2;">Queries and Suggestions</marquee><marquee direction="down" scrollamount="5" style="color: #ffcc00; font-family: Cursive; font-size: 14pt; height: 40; left: 182; position: absolute; top: 74; z-index: 2;">Queries and Suggestions</marquee><marquee direction="down" scrollamount="3" style="color: #ffcc00; font-family: Cursive; font-size: 14pt; height: 27; left: 226; position: absolute; top: 32; z-index: 2;">Queries and Suggestions</marquee><marquee direction="down" scrollamount="2" style="color: #ffcc00; font-family: Cursive; font-size: 14pt; height: 21; left: 289; position: absolute; top: 12; z-index: 2;">Queries and Suggestions</marquee><marquee direction="down" scrollamount="5" style="color: #ffcc00; font-family: Cursive; font-size: 14pt; height: 494; left: 145; position: absolute; top: 96; z-index: 2;">Queries and Suggestions</marquee><marquee direction="down" scrollamount="2" style="color: #ffcc00; font-family: Cursive; font-size: 14pt; height: 440; left: 0px; position: absolute; top: 0px; z-index: 2;">Queries and Suggestions</marquee><span style="position: absolute; top: 400px;"></span>
</div>
</td>
</tr>
</tbody></table>
<br />
<div style="float:left; padding-right:5px;">
<script type="text/javascript"><!--
google_ad_client = "ca-pub-9274462217825187";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text";
google_ad_channel ="";
google_color_border = "E8E7D0";
google_color_bg = "dcdcdc";
google_color_link = "B96F17";
google_color_url = "B96F17";
google_color_text = "000000";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
</div>
<br />
</div>
TShttp://www.blogger.com/profile/02381204600694943595noreply@blogger.com96tag:blogger.com,1999:blog-6005247006949384691.post-28928161386836436262011-09-10T11:21:00.000-07:002011-09-15T11:48:41.884-07:00What is Hashing , HashTable, Hash Function and its collision resolution strategies<div dir="ltr" style="text-align: left;" trbidi="on">
<b><span class="Apple-style-span" style="font-size: large;">Hashing </span></b>is the technique used for performing almost constant time search in case of insertion, deletion and find operation. Taking a very simple example of it, an array with its index as key is the example of hash table.<br />
So each index (key) can be used for accessing the value in a constant search time. This mapping key must be simple to compute and must helping in identifying the associated value. Function which helps us in generating such kind of key-value mapping is known as <b>Hash Function.</b> <br />
<br />
<b>Hash Table a.k.a Hash Map </b>is a data structure which uses hash function to generate key corresponding to the associated value.<br />
<br />
lets look at some sample hash function for strings<br />
<br />
<b>Folding Method:-</b><br />
int h(String x, int D)<br />
{<br />
int i, sum;<br />
for (sum=0, i=0; i<x.length(); i++)<br />
sum+= (int)x.charAt(i);<br />
return (sum%D);<br />
}<br />
<br />
<b>Cyclic Shift :-</b><br />
static long hashCode(String key, int D)<br />
{<br />
int h=0;<br />
for (int i=0, i<key.length(); i++)<br />
{<br />
h = (h << 4) | ( h >> 27);<br />
h += (int) key.charAt(i);<br />
}<br />
return h%D;<br />
}<br />
<br />
<br />
<br />
good link for hash function on string : <a href="http://research.cs.vt.edu/AVresearch/hashing/strings.php">click here</a><br />
<div>
<div>
<br /></div>
<div>
Coming to very important part of hashing , which is <b><span class="Apple-style-span" style="font-size: large;">collision resolution</span></b>. Since its always not possible to design perfect hash function with minimal overhead which would generate unique key. To address this problem following are the two main collision resolving techniques :-</div>
<div>
1) Open Hashing also known as separate chaining </div>
<div>
2) Closed Hashing also known as open addressing</div>
<div>
<br /></div>
<div>
Lets understand the difference between them</div>
<div>
<b>1) Open Hashing</b> :- In this strategy collision is resolved by keeping the conflicting element in a list. That is to keep all element in a list which generate same hash.</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-tuiWS8ztcWw/TmufNxuQT4I/AAAAAAAAAdA/QRixOa4ALnU/s1600/Open+Hashing+.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="171" src="http://1.bp.blogspot.com/-tuiWS8ztcWw/TmufNxuQT4I/AAAAAAAAAdA/QRixOa4ALnU/s320/Open+Hashing+.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Open Hashing</td></tr>
</tbody></table>
<div>
<br /></div>
<div>
From above figure its clear that how collision get resolved by keeping a linked list.</div>
<div>
<br /></div>
<div>
<b>2) Closed Hashing</b> :- In this strategy collision is resolved by placing the conflicting element near to the slot generated by the hash function. Associated with closed hashing is a rehash strategy:</div>
<div>
“If we try to place x in bucket h(x) and find it occupied, find alternative location h1(x), h2(x), etc. Try each in order, if none empty table is full,”</div>
<div>
Lets take an example to understand it</div>
<div>
<br /></div>
<div>
HASH_TABLE_SIZE = 8</div>
<div>
Input data :- a,b,c,d Hash for them H(a) = 0, H(b) = 3, H(c) = 7 and H(d) = 3</div>
<div>
<br /></div>
<div>
Now as 'c' and 'd' has same hash, where to insert 'd' then ?</div>
<div>
Finding position using linear hashing :</div>
<div>
h1(d) = (h(d)+1)%8 = 4%8 = 4</div>
<div>
<br /></div>
<div>
Adding 1 to hash function of h(d) we get new position 4, and slot 4 is currently non occupied. So entering d at position 4. In this way Closed hashing works.</div>
<div>
<br /></div>
<div>
<i>Disadvantage </i>of closed hashing is that it consumes more space as compared to open hashing </div>
<div>
also it has less flexibility in accommodating for duplicate hash element.</div>
<div>
Major <i>advantage </i>of closed hashing is that it reduces the overhead of introducing new data structure and reduces cost of new memory allocation per new element insertion.</div>
<div>
<br /></div>
</div>
</div>
TShttp://www.blogger.com/profile/02381204600694943595noreply@blogger.com103tag:blogger.com,1999:blog-6005247006949384691.post-35039616666529583992011-09-09T00:04:00.000-07:002011-09-09T00:13:04.356-07:00Iterator in C++<div dir="ltr" style="text-align: left;" trbidi="on"><b><span class="Apple-style-span" style="font-size: large;">Iterator </span></b>an object which help in traversing a container. Its like a navigator.<br />
For beginners its very difficult to digest/learn Iterator after Array. Since access to array is very easy just pass an index and get the value.<br />
So this post will help beginners to build understanding about Iterator.<br />
<br />
To start with lets look out for simple array traversal.<br />
<br />
<span class="Apple-style-span" style="background-color: #eeeeee;"> const int nLength = 10;<br />
int account[nLength] = {0};<br />
//to traverse the array one can simply provide for loop upto length and access it by index<br />
for(int i = 0; i< nLength; i++)<br />
{<br />
cout<<account[i];<br />
}</span><div><br />
Now lets solve the above problem if its a list container.<br />
<br />
<span class="Apple-style-span" style="background-color: #eeeeee;"> std::list lstAccount; //list container for account</span><br />
<span class="Apple-style-span" style="background-color: #eeeeee;"> stAccount.push_back(1);</span><br />
<span class="Apple-style-span" style="background-color: #eeeeee;"> lstAccount.push_back(2);</span><br />
<span class="Apple-style-span" style="background-color: #eeeeee;"> lstAccount.push_back(3);</span><br />
<span class="Apple-style-span" style="background-color: #eeeeee;"> lstAccount.push_back(4);</span><br />
<span class="Apple-style-span" style="background-color: #eeeeee;"> std::list::iterator lstAccountIterator;//iterator for traversing list</span><br />
<span class="Apple-style-span" style="background-color: #eeeeee;"> for(lstAccountIterator = lstAccount.begin(); //initialize iterator with begining</span><br />
<span class="Apple-style-span" style="background-color: #eeeeee;"> lstAccountIterator != lstAccount.end(); // traverse until iterator rach end</span><br />
<span class="Apple-style-span" style="background-color: #eeeeee;"> lstAccountIterator++) //move itertor to next element.</span><br />
<span class="Apple-style-span" style="background-color: #eeeeee;"> {</span><br />
<span class="Apple-style-span" style="background-color: #eeeeee;"> cout<<*lstAccountIterator; //print value at itertor<br />
}</span><br />
So above code will help in traversing a list container.<br />
Some good article on Iterator can be found at following links<br />
<a href="http://www.cplusplus.com/reference/std/iterator/">http://www.cplusplus.com/reference/std/iterator/</a><br />
<a href="http://www.cprogramming.com/tutorial/stl/iterators.html">http://www.cprogramming.com/tutorial/stl/iterators.html</a><br />
<a href="http://en.wikipedia.org/wiki/Iterator">http://en.wikipedia.org/wiki/Iterator</a><br />
<br />
Now moving to next level, lets understand the <b><span class="Apple-style-span" style="font-size: large;">iterator design pattern</span></b>.<br />
<br />
<b>Purpose:</b><br />
To provide a way for accessing and traversing the collection of elements, without actually exposing the internal structure/representation of the collection organisation.<br />
<br />
<br />
<b>Benefits:</b><br />
An abstraction which helps in simplifying the traversal mechanism.<br />
<br />
<b>Design Layout:</b><br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://3.bp.blogspot.com/-sa7NalKaLS0/Tmm4rHPi8nI/AAAAAAAAAc8/BmEz5o02tyo/s1600/iterator_Pattern.gif" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="196" src="http://3.bp.blogspot.com/-sa7NalKaLS0/Tmm4rHPi8nI/AAAAAAAAAc8/BmEz5o02tyo/s400/iterator_Pattern.gif" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fig. Iterator Design Pattern</td></tr>
</tbody></table><b> </b><br />
<br />
<br />
<br />
</div></div>TShttp://www.blogger.com/profile/02381204600694943595noreply@blogger.com74tag:blogger.com,1999:blog-6005247006949384691.post-53004122425113232012011-09-06T06:06:00.000-07:002011-09-06T06:16:47.818-07:00Some good SEO resources , links<div dir="ltr" style="text-align: left;" trbidi="on">Here are list of some good <b><span class="Apple-style-span" style="font-size: large;">SEO </span></b>resources :-<br />
<br />
One of the best description about SEO :-<br />
<a href="http://searchengineland.com/guide/what-is-seo">http://searchengineland.com/guide/what-is-seo</a><br />
<br />
This page contain many relevant pointers -<br />
<a href="http://www.pronetadvertising.com/articles/top-50-seo-resources.html">http://www.pronetadvertising.com/articles/top-50-seo-resources.html</a><br />
<br />
Good resource :-<br />
<a href="http://www.seoconsultants.com/seo-resources/">http://www.seoconsultants.com/seo-resources/</a><br />
<br />
It takes time to be consumed by crawlers, if we talk about google search engine. And it depends on many factors but focusing on the below key points are good enough for a new blogger.<br />
Some key facts about SEO:-<br />
1) Choose keywords (label) very effectively.<br />
2) Do not create complex titles.<br />
3) Leave back-links with relevant context.<br />
4) Be consistent with post, it will help in keeping readers interested in the blog.<br />
<br />
<br />
Keep Blogging<br />
-Tajendra<br />
<br />
</div>TShttp://www.blogger.com/profile/02381204600694943595noreply@blogger.com83tag:blogger.com,1999:blog-6005247006949384691.post-54545849026418019282011-09-06T04:35:00.000-07:002011-09-06T05:10:12.024-07:00sizeof operator , learning with experiments<div dir="ltr" style="text-align: left;" trbidi="on"><b><span class="Apple-style-span" style="color: #351c75; font-size: large;">sizeof</span> </b>a very interesting operator, lets do some experiments with it to gain more understanding about it.<br />
<br />
Lets look at the msdn definition of it first :-<br />
<blockquote>Yields the size of its operand with respect to the size of type char [definition from msdn].</blockquote><br />
<u><i>Now lets start experimenting with it :-</i></u><br />
<br />
what will following statement yields <br />
<br />
a) sizeof function ?<br />
sizeof(&main);<br />
sizeof(&printf);<br />
<br />
b) sizeof an empty class ? <br />
class A {};<br />
sizeof(A)<br />
<br />
c) Can sizeof return 0 ?<br />
<br />
d) What will be the output of following program ?<br />
int i = 1;<br />
sizeof(i++);<br />
cout<<"i="<<i;<br />
<br />
e) sizeof following class ? <br />
class A { char c; int i; };<br />
sizeof(A)<br />
<br />
<u><b><span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"><i>Now lets look at them one by one </i></span></b></u><br />
<br />
a) sizeof function ?<br />
sizeof(&main);<br />
sizeof(&printf);<br />
<br />
<b>Answer </b>: sizeof(&main) will return 4 on 32 bit OS.<br />
same hold true for sizeof(&printf). And the reason is very straight forward. As its returning size of function pointer.<br />
<br />
<br />
b) sizeof an empty class ? <br />
class A {};<br />
sizeof(A);<br />
<b>Answer </b>: Its a very interesting question which have very straight forward answer. It directly depends on sizeof operator implementation, if one looks at msdn documentation it says sizeof operator never returns zero. Considering this fact it returns 1. <br />
For more details one can go through link (stroustrup's FAQs):-<br />
<a href="http://www2.research.att.com/~bs/bs_faq2.html#sizeof-empty">http://www2.research.att.com/~bs/bs_faq2.html#sizeof-empty</a><br />
<br />
c) Can sizeof return 0 ?<br />
<b>Answer </b>: NO, sizeof operator never returns 0.<br />
<br />
<br />
d) What will be the output of following program ?<br />
int i = 1;<br />
sizeof(i++);<br />
cout<<"i="<<i;<br />
<b>Answer </b>: output would be 1, sizeof operator gets resolved at compile time only, no run-time execution will be entertained for sizeof operator. So the output would be 1.<br />
<br />
<br />
e) sizeof following class ? <br />
class A { char c; int i; };<br />
sizeof(A);<br />
<b>Answer </b>: Don't hurry up to reply with 5 byte, because it depends on the byte alignment of class.<br />
If it is 1 byte aligned, output would be 5;<br />
And for 4 byte aligned, output would be 8;<br />
<br />
<br />
</div>TShttp://www.blogger.com/profile/02381204600694943595noreply@blogger.com73tag:blogger.com,1999:blog-6005247006949384691.post-89420602473755019152011-09-01T07:14:00.000-07:002011-10-13T07:17:51.164-07:00Online Regular Expression / Regex Tools and Editor<div dir="ltr" style="text-align: left;" trbidi="on">
Some useful compiled link about online regex tester :-<br />
<ul style="text-align: left;">
<li>Regex tester from Regular Expression Info.com</li>
</ul>
<br />
<a href="http://www.regular-expressions.info/javascriptexample.html">http://www.regular-expressions.info/javascriptexample.html</a><br />
<br />
<br />
<table class="topad" style="background-color: #fff4e8; border-bottom-color: rgb(128, 51, 0); border-bottom-style: solid; border-bottom-width: 2px; border-left-color: rgb(128, 51, 0); border-left-style: solid; border-left-width: 2px; border-right-color: rgb(128, 51, 0); border-right-style: solid; border-right-width: 2px; border-top-color: rgb(128, 51, 0); border-top-style: solid; border-top-width: 2px; margin-bottom: 20px; margin-left: 10px; margin-right: 10px; margin-top: 20px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px;"><tbody>
<tr><td style="font-family: Arial, helvetica, sans-serif; font-size: 14px; line-height: 20px;" valign="top"><a href="http://www.regexbuddy.com/test.html" style="background-color: white; text-decoration: underline;" target="_top"><span class="Apple-style-span" style="color: black;"><img alt="RegexBuddy" border="0" height="145" src="http://www.regular-expressions.info/img/regexbuddyad.png" width="203" /></span></a></td><td class="topad" style="font-family: Arial, helvetica, sans-serif; font-size: 14px; line-height: 20px; padding-left: 10px; padding-right: 10px; text-align: justify;"><span class="Apple-style-span" style="background-color: white;"><b><a href="http://www.regexbuddy.com/test.html" style="text-decoration: underline;" target="_top">Interactively create and test regular expressions with RegexBuddy</a>.</b><br /><b>Create</b> and analyze regex patterns with RegexBuddy's intuitive regex building blocks. Quickly <b>test</b> regular expressions on sample data and files in a safe sandbox. <b>Debug</b> regexes easily with real-time highlighting and informative regex match details. <a href="http://www.regexbuddy.com/" style="text-decoration: underline;">Get your own copy of RegexBuddy now</a>.</span></td></tr>
</tbody></table>
<br />
<br />
<br />
<div style="float: left; padding-right: 5px;">
<script type="text/javascript">
<!--
google_ad_client = "ca-pub-9274462217825187";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text";
google_ad_channel ="";
google_color_text = "000000";
google_color_link = "B96F17";
google_color_url = "B96F17";
//-->
</script>
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script>
</div>
<br />
<br />
<br />
<br />
<br />
<br />
<ul style="text-align: left;">
<li>Online regular Expression tester from PageColumn.</li>
</ul>
<a href="http://www.pagecolumn.com/tool/regtest.htm">http://www.pagecolumn.com/tool/regtest.htm</a><div>
A very fast and effective regex tester.<br /><ul style="text-align: left;">
<li>FileFormat.Info</li>
</ul>
<a href="http://www.fileformat.info/tool/regex.htm">http://www.fileformat.info/tool/regex.htm</a></div>
<div>
<a href="http://www.fileformat.info/tool/regex.htm"><br /></a><b>Table For regular expression syntax:-</b><br /><span class="Apple-style-span" style="color: #3f529c; font-family: 'Segoe UI', Verdana, Arial; font-weight: bold;"> Regular Expression Syntax :- </span><a href="http://msdn.microsoft.com/en-us/library/1400241x(v=vs.85).aspx">http://msdn.microsoft.com/en-us/library/1400241x(v=vs.85).aspx</a></div>
</div>TShttp://www.blogger.com/profile/02381204600694943595noreply@blogger.com87