Archive

Archive for the ‘Technology’ Category

Monit apache with passphrase enabled SSL

May 26, 2009 Ritu Leave a comment

I wanted to montior my apache instance with Monit . Its so simple…

I just had to add the apache related configuration in monitrc file and start monit.

Looked like it worked…BUT…

 

When I looked at example.com:2812. It shows me something like “ ’apache’ process is not running.” I realized that as My server has purchased SSL certificate and for this we have given a passphrase. So When ever apache starts, it asks for the pass phrase for verification. When monit tries to run the apache it also sends the dialog box of asking the passphrase which monit is unable to give. Hence I can not monitor Apache with pass phrase enabled SSL via monit. 

Now when I sit to resolve this issue. I have an easy option : Repurchase the ssl with passphrase as nil. But that is costly and is not safe at all. So I looked for some other solution. And I found one in name of  ’SSLPassPhraseDialog‘.

One just has to add one line in their apache2.conf file :

 
SSLPassPhraseDialog exec:/content/ssl/pp/pp.out

This file should contain something like:

#!/bin/sh
echo 'mypassphrase'

 

and make this file executable by:

chmod +x passphrase_file
Done…Simple na. Now you can just restart your apache and check that its not asking for a passphrase now :)

Monitoring Passenger

May 22, 2009 Ritu Leave a comment

I have recently made some changes in my staging server to get 3 times better response. Would like to share the points with everyone so that other don’t have to do so much of googling that I did.

So, I have my staging(256MB) and production server(2GB). On staging when I had MaxPoolSize of 6(default: Max number of threads spawned by passenger). My server gets killed in 10 consecutive requests coz of use of lots of swap. So I had to make it to 2 as passenger doc suggests to make it 2-3 for 256 MB server.

 

But now one more problem arise, that response time for the request after long time(which could be anything > 10mins) was very high around 30s. Which is quite unacceptable. I found the reason being the MaxPoolTime(Max time in which the threads got killed if no request encountered). And once all the threads got killed and then comes a request  it takes whole lot of time to start these:

1. Framework Spawner

2. Application Spawner

3. Then Spawn a new thread

 

The solution to this problem  was not letting one of the thread get killed. I have searched a lot for this but got noway by which this can be implemented. So I have to find a work around. Which was… to set the Application Spawner not getting killed. This can be achieved by setting APP_SPAWNER_MAX_IDLE_TIME to very large(say 999999). 

I have received amazing improved performance by applying this. Would you like to try???

Lets try Extreme Programming-Day 1

December 11, 2008 Ritu 3 comments

Well I am reading a book on XP (Extreme Programming)currently and by almost every page its quoting the best amongst the good programming practices. The great part about XP is that though it is named as XP, if we apply the same practices in general life it can make our sailing smooth. I will be quoting some of them here time by time.

So today’s quotes are:

“XP is about the process of becoming more of our best selves and in the process our best as developers.”

“Good relationships lead to good business.”

“Leave yourself exposed and prepare for success. Dont scare.”

“People aren’t computers.”

VERY INTERESTING ONE HERE…

“Its not my job to manage someone else’s expectation. Its’s there job to match there expectation. It’s my job to do my best and to communicate clearly.”

“XP is fully appreciating yourself for total effort today and striving to do better tomorrow.”

What I learnt today:
There are values which programmer thinks are good for program/team/company/himself. And there are practices which make them apply these values. These both are complimentary. Good practice enhance the role of value and good values escalates the adoption through practice. Together they become principles.

Web’s Horoscope for 2007

January 2, 2007 Ritu Leave a comment
2007 Richard MacManus, Ebrahim Ezzy, Emre Sokullu, Alex Iskold and Rudy De Waele have made predictions of the trends to be followed in 2007 by web community. You will see Web 2.0 in its full blow in 2007. Wanna see the web2.0 speeding towards web 3.0 … jus follow the latest drift this year. Read all the predictions here. I am looking forward for the year of Google, Seach 2.0, RSS and of course last but not the least Rails 1.2 :)
Categories: Technology, web, www

Simple star rating in Rails

August 14, 2006 Ritu 19 comments

Those who wants to include simple 5 star rating mechanism in their ROR application.Can include a couple of functions in their helper to provide a form a rating field and display the result.Of course no 1/2 ratings can be achieved through this way. One needs to include the below given two function to some helper. And in view inside form tag call…


  star_rating_field("object", "fieldname", options)

Options are location, prefix, active_img, grey_img, hover_img…

For displaying the result of the rating in star images format…call from view


  img_tag_for_star_rating(rating_value,options)

Options are location, active_img, grey_img, hover_img…

Download the function to include in helper from here …I am finding it very difficult to put the code in wordpress without tampering so better to put it somewhere else ;)

Update: the file gets removed everytime.I m trying to out the code here only...


  #General function for star rating
  # Use these function as helpers
  # No half ratings are handled here
  # options can hav ...
  # location=>location of images( you need to have star_active.gif, star_grey.gif, star_hover.gif in this directory or provide names of image file in options)
  # prefix => prefix to append to each ids in DOM for descrimination of more then one star rating in the same page
  # grey_img => name of inactive/grey image of star
  # active_img => name of active image of star
  # hover_img => name of hover image of star
  def star_rating_field(obj_name, field_name, options={:location=>'/images',:hover_img=>"star_hover.gif", :active_img=>"star_active.gif", :grey_img=>"star_grey.gif"})

    # append a hidden field to store value of viz system field
    # this field is to be changed as hidden after testing
    hid = text_field(obj_name, field_name)
    hid_id = "#{obj_name}_#{field_name}"
    pref_id = options[:prefix].nil? ? 'star' : options[:prefix]+'_star'
    img_location = options[:location]
    # set initial value by javascript
    jscript = ""
    jscript += "var a; var v = parseInt($('#{hid_id}').value); for(var i = 1;i"
    img = ''

    # add images to field
    for i in 1..5
      img += ""+' '
    end
      return  img + hid + jscript
  end

  def jscript_for_star_rating(pref_id, img_location)
    jscript = " function set_star_status(n, id)    {  if( $(id).value != n){ for(var j=1; j"star_active.gif", :grey_img=>"star_grey.gif"})
    image = ''
    for i in 1..5
      if i "
      else
        image += ""
      end
    end
    return image
  end

Note:Do remember to include prototype library from script.aculo.us in your page.

UPDATE2:phew…finally trying to add the file again.Hope it work fine this time :( try this=>Star Rating functions

I discovered my true luv-ROR

August 6, 2006 Ritu 5 comments

I went to PHP Meetpup last week… there were some very good presentations ..one on Drupal by Saswata, which was more like a comparison between different Open source CMS. Then there was Prasun’s presentation on “Open Source business Models”. The third presentation was very technical one on Ruby on Rails By Manik (MJ).

When MJ was giving his presentation on ROR, someone asked “Why do you want to adopt ROR in place of PHP, when PHP is easy to code? What we need is get our work done and we can do that in PHP very easily. So why use ROR?”

At that particular moment I discovered my true love for Ruby On Rails. From my opinion coding is not only typing some software on keyboard …I think Programming == Logic. For the people who love to code “It’s all about doing it with Logic”. Following the same old tradition sucks your passion for coding and what you are left with is thousands of lines of code written without any interest just to get your job done. The best part of ROR is that it provides coders the ability to think. Instead of writing each and every query in PHP I can spend time on thinking the best way to design the application because I have ActiveRecord methods to protect me from writing those queries. For ROR its like, if you know about web programming you need not worry about basic things… what is needed is, ‘The Logic’ and the zest to learn all the time. So for those who wants a satisfied client… its ok to use whatever that suits them but for those who wants a “More then satisfied client” and an “even more then satisfied programmer “ the best thing I could suggest is Ruby On Rails.

What else I can say…I love ROR and very soon I am going to wear ROR (planning to get ROR T-shirts;)). I wish I could eat ROR also…Hey that’s a gr8 idea I am next going to invent a dish called Ruby On Rails :D

Automatic Ajaxification With KRJS

July 25, 2006 Ritu 3 comments

KRJS plugin developed by Chew Choon Keat could be called an extension to RJS templates by Cody Fauser . In his post KRJS: RJS without messing the Views Keat explains how KRJS can be used to update functionality in views without even touching the views.

Online Forms By Wufoo (Beta)

June 28, 2006 Ritu Leave a comment

Wufoo is a web-based tool to help you build and host amazing online forms. In only a few minutes, you can create a mailing list, survey, or even a customer management system.

For now in the beta version of Wufoo, Beta Accounts can create 10 forms, use 25MB of disk space for file upload, utilize all field types in their forms, and collect an unlimited amount of entries. If you need more, let us know and we’ll work something out. For those worried about what’s going to happen to your stuff when Wufoo goes live, don’t worry. They will not delete any of your forms or entries (you’ll always get to keep what you collected and used during beta), but you will lose the ability to create some forms and be limited by the features of the plan you settle on. So, for example, if you decide that you just want to use the free plan after beta, you won’t be allowed to use file upload anymore.
 

I think its very usefule for Indian Organisations which doesnt have any chance yet to host their sites online and needs window form submission.

Categories: General, Technology, www

Friday the 13th

May 3, 2006 Ritu Leave a comment

This year my birthday fell on the most notorious date of history…Friday the 13th.I was curious to know about the significance and reason for why this date brings horror in mind.I googled for it and found many thing about it.

But the most striking moment of my life was when this date hit me too. I am not a superstitious kinda person but this incident made me to think again. The incident goes like…

I was on verge of finishing a project.But as usually clients demand for a last minute changes my client asked to change a default value of a date in dateselect_tag to year 2100.I didnt mind as it was a kids play.

I made changes in code

@default_date = Time.utc(2100,"jan",1,0,0,0)

It looked fine but when i run the application again it collapsed with

 ArgumentError in Admin/account#new

 time out of range

I coudnt figure out what the problem was.den i changed the year to 2035 it worked fine.I tried different combinations and found it dont work for year greater then 2038 but dont know the reason.

Finally i look up to google for help.And as google usually do Google helped me hare too.And now what i found out was the most amazing thing in my life.see what i found in google .

If you follow the link you will know what my problem was. You see ruby is also 32-bit system so its affected too. The problem in short is …

 " 32-bit signed integer, such as a time_t, set to its maximum value of 2 147 483 647 and then incremented by 1, will become -2 147 483 648.  Note that "-" sign at the beginning of this large number.  A time_t value of -2 147 483 648 would represent December 13, 1901 at 8:45:52 PM GMT. "

The point that took me aback was December 13, 1901 at 8:45:52 PM GMT is going to fall on Friday .So you see i got another example of Friday the 13th horror among not at all superstitious IT community. Well this was actually an overstatement as nothing can horrify IT community :) this bug is easily fixable and by the year 2038 no one knows where would these fast growing techs. be taking us. I m proud to be a member of this community :)

Categories: General, Technology, rails