Saturday, September 18, 2010

Nokia software updater has detected a configuration error - vista

Go to services using 
Start Menu => search "services" in search box, select and execute
just enter services.msc in search box hit enter
Find Internet Connection Sharing(ICS) and stop this service

Update device software n enjoy!

Sunday, September 12, 2010

Stomp::Error::InvalidFormatreceive failed

I think stomp 1.1.6 having some bugs! I installed stomp 1.1.3 uninstalling 1.1.6 to get rid of this issue!
Though weird solution but it works for me!

Saturday, August 28, 2010

Install and setup PHPList

PHPList is an open-source newsletter manager, free to download, install and use. Follow this link to know more...
Here I'm trying to document how to set up PHPlist on Ubuntu that should work for other distributions with little modifications.

Setup Apache, PHP & MySQL:

Install Apache2 and PHP5
 apt-get install apache2 php5
Following NEW packages will be installed
 apache2 apache2-mpm-prefork apache2-utils apache2.2-common libapache2-mod-php5 libapr1 libaprutil1 libexpat1 libmagic1 libpq5 libxml2 php5 php5-common ucf
Install MySQL that must be 3.23 or higher
aptitude install mysql-server mysql-client libmysqlclient15-dev libapache2-mod-auth-mysql php5-mysql
The following NEW packages will be installed
apparmor apparmor-profiles libapache2-mod-auth-mysql libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient15-dev libmysqlclient15off libnet-daemon-perl libplrpc-perl libterm-readkey-perl mysql-client mysql-client-5.0 mysql-common mysql-server mysql-server-5.0 php5-mysql zlib1g-dev
You will be also prompted to enter an admin password

Get strong one.

To check whether these packages installed or not, just fire

 dpkg --get-selections
 dpkg -L php5|apache2|mysql-client-5.0
To check whereabouts of MySQL
root@moinhaidar:~# find / -type d -name "mysql"
It will give you sth like this...

Setup Database

Lets login to mysql we just installed
root@moinhaidar:~# mysql -uroot -p
Enter the password you fed while installation.
Now you should be on mysql command line as seen like this
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
Create a database for PHPList namely myphplist
mysql> create database myphplist;
Query OK, 1 row affected (0.00 sec)
Grant privileges
mysql> GRANT ALL PRIVILEGES ON myphplist.* TO 'root'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
Check that out
mysql> show databases;
| Database           |
| information_schema |
| myphplist          |
| mysql              |
3 rows in set (0.00 sec)
Now its time to look into PHP installation. Create file say test.php using your favorite editor having
Now fire root@moinhaidar:~# php test.php
Ooooo!!! You got an error like php not found! Okay lets install this package to get command line PHP.
 apt-get install php5-cli
So far so good!

Configuring PHP to Work With MYSQL

Again fire root@moinhaidar:~# php test.php and look for extension_dir something like below.
 extension_dir => /usr/lib/php5/20060613 => /usr/lib/php5/20060613
Now its time to find php.ini and get it configured...
 find / -name php.ini
Output should sth like this
Open /etc/php5/cli/php.ini and search for extension_dir this should be sth like this
; Directory in which the loadable extensions (modules) reside.
;extension_dir = 
Uncomment if commented and set extension_dir what you find with root@moinhaidar:~# php test.php like
extension_dir = "/usr/lib/php5/20060613"

Setup PHPList

Get the latest version of PHPList
Copy to appropriate loation, usually /var/www/ and untar/unzip whatever...
root@moinhaidar:~# mv phplist-2.11.5.tgz /var/www
root@moinhaidar:~# tar -xvzf phplist-2.11.5.tgz
root@moinhaidar:~# mv phplist-2.11.5 mylists
Now its time to configure ./mylist/config/config.php
[General settings for language and database]
$database_host = "localhost";
$database_name = "myphplist";
$database_user = "root";
$database_password = "dbpassword";
$installation_name = 'Whatever';

[Settings for handling bounces] $message_envelope = ''; $bounce_mailbox_user = 'noreply'; $bounce_protocol = 'mbox'; $bounce_mailbox = '/var/mail/noreply';
[Security related settings] $require_login = 1;
[Debugging and informational] define ("TEST",0); define('SEND_ONE_TESTMAIL',1);
Lets create new site namely phplist
root@moinhaidar:~# cp /etc/apache2/sites-available/default /etc/apache2/sites-available/phplist
Now "vi /etc/apache2/sites-available/phplist" and get it configure...
+ indicates new addition
* indicates modified
+ ServerName
* ServerAdmin
+ ServerAlias *
* DocumentRoot /var/www/mylists
#*Setting Off PHP safe mode in order to acheive bounce processing - site wise
php_admin_flag safe_mode Off

        Options FollowSymLinks
        AllowOverride None

        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
        + DirectoryIndex index.php index.html

Okay, Now enable mylists site and disable default one
sudo a2dissite default
sudo a2ensite lists
Now Check "vi /etc/apache2/sites-enabled/mylists", that should be same as sites-availabe one.
Installed IMAP module for PHP bcoz phpList bounce processing connects to your mail server via a PHP module called IMAP.
 apt-get install php5-imap


#Create a temp dir
Create tmp dir to ./var/www/mylists/ if not there.
#Change permission
root@moinhaidar:~# chmod -R 777 /var/www/mylists
#Restart server
root@moinhaidar:~# /etc/init.d/apache2 restart
Done Hit
Got uninitialized database?
Hit initialized database link. It will populate your database(myphplist).
Cross check the database
root@mail:~# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 5.0.51a-3ubuntu5.5 (Ubuntu)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use myphplist;
mysql> show tables;
| Tables_in_myphplist  |
| admin                |
| admin_attribute      |
| admin_task           |
Done! Go to and setup remaining thing and enjoy!

Basic Mail Server Setup

Install follwing package choosing options...
Option 1 - internet site : Mail will be get read/delivered directly via SMTP

Option 2 - : FQDN

root@moinhaidar:~# aptitude install postfix telnet mailx postfix-mysql
Configure /etc/postfix/ adding followings
myhostname =
myorigin = $mydomain
mydestination =  $mydomain, localhost.$mydomain, localhost
Edit /etc/mailname and /etc/hostname having
Edit /etc/hosts having     localhost localhost.localdomain
Reboot the system
sudo reboot
Add a user namely noreply

Setup Reverse DNS

Quick Test

Subject: test email from
test body of the email.
No confirmation is given that the email has been sent but the logs will show the details.

Check the receiving email address and I hope you got expected!!! :)

Monday, August 23, 2010

Open Social Ruby Wrapper 0.0.4 - NameError : uninitialized constant


NameError: uninitialized constant ActionController::AbstractRequest
        from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:440:in `load_missing_constant'
        from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:80:in `const_missing'
        from c:/ruby/lib/ruby/gems/1.8/gems/opensocial-0.0.4/lib/opensocial/auth/action_controller_request.rb:32
        from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
        from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from c:/ruby/lib/ruby/gems/1.8/gems/opensocial-0.0.4/lib/opensocial.rb:19
        from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
        from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'


and resplace "proxies ActionController::AbstractRequest" with "proxies ActionController::Request" at Line 32
or more specifically
module OAuth::RequestProxy #:nodoc: all
  class ActionControllerRequest < OAuth::RequestProxy::Base
    # proxies ActionController::AbstractRequest
    if ActionController.const_defined?(:AbstractRequest)
      proxies ActionController::AbstractRequest
      proxies ActionController::Request

Saturday, August 21, 2010

OAuth Twitter API: Post message , status 401 Unauthorized

   First thing first check out the access level. If its read only, fix it read and wirte both.

   If its already read and write then most probably you are doing post having read and write access but authorization is still of read only. Follow this link to revoke the access and reauthorize it again.

Tuesday, January 19, 2010

Extending Contacts Gem to fetch LinkedIn contacts to invite

Deprecated owing to captcha fixation!


Getting contacts gem to play as plugin make it easier to manipulate accordingly.
Do whatever way or find a simple cut & paste like solution here...
Extending Ruby on Rails Contacts Gem to invite Facebook users
Put linkedin.rb into "#{RAILS_ROOT}/vendor/plugins/contacts/lib/contacts"[Plugin] OR "#{GEM_PATH}/contacts-x.x.x/lib/contacts" containing...
class Contacts
  class Linkedin < Base
    URL = ""
    LOGIN_URL = ""
    HOME_URL = ""
    CONTACT_URL = ""
    REFERER_URL = ""
    PROTOCOL_ERROR = "LinkedIn has changed its protocols, please upgrade this library."
    def real_connect
      data, resp, cookies, forward = get(LOGIN_URL)
      if resp.code_type != Net::HTTPOK
        raise ConnectionError, PROTOCOL_ERROR
      postdata = "csrfToken=guest_token&session_key=#{@login}&session_password=#{@password}&session_login=Sign In&session_login=&session_rikey="
      data, resp, cookies, forward = post(LOGIN_POST_URL, postdata, cookies)
      if data.index("The email address or password you provided does not match our records.")
        raise AuthenticationError, "Username and password do not match!"
      elsif data.index('Please enter your password') || data.index('Please enter your email address.')
       raise AuthenticationError, "Email or Password can not be blank!"
      elsif cookies == ""
        raise ConnectionError, PROTOCOL_ERROR
      data, resp, cookies, forward = get(HOME_URL, cookies, URL)
      if resp.code_type != Net::HTTPOK
        raise ConnectionError, PROTOCOL_ERROR
      @ajax_session = get_element_string(data,'name="csrfToken" value="','"')
      @logout_url = ""
      @cookies = cookies
    def contacts      
   raise ConnectionError, PROTOCOL_ERROR unless @ajax_session
   postdata = "callCount=1"
   postdata+= "&JSESSIONID=#{@ajax_session}"
   postdata+= "&c0-scriptName=ConnectionsBrowserService"
   postdata+= "&c0-methodName=getMyConnections"
   postdata+= "&c0-param0=string:0"
   postdata+= "&c0-param1=number:-1"
   postdata+= "&c0-param2=string:DONT_CARE"
   postdata+= "&c0-param3=number:500"
   postdata+= "&c0-param4=boolean:false"
   postdata+= "&c0-param5=boolean:true"
   postdata+= "&xml=true"
   data, resp, cookies, forward = ajaxpost(CONTACT_URL, postdata, @cookies, REFERER_URL)
   raise ConnectionError, PROTOCOL_ERROR if resp.code_type != Net::HTTPOK
   cr = /detailsLink=s\d+;(.*?)\.firstName=/
   fr = /emailAddress=s\d+;var s\d+=\"(.*?)\";s\d+/
   er =  /var s\d+=\"(.*?)\";s\d+.emailAddress/
   contacts = []
   results = data.scan(cr)
   results.each do |result|
    result = result.to_s
    first_name = result.scan(fr).to_s
    email = result.scan(er).to_s
    contacts << [first_name, email]
   return contacts
    def logout
     return false unless @ajax_session
     if @logout_url && @cookies
      url = URI.parse(@logout_url)
       http = open_http(url)
        "Cookie" => @cookies
        return true
    def ajaxpost(url, postdata, cookies="", referer="")
   url = URI.parse(url)
   http = open_http(url)
   resp, data =, postdata,
     "User-Agent" => "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0",
     "Accept-Encoding" => "gzip",
     "Cookie" => cookies,
     "Referer" => referer,
     "Content-Type" => 'text/plain;charset=UTF-8'
   data = uncompress(resp, data)
   cookies = parse_cookies(resp.response['set-cookie'], cookies)
   forward = resp.response['Location']
   forward ||= (data =~ /<meta.*?url='([^']+)'/ ? CGI.unescapeHTML($1) : nil)
   if(not forward.nil?) && URI.parse(forward).host.nil?
    forward = url.scheme.to_s + "://" + + forward
   return data, resp, cookies, forward
  TYPES[:linkedin] = Linkedin
Require linkedin.rb into lib/contacts.rb
require 'linkedin'

Is it working?

=> [["User1", 'Email1'], ["User2", 'Email2'], ["User3", 'Email3']]
Yes! :)

Twitter API And Extending Rails Contacts Gem To Invite Friends


Yet to install contacts gem?
OR, how to get it to play as plugin?
Follow this link...
Extending Ruby on Rails Contacts Gem to invite Facebook users
Got through?
Put twitter.rb into "#{RAILS_ROOT}/vendor/plugins/contacts/lib/contacts" containing...
class Contacts
 class Twitter < Base
  URL = ""
  LOGIN_URL = ""
  PROTOCOL_ERROR = "Twitter has changed its protocols, please upgrade this library."
  def real_connect
   format = 'xml'
   api_url = LOGIN_URL + format
   url = URI.parse(api_url)
   req =
   req.basic_auth(@login, @password)
   resp =, url.port).start {|http| http.request(req) }
   if resp.code_type == Net::HTTPUnauthorized
    raise AuthenticationError, "Username and password do not match!"
   elsif resp.code_type != Net::HTTPOK
    raise ConnectionError, PROTOCOL_ERROR
   return true
  def contacts
   format = 'json'
   api_url = CONTACT_URL + format
   url = URI.parse(api_url)
   req =
   req.basic_auth(@login, @password)
   resp =, url.port).start {|http| http.request(req) }
   if resp.code_type != Net::HTTPOK
    raise ConnectionError, PROTOCOL_ERROR
   data = resp.body
   data = Contacts.parse_json(data) if data
   return [] if data.empty?
   contacts = []
   data.each do |d|
    contacts << [d['name'],d['id']]
   return contacts
  def send_message(contact, msg, format = 'json')
   return "Direct Message must been less than 140 characters." if msg && msg.length > 160
   return "Direct Message must have something in it..." if msg.nil? || msg.length < 1
   api_url = DMESSAGE_URL + format
   url = URI.parse(api_url)
   req =
   req.basic_auth(@login, @password)
   req.set_form_data({'user' => contact.last, 'text'=> msg }, '&')
   resp =, url.port).start {|http| http.request(req) }
   return true if resp.code_type == Net::HTTPOK
   return false
  def logout
 TYPES[:twitter] = Twitter
We also need to pick appropriate JSON, if we are getting contacts in json format.
# Use ActiveSupport's version of JSON if available
if !Object.const_defined?('ActiveSupport')
  require 'json/add/rails'

class Contacts
  def self.parse_json(string)
    if Object.const_defined?('ActiveSupport') && ActiveSupport.const_defined?('JSON')
    elsif Object.const_defined?('JSON')
      raise 'Contacts requires JSON or Rails (with ActiveSupport::JSON)'
Don't forget to add this into lib/contacts.rb
require 'twitter'


C:\Me\Workspace\contacts>ruby script/console
Loading development environment (Rails 2.3.4)
>> contacts = twitter.contacts
=> [["Jeremy Piven", 20221159], ["The Next Web", 10876852], ["bob saget", 38536306], ["Joel Stein", 24608680], ["Moin Haidar", 38841828]]
>> contacts.each{|c|twitter.send_message(c, 'Your Message')}
All should be well :)