Oct 9, 2014

Installing multiple SOLR Instances in Tomcat on Same Server

  1. Make sure Java is installed on the machine.
  2. Install Apache Tomcat on port 8983 (or any other port) (Installed at location: D:\Apache)
  3. Open URL: http://localhost:8983 to check if installation is working
  4. Download any version of SOLR (in my case it 3.6.2 file apache-solr-3.6.2.zip)
  5. Stop Tomcat
  6. Unzip the SOLR and goto apache-solr-3.6.2\dist
  7. Copy the war file (apache-solr-3.6.2.war) to D:\Apache\webapps twice
  8. Rename the war files to solr.war and  solr-preview.war respectively
  9. Create a SOLR home folder (in my case at location D:\Apache\solr  and D:\Apache\solr-preview)
  10. Started and stopped Tomcat.
  11. Goto D:\Apache\webapps\solr\META-INF
  12. Create a context.xml file with content:
    <Context docBase="D:\Apache\webapps\solr.war" debug="0" crossContext="true">
      <Environment name="solr/home" type="java.lang.String" value="D:\Apache\solr" override="true" /> 
    </Context>
  13. Goto D:\Apache\webapps\solr-preview\META-INF
  14. Create a context.xml file with content:
    <Context docBase="D:\Apache\webapps\solr-preview.war" debug="0" crossContext="true">
      <Environment name="solr/home" type="java.lang.String" value="D:\Apache\solr-preview" override="true" /> 
    </Context>
  15. Copy all files from apache-solr-3.6.2\example\solr to both SOLR home folders D:\Apache\solr  and D:\Apache\solr-preview)
  16. Start Tomcat Service
  17. The solr instances will be available on the URL: http://localhost:8983/solr and http://localhost:8983/solr-preview
  18. To test the settings create a SOLR node in any of the SOLR instances. E.g. in Solr-preview. The new instance will be available only on Solr-preview instance



Sep 29, 2014

Create column for Host IP in Fiddler

In the quick execute command window (screenshot below):





Run the following command:
cols add "Host IP" x-hostip

Note: If you’re behind a proxy server, it’s the proxy that does the DNS lookup, not Fiddler.


Oct 30, 2013

Adding Custom Configuration Section in Web.config

Recently I faced an issue where i had to read multiple key information for same settings from Web.config (as shown below):

<seacrhConfiguration>
  <add verticalName="Search1" verticalShard="server:9998" />
  <add verticalName="Search2" verticalShard="server:9999" />
</seacrhConfiguration>

You will need to three classes inheriting from System.Configuration namespace: ConfigurationSection, ConfigurationElementCollection, and ConfigurationElement as shown below:

using System;
using System.Collections.Generic;
using System.Configuration;

public class SearchConfigSection : ConfigurationSection
{
    [ConfigurationProperty("", IsRequired = true, IsDefaultCollection = true)]
    public SearchConfigCollection Instances
    {
        get { return (SearchConfigCollection)this[""]; }
        set { this[""] = value; }
    }
}
public class SearchConfigCollection : ConfigurationElementCollection
{
    protected override ConfigurationElement CreateNewElement()
    {
        return new SearchConfigInstanceElement();
    }
    protected override object GetElementKey(ConfigurationElement element)
    {
        return ((SearchConfigInstanceElement)element).VerticalName;
    }
}
public class SearchConfigInstanceElement : ConfigurationElement
{
    [ConfigurationProperty("verticalName", IsKey = true, IsRequired = true)]
    public string VerticalName
    {
        get { return (string)base["verticalName"]; }
        set { base["verticalName"] = value; }
    }

    [ConfigurationProperty("verticalShard", IsRequired = true)]
    public string VerticalShard
    {
        get { return (string)base["verticalShard"]; }
        set { base["verticalShard"] = value; }
    }
}


Now modify the web.config to include the new configurations:
<configSections>
 <section name="seacrhConfiguration" type="<AssemblyName+Namespace>.SearchConfigSection, <AssemblyName>" />
</configSections><seacrhConfiguration>
  <add verticalName="Search1" verticalShard="server:9998" />
  <add verticalName="Search2" verticalShard="server:9999" />
</seacrhConfiguration>

Read the configuration settings on page like:
string states = string.Empty;
SearchConfigSection sec = (SearchConfigSection)System.Configuration.ConfigurationManager.GetSection("seacrhConfiguration");
foreach (SearchConfigInstanceElement i in sec.Instances)
{
    states += string.Format("Name:{0} connectionName:{1}" + System.Environment.NewLine, i.VerticalName, i.VerticalShard);
}

Dec 17, 2012

How to make VMWare stop syncing your guest clock with your host

If you want the time in your vmware OS to persist through suspend, resume, reboot, etc. add these properties to your .vmx file:

tools.syncTime = FALSE
time.synchronize.continue = FALSE
time.synchronize.restore = FALSE
time.synchronize.resume.disk = FALSE
time.synchronize.shrink = FALSE
time.synchronize.tools.startup = FALSE

This will pretty much prevent your VM from ever syncing its clock with your host.

Reference: http://blog.thetoast.net/2009/03/make-vmware-stop-syncing-your-guest.html

Feb 2, 2012

Setting up Subversion on Windows through SVN protocol

This document explains how to setup Subversion on Windows through SVN protocol (svn:///)
(Click the link below)

Setting up Subversion on Windows



--

Nov 14, 2011

Call a client side javascript method after a specific update panel has been loaded

<script type="text/javascript"> 
    $(document).ready(function() { 
    panelsLoaded = 1;
    Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(PageLoaded) }); 

    function PageLoaded(sender, args) { 
        console.log("I have occured " + panelsLoaded++ + " times!"); 
        var panelsCreated = args.get_panelsCreated(); 
        for (var i = 0; i < panelsCreated.length; i++) 
        { 
            console.log("Panels Updating: " + panelsCreated[i].id); 
        } 
        var panelsUpdated = args.get_panelsUpdated(); 
        for (var i = 0; i < panelsUpdated.length; i++) 
        { 
            console.log("Panels Updating: " + panelsUpdated[i].id);
        }
    } 
</script>

Just add all the scripts in the PageLoaded() function.



Nov 2, 2011

Watch hulu outside US

http://lifehacker.com/5583515/access-hulu-from-outside-the-us-without-a-proxy-server