Canned Atropine!!

Navigation Menu

Using AJAX in Laravel

Posted by on in iDevelop, Javascript, 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

Setting up a PHP Development Environment - v2

Posted by on in iDevelop, PHP | 13 comments

Sometime back I wrote a step-by-step guide for setting up PHP development environment in a virtual machine. This is a simplified (& less tiring) version of that.

You’ll need a few things to proceed:

  • A computer, ofcourse. I used a MacBook Pro running OS-X Lion.
  • Oracle’s VirtualBox VM software – get it from here.
  • A linux distro. We will use Ubuntu Server here. Current LTS version is 12.04. Download the 32 bit ISO from here. Remember to download 32 bit version, the 64 bit version is kinda sluggish on less than 4 GB of RAM. 32 bit version is good enough for running web development stack unless you have specific needs.

 

Read More

iG:Twitter Cards - now available.....

Posted by on in iDevelop, iG:Twitter Cards, PHP, WP-Plugins | 0 comments

Twitter Cards are quite the rage now when it comes to sharing your stuff on Twitter. They add that zing to sharing. But there are loads of plugins for WordPress already, so why did I create my own?

Well, here’s the brief rundown:

  • The ones I saw, none of them are WordPress.com VIP compliant
  • Most just get the job done but the code is well….. unhealthy!
  • The ones I saw, none supported player card
  • I needed filters to be able to override the output etc. fully or partially
  • Being the attention seeking douche I am, I wanted to roll my own plugin 😀

Its all pretty easy and neat to use. Just activate the plugin, set a few global options on plugin settings page and done. By default it produces summary card tags for all posts and pages. If you want finer control or want player card for any post or page then select the global option for control on post pages and it will provide a meta box on post/page add and edit pages in wp-admin where you can set card to player card.

Read More

Brouhaha & moaning over Blink, Webkit.....

Posted by on in iDesign, iNews | 0 comments

So Google announced that it is forking Webkit (the rendering engine which powers its Chrome browser, & Apple’s Safari among others) and will be making significant changes to it under the project named Blink. All of a sudden exasperated bemoaning of idiots started which included run of the mill phrases like “web fragmentation”, “browser wars”, etc. And all that without seeing what Blink will bring to the table? Seriously?!! 🙄

Read More

PHP equivalent of Rails' to_sentence()

Posted by on in iDevelop, PHP | 0 comments

So Corey popped a question last night in company chat room on whether WordPress has an equivalent of Rails’ to_sentence() function or not. The answer was no it doesn’t, & I thought heck that can be written quick!

Here is what I wrote quickly (and updated after that):

It can be further improved, the evaluation of three cases in switch can be removed entirely as demonstrated here.

Read More

Updating a cache automatically

Posted by on in iDevelop, PHP | 0 comments

A change that I pushed in iG:Syntax Hiliter v4.2 was that shorthand style tags were enabled for all languages. Apart from the GeSHi language files bundled in the plugin, you can add additional language files in the “geshi” directory of your theme and those will be picked up by the plugin. Since the architecture of the plugin relies on Shortcode API of WordPress rather than doing its own regex for tag parsing, the plugin always needs to know what language files are available to it to be able to allow shorthand style tags else the code blocks won’t get picked up by the plugin.

Read More

iG:Syntax Hiliter v4.2

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

iG:Syntax Hiliter v4.2 is now available for download. Some bugs have been fixed in v4.1 and v4.2 along with a few new additions and improvements, some of which are:

  • Additional language files can be put in “geshi” folder inside current theme so that the files won’t get overwritten on plugin upgrade
  • Github Gist embed XSS bug fixed
  • Shorthand tags for all languages are now supported
  • A code block is parsed only once, subsequent similar code blocks in same post/page use the same output, for better performance

A more detailed changelog is available here.

Read More