Web Development

Setting Nginx, PHP Fastcgi and XCache on a new Ubuntu

Posted on

Recently, because of a mandatory VPS move I had an opportunity to migrate all my sites from apache to nginx. My old box was in a messy state and setting up a new box from scratch was always going to be fun. Here in this post, I will walk you through all the steps that helped me migrate seamlessly. Specially, how did I setup the new box ensuring zero downtime on the sites. Ensuring zero downtime while migration: By the time I will pin up various pieces on my new vps box, I didn’t want my site visitors to see […]

XMPP

Setting up ejabberd 2.1.x development environment on Ubuntu

Posted on

apt-get provide a convenient way of installing ejabberd on Ubuntu distributions. However, if you are an erlang developer and looking to write custom ejabberd modules, you might want to install ejabberd from the source code. Checkout ejabberd source To start with lets grab the ejabberd 2.1.x branch source code: sudo apt-get install git-core git clone git://git.process-one.net/ejabberd/mainline.git ejabberd cd ejabberd git checkout -b 2.1.x origin/2.1.x cd src Installing pre-requisites Lets setup necessary pre-requisites before compiling ejabberd source code: sudo apt-get install build-essential sudo apt-get install automake autoconf sudo apt-get install erlang erlang-manpages sudo apt-get install libexpat1-dev zlib1g-dev libssl-dev Compiling ejabberd source […]

Open Source

WordPress Toolbar v 2.2 : Custom toolbar url, Support for WPMU and bug fixes

Posted on

WordPress toolbar plugin provide a facebook, digg style toolbar for all outgoing links from your blog posts. The toolbar url defaults to http://yourblog/wp-content/plugins/wordpress-toolbar/toolbar.php. However with version 2.2, blog admin can customize toolbar url to http://yourblog/wordpress-toolbar/ through the admin panel. A lot of other enhancements have been added like cross-plugin compatibility and support for WPMU hosted blogs. Check full feature list below. What’s New? Listed below is list of new features and bug fixes released with v 2.2: Support for customizing toolbar url through admin panel Support for WPMU hosted blogs Support for removing “Get this Plugin” widget from the toolbar […]

XMPP

Writing your first facebook chat bot in PHP using Jaxl library

Posted on

Today facebook officially announced availability of it’s chat through jabber/xmpp clients. This is a big win for XMPP, with almost 400 million new probable users adding into XMPP club. In this post, I will demonstrate how to connect to facebook chat servers using Jaxl client library in PHP. It can further be used to make custom chat bots for facebook. Creating your first facebook chat bot: Follow the steps to successfully run a facebook chat bot: Download Jaxl or checkout latest from trunk svn checkout http://jaxl.googlecode.com/svn/trunk/ jaxl-read-only Edit the configuration file config.ini.php as follows: // Set an enviornment $env = […]

PHP

MEMQ : Fast queue implementation using Memcached and PHP only

Posted on

Memcached is a scalable caching solution developed by Danga interactive. One can do a lot of cool things using memcached including spam control, online-offline detection of users, building scalable web services. In this post, I will demonstrate and explain how to implement fast scalable queues in PHP. MEMQ: Overview Every queue is uniquely identified by it’s name. Let’s consider a queue named “foo” and see how MEMQ will implement it inside memcached: Two keys namely, foo_head and foo_tail contains meta information about the queue While queuing, item is saved in key foo_1234, where 1234 is the current value of key […]

WordPress

JAXL BOSH Demo: IM chat client for all WordPress blogs

Posted on

Have you ever wished of a wordpress plugin capable of providing a facebook style chat bar on your blog post. In this blog post, I will lay down the details of how Jaxl‘s bosh support comes in handy for building such browser based real time application. Specifically, I will explain how I achieved building a plugin for my wordpress blog. If everything goes perfect over next few weeks, this plugin might be submitted in wordpress plugin’s directory. Jaxl BOSH Support Framework Jaxl BOSH support comprise of three main parts: jaxl.jquery.js: JQuery extension written for Jaxl bosh support jaxl4bosh.class.php: Connection manager […]

XMPP

Get real time system & server load notification on any IM using PHP and XMPP

Posted on

There are various system and server related information which server administrators always need to have as soon as possible, infact I must say in real time. There are several open and closed source softwares in the market which can generate almost real time notifications for you. Most famous one being Nagios. In this blog post I will discuss, how to generate real time system notifications using PHP and XMPP. Specifically, I will present sample script using Jaxl (Jabber XMPP Client Library) for generating real time system load notifications, which can be received using any Instant Messengers. /proc/loadavg We will be […]

XMPP

Get lyrics for any song using XMPP and PHP right into your IM – Add [email protected]

Posted on

XMPP is soon finding it’s way into real time applications other than just chat. I have combined JAXL (Jabber XMPP client library written in PHP) and the API from lyricsfly.com to build a real time chat bot which can assist you with lyrics for any song. You can start using it by simply adding [email protected] to your IM account (e.g. Gtalk, Jabber etc). In this blog post, I will explain in brief the working of lyricsfly bot and how you can integrate XMPP into your own application. Try out [email protected] Follow the following steps to get the bot working for […]

Scalability

WordPress style “Duplicate comment detected” using Memcached and PHP

Posted on

If you have a knack of leaving comments on blogs, chances are you might have experienced a wordpress error page saying “Duplicate comment detected; it looks as though you’ve already said that!“, probably because you were not sure that your comment was saved last time and you tried to re-post your comment. In this blog post, I will put up some sample PHP code for Duplicate comment detection using Memcached without touching the databases. Towards the end, I will also discuss how the script can be modified for usage in any environment including forums and social networking websites. Duplicate comment […]

PHP

How to use locks in PHP cron jobs to avoid cron overlaps

Posted on

Cron jobs are hidden building blocks for most of the websites. They are generally used to process/aggregate data in the background. However as a website starts to grow and there is gigabytes of data to be processed by every cron job, chances are that our cron jobs might overlap and possibly corrupt our data. In this blog post, I will demonstrate how can we avoid such overlaps by using simple locking techniques. I will also discuss a few edge cases we need to consider while using locks to avoid overlap. Cron job helper class Here is a helper class (cron.helper.php) […]