code help

nonstandard property :: innerHTML (but is a de facto standard)

The innerHTML property is not part of the DOM. It isn’t part of any standard. It is a proprietary addition created by Microsoft.

Normally, I wouldn’t recommend using anything proprietary in JavaScript code (although the XMLHttpRequest object itself is a proprietary addition). However, the innerHTML property is exceptionally well supported, considering that it is nonstandard. It is, in effect, a de facto standard: it is supported in all the major browsers. The reason why innerHTML has been so widely adopted, without any endorsement from the W3C, is that it is very useful in certain situations.

DOM methods allow you to manipulate a document very precisely. You can create elements, attributes, and text, one node at a time. That is very powerful, but it is also quite time-consuming.

The innerHTML property uses brute force. If you read the innerHTML property of an element, you will receive a string of HTML. This is a read/write property, meaning that you can also assign a string of HTML to go inside an element.

Any HTML that was previously inside the element will be obliterated and replaced with the contents of the string.

Copy MySQL database from one server to another remote server

Usually you run mysqldump to create database copy:
$ mysqldump -u user -p db-name > db-name.out

Copy db-name.out file using sftp/ssh to remote MySQL server:
$ scp db-name.out user@remote.box.com:/backup

Restore database at remote server (login over ssh):
$ mysql -u user -p db-name <>
How do I copy a MySQL database from one computer/server to another?

Short answer is you can copy database from one computer/server to another using ssh or MySQL client.

You can run all the above 3 commands in one pass using mysqldump and mysql commands (insecure method, use only if you are using VPN or trust your network):
$ mysqldump db-name | mysql -h remote.box.com db-name

Use ssh if you don’t have direct access to remote mysql server (secure method):
$ mysqldump db-name | ssh user@remote.box.com mysql db-name

You can just copy table called foo to remote database (and remote mysql server remote.box.com) called bar using same syntax:
$ mysqldump db-name foo | ssh user@remote.box.com mysql bar

This will not just save your time but you can impress your friend too ;) .
Almost all commands can be run using pipes under UNIX/Linux oses.

MySQL connections can be made securely to a remote server via SSL. Just thought I would mention that as it is an additional option to consider. http://dev.mysql.com/doc/refman/5.0/en/secure-connections.html

Hack MS Office Excel Sheet Protection Password

Yes this code does as it says. Following code hacks up the Excel sheet protection password and opens the protected sheet for you. I tried this code on most of the protected Excel sheets and it worked great.

Beware this hack is not for bad use, it is just for some fun. I used it to learn functionality of an Excel Cricket Schedule found on net. Not more than just learning.

So here are the instructions & code:
Open the workbook that has the protected sheet in it. Hit Alt+F11 to view the Visual Basic Editor. Hit Insert-Module and paste following code into the right-hand code window:

‘CODE START:

Sub PasswordBreaker()

Dim i As Integer, j As Integer, k As Integer
Dim l As Integer, m As Integer, n As Integer
Dim i1 As Integer, i2 As Integer, i3 As Integer
Dim i4 As Integer, i5 As Integer, i6 As Integer
On Error Resume Next
For i = 65 To 66: For j = 65 To 66: For k = 65 To 66
For l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66
For i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66
For i5 = 65 To 66: For i6 = 65 To 66: For n = 32 To 126
ActiveSheet.Unprotect Chr(i) & Chr(j) &amp;amp;amp; Chr(k) & _
Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) & _
Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
If ActiveSheet.ProtectContents = False Then
MsgBox “One usable password is ” &amp;amp;amp; Chr(i) & Chr(j) & _
Chr(k) & Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & _
Chr(i3) & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
ActiveWorkbook.Sheets(1).Select
Range(“a1″).FormulaR1C1 = Chr(i) &amp;amp; Chr(j) & _
Chr(k) & Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & _
Chr(i3) & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
Exit Sub
End If
Next: Next: Next: Next: Next: Next
Next: Next: Next: Next: Next: Next

End Sub

‘CODE END:

Now Close the VB Editor window. Navigate to the worksheet you want to unprotect. Click Tools-Macro-Macros and double-click PasswordBreaker in the list.

When the macro finishes the work the protected sheet will be unprotected and you can fool around with sheet.

But I remind you, this hack routine provides a password to unprotect your worksheet. However, it may not give you the original password that was used and don’t use this hack for bad job.

Thanks & Enjoy!

Good & Useful cheat * Cheat Sheets *

It’s very difficult to be regular on blog but i am trying my best. It’s been couple of days i was away again but again i am back with some sweet knowledge.

The most useful thing to a developer or designer or someone else like gamer or something is Cheat Sheet. If you don’t know what it is let me tell you a little.

What is Cheat Sheet?
A cheat sheet is a physical piece of paper, often filled with equations and facts in compressed writing. Various tools can be used to produce cheat sheets, besides pen and paper.

The computer industry has many cheat sheets due to the high number of commands and actions one must learn to use programming languages and command-line interfaces. Professionally prepared cheat sheets for some subjects are available for purchase.

But i am not here to sell any of those, i am here with few links to freely available Cheat Sheets and to me all are very useful. Here the links ( i am not giving any download, have it yourself )

It’s not necessary that only programming languages has Cheat Sheets, Cheat Sheets can relate to any information available. Following are more links to useful Cheat Sheets most users of Internet should have.

I think i have taken a lot space on screen. Links are countless and i have tried to be as short as possible and as good content as possible. Open the links get the Cheat Sheet you like and have fun with it. I will keep updating this post as i get more links & time.


PS: The most thanks to Jack Daniel as he has worked on great Cheat Sheets. You can check his website at http://ilovejackdaniels.com. Thanks Jack!

Back to myBlog with few Database Connections

Last two weeks were very hactic and tiring. I attended lots of work and meetings in these days and didn’t get time to post on myBlog.

Well here i am again with some cool and new stuff i found on net in these days, ready to share with readers and implement in my programming.

I will try to be regular on posting from now on, i really missed it. Well all this later, now to the point.

Last week, while searching on net i again found a useful site named Connectionstrings.com

What is this About?
(from the website)
The idea of ConnectionStrings.com is to provide an easy reference for connection strings.Today there is 178 connection strings in the database wich have been collected from other internet sites, books, help files, msdn etc or have been submitted by fellow developers from all around the world, Thank You!

(From Me)
As it says (not clearly) the website provides you the connection strings to connect to different database through programming languages like .NET and/or more.

Well it is not much useful for me now but may be in future, as it does not relate to PHP. But hey it is a useful site and should be mentioned here.

Go here and check out yourself that if they provide connection string you are looking for.

Enjoy !

Fixing PNG transperency for Internet Explorer (MSIE): A Little Hack

Recently I have started using PNG format images for my web application icons because of its lossless data compression and variety of transparency options. More on PNG can be found on Wikipedia. (http://en.wikipedia.org/wiki/png)

Problem I faced with PNG images:
Well it is good to use PNG but there is one problem for PNG images with Internet Explorer (thanks to Microsoft and Bill Gates). Internet Explorer (IE) does not render PNG’s transparency properly so background is shown for transparent PNG images. It was really bad hit for my development. But i believe ‘where there is will, there is a way’ or you can say ‘where there is a problem, there is a solution’.

Solution I found and Implemented:
While searching for solution on Internet, I found a simple and useful solution to the problem. I implemented it and it worked great as the author said so. Well it is a little javascript hack for only Internet Explorer which renders PNG images as SPAN and displays the image as it is meant. The hack uses Microsoft’s AlphaImageLoader filter to display the transparency of PNG images. The little javascript code only works with IE and does not bother other browsers.

Where to get it:
I have pasted the code at bottom of this post but i will recommend to go to official site for updated version of the code. The code is placed at the website http://homepage.ntlworld.com/bobosola/. I didn’t get the name of author, I feel sorry for I was not able to mention his/her name here. I didn’t find it on site, if someone gets it please let me know. But the author has thanked many people on his website.

Disadvantages:
The hack is based on javascript and works only for Internet Explorer 5.5 and 6 on Windows. If javascript is OFF the images are shown as with background. (but i don’t bother for that because my most web applications are based on Ajax so it is meant only for user with javascript ON). There are few more cons in hack which are explained on the site mentioned above.

The Code:
There are two ways of using the hack.

  1. Put following code to head section of your web page. (just copy/paste)


  2. Second is save the above code in file and name it pngfix.js and copy the following code to head section of your web page.

Help for implementation:
If you need any help for implementing the code just visit the website of the author where he has explained it in a simple and effective way with demos. And secondly you can post comment here for help and I will help if I am able to.

Keep Sharing !

 Scroll to top