For a cd based time limited working copy, of one of our products, I decided to port our mysql application to sqlite3. Since we had about 70 tables, and all with optimized indexes, and about 24 user defined function 3 triggers and 12 procedures, normally anyone would have thought of simply getting along with the mysql system itself. But I wanted to face the challenge. Thanks to Rob Cameron for the shell script published on his blog RidingTheClutch, Convert a MySQL database to a SQLite3 database, which sparked my thoughts.
Continue reading “Convert MySQL Database to SQLite3 Database”
Author: Jiju Thomas Mathew
Lighttpd – Separate log files for each vhost
I could not resist digging into my administrative and shell experience when I saw that somebody wrote a php script to dynamically split lighttpd logs. Hmm I use php for more complicated stuff.
I achieved this by putting the following into lighttpd.conf
accesslog.filename = "|/usr/bin/splitlog.sh"
Continue reading “Lighttpd – Separate log files for each vhost”
Automatic image sizing with static delivery – WordPress Enhancement
Recently I got fed up trying to convince the operators of a client, for whom we had implemented a wordpress site. The operators, even after we repeatedly asked to upload only relevant sizes for certian positions, were trying to make one size fit for all. Hell, places where thumbnails of 1 to 2K would suffice, were being used up by 30K images, resized by our theme constraints. We were running wordpress on lighttpd.
Continue reading “Automatic image sizing with static delivery – WordPress Enhancement”
JSON feed for WordPress
Pretty simple, really. Adds a new type of feed you can subscribe to. Simply add ?feed=json to anywhere you get a normal feed to get it in JSON form (but with a cutdown version of events).
Version 1.1 added support for JSONP. To get a JSONP response instead of a normal JSON structure, simply add jsonp=callbackName to your query, where callbackName is the name of the function to be wrapped with.
Author: Chris Northwood
Download: WordPress Plugin Repository
Short PHP twitter-counter
While strolling around I found some bits and pieces which I put together to get a short twitter counter in php.
<?php
ob_start();
$json = file_get_contents("https://twitter.com/statuses/user_timeline/php_trivandrum.json?count=1");
$data = json_decode($json, true);
ob_get_clean();
echo $data[0]['user']['followers_count'];
?>
Nothing more to write now..
Speeding up WordPress home page
After about an year, since we launched Asianet News Portal the home page with all the complications had started to show a dead slow performance, and by using our Query Profiler, I could identify the bottleneck as the number of queries, and wordpress itself was telling the status as 48 queries in 6.344 seconds. Now this was a whopping value, and when the latency of 2 to 3 seconds is added to this, the initial html load would be in 9 seconds. Making the total site complete load in about 53 seconds. One can imagine the agony I was feeling, after all the work I had done to get backlinks, and if users who are visiting the site is just running away without waiting for the site to load, then I better not run the site atall.
Continue reading “Speeding up WordPress home page”
MySQL FileSystem – A PHP Implementaion
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. Continue reading “MySQL FileSystem – A PHP Implementaion”
Paged Navigation – My own way
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.. Continue reading “Paged Navigation – My own way”
Fun digging into WordPress XML RPC
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.
Continue reading “Fun digging into WordPress XML RPC”
Importance of event logging in server side scripting
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.
Continue reading “Importance of event logging in server side scripting”