Archive for October, 2008

How to count inode via ssh

Posted by Ivan Guan under Linux

If your provider allows you to ssh to your account, then once you are connected, all you have to do is type the following:

find . -printf “%i\n” | sort -u | wc -l

For more options you can visit http://www.olivetalks.com

Docx is the new file format of Word 2007 and this is the default format of Word 2007. This format cannot be opened in previous versions of Word unless you have the office compatibility pack installed. Incase you do not wish to install the compatibility pack, there are
online
converters
to do the job of converting to .doc format. Here is the list of top 3
online
converters.

1. Zamzar: Zamzar can
convert
variety of file formats and

Docx
is one of them. Select the file and format to be converted and enter your email id, the file will be converted and a link will be sent to your email ID for download.

2. Docx2Doc: As the name indicated, this service converts
docx
formats into doc files so that it can be viewed in
Word 2003 or lower. The major disadvantage with this service its that there is a one hour delay in downloading the converted files to reduce website bandwidth.

3. Docx Converter:  This is again a
good service
to
convert

Docx
file and the output file is in
html format so that it can be read in all systems. There is also a desktop widget for converting.

In case you just want to view a
docx
file, then there is a simpler way for this. Rename the extension of file from
.
docx
to .zip and then extract the contents.
Docx
is basically a set of xml files. When you unzip the file, you get a folder named Word and inside that you can see a file named
document.xml. To view the contents of the document, open document.xml.

A Shell Script for Automating Backups

You can automate the backup process by making a small shell script which will create a daily backup file. How do you get cron to back up your database without overwriting the older backup? You can use a tiny shell script to add the date to your backup file. An example of a shell script you could use is shown below.

#!/bin/sh
date=`date -I`
mysqldump –all-databases | gzip > /var/backup/backup-$date.sql.gz

Creating a Cron Job

Login to the Standard Cron Manager under CPanel, You can set a job to run at a specific interval or at a specific times. Creating a cron job requires only three simple steps

  1. Enter your email address where it says: Please enter an email address where the cron output will be sent. Cron will send you a message when the job is executed, so you’ll know if there are any errors.
  2. In the Command to run: field, enter the full path to your script (you may need to check with your host for this).If you want to run a php file, the command will begin with php. For example, if you want to run RSS Import to update your Pligg feeds, you’d enter php and the path to your import_feeds.php file.

    Your path would look something like this:

    php /home/[your username]/public_html/rss/import_feeds.php.

    If you want to run the automatic backup script, which backs up your MySQL database and emails a copy to you, you’d enter /bin/sh (since this is a shell script), and the path to your script.

    Your path would look something like this:

    /bin/sh /home/[your username]/etc/upstart_cron_backup.sh

  3. Now you need to set the schedule.
    • Set the Minute(s). You can set a short interval here, or minutes of the hour (you can select multiple items in this—and the other— boxes by using the Shift and Command keys). If you don’t care about minutes, leave this set to 0).If you want to test things, set this to run Every Five Minutes. This is a good interval for running the script, checking your email for errors, and changing settings before your inbox gets inundated with cron messages.
    • Set the Hour(s). If you’re creating a cron job to run RSS Import, you might want to set this to Every Hour. If you’re setting up a backup script, you might choose an hour in the middle of the night for nightly backups.
    • Set the Day(s). You’ll probably want to leave this set to Every Day, but you can also choose specific days of the month.
    • Set the Weekday(s).
    • Set the Month(s).

When you’ve set the schedule, your cron job is done. Click the Save Crontab button. If you set it to a short interval for testing, you should have an email with your output within a few minutes. If there’s an error (usually a problem with your path), check your settings.

VTiger Tricks

Posted by Ivan Guan under Web Application

If you have installed vtiger with demo data and want to delete all data you can use the following SQL.

update vtiger_crmentity set deleted = 1

This SQL will set deleted flag of all existing module records in vtiger. You can revert back any record by setting deleted = 0.

If you want to sync only certain contact with vtiger

- Create new folder (for example: vtiger) under Contacts module in Outlook.
In vtiger outlook toolbar you can see preferences.
- In vtiger Preference you can see (Choose Contact Folder for Synhronization),
update the default Folder as the new folder (Eg ; Personal Folders\Contacts\vtiger)
Synhronize contacts. Now contacts from vtiger will be added into Outlook under newly created(vtiger) Folder.

Using a free CRM (Customer Relationship Management) online system, or one that is free open source software, is an excellent way to manage your sales leads. Free CRM software systems allow you the most inexpensive way to automate your lead list, sales pipeline, after the sale follow up, and sometimes even your inventory.

There are many CRM (Customer Relationship Management) software systems to choose from but, if you are just starting out in Sales, or if you own a small business, then before you invest in CRM software, it is a great idea to first consider trying some of the free CRM online (or web based) solutions. Some are available as free open source software for you to download to your computer. Once you try one or two of them, you will then have a better idea and know first hand what you want or don’t want “feature-wise” should you decide to purchase a CRM system down the road. Here is a list of websites to visit that offer free CRM software.

List of Free CRM Online Services and Free Open Source Software

  • FreeCRM.com – This is a very popular free CRM system and will no doubt cover all of your needs for sales lead management. This system is an online or web-based service so you do not need to download any software. It also makes it easy to access from any computer when you are away from your office. It’s easy to use with a long list of features. Register for free.
  • SalesForce.com - Salesforce CRM is another free CRM online service; there is no need to download anything to your computer. The Personal Edition is free for a single user only. Register an account for free.
  • Zoho.com – Zoho offers a free online CRM solution for up to three users. This system also has features that can accommodate the small business owner with an ingetrated inventory management system. Register for free.
  • Vtiger.com - Vtiger is free open source software for CRM. It is available for both Windows and Linux systems. It offers many features that were developed mainly for the small to medium sized business. Free for anyone to download and use.
  • SassLight.com – SassLight is a free web based (or online) CRM solution. Very easy to use with video tutorials available on the website. Free to register and use for one person only.

// this function convert date from YYYY-MM-DD to DD-MM-YYYY in order to use in HTML table for example
function mysql2table($date) {

$new = explode(”-”,$date);
$a=array ($new[2], $new[1], $new[0]);

return $n_date=implode(”-”, $a);
}

// this function convert date from DD-MM-YYYY to YYYY-MM-DD in order to use in MySQL table in DATE format for example

function table2mysql($year,$month,$day) {

if ($day<=9) { $day=”0″.$day; }
if ($month<=9) { $month=”0″.$month; }
$a=array ($year, $month, $year);

return $n_date=implode(”-”, $a);
}

The Microsoft Access Order Entry form you created contains all the information that your customer reps need to take a phone order. But every now and then the customer rep needs to access another form that has information that isn’t on the order form.

Instead of adding a subform to the order form, you can add a command button that let’s your rep pop open the desired form when needed. For example, a customer may need to change their e-mail address, which may be kept on the Customer E-mail Address form.

To create a command button that, when clicked, will pop open the necessary form, follow these steps:

  1. Open the Order Entry form in design mode.
  2. Click the Command Button tool on the toolbox and click and drag it to insert the command button control on the Order Entry form.
  3. Right-click the command button and select Properties.
  4. Under the Format tab, change the caption to E-mail Address.
  5. Select the Event tab, click the On-Click Property’s drop-down menu, and then select Event Procedure.
  6. Click the On-Click Property’s Build button.
  7. Enter the following command at the prompt:
DoCmd.OpenForm "Customer E-mail Addresses"
  1. Press [Alt][Q].

Now when your reps’ customers need to update their e-mail addresses, the rep can click the command button to access the correct form and make the necessary changes.

Referential integrity is an important concept in database design. The term refers to a state when all the references in a database are valid and no invalid links exist between the various tables that make up the system. When referential integrity exists, any attempt to link to a record which does not already exist will fail; this helps prevent user errors, producing a more accurate (and useful) database.

Referential integrity is usually implemented through the use of foreign keys. For a long time, the popular open-source RDBMS MySQL did not support foreign keys, citing concerns that such support would erode RDBMS speed and performance. However, given the high volume of user interest in this feature, recent versions of MySQL have implemented support for foreign keys through the new InnoDB table engine. Consequently, maintaining referential integrity within the tables that make up a database has become significantly simpler.

In order to set up a foreign key relationship between two MySQL tables, three conditions must be met:

  1. Both tables must be of the InnoDB table type.
  2. The fields used in the foreign key relationship must be indexed.
  3. The fields used in the foreign key relationship must be similar in data type.

The best way to understand how this works is with an example. Begin by creating two tables (Listing A), one listing animal species and their corresponding codes (table name: species) and the other listing animals in a zoo (table name: zoo). The idea here is to link the two tables by the species code, so that only those entries in the zoo table which have a valid species code in the species table are accepted and saved to the database.

Listing A

mysql> CREATE TABLE species (id TINYINT NOT NULL AUTO_INCREMENT, name VARCHAR(50) NOT NULL, PRIMARY KEY(id)) ENGINE=INNODB;
Query OK, 0 rows affected (0.11 sec)

mysql> INSERT INTO species VALUES (1, ‘orangutan’), (2, ‘elephant’), (3, ‘hippopotamus’), (4, ‘yak’);
Query OK, 4 rows affected (0.06 sec)
Records: 4  Duplicates: 0  Warnings: 0

mysql> CREATE TABLE zoo (id INT(4) NOT NULL, name VARCHAR(50) NOT NULL, FK_species TINYINT(4) NOT NULL, INDEX (FK_species), FOREIGN KEY (FK_species) REFERENCES species (id), PRIMARY KEY(id)) ENGINE=INNODB;

Important: For non-InnoDB tables, the FOREIGN KEY clause is ignored.

As the above illustrates, a foreign key relationship now exists between the fieldszoo.species and species.id. An entry in the zoo table will be permitted only if the corresponding zoo.species field matches a value in the species.idfield. This is clearly visible in the following output, which demonstrates what happens when you attempt to enter a record for Harry Hippopotamus with an invalid species code:

mysql> INSERT INTO zoo VALUES (1, ‘Harry’, 5);
ERROR 1216 (23000): Cannot add or update a child row: a foreign key constraint fails

Here, MySQL checks the speciestable to see if the species code exists and, finding that it does not, rejects the record. Contrast this with what happens when you enter the same record with a valid species code (one that already exists in the species table):

mysql> INSERT INTO zoo VALUES (1, ‘Harry’, 3);
Query OK, 1 row affected (0.06 sec)

Here, MySQL checks the species table to see if the species code exists and, finding that it does, permits the record to be saved to the zoo table.

To delete a foreign key relationship, first use the SHOW CREATE TABLE command to find out InnoDB’s internal label for the field (Listing B).

Listing B

+——-+—————————————————+
| Table | Create Table                                      |
+——-+—————————————————+
| zoo   | CREATE TABLE `zoo` (
  `id` int(4) NOT NULL default ‘0′,
  `name` varchar(50) NOT NULL default ”,
  `FK_species` tinyint(4) NOT NULL default ‘0′,
  KEY `FK_species` (`FK_species`),
  CONSTRAINT `zoo_ibfk_1` FOREIGN KEY (`FK_species`)
  REFERENCES `species` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+——-+—————————————————-+

And then use the ALTER TABLE command with the DROP FOREIGN KEY clause, as below:

mysql> ALTER TABLE zoo DROP FOREIGN KEY zoo_ibfk_1;
Query OK, 1 row affected (0.11 sec)
Records: 1  Duplicates: 0  Warnings: 0

To add a foreign key to an existing table, use the ALTER TABLE command with an ADD FOREIGN KEY clause to define the appropriate field as a foreign key:

mysql> ALTER TABLE zoo ADD FOREIGN KEY (FK_species) REFERENCES species (id);
Query OK, 1 rows affected (0.11 sec)
Records: 1  Duplicates: 0  Warnings: 0

As the examples above illustrate, foreign key relationships can play an important role in catching data entry errors, and implementing them usually results in a stronger, better-integrated database. On the other hand, it’s worthwhile noting that performing foreign key checks is a resource-intensive process and defining complicated inter-relationships between tables can result in a significant performance drop. Therefore, it’s important to always balance referential integrity considerations with performance considerations, and use foreign keys judiciously to ensure an optimal mix of speed and strength.