Sunday, December 2, 2012

jQuery code hinting in Notepad++

The files required to get jQuery code hinting and autocompletion in Notepad++ can now be found on GitHub, or downloaded at the bottom of this article. Enjoy!


I'm sure if you're reading this then you, like me, are a fan of Notepad++ for all your text-editing needs. I often use Notepad++ for editing JavaScript, and I often have the auto-completion feature enabled, which is great, but not so great when the file you're working on is full of jQuery methods. Fortunately, it's possible to define your own languages, auto-complete method signatures and all.

So that's what I've done. Now, obviously jQuery isn't a language in its own right, so I've tried to bring the normal Notepad++ JavaScript styles into this as well. There are also a couple of notable exceptions. I've not included the live or die methods, due to the fact that they are deprecated as of jQuery 1.7. I've also not managed to find a reliable way of including any selectors, and I have't yet added any methods that don't belong to jQuery itself (such as those of the new Callback object).

But other than those small omissions, I personally think this is quite useful and will be using it myself. Feel free to comment if you notice anything I've missed out or got wrong.

Files

notepadplus-jQuery-master.zip - Contains userDefineLang_jQuery.xml and jquery.xml

Installation

1. Download the .zip file
2. Unzip the file you just downloaded
3. Open your Notepad++ installation directory, and find userDefineLang.xml
4. Open that file for editing. If you don't have any user defined languages saved already, you can simply rename userDefineLang_jQuery.xml to userDefineLang.xml and copy it into the Notepad++ installation directory. If you do have other custom languages, you need to merge the existing file and the new jQuery one. Simply copy the contents of userDefineLang_jQuery.xml and paste it into the bottom of userDefineLang.xml, and be sure to remove the extra </NotepadPlus><NotepadPlus> at the point where you pasted in the new content.
5. Save and close, and open up the plugins/APIs directory.
6. Copy jquery.xml into this folder, and start up Notepad++
7. You should be able to select "jQuery" from the bottom of the Language menu. Great, you're done! If you don't see it, continue to the next step...
8. If jQuery is not available in your language list, click on "View", then "User-Defined Dialogue..."
9. When the User-Defined Dialogue opens, click "Import" and select the userDefineLang.xml file.
10. Close the User-Defined Dialogue and restart Notepad++. jQuery should now be an option in the Language menu.


Screenshots
jQuery code hinting
jQuery code hinting






Donot forget to give your comments /suggestions and refer to your friends.

Sunday, November 25, 2012

TF237002: Cannot open the document because Microsoft Excel 2007 or later, or one of its components is not installed.


One of my colleagues got the following error each time he tried to export workitems to Excel from within the Team Explorer 2010 client:

    TF237002: Cannot open the document because Microsoft Excel 2007 or later, or one of its components is not installed.

It took me some time to figure out what was wrong:

During the installation of Office 2007 he disabled the Office .Net Programmability Support.

To enable it you need to modify your installed version of Office and install this option.

1. In Add/Remove programs, locate your Office application and select it.
2. Click on the 'Change' button
3. Select 'Add or Remove features' and click 'next'
4. Select 'Choose advanced customization of applications' and click 'next' OR select something like 'Add .Net programmability support'.
5. In the tree view, expand 'Microsoft Office Excel' and make sure the .NET Programmability Support option is set to 'run from my computer'.
6. Click 'update'.


Donot forget to give your comments /suggestions and refer to your friends.

Enable Excel 2007 integration with TFS 2010


If you installed Office after installing Team Explorer 2010, it’s possible that the Excel button in Team Explorer and the Team Add-in in Excel are disabled.

To (re-)enable this, execute the following steps:

    Open Excel 2007.
    Click the Office button in the left corner. A menu is loaded.
    Click the Excel Options  button at the bottom of the menu.
    Select the Add-Ins tab on the left. A list of available add-ins is shown.
    At the bottom select COM Add-ins from the dropdown and press Go.
    Check the Team Foundation Add-in and click OK. The Team bar should be available.

Remark: TFS 2010 requires Office 2007 or higher to enable the Office integration. However it’s still possible to use Office 2003 by using the Team Explorer 2008 and Forward compatibily pack to connect to TFS 2010(although you’ll loose some functionality).


Donot forget to give your comments /suggestions and refer to your friends.

Monday, November 5, 2012

Export table data to Excel using jquery


<html>
<title>Export Table Data To Excel</title>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<style type="text/css">
body
{
font-size: 12pt;
font-family: Calibri;
padding : 10px;
}

table
{
border: 1px solid black;

}
th
{
border: 1px solid black;
padding: 5px;
background-color:grey;
color: white;

}
td
{
border: 1px solid black;
padding: 5px;
}

input
{
font-size: 12pt;
font-family: Calibri;
}
</style>
<script type="text/javascript">
$(function(){
$("#btnExport").click(function(e) {
window.open('data:application/vnd.ms-excel,' + $('#dvData').html());
e.preventDefault();
});
});
</script>
</head>
<body>
<br/>
<div id="dvData">
<table>
<tr>
<th>Column One </th>
<th>Column Two</th>
<th>Column Three</th>
</tr>
<tr>
<td>row1 Col1</td>
<td>row1 Col2</td>
<td>row1 Col3</td>
  </tr>
  <tr>
<td>row2 Col1</td>
<td>row2 Col2</td>
<td>row2 Col3</td>
  </tr>
 <tr>
<td>row3 Col1</td>
<td>row3 Col2</td>
<td>row3 Col3</td>
  </tr>
</table>
</div>
<br/>
<input type="button" id="btnExport" value=" Export Table data into Excel " />
</body>
</html>


Donot forget to give your comments /suggestions and refer to your friends.

Check Browser Plugins Using Jquery


(function($){
if(typeof $.browser==="undefined"||!$.browser){
var browser={};
$.extend(browser);
}
var pluginList={
flash:{activex:"ShockwaveFlash.ShockwaveFlash",plugin:/flash/gim},
sl:{activex:["AgControl.AgControl"],plugin:/silverlight/gim},
pdf:{activex:"PDF.PdfCtrl",plugin:/adobe\s?acrobat/gim},
qtime:{activex:"QuickTime.QuickTime",plugin:/quicktime/gim},
wmp:{activex:"WMPlayer.OCX",plugin:/(windows\smedia)|(Microsoft)/gim},
shk:{activex:"SWCtl.SWCtl",plugin:/shockwave/gim},
rp:{activex:"RealPlayer",plugin:/realplayer/gim},
java:{activex:navigator.javaEnabled(),plugin:/java/gim}
};
var isSupported=function(p){
if(window.ActiveXObject){
try{
new ActiveXObject(pluginList[p].activex);
$.browser[p]=true;
}catch(e){
$.browser[p]=false;
}
}else{
$.each(navigator.plugins,function(){
if(this.name.match(pluginList[p].plugin)){
$.browser[p]=true;
return false;
}else{
$.browser[p]=false;
}
});
}
};
$.each(pluginList,function(i,n){
isSupported(i);
});
})(jQuery);


Donot forget to give your comments /suggestions and refer to your friends.

Tuesday, October 2, 2012

How to send test emails using php mail from your local wamp installation


How do you send emails using plain PHP mail on WAMP on Windows?

Normally, PHP mail works by using Sendmail which is installed on *nixes, so it doesn't work on a Windows box. However, normally we just rewrite our code to using a SMTP server, but what about when we really don't want to - or can't - modify third-party code?

Fake sendmail to the rescue!

Prequisites 

Make sure that you get the following:

Fake sendmail - sendmail.exe - emulates Sendmails "-t" option to send emails and it needs a working SMTP configuration. For this example we use a Gmail account, but you can use any compatible SMTP server.

If you've installed Wampserver in C:\wamp, unzip the contents of the fake sendmail archive into C:\wamp\sendmail. Otherwise adjust accordingly.

Configuration 

Sendmail 

Now, we need to edit C:\wamp\sendmail\sendmail.ini:


smtp_server=smtp.gmail.com
smtp_port=465
auth_username=user@gmail.com
auth_password=your_password


The above will work against a Gmail account. :)

PHP

Now we need to edit php.ini and set sendmail_path:

Search for the line ';sendmail_path = "\"YOUR_XAMPP_PATH (or) YOUR_WAMP_PATH\sendmail\sendmail.exe\" -t"'
If it has a ';' in the beggining, remove it

sendmail_path = "C:\wamp\sendmail\sendmail.exe -t"

Now, restart Apache, and that is basically all you need to do.

Sending a test email

Now we can't wait to test if it works!

Create a php script, like this:


<?php
$to      = 'some@email.here';
$subject = 'Fake sendmail test';
$message = 'If we can read this, it means that our fake Sendmail setup works!';
$headers = 'From: your@email.here' . "\r\n" .
    'Reply-To: your@email.here' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

if(mail($to, $subject, $message, $headers)) {
    echo 'Email sent successfully!';
} else {
    die('Failure: Email was not sent!');
}
?>

Put it in your www directory and run it.

If it worked successfully - you should receive an email from yourself shortly - you can now use the 'vanilla' PHP mail function. And you don't need to modify existing code to work on non-sendmail platforms.

Donot forget to give your comments /suggestions and refer to your friends.

Sunday, September 30, 2012


Invoke a java webservice from browser using javascript ( xmlhttp)

Have you felt tired of seeing pages of matter on invoking a webservice from browser without much understanding . Let us try our way.

The tutorial will have two sections :
1. A simple java method exposed as a webservice ( using java embedded webserver. No need of axis, tomcat etc.,)
2. A simple html page which will invoke the webservice ( no need of php , jsp etc., ) with a simple xmlhttp request / reposnse.

Two steps for Creating and Publishing Webservice using jax-ws:


1) create a java class and add methods which will be exposed as webservices. To make normal java methods as webservices we have to annotate the methods using@WebMethod annotaiion. Java class must be annotated with @WebServiceannotation. To Customize the parameter names in the request use @WebParamannotation
Example: This example exposes the webservices to add the two numbers and multiply the two numbers

package com.sree.myservice;

import javax.jws.WebMethod;

import javax.jws.WebParam;
import javax.jws.WebService;
import javax.xml.ws.Endpoint;

@WebService

public class ArthimaticOperations {

@WebMethod

public int addNumbers(@WebParam(name="first") int first, @WebParam(name="second") int second){

return first + second;

}

@WebMethod
public int mutiplyNumbers(@WebParam(name="first") int first, @WebParam(name="second") int second){

return first * second;

}

public static void main(String[] args) {

ArthimaticOperations aop = new ArthimaticOperations();
String url = "http://localhost:9090/arthimatic"; // end point of webservice.
System.out.println(url+"?wsdl");
Endpoint.publish(url, aop); // publishing the webservice

}


}


2) Run the below command from source location
apt -d . com\sree\myservice\ArthimaticOperations.java
This command will generate the required wrapper classes one correspoding to request and other corresponding to response.

Now your webservice is ready to use. Just run the class com.sree.myservice.ArthimaticOperations
you can view the wsdl of the service using url http://localhost:9090/arthimatic?wsdl
Hope you are getting it running.

Calling webservice from browser using XMLHttpRequest
The webserive exposed can be accessed using soap request sending from browser

<html>
<head>
<script language="javascript">
function callMyService()
{
var req = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:web=\"http://myservice.sree.com/\"><soapenv:Body><web:addNumbers><first>" + document.getElementById("firstnum").value + "</first><second>" + document.getElementById("secondnum").value + "</second></web:addNumbers></soapenv:Body></soapenv:Envelope>";
if(window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
var response = xmlhttp.responseXML;
document.getElementById("resultDIV").innerHTML = response.selectSingleNode(".//return").text;
}
}
var soapaction = "http://myservice.sree.com/addNumbers";
xmlhttp.open("POST","http://localhost:9090/arthimatic?wsdl",true);
xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlhttp.setRequestHeader("SOAPAction", soapaction);
xmlhttp.send(req);
}
</script>
</head>
<body>
<div><label>Enter First Number:</label><input type="text" id="firstnum"></input></div>
<div><label>Enter Second Number:</label><input type="text" id="secondnum"></input></div>
<div><button onclick="callMyService()">Add Numbers</button></div>
<div id="resultDIV"></div>
</body>
</html>



Donot forget to give your comments /suggestions and refer to your friends.

Friday, September 21, 2012

IIS 5.1 Configuration Using VBScript with Command Line


IIS 5.1 Configuration Guide
Q). How to Creating Virtual Directory Using VBScript with Command line?
A). You can use mkwebdir.vbs at Inetpub\AdminScripts directory.

 mkwebdir [--computer|-c COMPUTER1, COMPUTER2, COMPUTER3]
         <--website|-w WEBSITE>
         <--virtualdir|-v NAME1,PATH1,NAME2,PATH2,...>
         [--help|-?]
cscript mkwebdir.vbs -c localhost -w “Default Web Site” –v “Virtual Dir1,c:\inetpub\wwwroot\dir1,Virtual Dir2,c:\inetpub\wwwroot\dir2”  (OR)
cscript mkwebdir.vbs -c localhost -w 1  –v “Virtual Dir1,c:\inetpub\wwwroot\dir1,Virtual Dir2,c:\inetpub\wwwroot\dir2”  (OR)
You can use adsutil.vbs at Inetpub\AdminScripts directory.
adsutil.vbs create  w3svc/1/root/vdName "IISWebVirtualDir"
adsutil.vbs  set  w3svc/1/root/vdName/path "C:\MyFolder"
The first command create a virtual directory under w3svc/1/root. The w3svc/1/root is a IIS metabase path. 1 here is the default website's identifier. The second command specify the virtual directory's physical path.

NOTE: w3svc/1/ means “Default Web Site”.
Q). How to Delete Virtual Directory Using VBScript with Command line?
A). You can use adsutil.vbs at Inetpub\AdminScripts directory.
cscript adsutil.vbs DELETE W3SVC\1\ROOT\YourVDirName
Q). How to Change Access to Virtual Directory Using VBScript with Command line?
A). You can use chaccess.vbs at Inetpub\AdminScripts directory.
chaccess <--ADSPath|-a relative config store path>
                          [--computer|-c COMPUTER1[,COMPUTER2...]]
                          [+read|-read]
                          [+write|-write]
                          [+script|-script]
                          [+execute|-execute]
                          [+browse|-browse]
                        [--verbose|-v]
                           [--help|-?]
cscript chaccess.vbs -a w3svc/1/ROOT/<Name Of Virtual Directory> +script +execute +read
cscript chaccess.vbs -a w3svc/1/ROOT/<Name Of Virtual Directory> -script -execute -read
Q). How to Convert Virtual Directory To ASP.NET Application Using VBScript with Command line?
A). You can use adsutil.vbs at Inetpub\AdminScripts directory.
cscript adsutil.vbs APPCREATEPOOLPROC w3svc/1/root/VDirName.
Q). What is the difference between wscript and cscript?
A). wscript is used while executing vbscripts through command line get the result in window based.
Cscript is used while executing vbscripts through command line get the result in console.
NOTE: More details to see vbscripts at inetpub\adminscripts.
Q). Why below error came? And what should I do?
ERROR:
Server Error in '/Events' Application.
--------------------------------------------------------------------------------
Failed to access IIS metabase.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Web.Hosting.HostingEnvironmentException: Failed to
access IIS metabase.

The process account used to run ASP.NET must have read access to the IIS
metabase (e.g. IIS://servername/W3SVC). For information on modifying
metabase permissions, please see http://support.microsoft.com/?kbid=267904.

Source Error:

An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.

Stack Trace:

[HostingEnvironmentException: Failed to access IIS metabase.]
System.Web.Configuration.MetabaseServerConfig.MapP athCaching(String
siteID, VirtualPath path) +3591442
System.Web.Configuration.MetabaseServerConfig.Syst em.Web.Configuration.IConfigMapPath2.MapPath(Strin g
siteID, VirtualPath vpath) +9
System.Web.Hosting.HostingEnvironment.MapPathActua l(VirtualPath
virtualPath, Boolean permitNull) +169
System.Web.CachedPathData.GetConfigPathData(String configPath) +389
System.Web.CachedPathData.GetConfigPathData(String configPath) +243
System.Web.CachedPathData.GetApplicationPathData() +68
System.Web.CachedPathData.GetVirtualPathData(Virtu alPath virtualPath,
Boolean permitPathsOutsideApp) +3536567
System.Web.Configuration.RuntimeConfig.GetLKGRunti meConfig(VirtualPath
path) +189
A).
  1. Go to start àRun àtype cmd press Enter
  2. Change the directory to C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 (Note: Your application web.config existing version folder i.e 1.0, 2.0, 3.0, 3.5, 4.0.)
  3. iisreset /stop
  4. aspnet_regiis –i
  5. aspnet_regiis –c
  6. aspnet_regiis -ga ASPNET (Note:If you're using XP, the account is "ASPNET".
If you're using Server 2003, the account is "Network Service".
If you're using Vista, the account is "Network Service".)

Donot forget to give your comments /suggestions and refer to your friends.