Saturday, February 02, 2013

Ad-Hoc WiFi in Windows 7

The behavior of Ad-Hoc WiFi in Windows 7:

In order to be able to share your internet connection via WiFi you must create the Ad-Hoc connection from a User account with administrator privileges. Only then you get the "Turn On Internet Connection Sharing" Option towards the end.

In order to be able to share files - you must use a secure WiFi connection and not 'No Authentication' i.e. Open with WEP. Only then will you be able to change the Network to a Private/Home network from Public Network.

Friday, February 01, 2013

Solving: "The certificate's CN name does not match the passed value"

In mail clients like Windows Mail - if you get the error: "The certificate's CN name does not match the passed value", it is because you are connecting to a mail server whose SSL Certificate does not match its exact fully qualified domain name (FQDN).

This could be because of the following:

  1. The server address may be missing a single character.
    e.g. mail.example.com. against mail.example.com [ notice the trailing period]

    Solution: add the missing period '.'
  2. Perhaps your mail server is simply redirected to the actual mail server via a CName DNS Record.
    e.g. mail.example.com ==> server1.mailbox_example.com

    To check this, you can examine the DNS details for interconnecting server (here mail.example.com) using a lookup service like MXToolBox CName lookup.

    You may also check the server certificate to find out the server to which the certificate has been issued to.
    You may use OpenSSL Client also with the following syntax:
    OpenSSL s_client -connect <RemoteHost>:<RemotePort>
    -showcerts


    Solution: Connect directly to the final server and not the redirected CName address.

Tuesday, January 08, 2013

Load LinkedIn API asynchronously


  1. Use the async version of the API
    http://platform.linkedin.com/in.js?async=true
  2. Load the library asynchronously
    <script type="text/javascript">
    (function()
    {
    var e = document.createElement('script');
    e.type = 'text/javascript';
    e.async = false;
    e.src = 'http://platform.linkedin.com/in.js?async=true';
    e.onload = function(){IN.init() };
    var s = document.getElementsByTagName('script')[0];
      s.parentNode.insertBefore(e, s);
    })();
    </script>
You may provide additional parameters like  "onLoad" -callback function & APIKey
in the call to IN.init({Param1:Value1, Param2:Value2})

Friday, January 04, 2013

"ReadKey Exception" trying to pause PowerShell Script

If you use $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") to pause in a PowerShell script, you get the following error message:
Exception calling "ReadKey" with "1" argument(s): "The method or operation is not implemented."

Reason: You are probably running the PowerShell script in the PowerShell ISE thus the related IO sub-system is unavailable.

Solution: Run the script directly and not from the PowerShell - ISE, it will work as expected.

Thursday, September 20, 2012

Resource file does not support multiplication and division operators

Microsoft Visual Studio 2008 - Resource Scripts support only addition '+' and subtraction '-' operators for the Numerical fields. Multiplication '*' and Division '\' operators and Parentheses '( )' are not supported.

e.g. 
Main.rc

# define WINDOW_X 0
# define WINDOW_Y 0
# define WINDOW_WIDTH 300
# define WINDOW_HEIGHT 120

# define BORDER_SIZE 2

IDD_MAINDIALOG  DIALOG  WINDOW_X, WINDOW_Y, WINDOW_WIDTH-2*BORDER_SIZE, WINDOW_HEIGHT

// Here WINDOW_WIDTH-2*BORDER_SIZE will evaluate to only: WINDOW_WIDTH

// Thus instead use:

WINDOW_WIDTH-BORDER_SIZE-BORDER_SIZE

Friday, September 07, 2012

Multiple Partitions or One?

I recommend that you have only a single drive instead of dividing your disk into multiple partitions.

It is a general belief that multiple partitions help you organize your data and protects your data - in-case you happen to have to format your disk.

Well both of these reasons are wrong.
  1. Folders themselves are the best way to separate and organize your files.
    Having to go all the way upto the list of drives then navigating to your file is very inconvenient - as it likely that you will have to do that many times in a day.

    More over you will have to remember more - first: which drive is it in.
  2. There is no reason to format only one drive - it is not required when you upgrade or re-install your operating system. Also only formatting one drive and leaving the rest offers you no advantage in eradicating a virus infection.
Dividing your drive into multiple partitions is like dividing your hall into small 'rooms' with card-board. This only constricts the available space and regularly gives you the headache of low disk space - when in-fact you are likely to have that space.

I would even recommend that if you have existing additional partitions on the same disk - you should merge it into one single drive.

Only exception that comes to my mind is when you have to have multiple operating systems. But again in many, if not most, cases you would be better off with Virtual machines and virtual hard-disks that are dynamically sized, for secondary operating systems.

Also usually laptops come with recovery partitions - If you are pro user I think its best to have that recovery transferred to an another media like a DVD and to reclaim that precious non used disk space.

Wednesday, September 05, 2012

Get Clipboard Size : Windows

The windows clipboard has a group of parallel versions of the same data.

To get clipboard data you use the function GetClipboardData with the format-ID parameter.
This gives you the handle to the Global Memory block that contains this particular version of the clipboard data.
In-order to get the size of this block in bytes use: GlobalSize on the handle got by GetClipboardData.

HGLOBAL hMem;
hMem = GetClipboardData(uformat_id);
cbSize = GlobalSize(hMem); // got the size in cbSize
pData = GlobalLock(hMem);

Sunday, August 26, 2012

WiX ICE69: Mismatched component reference Warning

When using WiX you receive the following warning:
LGHT1076:  Mismatched component reference *** however Components are in the same feature.
The important thing to understand here: is that its only a "Warning". WiX is only trying to be sure it does not let you bite your own tongue. You may or may-not be doing anything wrong here.

If you have a <condition> in one of your component which is being referenced by another component. e.g. A shortcut referring to an Executable. Then this warning is valid.

So if you are not doing any thing wrong - simply [ignore] this warning.

You may want to use the -sice:ICE69 command-line parameter to suppress this warning.
In Visual Studio you can go to the WiX Project's Property page:
> Tool Settings > ICE validation : Suppress specific ICE validation: ICE69.

I suggest you set ignore warning only for the "Release" project configuration - so that you do not risk missing new valid warnings that may come later in the development.

Sunday, June 24, 2012

Disable Sync Center from Auto Starting

In Windows 7, Once you have set up "Offline Folder" by selecting "Always available online" - the Sync Manager always starts automatically and shows up in the system tray.

This can not be reverted by removing "all" the folders previously made "Always available online"

One method is to Disable Offline files via Control Panel > Sync Center > Manage offline files > Disable offline files.

But the "correct" method would be to only deactivate the Sync Manager Handler via Registry:
@ HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\SyncMgr\
HandlerInstances\{750FDF10-2A26-11D1-A3EA-080036587F03}

revert "Active" to value '0'

This is the default state as it at before any folder where ever made "Always available online" and thus now the Sync Manger Icon will not show up in the system tray upon every start-up.

Wednesday, April 04, 2012

Google Chrome not Updating with 'Update server not available (Error: 3)'

If you are using Google Chrome and have disabled UAC (the popup with dark background that comes up every now and then; chances are your browser might be 'very' outdated. you can confirm this by clicking on the wrench on the top right,just  below the close button - then: 'About Google Chrome'.
It should say 'Google chrome is up to date' but instead if it says: 'Cannot reach update server Error 3'
- Re-enable UAC then reboot and check again.
Chrome has a standalone updater that is run by the Task-Scheduler; which if not misconfigured should have been able to update Chrome regardless.
http://support.google.com/chrome/bin/answer.py?hl=en&answer=111996

Thursday, February 23, 2012

Query directly from your Browser's Omnibar/Addressbar

We need information and we want it fast. In the Internet age when every other service is online, getting to the right information quickly depends only on your computer, internet connection, browser, your bookmarks or your proficiency at formulating the right search queries. Fortunately todays Browsers have evolved. They are much contextual, intelligent and proactive. There is no longer a need of separate forms for the URL address and the search box. The hybrid of these two and more is the Omnibar.

But with the added feature of 'Key word custom search' like "Edit search engines" in Google Chrome, this Omnibar now becomes virtually, a 'command prompt' to the Internet, saweeet :)
As an example: Imagine: you need to find the current status of your train ticket. For this you would first search for the Railway's website, then you will have to scan the whole page and travel back and forth a few links to get to the final form where you can input your ticket number. now imagine how convenient it'd be if this whole process were to be reduced to one single step.

This is what I mean by the Command Prompt to the internet: Ideally you could come to this command prompt: the omnibar of your browser, and just type: "Ticket-Status xxxnnnxxx" and Voila!! your browser would take you to the final page of Railways website which shows the status of your ticket; all in but just one step.

and here's the great news this can be done and you don't really have to be a programmer to accomplish this.

Here's how:
When we browse the internet we access a URL. e.g. google.com
When we search or query by clicking a button like 'Submit' after filling a form we also send that URL a bunch of variables/parameters.

there are two methods of sending information to a web server.

  1. Get: information is sent in plain text appended to the the Query String beginning with a Question Mark '?'
    e.g. www.google.com?q=hi
  2. Post: Most of the forms are submitted by this method. the Query string is sent in binary format and thus does not require appending of any text to any url.

So the idea is: If you know the right method - your information server is to be queried by, you could formulate the right 'request' that contains the information which you'd normally enter and then click, say 'submit', to get to the final information directly.

While all browsers support Direct Search,
Google Chrome lets you perform search queries only by Get method uptil v7.0.
Opera allows you to send requests by Post method also but unfortunately there is no way to pass more than one parameter.

Though there is a JavaScript hack to make use of multiple parameters in Get method, both in Chrome and Opera:
following line must be placed in the URL field of the "Add Seach engine" reference

javascript:url='lccp_pnrno1=%0s&lccp_pnrno2=%1s&submitpnr=Get+Status'; parts='%s'.split('qzq'); for(var i=0; i < parts.length; i++) url=url.replace(new RegExp('%'+i+'s', 'g'),parts[i]); location=url;


  • u may replace 'qzq' in the above with any thing that does not collide with the expected parameter values.
  • u may use an empty space ' ' instead of 'qzq' if you do not expect to have any space in any of the parameters.

    eg. keyword XqzqY => xyz.com?param1=X&param2=Y

I have not been able to find out a similar solution for the 'Query String' viz the parameter list in Opera for Post method.

thus Here I present to you an ingenious solution:

  1. the Browser forwards your query to a local file;
  2. a JavaScript in this local file then converts the Get query into the required Post query and
  3. then forwards it to the final Search/Query engine.


the Catch is: you will have to do a little bit of digging to find out the specific variable: the form name and parameter list then customize the HTML re-director accordingly.

Procedure:
To identify the information being sent to the web server: the easiest method is to convert your form into type 'Get' from 'Post'. This way when you click 'Submit' your form you are likely to see your form name and parameter list along with corresponding values in plain text right in the address bar. (Unless its a AJAX form)

Add the following Bookmarklet:

Make sure that u can see the BookMarks bar.
if its not visible press Ctrl + G
Drag this bookmarklet to the Bookmarks bar Or Add a new BookMark with name: "Post2Get" & url: as the following:

javascript:(function(){var x,i; x = document.forms; for (i = 0; i < x.length; ++i) x[i].method="get"; alert("Changed " + x.length + " forms to use the GET method.  After submitting a form from this page, you should be able to bookmark the result."); })();

Download the following redirector XHTML file into ProgramFiles\Tools Folder

  1. SingleParam
  2. MultiParam
Edit the parameters according to your specific case:

Add an entry to this redirector file into the Browser
Right Click on the Omnibar
Edit search engines... > Add... > Name: [SERVICE_NAME] > Keyword: [SN] > URL: [file:///C:/Program%20Files/Tools/Redirect.html?query=%s] > OK

Go to the Query/Search Engines particular page that contains the particular query form.
Click on the Post2Get Bookmarklet
 It will then tell you how many forms it has converted from 'Post' to 'Get'
Now after filling in the form when you click on the submit button -

  • Case I: if the query works:
    u can directly use this URL for adding the search reference
  • Case II: if the query fails:
    u will still see the query string in the address bar, copy this

 identify the two parts of this string:

  1. static location of the URL
  2. identify the static variables and their values
  3. identify the dynamic variables


 Optionally and as a good practice you may add validation checking for these variables.
 Rename the redirector file to ur particular query
 copy this address to the Redirector HTML file and save

Now just type the Keyword in the omnibar <space> followed by the query term.

[Work in progress...]

Run VBA Macro from another file via Command Line.

Microsoft Office Macro in a file other than the "Normal" template.

VBA Macro can be run from Command line using the following syntax:
WinWord {Path\to\Macro\File} /mMacroName

This will not work if you have set your Macro Security to any thing other than "Allow all macros"

To fix this:
I suggest you select: "Allow only signed Macros"
Now Sign your Macro Project using a Self Certificate from "Office Tools" > "Digital Signatures"
You will have to Place a copy of the Certificate in "Root Authority"

Still - No effect on calling from the command line. This is because even though the Macro Project is Digitally Signed - it is only self-signed; thus you will have to explicitly authorize this macro project's publisher - which is: you.
For that open the macro project document/Template - and you will be prompted to allow the "Self Publisher".

Once this is done - the macro can be run directly from the command line.

Friday, October 08, 2010

Get VTU Examination & Revaluation result - directly from your browser

to find the VTU Examination & Revaluation result directly from the omni-bar (address bar) or Search-bar of your browser:

Screenshot of Google Chrome's address-bar showing direct search using 'result' keyword

  1. Add the Search Provider reference in the browser:

    • Internet Explorer:
      Name:
            VTU Result
      URL:
            http://results.vtu.ac.in/vitavi.php?submit=submit&rid=TEST

      Name:
            VTU Reval
      URL:
            http://results.vtu.ac.in/vitavireval.php?submit=submit&rid=TEST

    • Mozilla FireFox:
        Download: VTUResult.xml & VTUReval.xml
          Copy to: "C:\Program Files\Mozilla Firefox\Search Plugin" Directory.

    • Google Chrome:
        Click the Wrench icon in the top right corner >
          Options > [Default Search:] Manage > Add :

    • Opera:
        Tools > Preferences > Search > Add :

    • Name: VTU Result
      Keyword: result or vturesult or v
      URL: http://results.vtu.ac.in/vitavi.php?submit=submit&rid=%s

      Name: VTU Reval
      Keyword: reval or vtureval or r
      URL: http://results.vtu.ac.in/vitavireval.php?submit=submit&rid=%s
  2. Search:

    • Internet Explorer & Mozilla Firefox:
      • Select the search provider as VTU Result or VTU Reval
      • now, just type the USN and u ll be taken to the VTU result/reval page directly.

    • Google Chrome & Opera:
      • just type: "result" or "reval" to select the Search Provider
      • followed by <space> and the USN no. eg: result 1DB00EE000
        and u ll be taken to the VTU revaluation result page directly.
     #    you may also enter "http://results.vtu.ac.in/vitavi.php?submit=submit&rid=1DB00EE000" in
          the address bar to get the result directly but manually.
     #    you may also enter "http://results.vtu.ac.in/vitavireval.php?submit=submit&rid=1DB00EE000" in
          the address bar to get the revaluation result directly but manually.
    *    In Google Chrome, u can also: Right Click on the address bar >  Edit search engines.
    *    you may use the short URL: "goo.gl/7C3H" (note: 7C3H in capitals), to access this page.

Wednesday, October 06, 2010

Get Indian Railways PNR status - directly from your browser:

to find the status of your Indian Railways: Passenger Name Record (PNR) directly from the omni-bar (address bar) of your browser:

Snapshot of the Google Chrome browser omni-bar/Addressbar depicting direct PNR quersy by the keyword
  1. u will require the customized "POST to GET" XHTML redirector:
    Download: "post InR PNR.html"

  2. Save this file in a generally accessible location like "C:\Program Files\Tools\" or anywhere else*.

  3. Add the Search Provider reference in the browser:

    • Internet Explorer:
         NOT SUPPORTED
            Reason: Internet Explorer does not allow local file URL as a Search provider.

    • Mozilla FireFox:
         
      NOT SUPPORTED
            Reason: 
      Mozilla Firefox does not allow local file URL as a Search provider.

    • Google Chrome:
         Click the Wrench icon in the top right corner >
            Options > [Default Search:] Manage > Add :

    • Opera:
         Tools > Preferences > Search > Add :

      Name: Indian Railways PNR
      Keyword: pnr or inrpnr
      URL*: file:///C:/Program%20Files/Tools/Post%20InR%20PNR.html?pnr=%s

  4. now just type: "pnr" <space> follwed by the PNR no. as nnn-nnnnnnn. eg: pnr 432-1815416
    and u ll be taken to the Indian Railways PNR status page directly.
     *    replace "C:/Program%20Files/Tools" in URL if you used a different path in step 2; here '%20' = <space>

Sunday, October 03, 2010

Startup/Shutdown Script not working:

Problem:

in Microsoft Windows 7, if you have ZoneAlarm Free Firewall: Startup and Shutdown scripts do not work.

Cause:

 the registry entries at:

 HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\Scripts\Startup\
 HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\Scripts\Shutdown\
 HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Startup\
 HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Shutdown\

-get automatically deleted by the process svchost.exe, which also hosts the Group Policy Client service (gpsvc).

here is a dump from Process Monitor:
delete registry operations captured by Process Monitor

Solution/Workaround:
  1. Shutdown ZoneAlarm
  2. recreate the Shutdown/Startup Script entry using the Group Policy Editor (GPEdit.msc).
  3. Start ZoneAlarm.

Wednesday, October 11, 2006

Data Compression

First: lets break the term:

  1. Data: here it is the sequence of data elements (say bytes).
  2. Compression: To 'pack' in such a way that the resultant takes lesser 'space' than the original.
Thus - Data Compression is a technique used to decrease the size of a given data to a smaller size (i.e. lesser no. of data elements) in such a way that the original data can be reproduced from this new smaller size data.
There are two types of Data Compression:
  1. Lossless: In this type the exact original data can be reformulated from the compressed data.
  2. Lossy: Here only a slightly different version of the original data can be reformulated.


For example: using this technique one can now pack the same data in less no. of discs, say 4 that would have other wise required say 14 discs. The compressed data then at the receiving end has to be decompressed (processed by a decompressing algorithm) to reproduce the original data.

-Though floppies are now obsolete, stressful lengthy downloads -we all are familiar with. Unfortunately even though this amazing tool has been around since decades the internet community has not yet adopted it completely & that efficiently or at least has not been able to keep up with advances in the technology. Data compression has an extremely wide spectrum of applications and even in standalone platforms. E.g. it is used in boosting a 3D-game’s performance by compressing high quality textures to take up minimal of the then “very precious” memory space. All the audio, video and image standards (at least pertaining to PCs) are basically only about different Data compression techniques (Lossy), (with one exception of multiple “channels”). Data compression utilities are readily available. E.g.: the popular WinZip*. there’s an another utility available called 7-Zip (7-zip.org) absolutely for free. The most amazing part of it is that it renders the BEST compression ratio (Owing to the new LZMA Algorithm); better than any other compression utility in the market. It’s even an "Open-Source" distributed under the GNU's LGPL. What this means is that the source code (lame: Formula) of the software is now available to anyone and every one for any kind of modification. And this kind of modification only means the bettering of the software. Moreover as per the "L" that prefixes the "GPL" mentioned above - the library version of 7-Zip (as a module) can be linked to even a proprietary software. And what this means is that it can be very efficiently & seamlessly integrated into say a Web Browser like  one more point that deserves mention here is that the linked module can be “updated”. In case of dynamic linking this can be accomplished completely independently. Even in case of static linking the software designer is obliged, under the terms of LGPL, to facilitate up-gradation of the module by providing the complete source code or linkable object files of the software. Even though employing more efficient compression technique does require more processing resource, the advantage offered by it completely overshadows this glitch- in most, if not all, circumstances. Never the less- the computing power of modern CPUs has been on a run and shows no sign of slowing -with advances like multi-core, Hyper threading, enhanced Microcode expansion, Ultra high speed buses. Whilst on the other hand the level of detail and data hunger of newer applications is also increasing rapidly and so is the number of nodes attached to the internet at any given instant. These factors have elevated Data Compression to high priority - to play a very influential role to modern computing. The “open”-ness and a standard model is going to be crucial to progress in Data Compression technology and hence modern computing. As of now what is needed is that ALL of the computing community adopt this solution, And bring awareness to those who use inefficient software for archiving their uploads.