Discover the power of algorithms

Complexities of algorithm, thier applicability. Optimization techniques associated with diffrent algos.

Discover Power of Blogging

What is Blogging , is it a Dream or Passion or Award or Making Money ?

Think Diffrent, be creative

Let's see how much conclusion one can draw from it. This will help testing your creativity.

Discover the power of technology

Technolgy, Programming, Optimization , Gadgets and more...

Discover the power of Blogging

Google widgets and gadgets.

Showing posts with label Misc. Show all posts
Showing posts with label Misc. Show all posts

Mar 11, 2016

Xiaomi redmi note 3 wifi connectivity issue

Issue observed:-

Faced Xiaomi redmi note 3 wifi connectivity issue.

It properly connect to wifi hotspot but fails to connect home wifi device.
Enabling/Disabling the router and mobile wifi does not helped much.

What worked for me is the MIUI version upgrade.
Upgraded it to MIUI Global 7.1 (7.1.7.0).
After upgrade, it properly detects and connects to home wifi.

Hope this will help.







Oct 1, 2013

Running bat file from the C++ source code

What to do when one has to execute batch script from the c++ source code ?

System command can solve the purpose in this context.
Here is the syntax details :-

int system(  const char *command );
int _wsystem(   const wchar_t *command );


Example :-
  Suppose if some one want to restart a service named "TestService" form the batch file.
Then c:\\sample.bat file would look like as:-

net stop TestService
net start TestService

calling it from source code:-
    system ("c:\\sample.bat");



For API refrenece
http://msdn.microsoft.com/en-us/library/277bwbdz(v=vs.90).aspx




Dec 13, 2011

How to increase service start/stop timeout ?


Windows provide SetServiceStatus function by which one can manage service time out period. It’s a very straight forward API here are its details:-
         BOOL WINAPI SetServiceStatus(
                            __in  SERVICE_STATUS_HANDLE hServiceStatus,
                            __in  LPSERVICE_STATUS lpServiceStatus
                          );

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.
A common bug is for the service to have the main thread perform the initialization while a separate thread continues to call SetServiceStatus 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.

Here are the details of structure

typedef struct _SERVICE_STATUS {
  DWORD dwServiceType;
  DWORD dwCurrentState;
  DWORD dwControlsAccepted;
  DWORD dwWin32ExitCode;
  DWORD dwServiceSpecificExitCode;
  DWORD dwCheckPoint;
  DWORD dwWaitHint;
} SERVICE_STAT

And following are the main parameters to be used while managing service time out duration in the structure

dwCheckPoint
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.

dwWaitHint
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 SetServiceStatus function with either an incremented dwCheckPoint value or a change in dwCurrentState. If the amount of time specified by dwWaitHint passes, and dwCheckPoint has not been incremented ordwCurrentState 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.

A sample code showing the use of above discussed variable :-

//
// Purpose: 
//   It will set the current service status and reports it to the SCM.
//
// Parameters:
//   dwCurrentState - The current state (see SERVICE_STATUS)
//   dwWin32ExitCode - The system error code
//   dwWaitHint - Estimated time for pending operation, 
//     in milliseconds
// 
VOID ReportServiceStatus( DWORD dwCurrentState,
                      DWORD dwWin32ExitCode,
                      DWORD dwWaitHint)
{
    static DWORD dwCheckPoint = 1;
 
    // Fill in the SERVICE_STATUS structure.
 
    gSvcStatus.dwCurrentState = dwCurrentState;
    gSvcStatus.dwWin32ExitCode = dwWin32ExitCode;
    gSvcStatus.dwWaitHint = dwWaitHint;
 
    if (dwCurrentState == SERVICE_START_PENDING)
        gSvcStatus.dwControlsAccepted = 0;
    else gSvcStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP;
 
    if ( (dwCurrentState == SERVICE_RUNNING) ||
           (dwCurrentState == SERVICE_STOPPED) )
        gSvcStatus.dwCheckPoint = 0;
    else gSvcStatus.dwCheckPoint = dwCheckPoint++;
 
    // Report the status of the service to the SCM.
    SetServiceStatus( gSvcStatusHandle, &gSvcStatus );
}


One more important thing to remember :

Ø   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.  
          Example:- 
 
        dwWaitTime = ssStatus.dwWaitHint / 10;
 
        if( dwWaitTime < 1000 )
            dwWaitTime = 1000;
        else if ( dwWaitTime > 10000 )
            dwWaitTime = 10000;



The following are some of the best practices when calling SetServiceStatus function:
  • Initialize all fields in the SERVICE_STATUS structure, ensuring that there are valid check-point and wait hint values for pending states. Use reasonable wait hints.
  • Do not register to accept controls while the status is SERVICE_START_PENDING or the service can crash. After initialization is completed, accept the SERVICE_CONTROL_STOP code.
  • 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.
  • Enter the stopped state with an appropriate exit code if ServiceMain fails.
  • If the status is SERVICE_STOPPED, perform all necessary cleanup and call SetServiceStatus one time only. This function makes an LRPC call to the SCM. The first call to the function in the SERVICE_STOPPED state closes the RPC context handle and any subsequent calls can cause the process to crash.
  • Do not attempt to perform any additional work after calling SetServiceStatus with SERVICE_STOPPED, because the service process can be terminated at any time.



Nov 22, 2011

How to start , stop perfmon from the command line in Windows ?

Logman command is the solution for it.
let's have a look at the command syntax

Syntax Verbs
Logman [create {counter | tracecollection_name ] [start collection_name] [stop collection_name] [delete collection_name] [query {collection_name|providers}] [update collection_name]

Parameter details:-

create {counter | tracecollection_name Creates collection queries for either counter or trace collections. You can use command line options to specify settings.
start collection_name Starts the data collection query collection_name. Use this option to change from scheduled collections to manual ones. Use the update parameter in the command line with begin-time (-b), end-time (-e), or repeat-time (-rt) to reschedule collections.
stop collection_name Stops the data collection query collection_name. Use this option to change from scheduled collections to manual ones. Use the update parameter in the command line with begin-time (-b), end-time (-e), or repeat-time (-rt) to reschedule collections.
delete collection_name Deletes the data collection query collection_name. If the collection_name does not exist, you will receive an error.
query {collection_name|providersIf no collection_name or providers are given, the status of all existing collection queries are displayed. Use collection_name to display the properties of a specific collection. To display the properties on remote computers, use the -s remote computer option in the command line. Use providers as your keyword in place of collection_name to display the registered providers installed on your local system. To list registered providers installed on the remote system, use the -soption in the command line.
update collection_name 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: -p provider [(flags[,flags ...])Level- max n- o PathName-ft mm:ss, or -fd.


This command is very helpful in performance automation scenario.
If performance monitoring counter name is test_perf_log
then start command will go as :-
    logman start test_perf_log
on similar line stop command will go as:-
    logman stop test_perf_log


For more detail jump to page :- http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/nt_command_typeperf.mspx?mfr=true



Oct 14, 2011

Google's new web programming language, Dart

Google recently came up with new programming language for web application named as Dart.
Let's look at its technical specification :-

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.

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.









Some Key feature mentioned by google about Dart.


Key features of the Dart language include:

Classes
Classes and interfaces provide a well understood mechanism for efficiently defining APIs. These constructs enable encapsulation and reuse of methods and data.
Optional types
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.
Libraries
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.
Tooling
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.

More information about Dart can be found at :- http://www.dartlang.org/

Sample "Hello World" program :-
  main() {
  var name = 'World';
  print('Hello, ${name}!');
}
Tutorial for Dart language :- http://www.dartlang.org/docs/getting-started/

How to use Dart with HTML ?
Like JavaScript, Dart programs can be directly embedded on HTML pages served to the browser.
Here is the example for it :-


simple Hello World in HTML using Dart. The main() method is the entry point.

<html>
  <body>
    <script type='application/dart'>
      void main() {
        HTMLElement element = document.getElementById('message');
        element.innerHTML = 'Hello from Dart';
      }
    </script>
    <div id='message'></div>
  </body>
</html>

The div element above is guaranteed to exist by the time the Dart code starts running.


Let's see now whether in future DART will hit its target or not.



Sep 1, 2011

Online Regular Expression / Regex Tools and Editor

Some useful compiled link about online regex tester :-
  • Regex tester from Regular Expression Info.com

             http://www.regular-expressions.info/javascriptexample.html


RegexBuddyInteractively create and test regular expressions with RegexBuddy.
Create and analyze regex patterns with RegexBuddy's intuitive regex building blocks. Quickly test regular expressions on sample data and files in a safe sandbox. Debug regexes easily with real-time highlighting and informative regex match details. Get your own copy of RegexBuddy now.









  • Online regular Expression tester from PageColumn.
           http://www.pagecolumn.com/tool/regtest.htm
          A very fast and effective regex tester.
  • FileFormat.Info
            http://www.fileformat.info/tool/regex.htm

Table For regular expression syntax:-
            Regular Expression Syntax :- http://msdn.microsoft.com/en-us/library/1400241x(v=vs.85).aspx



Feb 24, 2010

Sachin's record 200* In ODI vs South Africa, memorable milestone in cricketing world


I can’t stop myself writing on Sachin's 200, it’s a mmmmm what can I say just got spellbound from his performance.Its a magical mesmerizing memorable milestone performance from maestro the “Sachin Ramesh Tendulkar”.

Sachin slammed 200 not out today against one of the strongest ODI team South Africa at Captain Roop Singh Stadium Gwalior.




It’s a working day in our company and all are just busy with their scheduled work. And suddenly one guy screamed from his cube that “Sachin made 185 not out” this news just spreads like wildfire (technically like viruses on network). It infected almost every guy and all moved to our chill out zone which have television set. Quickly whole room got filled, each and every corner of room got occupied. All intellectuals who fights like anything in meeting rooms with their logical reasons were in total sync with each other and why not as all were  talking about the “Sachin Tendulkar”. All guys present in room had several positive comments on Sachin,
all were busy in proving that "They are the biggest fan of Sachin" and everyone in thier heart wanted Sachin to cmake first ever double century in ODI. 
Sachin crossed the magic number of 194 runs in 46th over and all went up clapping with a big smile on everyone's face.With this Sachin created a record of making a highest score in an ODI by breaking Saeed Anwar's record of 194 runs. But everyone was still holding breath eying for much bigger celebration.
Its now 47th over, Sachin reached 199 mark still requiring one golden run.We all were waiting for it and in next over we were hoping to see Sachin on strike but Dhoni faced all the 6 balls brilliantly and Sachin still on 199 mark :(. Despite Dhoni doing his job well, he was not getting any attention as everyone wanted to see Sachin on strike. And finally Sachin got strike in last over, Langeveldt the bowler, bowling 3rd ball of the last over, all stage set for Sachin to reach the milestone of double century. There was a complete silence in the room for a while, all praying for Sachin's 200. All were tensed but Sachin looking very confident and finally Langeveldt delivered the ball and Sachin guided ball for single run. All went up on their feet and this time celebration was much bigger and louder. Everyone were so happy and were feeling very proud. This moment will remain for a long time in memory of all the cricket lovers. 

This event was so big that when i entered "Sachin's 200" search string on google search, it fetched almost 2400 pages within minutes of his double century.
Sachin got more then 70 records under his name, for detail check this link :- 

Sachin is a living legend of cricketing world and adding to his greatness he dedicated this marvelous innings to Indian people.Sachin tussi great ho, jahanpanah tofah kabul karo :)