Blog News

SVN checkout depth of two levels

A strategy I found to get the first two levels of files of an SVN repository.

  1. Start by checking out only root and 1st level of folders
mkdir temp
cd temp
svn co . --depth immediates

2. Checkout content 1st level of folders

find ./ -type d ! -path "./.svn*" ! -path "./" -exec svn up --set-depth files {} \;

I guess it could also be used to go deeper if you use this version and run it more then once?

find ./ -type d ! -path "./.svn*" ! -path "./" -exec svn up --set-depth immediates {} \;
Blog News

Add WPML language switch without current language

This is a convenient way to add a link in the main menu to switch languages without including the active language. You’d figure this would be included in WPML but this doesn’t seem to be very high on their priority list.

Blog News Project Management

Three point estimation

As it happens, I often have to do estimates for small to kind of large projects. As most developers will know, estimating is not as easy as you think. It is even harder to guess-timate something you have never done before. During my project management classes, I did learn about three point estimation, a pretty useful tool which can help anyone get a more balanced estimate of how long the task or activity is likely to take.

Gantt Chart

As for all estimations, we need to first break down the project into individual tasks or activities. Once that is done, we need to decide on the time it will take to complete each task. However, rather than using a ballpark estimate, we can use three point estimating to get a more accurate idea. To do a three point estimation for a particular task or activity we need to get three different numbers: the most optimistic estimate, the most pessimistic estimate and the most likely estimate. Once we have these numbers, its possible to calculate the real value based on the three point formula. Start by adding your optimistic time to your your pessismistic time and then add four times the most likely time. Take the total and divide it by six. This will give us a result which is more likely to tell us exactly how long completing the task or activity is going to take.

The three point estimation formula

E = (O + P + 4 * L) / 6
O = most optimistic estimate
P = most pessimistic estimate
L = most likely estimate

For example, to write a blog post I could say that

O = 10 minutes
P = 60 minutes
L = 20 minutes

Thus my estimate is: (10+60+4*20)/6 = 25 minutes

PHP Programming

Fix Mantis corrupt attachment files

After upgrading to the latest Mantis version, I had a problem with zip attachments being corrupted when downloaded from Mantis. Turns out his error message is added to the files:

SYSTEM WARNING: ‘finfo::finfo() [finfo.finfo]: Failed to load magic database at ‘/etc/magic’.’ in ‘/srv/sites/’ line 273

To fix the problem I had to manually configure the proper path to the magic file on the server.

First I located the magic database file through the man page for magic

# man magic

magic – file command’s magic number file

This manual page documents the format of the magic file as used by the file(1) command, version 4.17. The file command identifies the type of a file using, among other tests, a test for whether the file begins with a certain magic number. The file /usr/share/file/magic specifies what magic numbers are to be tested for, what message to print if a particular magic number is found, and additional information to extract from the file.

Then I added a new configuration entry to the Mantis configuration file: config_inc.php. This file is located at the root of the Mantis folder and can be edited by any text editors such as nano, pico or vi.

$g_fileinfo_magic_db_file = '/usr/share/file/magic'

Linux Magento

Cleaning the log tables and rebuilding indexes with shell scripts

magento shells scripts usage

Based on the same idea as my “cache clearing script“ (but 10x better), Magento now includes some handy scripts to clean the log tables, to compile source files and to rebuild indexes. For people with very large databases (10k+ products) this is sometimes the only way to actually accomplish something without running out of memory or exceeding execution time limits. The scripts are located in the /shell folder. These scripts are made to be run manually by logging on the server with SSH or they may also be setup to be executed periodically as a cron job.

Below, is a little preview of the possible operations

Usage: php -f log.php -- [options]
php -f log.php -- clean --days 1
clean                Clean Logs
--days <days>  Save log, days. (Minimum 1 day, if defined - ignoring system value)
status               Display statistics per log tables
help                 This help
Usage: php -f indexer.php -- [options]
--status <indexer>         Show Indexer(s) Status
--mode <indexer>           Show Indexer(s) Index Mode
--mode-realtime <indexer>  Set index mode type "Update on Save"
--mode-manual <indexer>    Set index mode type "Manual Update"
--reindex <indexer>        Reindex Data
info                       Show allowed indexers
reindexall                 Reindex Data by all indexers
help                       This help
<indexer> Comma separated indexer codes or value "all" for all indexers
Usage:  php -f compiler.php -- [options]
state         Show Compilation State
compile       Run Compilation Process
clear         Disable Compiler include path and Remove compiled files
enable        Enable Compiler include path
disable       Disable Compiler include path
help          This help