Redirect WordPress XMLRPC Clients to a Custom Post Type

Lets say you want to post from your Android or Iphone WordPress clients to a custom post type instead of the the defualt ‘post’ type. Paste the code below in your functions.php and you should be good to go 🙂

function redirect_xmlrpc_to_custom_post_type ($data, $postarr) {
    $p2_custom_post_type = 'custom_post_type'; //Change this to the custom post type you are using for your blog
    if (defined('XMLRPC_REQUEST') || defined('APP_REQUEST')) {
        $data['post_type'] = $p2_custom_post_type;
        return $data;
    return $data;

add_filter('wp_insert_post_data', 'redirect_xmlrpc_to_custom_post_type', 99, 2);

Change $p2_custom_post_type = 'custom_post_type' to the custom post type you are using for your blog.

Now I can post from my Android Phone to my custom P2 micro-blog 🙂

Run Unique/Multiple Instances of Okular

Usually, when you open PDF files in Okular, it opens in the same okular window all the time. However there are times when you want to refer to more than one pdf file at the same time and would need multiple instances of the software to run. The way to get Okular to run unique instances is by firing it with the --unique argument.

okular --unique

You could also put this in your .bashrc or .bash_aliases if you want it as a permanent fix.

alias okular="okular --unique"

Host Custom Gems with Dreamhost – Your Own Gem Server

I have started working on a webapp on Heroku. Heroku requires you to specify where your external gems come from. This is nice as you can specify a RubyForge, RubyGems, GitHub or any repository for that matter. However RubyGems is the de-facto gem host these days. All the gems on RubyGems have owners/co-owners and only they can update/upgrade the gem. Now what happens if you have a lazy gem owner who hasn’t updated the gem for over 2 years? You get an outdated gem. The only option is to update the gem yourself and host it elsewhere. Thats what made me create my custom gem server on Dreamhost. Continue reading

PPA Updates for Ruby 1.9.1 and Ruby 1.9.2 – Handling Ruby Versions using the update-alternatives system

I recently created PPAs for Ruby 1.9.1 and Ruby 1.9.2. The default Ruby 1.9.1 package creates binaries in /usr/bin with names like ruby1.9.1, irb1.9.1 etc. However a lot of scripts depend on /usr/bin/ruby and /usr/bin/irb which are provided by Ruby1.8. Hence when I created the PPA for ruby1.9.1, I hardcoded the symlinks – /usr/bin/ruby1.9.2 => /usr/bin/ruby etc. Continue reading

Custom dynamic_sidebar Function to Generate Class Definitions Corresponding to a Widget’s Position

In wordpress, if 2 widgets are stacked horizontally, there is no straightforward way of setting the width of the left widget as x and that of the right widget as y through php/css. The only way to accomplish that is by using hardcoded class definitions in the css. I have jotted down an easy solution for this problem in the wordpress ideas forum. However the code that I pasted looks all gibberish because most of the HTML tags in the code are not allowed. Hence this post for anybody who wants to see the code and other details. Continue reading