Blog on WordPress using Sublime Text

Since I moved to a Mac, I started feeling a strange lack of freely available software for things I took granted on Linux(or Windows). Lets face it, OSX offers little choice in terms of software powertools. I was looking for a wordpress client for Mac and all I could find was very costly alternatives will even less functionality as their opensource Linux counterparts. As I spent quite a lot of time on Sublime text, I thought of exploring Sublime as a blog client. I stumbled upon Sublpress. If you are familiar with Sublime Text, you will already be using its excellent Package Manager. Installing Sublpress using the package manager is super-easy.

Open the command palette in Sublime Text and search for Package Control’s “Install Package” command. From there you should be able to search for “Sublpress” and have it automatically installed.

Once you have Sublpress installed, open sublime text command palette (CMD+Shift+P) and type WP: Manage Sites. A blank configuration file will be created for you where you can enter your wordpress credentials and type WP: Connect to Site. It’s that easy. Happy blogging.

 

How to recover your wordpress blog on heroku after recent upgrade

Recently heroku upgraded and migrated their postgres database to a different stack – unfortunately that broke wordpress blogs hosted on heroku. I wrote a detailed article on how to host your wordpress blog on heroku some time back – I found a few very useful wordpress bootstraps for heroku. After the recent upgrade, all the wp-config settings were invalidated and your wordpress blog could not connect to the database. There are two things to notice :

  • Your database is safe – its just moved and renamed
  • You need to edit your wp-config to change the db settings to the migrated database

But, where on earth is my wp-config.php ? If you are like me, you dont have the original copy which you used to create your blog in the first place. Many of you might not have hosted that wordpress installation on github. So how to update the wp-config ?

Trick is to know that heroku internally has a github link to every app it hosts. You will need to find which github repo heroku is internally linking your application to and you will need to find the modified database name, username, password and host.

  • Finding github repo for your app is easy. Login to heroku and click on the app that is used to host your blog.
  • Check the ‘Settings’ tab and you will find something like – Git URL: git@heroku.com:yourapp.git
  • <yourapp> is the actual name your app
  • Now head back to your terminal and clone this particular repo as follows


git clone git@heroku.com:furious-robot-218.git -o heroku
Initialized empty Git repository in /Users/adam/facebook-template-php/.git/
remote: Counting objects: 273, done.
remote: Compressing objects: 100% (183/183), done.
remote: Total 273 (delta 2), reused 261 (delta 0)
Receiving objects: 100% (273/273), 25.55 KiB, done.
Resolving deltas: 100% (2/2), done.

  • Once your code is cloned locally, head over to ‘Resources’ tab and you will find a link to ‘Heroku Postgres Dev :: Cobalt’
  • Clicking on this link will show you a page where you will find the migrated DB name, username, password and host – Note these down
  • Head back to your local terminal and edit wp-config.php file and modify the following with the new values :


/** The name of the database for WordPress */
define('DB_NAME', 'new_value');
/** MySQL database username */
define('DB_USER', 'new_value');
/** MySQL database password */
define('DB_PASSWORD', 'new_value');
/** MySQL hostname */
define('DB_HOST', 'new_value');

  • Once you have updated wp-config.php with the modified values. Push it to heroku as follows:


$ git commit -am "changed greeting"
[master 0ff313a] changed greeting
1 files changed, 1 insertions(+), 1 deletions(-)
$ git push heroku
...

Thats it. Your modified settings are uploaded to heroku and your app is restarted.

 

rdesktop : With Cleartype ?

Ever tried running Windows 7 as remote desktop using rdesktop? I always wonder why the earlier enabled ClearType settings are disabled on rdesktop. Try the following flag :
-x 0x80
More details on how to arrive at this flag – check this blog.

 

Java's LinkedHashMap – demystified. Sort of.

A few days back I came across a problem : Design a system with following APIs :

  1. put(n) : Puts the value n
  2. get() : Gets the first added value

Obviously, this was a queue because we want get() operation to return the element added first. Here the order of adding elements is important. So far, things look good. We create a Queue using a doubly linked list with head and tail pointer so that get() and put(n) are both O(1) operations.

How about adding one more operation to this system? We want to add an API – removeElement(n) – that removes an element n from the queue in best possible time. Hmm, we have a problem. What options do we have ?

… 

 

rbenv and Passenger – not a good idea.

I read a lot of hype around how rbenv is the best thing since sliced-bread (RVM) – so on a fresh machine, I jumped ahead and installed rbenv instead of RVM – wow, and I loved it instantly. Setup was fast and nothing broke…umm, well not exactly.
I remembered that all my weekend hacks are hosted on servers crunching rubies out of RVM and I am still using Capistrano (with RVM integration) to remotely deploy my code.

Is there a way to use Capistrano with rbenv ? The problem is that passenger does not recognize rbenv’s rubies (check my stackoverflow – ) – so passenger can’t be spawned by nginx. I did not find any answers.
Finally, I removed rbenv and switched back to RVM (but not without problems).

One important thing to remember while installing RVM as root (you will be doing this on your own hosted machines) is that when you deploy your app with Capistrano, always add the following line to your deploy.rb file :

set :rvm_bin_path, “/usr/local/bin”

or you will hit – https://github.com/capistrano/capistrano/issues/43 while doing cap deploy:setup.

 

Move icons from Message tray (bottom tray) to the Top Bar in Gnome shell

Some might find the notification area icons showing up in the Message Tray (at the bottom of the screen, hidden by default) annoying or confusing. But you can move the icon on the Top Bar using an extension:

sudo apt-get install git-core
cd
git clone https://github.com/rcmorano/gnome-shell-gnome2-notifications.git
sudo cp -r gnome-shell-gnome2-notifications/gnome-shell-gnome2-notifications@emergya.com /usr/share/gnome-shell/extensions/

Then press ALT + F2 and enter “r” to restart GNOME Shell.

 

Microcaching

Happened to stumble upon this fantastic writeup on microcaching. A must read.

http://fennb.com/microcaching-speed-your-app-up-250x-with-no-n

 

Stanford comes to you…

This weekend (and few more) are going to be very interesting. Stanford has opened up a great line-up of courses.

 

Passenger can't compile nginx module under Ubuntu 11.10 ?

Ah! another post discussing Ubuntu 11.10 breakage. It seems that you can’t compile nginx module on passenger if you are on Ubuntu 11.10.

The error is something like :

common/libpassenger_common.a(aggregate.o): undefined reference to symbol 'pow@@GLIBC_2.0'

After some internet search, I found the following solution. Go to directory :

/home/ved/.passenger/standalone/3.0.8-x86-ruby1.9.2-linux-gcc4.6.1-1002/support/ext/nginx

(Your path may vary based on your installation).
Edit file : config and move the following block :

ngx_feature="Math library"
ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs="#include"
ngx_feature_path=
ngx_feature_libs="-lm"
ngx_feature_test="pow(1, 2)"
. auto/feature
if [ $ngx_found = yes ]; then
CORE_LIBS="$CORE_LIBS -lm"
fi

after this block :

ngx_addon_name=ngx_http_passenger_module
HTTP_MODULES="$HTTP_MODULES ngx_http_passenger_module"
NGX_ADDON_SRCS="$NGX_ADDON_SRCS
${ngx_addon_dir}/ngx_http_passenger_module.c
${ngx_addon_dir}/Configuration.c
${ngx_addon_dir}/ContentHandler.c
${ngx_addon_dir}/StaticContentHandler.c"
NGX_ADDON_DEPS="$NGX_ADDON_DEPS
${ngx_addon_dir}/Configuration.h
${ngx_addon_dir}/ContentHandler.h
${ngx_addon_dir}/StaticContentHandler.h
${ngx_addon_dir}/ngx_http_passenger_module.h
${ngx_addon_dir}/../common/Constants.h"
CORE_LIBS="$CORE_LIBS
${ngx_addon_dir}/../common/libpassenger_common.a
${ngx_addon_dir}/../common/libboost_oxt.a
-lstdc++ -lpthread"

Try recompiling nginx again by “passenger start” – see if it works. If you are curious on how this works, take a look at

 

VMPlayer not compiling for latest Linux kernel ?

I recently upgraded my kernel to 3.0.0.12 and found VMPlayer failing to compile. After so much failed attempts to search over the internet, I failed to compile VMPlayer. VMWare has not provided any patches.

This article(see comment:56) is written for 3.0.0.9 but works fine for newer kernals also.


$ lsb_release -rd
Description: Ubuntu oneiric (development branch)
Release: 11.10

$ uname -a
Linux myUBT 3.0.0-9-generic #15-Ubuntu SMP Tue Aug 30 15:03:37 UTC 2011 i686 i686 i386 GNU/Linux

——-
STEPS:
——-
Close VMware dialog from where you got the error. (no need to uninstall/remove VMware)

sudo -i
mkdir /tmp/vmware && cd /tmp/vmware
cp -R /usr/lib/vmware/modules/source/
cp -R /usr/lib/vmware/modules/source/ /tmp/vmware
cd /tmp/vmware/source
wget http://weltall.heliohost.org/wordpress/wp-content/uploads/2011/05/vmware2.6.39patchv3.tar.bz2
tar -jxvf vmware2.6.39patchv3.tar.bz2
for i in ./*.tar; do tar -xf $i; done
for i in ./*.tar; do mv $i $i.orginal; done
patch -t -f -p1 < vmware2.6.39fixedv3.patch
tar cf vmblock.tar vmblock-only
tar cf vmci.tar vmci-only
tar cf vmmon.tar vmmon-only
tar cf vmnet.tar vmnet-only
tar cf vsock.tar vsock-only
cp -vf *.tar /usr/lib/vmware/modules/source/

Run VMWare Player