Tuesday, January 13, 2009

Reverse engineering MySQL database schema in Mircrosoft Visio 2007

Following are the steps to reverse engineer MySQL database schema in Microsoft Visio 2007.

  • Download and install MySQL ODBC driver 5.1 from MySQL website.
  • Create System DSN for the MySQL Database using this driver (Run odbcad32)
  • Create a new document of type "Database Model Diagram"
  • Click on Reverse Engineer in Visio under Database menu.
  • Select the install Visio driver as ODBC Generic driver. Goto Setup and select MySQL ODBC driver 5.1
  • Select your DSN as Data Source.
  • Press next, it will give you some warning/error in conversion but at last when you press finish, it will reverse engineer the diagram

Ref: updated post from Manish Pansiniya’s Blog

Cron jobs

Cron job is a time based scheduling service in Unix-like operating systems. The schedules modified in crontab and executed by a daemon, crond, which runs constantly in the background and checks once a minute to see if any of the scheduled jobs need to be executed.

Example:

The following will run jar file at one minute past midnight each day.


01 00 * * * echo "" > java -jar MyApplication.jar param1


Fields:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
* * * * * command to be executed

Examples:

01 * * * * root echo "This command is run at one min past every hour"
17 8 * * * root echo "This command is run daily at 8:17 am"
17 20 * * * root echo "This command is run daily at 8:17 pm"
00 4 * * 0 root echo "This command is run at 4 am every Sunday"
* 4 * * Sun root echo "So is this"
42 4 1 * * root echo "This command is run 4:42 am every 1st of the month"
01 * 19 07 * root echo "This command is run hourly on the 19th of July"


References:
http://en.wikipedia.org/wiki/Cron
http://www.unixgeeks.org/security/newbie/unix/cron-1.html

Thursday, January 8, 2009

Installling Ubuntu

Today I've installed on my Thinkpad T61. I'm looking forward to switch to Linux. Well lets see, I will try to fix my developement tools over the Ubuntu and if I got lucky enough and could manage my tools over Ubuntu then I will love to join Linux community.

Tuesday, January 6, 2009

JSON

JSON (JavaScript Object Notation) is a lightweight taxt based data-interchange format. It is based on subset of Javascript standar ECMA-262 3rd Edition.

JSON is built on two structures:

  1. A collection of name/value pairs.
  2. An ordered list of values.
Examples

The following example shows the JSON representation of an object that describes a person. The object has string fields for first name and last name, contains an object representing the person's address, and contains a list of phone numbers (an array).

{
"firstName": "John",
"lastName": "Smith",
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": 10021
},
"phoneNumbers": [
"212 555-1234",
"646 555-4567"
]
}

Suppose the above text is contained in the JavaScript string variable contact. Since JSON is a subset of JavaScript's object literal notation, one can then recreate the object describing John Smith with a simple eval():

 var p = eval('(' + contact + ')');

and the fields p.firstName, p.address.city, p.phoneNumbers[0] etc. are then accessible. The contact variable must be wrapped in parentheses to avoid an ambiguity in JavaScript's syntax.

Security issues

eval technique is subject to security vulnerabilities if the data and the entire JavaScript environment is not within the control of a single trusted source. If the data is itself not trusted, for example, it may be subject to malicious JavaScript code injection attacks; unless some additional means is used to validate the data first. Regular expressions are sometimes used to perform this check prior to invoking eval. Also, such breaches of trust may create vulnerabilities for data theft, authentication forgery, and other potential misuse of data and resources. The RFC that defines JSON suggests using the following code to validate JSON before eval'ing it (the variable 'text' is the input JSON) :

var my_JSON_object = !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(
text.replace(/"(\\.|[^"\\])*"/g, ''))) &&
eval('(' + text + ')');
Source: www.json.org,http://en.wikipedia.org/wiki/JSON