Dynamic positioning of the jquery tooltip object
January 20th, 2012 by richa No comments »We are using dynamic plugin which repositions our tooltips so that it is always visible on the viewport.
If there is no room on the top edge then the tooltip is shown on the bottom edge. The same happens on every edge of the tooltip: top, bottom, left and right. When there is no room then the opposite edge is used. Note that this demo is only for vertical repositioning.
It is possible to change the style, effect and other configuration variables whenever the dynamic repositioning occurs.
We are using the offset option to position the tooltip a little higher by default. When using the dynamic effect this value is inverted. Higher means lower and further right means further left.
JavaScript coding
After initializing the tooltip we will chain our dynamic()plugin. We have used the bottom parameter to alter the tooltip configuration for the bottom edge. Every configuration option can be used to alter the tooltip’s behaviour.
<script type=”text/javascript”>
jQuery(function() {
$(“.tooltip_anchor”).tooltip ({
offset : [10,2],
effect : ‘slide’,
predelay: ’10′
// add dynamic plugin with optional configuration for bottom edge
}).dynamic({ bottom: { direction: ‘down’, bounce: true } });
});
</script>
Note : the dynamic plugin and the slide effect are not included in the standard jQuery Tools distribution. You must download a custom combination to include those effects.
Downgrading IIS from 64 bit to 32 bit after reinstalling ASP.NET 2.0
January 4th, 2012 by amit No comments »To enable 32 bit apps to run:
1.Go to command prompt and navigate to %systemdrive%\Inetpub\AdminScripts
2.Run the command cscript.exe adsutil.vbs set W3SVC/AppPools/Enable32BitAppOnWin64 “true”
Next to reinstall ASP.NET 2.0.x
1.Go to command prompt
2.Navigate to C:\%WINDIR%\Microsoft.NET\Framework\v1.1.4322
3. Type aspnet_regiis /i
Install SQL Server 2008 Express
January 4th, 2012 by richa No comments »SQL 2008 Express is available free from Microsoft.
Step 1 : Download SQL Server 2008 Express
First, you will need to download SQL Server 2008 Express.
You have two options to download.
- You can either download SQL Server 2008 Express without any management tools (61 MB) from http://go.microsoft.com/?linkid=9314315
OR
- you can download SQL Server 2008 Express with management tools (219 MB) from http://go.microsoft.com/?linkid=9394725
I recommend to install “SQL Server 2008 Express with Tools” because it is worth the extra 150 MB to be able to troubleshoot your SQL Server if anything ever goes wrong.
Step 2: Install SQL Server 2008 Express
SQL Server 2008 Express requires .NET Framework 3.5 SP1, if your server does not have .NET Framework 3.5 SP1 you will need to download .NET Framework 3.5 SP1 and install it on your server. You can download .NET Framework 3.5 SP1 from http://go.microsoft.com/fwlink/?LinkId=120550
SQL Server 2008 Express requires Windows Installer 4.5, if your server does not have Windows Installer 4.5 you will need to download Windows Installer 4.5 and install it on your server. You can download Windows Installer 4.5 from http://go.microsoft.com/fwlink/?LinkId=123422
SQL Server 2008 Express requires Windows PowerShell 1.0, if your server does not have Windows PowerShell 1.0 you will need to download Windows PowerShell 1.0 and install it on your server. You can download Windows PowerShell 1.0 from http://go.microsoft.com/fwlink/?LinkId=120552
When you are ready to install SQL 2008 Express, follow these steps
- Run your exe to install SQL 2008 Express.
- At the “SQL Server Installation Center”, choose “System Configuration Checker” to make sure you are ready to install SQL 2008 Express
- When the “System Configuration Checker” has validated that you are ready to install SQL 2008 Express, return to the “SQL Server Installation Center” and click on Installation.
- Select “New SQL Server stand-alone installation or add features to an existing installation”
- A setup support check will run. Make sure there are no errors or warnings, press OK.
- The “SQL Server 2008″ Setup will now appear, on the Product Key page, click Next.
- Check the box “I accept the license terms” and click Next.
- Click “Install” to install the Setup Support Files.
- When the Setup Support Files install is complete, click Next.
- You will now be in the “Feature Selection” page. Select “Database Engine Services” and “Management Tools – Basic” and then click Next.
- In the “Instance Configuration” page, specify MSSQLSERVER in both the “Named instance” and “Instance ID” fields, this will force SQL Server 2008 Express to install as the Default instance. If you want to install as a named instance, specify a name other than MSSQLSERVER.
- Click Next twice.
- You will now be in the “Server Configuration” page. Change the SQL Server Database Engine’s Account Name to “NT AUTHORITY\SYSTEM” and SQL Server Browser’s Startup Type to Automatic, then click Next.
- On the Database Engine Configuration page, you can either leave it configured to use Windows Authentication Mode only or Mixed Mode (SQL Server authentication and Windows authentication). I usually enable Mixed Mode so that if for some reason my security gets messed up I always have a backdoor account (the SA account). If you choose Mixed Mode, you will need to enter and confirm a password for the SA account.
- Before you can continue, you will need to specify the group(s) that you want to have unrestricted access to SQL Server. Click “Add…” and select the group(s). I recommend that you at least add Administrators and the “Current User” (Service Account). When you are done here, click Next three times, and then click Install.
- When the installer completes, click Next and then Close.
Step 3 : Firewall Exceptions
If you have a software firewall installed on your server, you will need to add exceptions for the SQL Server and SQL Browser services. If you are using Windows Firewall, do the following:
- In your Control Panel, open the Windows Firewall applet.
- Go to the Exceptions tab.
- Click Add Program
- Browse to and select “C:\Program Files\Microsoft SQL Server\MSSQL.10\MSSQL\Binn\sqlservr.exe”
- Click OK.
- Click Add Program
- Browse to and select “C:\Program Files\Microsoft SQL Server\90\Shared\sqlbrowser.exe”
- Click OK and then click OK again.
If you are using a third-party software firewall, you will need to follow their instructions to add exceptions to sqlservr.exe and sqlbrowser.exe.
Now when you have completed all of these , restart your SQL Server to complete the process.
View Table Constraints in SQL Server
December 16th, 2011 by amit No comments »To view all the constraints set for a table in MS SQL Server use the built in stored proc:
sp_helpconstraint ‘tablename’
Complete solution to migrate a large database sql file in MySql
December 8th, 2011 by sanjay No comments »
During my recent project, i was in a situation where I had to move a large mysql database from a testing server to live server. I got stuck almost on every phase of this whole situation. Firstly it created problems in exporting the database from testing server (phpmyadmin has many issues with large sql file handling, I guess) and when I was importing on live server it again threw me many problems.
The purpose of this blog is to tell others how to overcome all these steps and how to move a large database using different methods. This method is not the only method, but was my personal choice. Many experienced users have used other alternative solutions for doing this stuff.
My situation is that I have the database userid and password (for live server) which does not have superuser privileges. So here we go.
Export Database
My personal experience in using phpmyadmin for exporting large database is not good, so I suggest using php scripts available on internet to import large sql files eg. phpminiadmin or any other. Also you can write your own script. Simply put the script on your testing server via ftp and browse the url of this script, put database credentials and export it
Other options are using command line or SSH client for Windows which is explained below
Let us assume username is abc and password is abc123, the testing server from which you have to export database is example.com and database name is test_db1, therefore command to import it from your local Windows machine is.
mysqldump –u abc –p –h example.com test_db1 >> c:\dbsqlfile.sql
Enter the password (in this case abc123); of course you can use any destination path instead of c:\dbsqlfile.sql on your local window machine.
If you are able to SSH to your testing server (example.com) then put the following command in SSH client for window like putty or winscp
mysqldump –u abc –p test_db > httpdocs/dbsqlfile.sql
Enter password and remember that this command will save the sql file on the testing server (example.com) to the defined path in above command. Here you have to be careful while choosing destination path for saving the sql file because the folder may have permission issues. Now using secure file transfer protocol you can download this sql file on your system
Import Database
If you use phpmyadmin installed on the live server to import the large sql file chances are you may get ‘maximum time execution’ error even if your file is smaller than the maximum allowed size to upload on phpmyadmin (that was the problem with me). So here is what you should do (some of you would that think changing the maximum execution time setting will help but in my case it didn’t).
Suppose your live server is liveexample.com, database name is test_db2 with username xyz and password xyz123. Remember this user has only permission to access database test_db2.
On your local Windows machine open command line tool and enter the following command
mysql –u xyz –p –h liveeaxample.com test_db2 < c:\dbsqlfile.sql
Enter your password (xyz123). Remember to use the correct source path.
If you have uploaded your database sql file on the live server then you can use the free SFTP, FTP and SCP client for Windows called Putty or WinSCP and enter the following command
mysql -u xyz –p test_db2 < httpdocs/dbsqlfile.file
Enter your password (xyz123), again remember the correct path of the database sql file (it is the path where you have uploaded sql file on live server). You can also use source command after login in mysql for the same.
One important thing I would like to mention that the process of exporting database from testing server on your local computer and then uploading it on live server for importing it on the database, can be done in many other efficient way which is a lot faster than this process, if you know tar, scp or rsync unix commands to transfer file over a network you can directly transfer your large sql file from one server to another without any problem. I myself used tar command to transfer large file (though not in this case). Even if you are not very experienced user you can Google the command and shoot it on any SSH client program like putty
Coming back on main topic, there are chances that after executing the above commands for importing the database you may get Error “Got a packet bigger than ‘max_allowed_packet’ bytes”. This is the major problem which I faced during all these steps and it also encouraged me to write this blog.
For this you have to change the max_allowed_packet value for your local system mysql daemon as well as live server mysql daemon.
If you have superuser privileges for your database user xyz than you can do the steps below without any error.
SSH to the live server, login to mysql console connected to the live server and run these commands
set global net_buffer_length=1000000;
set global max_allowed_packet=1000000000;
Try to use large value for packet size.
To check if they’re set, use
select @@max_allowed_packet;
Now open another SSH terminal and shoot the following command
mysql –max_allowed_packet=100M -u xyz -p test_db2 < httpdocs/dbsqlfile.file
Enter the password (xyz123) and you are done.
But as I mentioned above that I had no superuser privilege for my database user so running the above mentioned command still failed with error message “access denied; you need the SUPER privilege for this operation- …..”. So what to do now? Either you can ask the hosting company to give you the password of the root user (which has all the privileges) or take permission to change mysql root password (which will not be allowed in shared hosting unless you have a dedicated server) and do the importing stuff as mentioned above. Another thing you can do is you can ask the hosting company to grant all privileges to database user xyz.
I assume that you have got the permission to reset the root password, so here is the way you can reset the root password (This technique can also be used to reset the root password of mysql server in any other case)
Log in as root user (remember only root user has all the privileges to execute commands, this root user is not same as the database root user, it is root user of live server) in your live server using SSH client
Stop the mysql server:
service mysqld stop or /etc/rc.d/init.d/mysql stop
start mysql server without password:
mysqld_safe –skip-grant-tables &
connect to mysql server:
mysql –u root
Now start the process of setting password for root user:
mysql> use mysql;
Database called mysql has a table called user which contains all the users information including root user, sometime there is no root user instead you can find user with name admin which has all the privileges, so in this case you have to reset the password of admin. To list all the users in user table you can use following command.
mysql> select User form user;
I myself found admin instead of root. Now use update command to reset the password of the root user
mysql> update user set password=PASSWORD(“NEW PASSWORD”) where User=’root’;
where NEW PASSWORD is your new password which you want to set for the root user (remember you may have to change root with admin in above command if you found user admin instead of root). Now to retain all the privileges run
mysql> flush privileges;
mysql> quit;
After quitting from mysql client again stop msyql server:
service mysqld stop or /etc/rc.d/init.d/mysql stop
Again start mysql server and try your new password
service mysql start or /etc/rc.d/init.d/mysql start
mysql –u root –p or mysql –u admin –p
Enter your new password and you will login in mysql. You can set max_allowed_packet and net_buffer_length and able to import database using large sql file as mentioned above without any error.
This is all you need to export and import a large database, hope you enjoyed the blog.
I would like to hear your suggestions and comments
Fixing Plesk Panel password error
December 5th, 2011 by amit No comments »If you get the error while trying to connect to Parallels Plesk Panel:
Service is not available now, probably your Plesk is misconfigured. Contact Your provider for details. Internal Plesk error occurred: Unable to connect to database: saved admin password is incorrect.
then the steps to follow are given below. It is assumed you have logged into SSH with root credentials.
1.Reset Plesk admin password in the mysql database
First stop the plesk service:
/etc/init.d/psa stopall
Note that this will also stop apache and mysql services.
Next set the new password:
export PSA_PASSWORD=’NEW_PASSWORD’ ; /usr/local/psa/admin/sbin/ch_admin_passwd; unset PSA_PASSWORD
2.Start Apache
/usr/sbin/apachectl restart
3.Start MySQL
/etc/init.d/mysqld start
4.Start Plesk Service
/etc/init.d/psa start
The above instructions are valid for GNU Linux. It is more or less the same for all distros of Linux except sometimes the paths will change.
You dont write apps for the mobile platform? Thats not a problem really..
December 1st, 2011 by amit No comments »This short blog was inspired by MSDN Magazine editor Keith Ward’s editorial note in the May 2011 edition of MSDN magazine.
Mobile/smartphone/iPad apps seem to be the rage these days. Almost everyone is coming up with an Android version of their software or announcing their skills to create apps on java phones etc.
Does that mean software for mainstream desktops, mainframes, websites are not in demand anymore? Certainly not. ‘Android’ is the latest buzzword today just like ASP.NET was the latest buzzword a few years back or VB6 was the hot thing even earlier than that. I remember way back in the early 90s when IBM AS/400 application development was in huge demand. But just because a new wave comes up does not mean that the rest of the platforms are dying a slow death.
So lets see, what can be done on a mobile platform? After thinking for 10 minutes I cant think of a single serious application which can be done on a mobile platform. Ever tried writing a two page document on your ipad or iphone or blackberry? What about creating a Powerpoint presentation? What about viewing your sales forecasts? Ok, you are a developer? Ever tried writing code using the blackberry keypad? Ever tried hosting a website on an Android phone? Or running an ERP application?
The point is apart from emails or light browsing , most mobiles or smartphones cant do much. They were basically meant to be phones and still remain phones through which you can communicate with the world. They dont have the processing power or the hardware resources to do anything more involved. And most important of all, you really cant do much with a tiny screen and a tiny keyboard.
So, if you are still not on the mobile bandwagon, take heart. Your C++ skills will still be required for the next few years at least. Mainstream development is not going out of fashion anytime soon. We still need big computers to do the serious stuff. So all you ASP.NET, PHP, Oracle, SAP, VC++ ,J2EE guys – dont worry, you will be around for a long time to come.
I have nothing against Android or Blackberry application development (I have a Blackberry myself). But I dont like it when people look down on you when you say that you are not on the Android application space yet. The advent of television didnt make movies obsolete, and the advent of cars didnt make bicycles obsolete.
Search for jobs on any major jobsite. The most in-demand skills are still Oracle, SAP, ASP.NET and C++. Android jobs are definitely there ,but they are not overshadowing other jobs in any way,
Lets take the the other end of the spectrum. COBOL , the dinosaur is still in huge demand. The average American still interacts with a COBOL program 13 times a day. 90% of global financial transactions are processed in COBOL.
As per the latest Nov 2011 salary surveys in USA, a COBOL programmer has an average salary of $66,000 , an ASP.NET developer gets about $60,000, a C++ developer gets about $80,000 and an Android developer gets about $16,000.
You dont write apps for the mobile platform? Thats not a problem really..
Undocumented CKEditor hack to do your own image uploads.
November 28th, 2011 by amit 1 comment »
OVERVIEW
CKeditor is notorious for its bad documentation and often people have to run around in circles when they have to write plugins or finding ways of customizing its behavior. One of the most common problems faced is generally to do with image insertions in the text or uploading images.
The official way to customize your own image uploads is to write your own plugin. But a ckeditor plugin has its limitations so there are limits to how much you can customize.
We recently implemented our own image uploading method for a project which uses ckeditor. Part of it uses an unofficial hack , but it turned out to be the simplest and most direct way of getting the custom uploader to work.
STEPS TO FOLLOW
1. Creating the custom upload form
2. Adding a custom icon in the ckeditor toolbar to invoke the form
3. Making a ckeditor plugin to open the custom upload form in ckeditor
4. Integrating the custom upload form with the custom toolbar icon
5. Inserting the uploaded image into the ckeditor text
6. Invoking the standard Image attributes dialog form
SIMPLE EXPLANATION
We will first go through the visual steps of how the above steps work
STEP 1 – Creating the custom upload form
This step is completely independent of ckeditor. We can set up our own way of uploading images, in whatever way we want and store it whereever we want to. The form we have used is shown below:
This form uploads an image on the server side, updates the database if required and does other housekeeping functions.
STEP 2 – Adding a custom icon in the ckeditor toolbar to invoke the form
This step is taken care of in Step 3 below . The icon needs to be a 16×16 png image as shown below:
STEP 3 – Making a ckeditor plugin to open the custom upload form in ckeditor
Since we want to invoke our own custom image uploader form from ckeditor , we need to write a ckeditor plugin. This plugin will
• Add a custom icon to the ckeditor toolbar
• Call the custom image upload form when this icon is clicked
Once the plugin is in place, the custom icon appears as shown in the screenshot below:
STEP 4 – Integrating the custom upload form with the custom toolbar icon
Once the plugin is hooked to the custom icon, we use the plugin to call our custom uploader form in an iframe. This makes it look like the custom upload form is a native ckeditor dialog, because the plugin frame automatically takes on the appearance of a ckeditor dialog.
See the screenshot below:
STEP 5 – Inserting the uploaded image into the ckeditor text
Once the image is uploaded, then it calls a javascript function in the plugin.js javascript to insert a new image tag into the current cursor location in ckeditor.
STEP 6 – Invoking the standard Image attributes dialog form
Once the image has been inserted into ckeditor, we hook the click event of the standard image attributes icon in the ckeditor toolbar to open up with the inserted image selected.
See screenshot below:
TECHNICAL EXPLANATION
FILES/FOLDERS
All the actual files will be in our custom plugin folder which itself goes into the ckeditor/plugins folder. Our plugin is called testimage so all our files go into the folder ckeditor/plugins/testimage
These files are:
- Expanding-image-mouse-out.png – the image for the toolbar icon
- form.php – our custom uploader form which will be called within the plugin
- loading.gif – image used in the custom uploader form
- plugin.js – the definition file for our plugin
- uploadimage.php – this file is called from form.php to handle the actual upload and server-side processing
Apart from this, we need to change ckeditor/config.js to specify our plugin. This involves two steps:
- Specifying the location of our plugin icon in the toolbar configuration array.
- Adding our plugin name to the extraPlugins property of ckeditor.
Since our plugin folder is called testimage (case sensitive), the icon specified in the toolbar configuration array has to be exactly the same name. This is shown below:
PROCESS SEQUENCE
The sequence diagram given below shows the how the process flow works:
INSERTING THE UPLOADED IMAGE INTO THE CKEDITOR TEXTAREA
Once we have uploaded the image to the server and we have the full path available to us, we use the function CKEDITOR.instances.(our instance name).insertHTML() function to insert an IMG tag with the full image path.
We assign our own id atribute to the image tag. Note that if multiple images will be inserted then the id has to be unique across all images. Our approach is to generate a unique id from the server-side code which uploads the image and then pass this id to the client-side script.
SELECTING THE INSERTED IMAGE
Once the image is inserted, we create a javascript variable to the image element by the following code:
var element = CKEDITOR.instances.(our instance name).document.getById(whatever id attrib the image tag has been given) Once the element is obtained, we select it in Ckeditor by: CKEDITOR.instances.(our instance name).getSelection().selectElement(element);
CALLING THE IMAGE ATTRIBUTES DIALOG IN CKEDITOR
When the previous step is executed, the image is selected in ckeditor. Now we need to popup the image attributes dialog. To do this we use an undocumented method of hooking the onclick function of the image icon in the ckeditor toolbar.
Each icon in the toolbar is assigned an onclick function which is a number eg.1,2,4,25 ,36 etc. A particular icon’s onclick function can be found out by using Firebug or a similar tool.
So if we find that the image icon has a function called 49, then we call it by:
CKEDITOR.tools.callFunction(49, this);
IMPORTANT TO NOTE: The function numbers will change as per the current toolbar configuration. In other words, depending on the placement of the icons on the toolbar, the function numbers are assigned by ckeditor. So if you switch toolbar configurations then the function number will change. If you are using different toolbars in various pages, then its best to create a generic javascript function where the function number is passed as an argument and then then the call can be made as :
function clickfunction(num){
CKEDITOR.tools.callFunction(num, this);
}
FILE LISTINGS
The toolbar configuration in config.js with the custom icon is shown below. Note the extraPlugins attribute being set at the bottom.:
config.toolbar = 'Full';
config.toolbar_Full =
[
['Source','-','Save','NewPage','Preview','-','Templates'],
['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'],
['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'],
'/',
['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
['BidiLtr', 'BidiRtl'],
['Link','Unlink','Anchor'],
['Image','testimage','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe'],
'/',
['Styles','Format','Font','FontSize'],
['TextColor','BGColor'],
['Maximize', 'ShowBlocks','-','About'],
];
config.extraPlugins = "testimage";
The plugin.js listing is given below. The addIFrame() method is used to link the external upload form to the plugin:
CKEDITOR.plugins.add('testimage',
{
requires: ['iframedialog'],
init:function(editor){
editor.addCommand('testimage', new CKEDITOR.dialogCommand('testimage' )); // associating the executable code with the button
editor.ui.addButton('testimage',
{
label:'Expanding Image',
command : 'testimage',
icon: this.path + 'Expanding-image-mouse-out.png',
});
CKEDITOR.dialog.addIframe( 'testimage', 'upload image', 'ckeditor/plugins/testimage/form.php', 500, 400);
},
});
function closedialog(url)
{
CKEDITOR.dialog.getCurrent().hide();
}
function setText(image_path,id,toolNum) {
CKEDITOR.instances.FCKeditor1.insertHtml('<img src=\x22' + image_path + '\x22 border=0 id=image'+id+'>');
var element = CKEDITOR.instances.FCKeditor1.document.getById( 'image'+id );
CKEDITOR.instances.FCKeditor1.getSelection().selectElement( element );
getToolbar(toolNum);
}
function getToolbar(num) {
CKEDITOR.tools.callFunction(num, this); return false;
}
The critical functions which make it all come together are setText() and getToolbar()
In setText() the image path is passed from the server-side code to the ckeditor. Then this path is inserted into ckeditor. Since we cannot directly insert quotes into ckeditor we escape it by x22 within the img tag.
The toolNum argument contains the function number which has to be called within ckeditor to popup the image attributes dialog after the image is inserted and selected in ckeditor.
CALLING THE PLUGIN.JS JAVASCRIPT FUNCTIONS FROM SERVER-SIDE CODE
We have used PHP here for server-side but the logic is applicable to any language.
Once the image has been uploaded and processed, the server-side script should have the image file path, the image tag id to be used and optionally the ckeditor function number to be called in plugin.js . The code below uses JQuery to call the javascript functions in plugin.js
We have used a php variable called $uploaded to check for a successful upload and $url to store the full image path. $new_id stores the img tag id to be used. $toolbarNum is the function number to be called in ckeditor.
<script language="Javascript" src="../../../includes/jquery-1.5.1.min.js"></script>
<script language="Javascript">
$(document).ready(function() {
<?php if ($uploaded) { ?>
window.parent.closedialog();
window.parent.setText('<?php echo($url);?>', '<?php echo($new_id);?>', '<?php echo($toolbarNum)?>');
<?php } ?>
});
</script>
HOOKING THE CLICK FUNCTION FOR A TOOLBAR ICON
Check the image below on what to look for, if you are using FireBug







