Introduction About Site Map

XML
RSS 2 Feed RSS 2 Feed
Navigation

Main Page | Blog Index

Archive for the ‘Programming’ Category

A Weekend of Wrestling With PHP

YESTERDAY I ranted about PhpWiki, blaming PHP for the most part. Why? My Web host has ‘broken’ a lot of the software that I run in this Web site. Some software has relentlessly and happily been running for a decade or more. It is a lot of software (all in all about 20 databases), some of which I have manually patched or changed/hacked whenever the host upgraded PHP. It is a lot of work. It is a lot of inevitable maintenance. I blame PHP. The latest upgrade is to PHP 5.3. The host reverted back to the older version (5.2) for two weeks (a sort of an ultimatum) to help me sort things out before this upgrade is permanently imposed. PhpWiki was not the only cause of issues, but it was part of it that took a whole noon plus afternoon (almost as much time as it would take to just rebuilt it all manually). While I was able to (eventually) make a minor upgrade (from a 2006 version to a 2008 version, not to the current or even recent versions) it remains unclear why PHP decided to not be backward-compatible. It is a total nightmare for sites for have a lot of PHP code, especially if their maintainers are not full-time PHP developers or are ingratiating components of software which is no longer actively maintained. PHP is risky to choose or work with. I learned this the hard way. It may be normal for proprietary frameworks to do this, but why FOSS?

Today I successfully upgraded two PHP-Nuke sites (thankfully there were upgrade scripts which worked reasonably well) and then I struggled for a whole with Gallery 2, where the upgrade process is complicated and very long, resulting in a sub-optimal outcome (e.g. no thumbnails and no tolerance of a perfectly fine ImageMagick installation). People without very advanced knowledge of UNIX and other such skillsets won’t manage to keep their photo galleries up to date. This is a real travesty. This is the catalyst of ‘Web rot’.

What I’ve identified and am eager to summarise after two days of frustrating work is this:

  1. PHP-based software cannot be counted on, especially if it’s intended to run for years (the long run)
  2. Choosing less established PHP-based software is risky as it might cease being maintained
  3. cPanel does give access to PHP error logs, but this is not too trivial to find
  4. Internal server errors can be due to restrictive Web hosts who deny access to scripts based on their UNIX-style permissions
  5. It is always better to install software from front-end scripts, such as those found in Fantastico
  6. Don’t use too many pertinent bits of software; diversity can be a nightmare to deal with
  7. When patching existing software, keep a log/record of everything that has changed
  8. If a lot of people across the Web complain about upgraders, importers, exporters, etc. then it’s better not to bother with them at all as they won’t work correctly and just waste time
  9. Check carefully and exhaustively a good test set of data following upgrade, or missing data will only be identified several years down the line when backups are too hard to find and revert to (I just found out that this happened to me)
  10. Use static HTML where you deem it suitable because the cost of maintaining/upgrading PHP is often too high to justify such a reliance

I am fed up with PHP. One cannot just install something and let it run along for years. It’s a lot of work to maintain and sometimes there’s loss of data, induced by improper upgrade paths and mistakes/accidents.

Splitting SQL Loads to Multiple CPU Cores

Foday I wrote the following bash script (note: written for 16 cores although it can be modified for more or for less), which splits SQL operations, preceded by “ [NUMERIC WEIGHT] |“. This helps assure a nice distribution of load on the bare metal. This might be reusable, so I decided to post it on my site.


IFS=$'\n'

CORE0LOAD=0
CORE1LOAD=0
CORE2LOAD=0
CORE3LOAD=0
CORE4LOAD=0
CORE5LOAD=0
CORE6LOAD=0
CORE7LOAD=0
CORE8LOAD=0
CORE9LOAD=0
CORE10LOAD=0
CORE11LOAD=0
CORE12LOAD=0
CORE13LOAD=0
CORE14LOAD=0
CORE15LOAD=0

WEIGHT=0;

echo Starting...

for line in $(cat ~/Desktop/input)
# while read line < ~/Desktop/input
# for line in `cat ~/Desktop/input`
do
# echo -e line="$line"
# $line="$line"
# echo $line
# exit
	if [ $CORE0LOAD -lt $CORE15LOAD ]
	then
# echo $line
		echo $line > current_line
		cut -b 1-13 current_line > current_number
		read SCORE < current_number
		echo $(($CORE0LOAD+$SCORE)) > total
		read SCORETOTAL < total
# echo $SCORETOTAL
		CORE0LOAD=$((SCORETOTAL))
		cut -b 16-10000 current_line >> core0.sh



	elif [ $CORE1LOAD -lt $CORE2LOAD ]
	then
		echo $line > current_line
		cut -b 1-13 current_line > current_number
		read SCORE < current_number
		echo $(($CORE1LOAD+$SCORE)) > total
		read SCORETOTAL < total
		CORE1LOAD=$((SCORETOTAL))
		cut -b 16-10000 current_line  >> core1.sh
	elif [ $CORE2LOAD -lt $CORE3LOAD ]
	then
		echo $line > current_line
		cut -b 1-13 current_line > current_number
		read SCORE < current_number
		echo $(($CORE2LOAD+$SCORE)) > total
		read SCORETOTAL < total
		CORE2LOAD=$((SCORETOTAL))
		cut -b 16-10000 current_line  >> core2.sh
	elif [ $CORE3LOAD -lt $CORE4LOAD ]
	then
		echo $line > current_line
		cut -b 1-13 current_line > current_number
		read SCORE < current_number
		echo $(($CORE3LOAD+$SCORE)) > total
		read SCORETOTAL < total
		CORE3LOAD=$((SCORETOTAL))
		cut -b 16-10000 current_line  >> core3.sh
	elif [ $CORE4LOAD -lt $CORE5LOAD ]
	then
		echo $line > current_line
		cut -b 1-13 current_line > current_number
		read SCORE < current_number
		echo $(($CORE4LOAD+$SCORE)) > total
		read SCORETOTAL < total
		CORE4LOAD=$((SCORETOTAL))
		cut -b 16-10000 current_line  >> core4.sh
	elif [ $CORE5LOAD -lt $CORE6LOAD ]
	then
		echo $line > current_line
		cut -b 1-13 current_line > current_number
		read SCORE < current_number
		echo $(($CORE5LOAD+$SCORE)) > total
		read SCORETOTAL < total
		CORE5LOAD=$((SCORETOTAL))
		cut -b 16-10000 current_line  >> core5.sh
	elif [ $CORE6LOAD -lt $CORE7LOAD ]
	then
		echo $line > current_line
		cut -b 1-13 current_line > current_number
		read SCORE < current_number
		echo $(($CORE6LOAD+$SCORE)) > total
		read SCORETOTAL < total
		CORE6LOAD=$((SCORETOTAL))
		cut -b 16-10000 current_line  >> core6.sh
	elif [ $CORE7LOAD -lt $CORE8LOAD ]
	then
		echo $line > current_line
		cut -b 1-13 current_line > current_number
		read SCORE < current_number
		echo $(($CORE7LOAD+$SCORE)) > total
		read SCORETOTAL < total
		CORE7LOAD=$((SCORETOTAL))
		cut -b 16-10000 current_line  >> core7.sh
	elif [ $CORE8LOAD -lt $CORE9LOAD ]
	then
		echo $line > current_line
		cut -b 1-13 current_line > current_number
		read SCORE < current_number
		echo $(($CORE8LOAD+$SCORE)) > total
		read SCORETOTAL < total
		CORE8LOAD=$((SCORETOTAL))
		cut -b 16-10000 current_line  >> core8.sh
	elif [ $CORE9LOAD -lt $CORE10LOAD ]
	then
		echo $line > current_line
		cut -b 1-13 current_line > current_number
		read SCORE < current_number
		echo $(($CORE9LOAD+$SCORE)) > total
		read SCORETOTAL < total
		CORE9LOAD=$((SCORETOTAL))
		cut -b 16-10000 current_line  >> core9.sh
	elif [ $CORE10LOAD -lt $CORE11LOAD ]
	then
		echo $line > current_line
		cut -b 1-13 current_line > current_number
		read SCORE < current_number
		echo $(($CORE10LOAD+$SCORE)) > total
		read SCORETOTAL < total
		CORE10LOAD=$((SCORETOTAL))
		cut -b 16-10000 current_line  >> core10.sh
	elif [ $CORE11LOAD -lt $CORE12LOAD ]
	then
		echo $line > current_line
		cut -b 1-13 current_line > current_number
		read SCORE < current_number
		echo $(($CORE11LOAD+$SCORE)) > total
		read SCORETOTAL < total
		CORE11LOAD=$((SCORETOTAL))
		cut -b 16-10000 current_line  >> core11.sh
	elif [ $CORE12LOAD -lt $CORE13LOAD ]
	then
		echo $line > current_line
		cut -b 1-13 current_line > current_number
		read SCORE < current_number
		echo $(($CORE12LOAD+$SCORE)) > total
		read SCORETOTAL < total
		CORE12LOAD=$((SCORETOTAL))
		cut -b 16-10000 current_line  >> core12.sh
	elif [ $CORE13LOAD -lt $CORE14LOAD ]
	then
		echo $line > current_line
		cut -b 1-13 current_line > current_number
		read SCORE < current_number
		echo $(($CORE13LOAD+$SCORE)) > total
		read SCORETOTAL < total
		CORE13LOAD=$((SCORETOTAL))
		cut -b 16-10000 current_line  >> core13.sh
	elif [ $CORE14LOAD -lt $CORE15LOAD ]
	then
		echo $line > current_line
		cut -b 1-13 current_line > current_number
		read SCORE < current_number
		echo $(($CORE14LOAD+$SCORE)) > total
		read SCORETOTAL < total
		CORE14LOAD=$((SCORETOTAL))
		cut -b 16-10000 current_line  >> core14.sh
	else
# echo $line
		echo $line > current_line
		cut -b 1-13 current_line > current_number
		read SCORE < current_number
		echo $(($CORE15LOAD+$SCORE)) > total
		read SCORETOTAL < total
		CORE15LOAD=$((SCORETOTAL))
		cut -b 16-10000 current_line >> core15.sh
	fi
done
echo Ended...
 

Now, each file contains operations to be run on one core, without conflict (order or load imbalance).

Car Navigation Single Car Classifier

With a training set of just a dozen positives from a single car I have let the experiment run. The purpose of this experiment is to test the alarm (collision) mechanism for short-range D alone.

Car Navigation Version 6.3 (Android)

Dashboard and tracking enriched somewhat, footage on Motorola Droid (captured by someone else). I’ve not gotten around to implementing better tracking yet.

Cascade Classification in OpenCV – Parts 1-9

Cascade classification is easy to work with in OpenCV, but it is not so well documented. This series of short videos explains how this is done on GNU/Linux-based systems (although it may be useful and applicable to other platforms too). The videos were not scripted or planned, so please excuse the occasional stuttering and mistakes.

Keywords: OpenCV android linux gnu ubuntu cmake eclipse computervision research haar tracking machinelearning

Android in Vehicles (Machine Vision)

I AM going to start an Android project quite soon, as my latest posts probably helped show. The drawback is that it will be less research-oriented and more implementation-oriented. On the other hand, Android is becoming de facto OS in the mobile market and it increasingly seems like Dalvik development is a valuable skill. My three siblings all use Eclipse and my fiancée studied Java back in the days as well, so it only makes sense for me to come back to Java. Currently we explore what the project will involve, with questions arising such as:

  • What features are simpler to implement for baseline functionality, e.g. collision detection?
  • What framework, e.g. opencv, is available for rapid development?
  • Possible technical collaborations of relevance?
  • What is the innovation worth exploring/adding?
  • Is stereovision (deriving 3-D) an option or just 2-D?
  • What products are already out there and how competitive are they?

PHP Sucks on Backward Compatibility (or How ‘Gallery’ and PHP 5.3 Don’t Play Nice)

As a bit of a dinosaur in technology (I still use a Palm PDA and single- or dual-core AMD), backward compatibility and long-term support are important to me. I am not a fan of PHP even though many programs that I like (the latest being Roundcube) use it almost exclusively.

Many problems seem to occur for those who use old versions of Gallery with the latest PHP, which has become notorious for its backward compatibility deficiencies. One bit of software that I use which is not compatible with PHP 5.3 is Gallery 1.x. It’s a version that I hacked a bit to suit my purposes, so upgrading would flush all my customisations away. Whether a sandboxed compatibility mode is available (such that, e.g., PHP 5.2 is run for specified paths) I do not know yet, but based on what people are saying suppressing the warnings and errors should be possible. It’s not a real solution but a cosmetic hack. If your Web host undergoes a PHP upgrade to 5.3 it can lead to lots of issues associated with out-of-date software. “A short time ago,” wrote my host (with which I host about 10 domains), “we emailed you to let you know that we were upgrading all our servers to the latest version of PHP. This is now complete. We therefore recommend you have a quick check of your site and ensure everything is working as it should.”

The bottom line is, from my personal point of view, is that PHP yet again proves that backward compatibility is too much for it to handle and, as such, one oughtn’t rely on long-term usage of programs written in PHP. Other authors pointed this out before. It’s quite the blunder. In Web-based environments in particular, a case of “lose compatibility or get cracked” may become more common if we become dependent on PHP.

Retrieval statistics: 21 queries taking a total of 0.332 seconds • Please report low bandwidth using the feedback form
Original styles created by Ian Main (all acknowledgements) • PHP scripts and styles later modified by Roy Schestowitz • Help yourself to a GPL'd copy
|— Proudly powered by W o r d P r e s s — based on a heavily-hacked version 1.2.1 (Mingus) installation —|