Archive

Archive for October, 2009

MySQL FileSystem – A PHP Implementaion

October 28th, 2009 No comments

After reading Using MySQL as a filesystem, by Ben Martin @ linux.com, I had been pondering over the idea for a long time. And a couple of sleepless nights, the base for phpmyfs, a mysql file storage engine using php at the front end is almost ready.  This is not yet production ready, though the image, or media management part is upto my expectations. Read more…

Paged Navigation – My own way

October 24th, 2009 No comments

Recently while working for a wordpress plugin, though there are a lot of solutions for this, I could not find the exact thing which I needed, and thought about writing one of my own. Just writing it and using in the current project would be a waste, so thought I would slap it on here. It would help me in the long run.. Read more…

Fun digging into WordPress XML RPC

October 18th, 2009 1 comment

Once we achieved 20K visits per day at asianetindia.com (maintained by Saturn SPL), we planned to hammer in and our target was 30k in three months. We have achived that view the stats. For this twitter and blog helped a lot. We had added auto blogging, and wordtwit both to the existing asianetindia.com. It means each post when published will be tweeted, as well as a post to blog, which contains the excerpt with a back link to the original.

We wanted to get maximum links back into the blog also, and thought that a track back would be the best method and choose that against auto commenting systems. And a full time tester was doing linking related news and posts from other sites to our blog posts. It started to turn tiring when thought of the volume that was getting posted in a day. At this point, we at saturn started to think of automating the linking drive. The out come is autolinker, which is run using the random cron.
Read more…

Importance of event logging in server side scripting

October 12th, 2009 No comments

Now a days script driven web applications are getting more and more complicated with background operations and triggered events. Debugging or event tracking is tough once the application is moved into production. Fresh and aspiring programmers are always too cautious to wade into deeper waters, and always go with line by line testing. Almost always in the course of debugging or code optimizations I see a lot of them using file_put_contents or echo to check variables at a particular point of execution.

I always gave the pressure to use a good logging system from the start itself, and to add level based message logging with debug_backtrace wherever needed. The most recent class abstraction for php programmers which is being used in our custom framework is attached to the downloads here. The file logging is being done after serializing, compressing and base64_encoding to keep logs in single lines, and to make sure they dont take up too much of the space.
Read more…

Binary tree in MySQL for MLM

October 3rd, 2009 35 comments

Recently for a student, I was asked to explain the design considerations of a Binary Tree which was to be used in an MLM solution. About 10 years back it was a nightmare, and in my career, I was lucky to get that privilage for more than a dozen times with varying schemes and structures. But now with MySQL having procedures, and functions, the tree design and related functions were a breze. Reproducing it here for future reference. This is in no way a complete solution, but just bits and pieces which may even be discarded as crap.

CREATE TABLE  `binTree` (
  `nodeid` int(10) unsigned NOT NULL auto_increment,
  `lnode` int(10) unsigned NOT NULL default '0',
  `rnode` int(10) unsigned NOT NULL default '0',
  `pnode` int(10) unsigned NOT NULL default '0',
  `pside` enum('l','r') NOT NULL default 'l',
  `tLevel` int(10) unsigned NOT NULL default '1',
  PRIMARY KEY  (`nodeid`),
  KEY `parent` (`pnode`),
  KEY `treelevel` (`tLevel`),
  KEY `lside` (`lnode`),
  KEY `rside` (`rnode`)
) ENGINE=MyISAM;

The above is the basic structure of the tree table, and some complementary functions and procedures are accompanied to make the usage simple, otherwise would be a herculian task for the developer to do the same.
Read more…