[MySql] How to export MySql database schema using command line

Following command dumps MySql database's schema into a file:


mysqldump -u<username>i -p<password> -h<host> --databases <database1> --no-data > dump.sql

Above command exports single or multiple databases into dump.sql. This only exports database schema without any table contents.


This exported schema can be restored using following command:


mysql -u<username>i -p<password> -h<host> <database_name> < dump.sql

Uploading files to Remote Server


There are different ways we can upload files to remote servers. Few command line tools are listed here"
1- Securely Copy files (scp):
scp -v -r -o IdentityFile=<cert.pem> <source folder> <user>@<remoteserverip>:/home/<user>/<destination folder>

Note: If a certificate is needed, then IdentityFile=<cert.pem> should be used.

2- rSync: 
rsync -vcrz --delete-after <source folder> <user>@<remoteserverip>:/home/<user>/<destination folder>

jQuery Chaining Interview question

Which one of the following will break the chain and Why?
A-

$(…)
.html('Breaks chain')
.addClass('chainbreaker')

B-

$(…)
.html()
.addClass('chainbreaker')

Solution:
In A, .html('Breaks chain') behaves like a setter and returns object, on which .addClass(…) adds the given class. But in B, .html() behaves like a getter and returns a string, on which .addClass(…) methods fails to perform and gives runtime error.

How to get File Extension in PHP ?

Very Simple! This command should do that:
$ext = pathinfo($filename, PATHINFO_EXTENSION);

Another GoogleDoc API Issue

After getting past of one issue. Here is another error log I got:
com.google.gdata.util.ResourceNotFoundException: Not Found <HTML> <HEAD> <TITLE>Not Found</TITLE> </HEAD> <BODY BGCOLOR="#FFFFFF" TEXT="#000000"> <H1>Not Found</H1> <H2>Error 404</H2> </BODY> </HTML>

Solution is simple ! Replace URL mentioned in Google documentation.
Replace this: URL documentListFeedUrl = new URL("http://docs.google.com/feeds/documents/private/full");
To: URL documentListFeedUrl = new URL("http://docs.google.com/feeds/default/private/full");

You will get your document listing :)

Started Using GoogleAPIs ?

I have recently tried out google apis and found this dazzling problem after importing all the jars documented in GoogleAPI documentation:

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/Maps
at com.google.gdata.wireformats.AltRegistry.(AltRegistry.java:118)
at com.google.gdata.wireformats.AltRegistry.
(AltRegistry.java:100)
at com.google.gdata.client.Service.
(Service.java:555)
at TestDocumentList.main(TestDocumentList.java:14)
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.Maps
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 4 more


Actually, in documentation they forgot about importing google-collect-1.0-rc1.jar. You can find this jar in gdata/bin/deps/google-collect-1.0-rc1.jar. Don't forget to add this in your build path.

How to make MySQL working on Mac OS X

Installing and configuring MySql in Mac was such a pain for me. I have installed and run MySql on Windows and Linux systems at least for 20 times by now, without any trouble. I assumed it will be quite simple in Mac as well. Actually, I hoped for easy installation because Apple products are considered user-friendly....but not developer friendly :(

Anyhow, I got it working now :)
1- Download binary from Mysql downloads
2- Copy /usr/local/mysql/support-files/my-medium.cnf to /etc/my.cnf
3- Start MySql using : /usr/local/mysql/support-files/mysql.server start
4- Stop MySql using : /usr/local/mysql/support-files/mysql.server stop
5- Check MySql Status: ps xa | grep "/usr/local/mysql/bin/[m]ysqld"

You may get some errors in bin dir path. You may want to fix paths in /usr/local/mysql/support-files/mysql.server (at least I did)

I have installed Workbench GUI for administration purpose. Good enough to give a try !

Scheduling Repeating Local Notifications using Alarm Manager

Learn about Scheduling Repeating Local Notifications using Alarm Manager in this post .