SSH Tunneling for Ruby on Rails app

It is quite annoying to develop and test an app which is likely to receive data/notification from a third party site if your development computer isn’t globally reachable. You have to deploy to a server and test it and do this each time until it completely works. Examples of such cases include:

  • Facebook app development
  • PayPal or any other payment gateway integration

While there are probably several options, SSH Tunneling is the simplest, at least to me. It needs less than 2 minutes to configure. Let’s do it.

I’m assuming:

  • You’ve a dedicated server/VPS with root access or somehow access to sshd_config file (we’re going to call this remote server)
  • Your domain is and which points to the above server with IP
  • You wanted the remote server to listen to 80 port
  • You’re running your rails server at port 3000 in your development computer (we gonna call this local server)

(You may have to change the values marked in italic font as your own settings)
Continue reading →

Ruby and MongoDB Web Development Beginner’s Guide Review

I remember the days when I’ve used MongoDB  in simple Ruby on Rails (RoR) project using Mongoid. It’s so simple to use MongoDB with RoR without knowing much about it. While using MongoDB, as a project requirement, I became more interested about it and decided to dig more. The moment I wanted to learn more about it, I found the book Ruby and MongoDB Web Development written by Gautam Rege. Thank goes to my colleague Rubayeet Islam, who suggested me this book. When I started reading it, I started feeling at home as I’ve already familiar with several Ruby/Rails/MongoDB concepts that I’ve learned during my works. However, here is my overall feelings about the book.

The first four chapters of the books talks solely about MongoDB. You will learn how to install it, run it, query it, use complex queries etc. and all of these using the default mongodb client.

Continue reading →

PHP Application Development with NetBeans

I’m huge fan of NetBeans IDE for PHP based application development. Though I’m fully comfortable writing codes in text editors developed in mediavel ages :p, I’ve seen how IDEs like NetBeans let you concern about your application problem only while they take care of project management, code refactoring, syntax highlighting, versioning, code completion and any other features.

However, we can get most out of IDE (and anything) if we knew its usages very well. NetBeans were missing such manuals until recently a guide is written by PHP developer M A Hossain Tonu. The title of the book is PHP Application Development with NetBeans which is published by Packt Publishing, U.K.

Continue reading →

Rails scaffold, create .haml rather than .erb views

After being tired of refactoring .erb files to .haml I headed for a way to modify the rails generator that will create .haml view files rather than .erb view files.

After a while, I found what exactly I needed. ‘haml-rails’ is the name of the solution. This is how you do it.

Add the following line to your Gemfile:

gem 'haml-rails'

Then run the bundler (bundle install).

Now append the following lines in your application.rb file (at the end of Application class):

config.generators do |g|
   g.template_engine :haml

That’s it. Your new scaffolds will generate .haml files (and obviously haml syntaxes) for you.

This is much easier than Haml-scaffold.

How to avoid or skip Trash in WordPress

If you come to this post, it is highly possible that yo are already annoyed by the Trash feature of WordPress that was introduced in its version 2.9.

I personally find it very helpful in live sites but I believe no one than me is annoyed most by it on development site. However, WordPress is always sweet and its programmers has longer nose. So they put a configurable option to adjust it.

All you need is to add a line in wp-config.php file. You will need to add a constant like:

define('EMPTY_TRASH_DAYS', 0);

That’s it. The trash button from your WordPress will just elope and your old loving Delete button will come back:).

One more thing, by default WordPress keeps stuffs in trash for 30 days. So if you want to keep the posts in Trash for 3 days, write like:

define('EMPTY_TRASH_DAYS', 3);