Canned Atropine!!

Navigation Menu

Fixing data encoding in a MySQL database

Posted by on in iDevelop, PHP | 0 comments

Offlate I’ve been working on a pet project, part of which involved restoring an old MySQL database. The backup was of MySQL data files and not a SQL dump. However, restoring database from those data files was not much of an issue; I just hopped over to PuPHPet and downloaded config for a VM which was quickly setup, MySQL data files copied over to /var/lib/mysql/<db-name>, repair command run and a SQL dump created.

Read More

iG:Syntax Hiliter v5.0

Posted by on in iDevelop, iG:Syntax Hiliter, PHP, WP-Plugins | 0 comments

iG:Syntax Hiliter v5.0 is now available for download. Its been about two and half years since last release of v4.2 (v4.3 was a bugfix release made next day).

What has changed?
Well, lots on the code front, a bit on the user front. Some of those things are:

  • Language file/name cache was not re-building automatically, fixed now.
  • Finer control over GeSHi behaviour & code parsing.
  • Plugin stylesheet can be disabled if you want to use your own for code boxes.
  • CSS & JS assets are enqueued only if they’re needed.

This version sees a major code over-haul, a major re-write/restructuring of the code which has resulted in a cleaner, modular & better performing code. Also the PHP version requirement has been bumped up to PHP 5.3.0. The core code of the plugin would not load if installed PHP version is less than 5.3.0, fail gracefully & show you a friendly notice in wp-admin about it.

Read More

Abstract properties in PHP

Posted by on in iDevelop, PHP | 3 comments

What are abstract properties? There are abstract methods but the notion of an abstract property seems a bit ridiculous. Why so, you might ask! Well, the thing is, methods are declared & defined (not necessarily at same time). So you can declare a method without actually defining it (ie., no body, no set of commands which it will execute) and the same can be defined at a later stage. But there is no such thing as defining a property of a class; properties are always declared as containers of data which reserve a space in memory on class initialization.

Read More

Supercharged Models in Laravel

Posted by on in iDevelop, PHP | 0 comments

When I was first started playing around with NodeJS few months back, I came across Mongoose, a really neat ODM for MongoDB. You just needed to define the schema for each entity and pass it to that model and Mongoose would validate all data against that schema. That concept kinda intrigued me, as you wouldn’t need to create your own validation for the data.

Read More

API Design, Consumption & Sanity

Posted by on in iDevelop | 0 comments

Few days back I was going through the usual rounds of some forums I visit now & then and once again I came across more than one post where some poor soul used undocumented API of a library/package to achieve his goals and when the next update came out for the said library/package, his shit broke because the API changed in a stupid way.

Read More

Using AJAX in Laravel

Posted by on in iDevelop, PHP | 24 comments

This question came up in a forum where I drop by now & then. It is also something that I recall answering previously on one or two occasions. So I thought I’d write about it here with a rudimentary example to provide a gist of how it works.

There’s no mystery or secret voodoo involved in having AJAX work in a Laravel app. On its own Laravel 4 (current version) doesn’t have any API for implementing AJAX, so you’ll need to do the footwork yourself. The basic concept that applies everywhere else applies here as well; grab the data from a HTML form, create an AJAX request and send it to server to a URL on which data is expected. Form data is retrieved on server just like any normal form data would be, the only key part is since you’re dealing with an AJAX request you can’t send back a normal View as response, you’ll need to make your own response with proper headers.

Read More

PHP: Which framework??

Posted by on in iDevelop, PHP | 2 comments

At recently concluded BarCamp Delhi 10, there was more than one discussion on frameworks, be it Javascript or PHP. There are a lot of frameworks around for just about everything – server side stuff (like for PHP, Ruby, Python, Java etc), layout (CSS frameworks) or client side frameworks (for Javascript). Over the years I’ve tried out & played with a number of them across different programming languages but since I mainly work in PHP, lets talk about that here. I wrote a similar blog post about 7 years ago which referenced a comparison done by someone else and which I used as a point of reference to choose a framework which best suited me, but times have changed a lot and so have the requirements, expectations etc.

Read More

Of stupid NPM & symlinks on guest OS in VirtualBox

Posted by on in iDevelop | 3 comments

A week or so ago I finally got around to installing Node.js and started playing around in it. So far I liked what I saw, ie., till this weekend when I decided to grab Express.js and play with that. Now, I run Ubuntu (server edition) as a VirtualBox VM on my Mac OSX and primarily use it as LAMP stack for developing on WordPress. I installed Express.js globally via NPM for ease of use (since its dev environment & I like not having to install it for every project) and here came the first bummer. In NPM 1.10.0, the path where global Node modules are installed changed and Node is unaware of this change so far. 😮 So when I created the Express.js project and ran the app.js, it threw up error as it couldn’t find Express.js module. Looking up on this revealed that NPM installed Express.js at /usr/local/lib/node_modules/ which isn’t the place where Node.js looks for global modules. So the way to resolve this situation is to go into project folder and run the following command:

Read More

Zen of WordPress development.....

Posted by on in iDevelop, PHP | 1 comment

At BarCamp Delhi 9 someone asked me how I go about developing on WordPress and what would I advice to someone starting on it. We had a good discussion at length & though its been a couple of months since then, I thought I’d share my insights here as well.

Basics:

The usual basics and good development practices apply here as well, so keep them in mind. WordPress has documented & sane coding standards, so make sure you understand & follow them. Other basic principles like DRY, KISS, etc. also apply. If you don’t already, then document your code. Use code comments extensively, document each function and every complex code block.

Read More