Ubuntu Hardy Heron: A great synch with whats in demand

I upgraded the dist to Hardy Heron, the Ubuntu 8.04. And my experience with it so far has been very satisfactory.
Its much more stable now. I found various stuff already bundled which previously I had to explicitly install. For me the good things bundled…

Firefox 3

Hardy provides Firefox 3(beta) by default, comparatively its a super fast browser now. I am desperately waiting for Firfox 3 final release. Once I was a bit upset to see that the Firbug is no more compatible with Firefox3 but then I found Firebug’s release 1.2 which works fine with Firefox3. Till yet have not found any problem and both are working fine. Firefox3 is certainly quite faster.

Ruby 1.8.6

Provides Ruby 1.8.6 (patchlevel 111). Good!
The libmagick is also available but still the RMagick needs to be installed the way I posted here.

Pidgin

A one stop shop for almost all the messenger services like gtalk, aim, yahoo, irc and many more. In previous dist I had to install gaim.

This new ubuntu is operating quite faster and I am enjoying it a lot.

Filed in: hard_heron, ubuntu

by: Sur

4 Comments

RubyOnRails Plugin: Auto Tags

Announcing the release of this tiny useful plugin AutoTags.
A couple of weeks ago I travelled to Mumbai in train which was a long 17hrs journey… and I utilized that by coding down the idea while travelling. So here it comes…

AutoTags, an open source project, is a plugin for RubyOnRails applications to automatically generate the relevant tags for the provided content. Its quite simple to use and provide easy integration with ActiveRecord. The plugin is very useful for social applications, community websites and all those networking applications where there is a scope of user generate content to be tagged. No more heck for the admin to sit and add the tags to the content or waiting for the users to add the tags to their content.

For installation and usage read here.

If you liked the plugin then please recommend me on workingwithrails.

Filed in: auto_tags, networking, open_source, plugin, rubyonrails

by: sur

1 Comment

New in Ruby 1.9: Threads

The ruby is getting changed and improved a lot with every release. No doubt the existing demerits of rails are soon going to be history.

Currently for my rails applications I am running Ruby1.8… and exploring 1.9 to get ready as we are heading with nice speed in the rails developments. Modrails has already started making waves all around.
Soon I would be publishing a couple of posts on threads, processes and sockets in ruby… here is a bit on how they are going to be different in Ruby1.9.

In Ruby1.9 the threads implementation is going to be really different than what we all know/do in Ruby1.8. The Ruby1.8 uses a single native thread and runs all Ruby threads within that… which certainly protects the Ruby threads to take on much responsibilities and to completely leverage the hardware with multiple processors.

Now, the good news, the Ruby1.9 allocates a separate native thread for every Ruby thread. But at this very moment it is not fully functional… as because of some C libraries, used here, are not thread-safe that it will not allow Ruby1.9 to take control on multiple native threads. Still, great signs of improvements in these directions… It has been mentioned that this restriction will be removed in the upcoming versions of Ruby1.9 and there will be full fledged implementation of multithreading in Ruby with multiple native threads, and the charm of parallel execution… means a lot more scope of improvements for all related libraries, frameworks built on the top of Ruby.

Filed in: ruby, ruby1.9, threads

by: sur

No Comments

Avoiding the Distractions

I was reading something about how to avoid the distractions and the article exemplified it using a scene from the Indian mythology ‘Mahabharata’ where the Guru Dronacharya asked all the students to aim at the bird’s eye sitting at a branch of the tree, then he asked what you can see… most students replied they can clearly see the branch, tree and the bird… only Arjuna said he can only see the bird’s eye… At that very young age he had learned the willingness of how to avoid the distractions which are joyful to you.

Here in this post I admit that gaming, especially playing ‘Tekken3′ is one of the biggest distraction for me. As whenever I spend continuous hours on work, I get the time out and start playing ‘Tekken3′ which surely very much joyful. But, actually I know I make reason to myself to play that game and not actually to take some time off to have rest. Playing game certainly gives some enjoyment but not exactly the rest, I still be in the same position on my desk, sitting on my chair, and playing the game instead of doing the work… so its almost that I am doing work and not giving rest to my body. So, basically I was not willing enough to say that the game is a distraction for me… instead I kept on saying that I am playing it to take a time out of the work, But its for sure a wastage of time. And now I am sure enough to say its purely a wastage of time as I have made a resolution to say NO TO GAMES. I am in my 20s and need to conquer many of my dreams and need to work really hard to do so… which will certainly require killing of all these distractions in my life. And I’ve started very well by signing off from games… Though its true that I have a dream to run a Gaming company… and if I would be able to do so… the Gaming will also be my work ;)
So, to take time out from my work I would rather now read my newspaper and I can now allocate the time I used to spend in reading newspaper back to work. Reading newspaper is a required task to be accomplished and would not be a reason to take a forced time out from the work… moreover I can relax while reading newspaper that I couldn’t do while gaming. I must say I have dumped a biggest distraction of mine.

Filed in: distractions

by: sur

1 Comment

Acts as solr: Logical Search

There are a couple of ways described in acts_as_solr documentation for the logical search, with AND or OR operations. But I needed to dig a bit into the code as the documentation is not complete and doesn’t suggest all the possible implementations of making the complex Logic Gates for searching.
Here I am consolidating various possibilities of Logical Search…

Find all blogs with category ruby or rails


  Blog.find_by_solr("category:rails category:ruby", :operator => :or)

another way


  Blog.find_by_solr("category:rails OR category:ruby")

Find all blogs with categories ruby and rails

  Blog.find_by_solr("category:rails category:ruby", :operator => :and)

another way

  Blog.find_by_solr("category:rails AND category:ruby")

Grouping for more precision

NOTE: mind the grouping using parenthesis, you might get unexpected results without proper grouping.

Find all blogs with categories ruby or rails with author Sur

  Blog.find_by_solr("(category:rails OR category:ruby) author:sur")

Find all blogs with categories ruby AND rails with author Sur

  Blog.find_by_solr("(category:rails AND category:ruby) author:sur")

Find all blogs with categories ruby or rails with author Sur or David

  Blog.find_by_solr("(category:rails OR category:ruby) (author:sur OR author:David)")

Find all blogs with categories ruby and rails with author Sur or David

  Blog.find_by_solr("(category:rails AND category:ruby) (author:sur OR author:David)")

Filed in: acts_as_solr, logical_search

by: sur

1 Comment

Mongrel to THIN

For Rails applications I am using THIN on my local machine since a couple of weeks and found it better than Mongrel. I’ve started replacing mongrel with THIN on servers as well. THIN leverages the best of the available resources… It uses mongrel’s parser along with the Eventmachine and the Rack Ruby libraries which together provide better speed, greater requests/sec and certainly consumes lesser memory.

Install THIN by issuing

  sudo gem install thin

THIN accepts more or less similar switches as that of mongrel. You start THIN by issuing

  thin start -p 9090 -d -e production

-p — port, defaults to 3000
-e — environment, defaults to development
-d — daemonize mode

THIN provides an in built support for clustering and running multiple servers for the same applications. You can start say 3 servers for the single application by providing the -s switch as…

  thin start -p 9090 -d -e production -s 3

And similar to mongrel it will start three servers on the ports 9090, 9091 and 9092.

Filed in: mongrel, thin

by: sur

7 Comments

Design-o-Logics: Today’s market is the market of Design

Today’s market is the market of the Design but the technology. Not only related to the web applications but in a very generic sense. The greatly designed application basecamp turned Rails into a favorite framework of numerous programmers all over the globe. But the non-tech end users who are using basecamp don’t even think on which tech it has been built. Its all design and usability that matters. If you are in product business, the technology matters when it comes to scalability. A lots of frameworks offers good scalability… Rails applications are now even much more scalable. The great thing, which certainly adds up much a +ve biasing to select Rails as a framework of choice is the boost it adds to the development speed for a product business. But, for a services and consultancy most people opt for whats in demand in the market. I really like working on rails, naturally in consultancy it gives good business and in product it adds up a speed which second to none.
But the only thing which is mandatory to be on top with any tech you select for your product is the design and the vice-versa doesn’t stand here.

Great words from great design enginners…

With the market being ultra-competitive and high on style, it is not enough to just have a good product — it has to score good on looks too.

Design gives the consumer an experience and not just a product, which, in turn, leads to a loyal customer base. This is one area where investments are small when compared to the benefits a company can get out of it.

It takes time fort a startup to realize the worth of design. A startup is also, more often than not, cash strapped and thus does not have funds to invest in designing, which is an area that requires huge investments.

Filed in: design

by: sur

No Comments

Nginx: Set up error pages

Setting up custom error pages are needed whenever the app goes in maintenance or when the code gets crashed :P … In Nginx, its fairly simple but once when you know it.

Say your app example.com is residing in /var/www/apps/example

Nginx configurations

say your existing configuration looks like…

  server{
      listen 80;
      server_name .example.com;
      location / {
           proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_set_header Host $http_host;
           proxy_redirect false;
           proxy_pass http://127.0.0.1:9002;
      }
  }

add the error page configurations

  server{
      listen 80;
      server_name .example.com;
      location / {
           proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_set_header Host $http_host;
           proxy_redirect false;
           proxy_pass http://127.0.0.1:9002;
      }
      error_page 500 502 503 504  /500.html;
      location = /500.html {
          root  /var/www/maintenance/example;
      }
  }

Create the required html error page at /var/www/maintenance/example/500.html.
Now, restart the nginx to reload the configurations by issuing /etc/init.d/nginx restart.
And you are done!

Filed in: nginx

by: sur

No Comments

New in Ruby 1.9: Block Scoping

Ruby 1.9 provides the block scoping of the local variables. It shadows the outside local variable in the block and allocates a new object_id in the memory to the block variable, which essentially means much more flexibility in using the lambdas without worrying about the name of the block variable. Remember that instance, class and global variables are still the same and can be used outside and inside the block as usual.

ruby <= 1.8

a = 9
p a # => 9
[1, 2, 3].each{|a|}
p a # => 3

ruby 1.9 (shadows the local variable a)

a = 9
p a # => 9
[1, 2, 3].each{|a|}
p a # => 9

Filed in: ruby, ruby1.9

by: sur

No Comments

Ruby interface for OpenSSL

If you have installed ruby using apt-get or if you have not mentioned the configuration option for openssl while installing from source, you can expect openssl will not work with ruby.

Here is the solution for the same…

Step 1

Install gcc and make(if you don’t have already on your box)

  sudo apt-get install gcc make

Step 2

Install the system level OpenSSL and dev libraries

  sudo apt-get install openssl libssl-dev

Step 3

Install the ruby’s openssl interface to the system’s openssl

switch the directory to the ruby’s source code’s openssl

  cd /usr/local/src/ruby1.8.6/ext/openssl

install the ruby’s openssl interface

  sudo ruby extconf.rb
  make
  make install

try requiring the openssl in irb

  require 'openssl'

if returns true, installed successfully!

Filed in: openssl, ruby, ubuntu

by: sur

1 Comment