Tuesday, December 26, 2006

Why I abandoned ruby on rails

I have been a java developer for quite some time. I started doing my website in Perl (even writing my own modules ) because I wanted a cheap hosting option. As you know , java hosting is not cheap. my initial goal was to go online with yahoo's 10$ hosting plan. That plan had support only for few perl / PHP modules . since I had done some perl and *no* PHP , I decided to stick with Perl. But the kind of web application i am doing is very difficult to do with HTML::Template and few basic modules. At one point , I became sick and tired of writing everything by hand. That just takes lot of time. I needed a better framework and thats why I decided to switch to rails. I switched to rails because I did not want to write all and sundry stuff myself.

The switch was okay for me. I like playing around with scripting languages and I had gone through the pragmatic programmer's guide already. Ruby on Rails (ROR) is as such a nice framework. Nothing against the framework. It works neat and nice. My only problem was working with ActiveRecord. I did not like it in full so I was writing all my SQL by hand. I have been playing with rails for last 1 month or so. All my development was done using the built-in webrick server. Few days back, I decided to check out the rails production deployment options. However when I looked at the production deployment options for rails , I came back to square one. There is not much material for deploying rails.

Looks like that in rails world , the way to go fast is to go with fastCGI. However, I do not have a linux box right now and I could not locate fastCGI for windows. I could have looked hard but then i was just scanning the field. According to sources fastCGI development is not active. (But again there were some links refuting this assertion so take everything with a pinch of salt). That prompted me to look at SCGI. But the version number, 0.4.3 of SCGI did not inspire much confidence. All the rails crowd is heavily biased towards lighttpd whereas I am a hard core apache fan. lighttpd in itself looks good but I am not sure how good or bad FCGI or SCGI clusters would be. The available literature is not much and I could not locate any benchmarks. That sort of prompted me to look back at my original intentions.

why did i start with Perl? Because i wanted cheap hosting. why did i ditch perl? because it was time consuming to write an interactive web application with few basic modules. So cheap hosting was now out of window. Take it, if you want new/ your own stuff , you just can not do it with cheap web hosting. That is good only for hosting static HTML pages. But why did i switch to rails and not java frameworks? Because i had heard a lot about rails and I like experimenting with new things. I was okay with ruby and more than anything else I was not sure if i could host a java app on anything less than a dedicated server. I had increased my budget to go with a VPS and do my rail deployment there.

Couple of things happened last week that forced me to re-look at my framework decision. First, I came to know of Rimuhosting.com that provides java hosting on VPS plans. So cost wise it works okay. My budget was 100$ / month and it looks like I can do my java hosting within my budget. Second, I asked a friend to do some work on my website. This guy was not so sure that he wanted to work with ruby/rails because he is a java developer. He said he can churn out things much quickly in java because he knows how things work in that world. Basically he would like to play to his strengths. That convinced me too because I know all the things in java world. I do not have to learn anything new. I have already done everything that is there to be done for a web application. I can work much quicker there.

Final nail came after looking at the rails deployment options. I much familiar with apache 2 and tomcat deployments and can do any level of tuning there. i am not so sure about fastCGI / SCGI clusters. To summarize, I have decided to abandon ROR because
  • It is possible to host java application in a VPS budget. I do not require a dedicated server
  • I may be interested in RUBY but other people are not
  • I am familiar with Java and most of the guys around me would prefer to work in java so there is no learning curve
  • I have already done apache 2 and tomcat deployments so I can save time there as well
  • whatever people may say, the production deployment of rails is not covered in detail right now, so deploying It would be like getting in untested waters.
Maybe I should have given PHP a spin after all ;o)

Wednesday, December 20, 2006

Down with Flu

No updates. Nothing at all in last 10-12 days. Point is , I was down with flu and did not feel like doing anything. Last week was more or less spent sleeping in bed. You feel no energy. Even now my system is not restored to normal, I guess , this is a side effect of all those anti-biotics I took. There is nothing new or exciting to do at workplace. Same old stuff. One question though is to do file caching. I need to research that a bit. I am not sure if just putting squid in front of apache would solve my problem. I should also look at lighty. (http://www.lighttpd.net) I will set myself some  tasks when I recover fully.

Saturday, December 09, 2006

JSON data with ruby rails

My requirement is to fetch the JSON data from rails server and use it to update the place marks on a google map. I start with a view form that submits the user query. I am submitting this query form using the form_remote_tag

 

<%= form_remote_tag (:update =>; 'searchMapResults',:loading =>; "Element.show('spinner')",:complete =>; " Element.hide('spinner') ; ",
:id =>; 'searchMapForm' ,
:url =>; {:action =>; :searchMap}) %>;

Next, we go to the controller action that handles this request. searchMap action should fire a SQL query, load some data in instance variables and return part of data as JSON string to the UI. The controller action looks like




def searchMap
 # get the area and search token
 filter = params[:filter]
 binds = Hash.new 

 sql = { some sql ..... }
 @pmarks = Pmark.find_by_sql [sql, binds] payload = Hash.new
 points = Array.new

 @pmarks.each do |pmark|
 point = Hash.new
 point[:latitude] = pmark.latitude
 point[:longitude] = pmark.longitude
 point[:name] = pmark.name

 point[:description] = pmark.description 
 points.push(point)
 end
 payload[:markers] = points 
 @jsonData = payload.to_json
 logger.debug( " gloo : markers json data" + @jsonData);
 render(:layout => false )

end

We fire a SQL query and load the results. Next we create a Hash (payload) of arrays (markers) of hash (point). we convert this payload RUBY data structure to JSON string using the Active support JSON gem. I installed this gem using command


$gem install json

This gem provides a ready made to_json method. Next step is to use this JSON data string inside our view and javascript files. Our searchMap.html (view for this action looks like:)
 


<script>
loadPoints('<%= @jsonData %>');
</script>

And finally inside a loadPoints javascript function we evaluate the JSON data and use it.
 

function loadPoints(content){
 var jsonData = eval('(' + content + ')');
  for (var i=0; i<>
   alert(jsonData.markers[i].name);

  }
 }



Wednesday, December 06, 2006

How to kill your hung oracle session

Use v$session to find the logged in users and their sessions.



SQL> SELECT s.sid,
2 s.serial#,
3 s.osuser,
4 s.program
5 FROM v$session s;


Then kill the session using the alter system command 

SQL> alter system kill session '34,3464'; [sid, serial#] 

Monday, November 27, 2006

useful mysql commands and snippets

For most of my toy projects i work with mysql. It is easy to setup on windows and came bundled with my mac OS X iBook. There are few tasks that I keep doing time and again. Like creating users , doing a mysql dump and analyzing the tables. First let me list the often-repeated tasks
  • How to create a mysql database
  • How to create a mysql database user
  • How to load a SQL file in MySQL Database(basically a batch file)
  • How to dump mysql database using mysqldump
  • How to dump mysql schema
  • How to dump mysql tables data
  • How to load data from previous mysql dump
  • How to analyze mysql tables
Create MySQL Database
 
$mysql/> create database gloo;
 
Create MySQL local database user
 
mysql> grant all privileges on gloo.*
-> to 'snoopy'@'localhost' identified by 'peanuts'
-> with grant option
-> ;
Query OK, 0 rows affected (0.00 sec)
 
Create MySQL remote database user
 
mysql> grant all privileges on gloo.*
-> to 'snoopy'@'%' identified by 'peanuts'
-> with grant option
-> ;
Query OK, 0 rows affected (0.00 sec)
 
Load a SQL file into MySQL database
 
$mysql -u gloo -p < /usr/rjha94/schema.sql
 
Dump MySQL database using mysqldump utility 
 
syntax is mysqldump -u {user} -p {database} > {file_name}
$ mysqldump -u snoopy -p gloo > gloo.full.sql
 
Dump MySQL schema
 
(useful for creating schema across sites)
$mysqldump --no-data --add-drop-table -u snoopy -p gloo > gloo.schema.sql
[ This will not load the row information. ]
 
Dump MySQL database tables
 
$mysqldump --no-create-info -u snoopy -p gloo > gloo.data.sql
 
Load data from a dump file into MySQL
 
$ mysql -u snoopy -p < gloo.sql
 

Sunday, November 26, 2006

Google satellite map of bangalore

Today i spent some time working with Google maps. I do not know if Google or yahoo has map data for Bangalore. so i am working with satellite maps. Meanwhile i will continue the hunt for map data also. I am more interested in showing hot-spots within a radius of x miles when the map is centered on some well known location. so far i have managed to do the following
  • get the clicked point's lat and lon data
  • tool tip for the place marks
  • loading place marks on demand with the server supplied JSON data
  • change center of map based on what well-known point the user wants
  • place zoom and drag controls
  • mouse click handler for markers and map
I have not yet solved the show hot spots within a radius problem. I will plug that tomorrow. I think i have the basic ingredients now. sprinkle some ajax dust and soon i will have my small app ready ;o) Biggest headache now is to get the lat and lon data of well-known places in bangalore. I can do it manually using google earth but that would take a lot of time. I will post the code tomorrow or whenever i manage to finish.

Friday, November 24, 2006

select boxes with rails

This evening i started out making select boxes in rails. Data for first select box is coming directly from a table. it lists down all the options and includes a blank also. Rails has this convention of rendering param names as x[y] and you can access them in controller code using params[:x][:y]
<%=
@locations = Location.find(:all , :order=> "name")
collection_select(:location, :name, @locations, :name, :name,{ :include_blank => true }) %>

The name of select box would be location[name]. In some cases though we want the _TYPES_ coupled tightly with our model classes. in such cases , you can define options inside a class, like.

payment_types = [ ["check","check"], ["credit card" ,"cc"]].freeze

I found this on appendix c of agile web development with rails. To use this array we have to include

<%=
options = [ ["select a payment option", ""]] + Order::PAYMENT_TYPES
select ("order","pay_type",options, {:include_blank=>true}) %>

Monday, November 20, 2006

vim file backup location on windows

I use vim on windows. When I open a save a file with vim, it always creates a backup file with tilda (~) appended to the file name in same folder. Now this looks plain ugly and second thing is, I want to centralize my vim backup location. You need to overwrite the default behavior of your vim editor.
 my _vimrc is sourced from these 2 files
  • source $VIMRUNTIME/vimrc_example.vim
  • source $VIMRUNTIME/mswin.vim
So I just go ahead and put the following two lines in my vimrc_example.vim file. End of all problems and happy vimming ;o)

if has("vms")
 set nobackup " do not keep a backup file, use versions instead
else
 set backupdir=c:\logs\vim
 set backup " keep a backup file
endif
 

Mapping Hibernate many to many associations

Let me walk you through creating sample M N association with hibernate. M N associations require 2 entities table and one link table to map the association. The example I took is for groups and users. A group can have many users and one user can belong to many groups. Think of your workplace. User Rajeev Jha is part of HR group, La montage group and Serve Chilled Beer group. At the same time La Montage group has many other members including coolcat, fred and Wilma. The problem is to map this association using hibernate.

create table contact (

contact_id int(11) not null auto_increment ,
last_name varchar(50),
first_name varchar(50),
primary key (contact_id)) engine=innodb ;

create table my_user (
user_id int(11) not null auto_increment ,
last_name varchar(50),
first_name varchar(50),
primary key (user_id)) engine=innodb ;

create table my_group (
group_id int(11) not null auto_increment ,
name varchar(50),
primary key (group_id)) engine=innodb ;

create table user_group(
user_group_id int(11) not null auto_increment ,
group_id int(11) not null ,
user_id int(11) not null ,
primary key (user_group_id)) engine=innodb ;

user group is the link table. Now we want to see the mapping files for user and group classes. There is no need for a separate mapping file in case of mysql if you are using the auto_increment primary keys. But when I map to oracle , i usually keep a mapping file for link table also. Just map the link table primary key column. The mappings for groups follow in User.hbm.xml. This is the inverse end of relationship. I have omitted other property mappings for brevity sake.

<set name="groups" table="user_group" inverse="true" lazy="true" cascade="save-update">
<key column="user_id"/>
<many-to-many class="com.agiti.hib.Group" column="group_id" />
</set>

And this is the mapping for Group table, that contains users , the inverse end of the relationship inside Group.hbm.xml . I just followed along the hibernate bible . idbag is require to generate the PK for the link table.

<idbag name="users" table="user_group" lazy="true" cascade="save-update" >
<collection-id column="user_group_ID" type="java.lang.Long">
<generator class="increment"/>
</collection-id>
<key column="group_id"/>
<many-to-many column="user_id" class="com.agiti.hib.User"/>

After you are through with the mappings, create or reverse engineer the POJO classes. inside Group.java, the relevant bits are :

public class Group{

private Long id ;
private String name ;
private List users = new ArrayList();

public List getUsers(){ return this.users ;}
public void setUsers(List users){ this.users = users ;}
// other details nuked
public void addUser(User user){
this.users.add(user);
user.getGroups().add(this);
}

}

You can write User.java on the same lines. After that it is just a matter of using your POJO classes.

Thursday, November 16, 2006

head rush , wireless and frustrations

Frustration is creeping on me , from everywhere. Past 2 days i have not done much @ workplace. And i left gloo work midway after struggling with the layouts for 2 hours. whoever said making web forms is easy should be hanged and i want to be the hangman. Maybe time for a break, past 5 weeks have been truly 7 day weeks. in between i got two new books. head rush ajax and Agile ROR book. I kind of like the head series with all the pretty pictures though content wise it is not much! Only good thing to happen was the new shiny netgear wireless router. Now I and chota can share our internet connection. Maybe time to put the frustrations away and take a clean break for 2 days this weekend.

Monday, November 13, 2006

Decompile JAVA classes in vim

Vim has a cool jad plugin now. What that means is you can see the decompiled .class files right inside your vim editor. Just load any class file in vim editor and you can see the decompiled version. This is the http://www.vim.org/scripts/script.php?script_id=446  vim plugin and you can download jad from this location http://www.kpdus.com/jad.html  . Just copy the vim script to vim plugin folder and put jad in your path. Happy viming ;o)

Sunday, November 12, 2006

creating your own perl module

we are going yo create a simple perl module.  Good thing is there are tools shipped with perl that generate stub code. Lets say we want to generate module called Gloo::Store. To generate the stub issue the command $h2xs -AXc -n Gloo::Store. This would create a folder called Gloo-Store. Your module Store.pm would be located in Gloo-Store\\lib\\Gloo folder. I will skip over lot of details.

The intention is to just add two methods to our module that we can use in our other scripts.  we have added a method to this module called save that uses CGI::Session module to store data. The extra code we wrote is in color red. The stub generated code is in color black.  You can have your documentation right inside the module. All the documentation is in color blue. And finally we do not export any method names because we are using the OO interface.

package Gloo::Store;
use 5.008007;
use strict;
use warnings;
use CGI ;
use CGI::Session ;

require Exporter;

our @ISA = qw(Exporter);
our %EXPORT_TAGS = ( 'all' => [ qw( ) ] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
our $VERSION = '0.01';

sub new {
  my $package = shift;
  return bless({}, $package);
}

sub save {
    my $shelf = shift ;
    my ($cgi, $token, $value) = @_ ;
    if( !defined $token || $token eq "" || !defined $value || $value eq "") {
        return ;
    }
    print " $token :: $value \n " ;
    # @todo - change this location
    my $session = new CGI::Session(undef, $cgi,{Directory=>"c:/rajeev/perl/tmp"});
    $session->expire('+15m');
    my $sid = $session->id();
    # put data in  session
    $session->param($token, $value);
    return $sid ;
}

# Preloaded methods go here.
1;

__END__

=head1 NAME
Gloo::Store - Module for storing user preferences of Gloo website
=head1 SYNOPSIS
  use Gloo::Store;
  $gloo = new Gloo::Store ;
  $gloo->save('token','value');
=head1 DESCRIPTION
GlooStore is used to store the gloo user preferences in cgi sessions. The GlooStore module
uses cgi::session module. We require the user to have cookies enabled in their browser. And
no, no cookie monster will eat your computer because we just store the CGI session id in cookies.
=head2 EXPORT
None by default.
=head1 SEE ALSO
CGI::Session
=head1 Methods
=over
=item  save($cgi_handle,$name,$value)
 method to save name value pairs in gloo store.

=cut

=back
=head1 AUTHOR
rajeev jha, E jha.rajeev@gmail.com E
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2006 by rajeev jha

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.7 or,
at your option, any later version of Perl 5 you may have available.
=cut


The usage of this module has been included in the documentation itself. To install this module, go inside the Gloo-Store folder and issue
$perl Makefile.pl
$nmake
$nmake install

O
ur module would be installed to perl site/lib folder.


powered by performancing firefox

Saturday, November 11, 2006

Ruby on Rails Graffiti








This weekend i am going through Agile web development with rails. After 2 marathon sessions i have managed to skim over most of the books. Now i am realizing the side effects of speed reading, so many words dancing in my head



Friday, November 10, 2006

Finishing the UI takes a long time

Things look simple when you get the wireframes. backend coding also does not take much time. But when it comes to UI there is no end in sight. Creating a polished UI takes a lot of time. The kind of things that you need to do
  • Error validations. Empty fields, numeric validation, email format etc. I personally do not like doing validations in server scripts only. it is double the work if you want to do validations in javascripts as well as server scripts.
  • Make sure every font and font size is perfect.
  • All the navigation links should work  otherwise integration with the rest of the system would break.
  • Complex UI would have role based rendering. So you need show different UI to different type of users
  • Correct handling of data returned from server.
It can be frustating when you work on your UI for 3 days and people come back with hundreds of comments. But then that is part and parcel of developing an application.



powered by performancing firefox

Sunday, November 05, 2006

Passing UI filters as json to cgi scripts

We have a search page that allows the users to define custom filters through UI. One way to pass filter information to server side script is through hidden fields. However if the number of filters increase then this scheme can be a headache. For n filters you would need N input fields. what if we have a filter object in our javascript code ? How about taking all the input from user, creating a filter javascript object and passing that object to the server side script ?
Sounds nice ? All the house keeping can then be moved to OO style javascript.

Filter UI can be defined inside a standard HTML form.
<form name="filterForm" id="filterForm" method="post" action="/cgi-bin/store.pl">
name

other blah blah ..........
</form>

when the Filter form is submitted, a createFilter javascript method is called. This is not OO style but I would suggest doing that.

<script type="text/javascript" ="" src="/app/js/json.js"> </script>

<script>
filterObj = {};
function submitForm(){
var filterForm = document.getElementById('filterForm');
var name = filterForm.name.value ;
blah blah .....
filterObj.name = name ; filterObj.age = age ; filterObj.sex = sex ;
filterForm.payload.value = filterObj.toJSONString() ;
filterForm.submit(); }
</script>


I got json.js library from www.json.org . This makes javascript manipulation easier. so just go and grab a copy. one caveat , GET was not submitting the json string for me, it was submitting individual members of the json object . I am using apache 2.2.x. Now, on the server side. you just extract the json string from request parameter and convert the json string to perl object using cpan JSON module.

use JSON ;
my $json = new JSON ;
my $js = my $jsObj = $json->jsonToObj($cgi->param('payload'));
# print members of this object
print " \n $jsObj->{'name'} :: $jsObj->{'age'} :: $jsObj->{'sex'} \n" ;

thats it folks!

Thursday, November 02, 2006

Hibernate and oracle virtual private database

Separate data of user A from user B is a must-have of online hosted application in today's world. using separate schemas or database do not make much sense because everyone is using the same application . Point is , why do all the maintenance ?

Everywhere I looked, people just advise against this idea of multiple databases or multiple schemas citing performance reasons. same datamodel, same database. But you can not just let people query the base tables holding everyone's data. we need some form of security. The concept that provided security in a multi tenant database is called virtual private database or VPD.

Google for oracle row level access, oracle FGAC, sys_context and oracle VPD. One question to ask is , why not do this in web server layer (middleware). We can fetch result sets from database and filter it. YMMV but we wanted to do it at database level. our requirements are simple, so we do not want to use FGAC etc. Our scheme is to stripe base tables on a client_id. Then we create views on base table with a predicate

FROM BASE TABLE WHERE CLIENT_ID = GET_CLIENT_ID FROM CONTEXT

We do not provide select access on base tables, you can only query the views on base tables. Before doing any select queries , you need to set the client_id in sys context by executing a stored procedure. That is essentially how it works with Oracle.

Next question to ask is  how do we use this scheme with hibernate ? One idea people come up with is that get connection from hibernate session and then execute stored procedure on this connection. You work with your hibernate session after that. Your client_id would then already be set. This looks like lot of work and discipline. Doing something every time you get a hibernate session may not be the best solution.

so is there a better way? YES. we can provide a custom connectionProvider to hibernate. we use C3P0ConnectionProvider. So we decided to write our custom connection provider by extending C3P0ConnectionProvider and pluggin in required logic.

we override just one method of Connectionprovider interface called getConnection()




VPDConnectionProvide extends C3P0ConnectionProvider{
   getConnection(){
      Connection conn = super.getConnection();
      // execute stored procedure to set client_id in sys context for session
      return conn ;
   } 
}

 
Now whenever hibernate requests a connection from ConnectionProvider ,the stored procedure is executed. Use hibernate mapping over this t_view. Thats it!

see the following resources also

Tuesday, October 31, 2006

rome rss atom parsing java library

Rome is a really nice library to parse and create syndication feeds. it works seamless with many rss versions and atom. It could be very tempting to write your own rss parser after going through the rss specs. But the main issue is , there are so many versions of rss floating around the net. One of the feeds i use is still 0.91. so a simple exercise in parsing document may soon turn into a quagmire given all the different formats of feeds. with rome, you work with uniform interfaces irrespective of underlying feed format.

Monday, October 30, 2006

our poster boy


Today i thought of posting our poster boy and indiglooo senior programmer bunbun's profile. For quite some time i have been wondering how to give him a wash. There is lot of dust in bangalore air, even on my 3rd floor flat. So bunbun is now all dirty , even his soles are black with soot. Earlier he had a T shirt on but now a days he prefers being naked. This shot was taken during winter months. bunbun stayed in this T shirt for more than 3 months. he hates windows but likes my small 12" iBOOK. BunBun does most of his coding on this iBook when everyone around is sound asleep ;o)

Wink screencast creation tool

Weekend just flew by. I had carried back the black and ugly thinkpad R52 from work but i might as well have left it on my desk. The only piece was looking at wink in action.

wink is a tool from debug mode. (http://www.debugmode.com/wink/) that can create screencasts (I am not sure if that is right , i have not seen much ;o) and do static capture of slides , print PDF etc.

wink appears to be a nice tool and i would give it a spin some time soon. Sanjeev has been preaching us his technique of solving aptitude test papers. Now he hopes to capture his techniques in a nice tutorial format with wink. I tried writing some code twice and then just gave up. sometimes you should not fight your inner self too much ;o)

Friday, October 27, 2006

CPAN with Activestate PERL on windows

You need CPAN if you are doing any serious work. During the course of my work I was using EMail::Valid and GMail::Checker and perl JSON modules. None of this was available from activestate PPM repository.

This is a serious limitation and I was looking for a way to install CPAN modules on windows.
To make CPAN install work you have to install the Visual C++ /.NET framework toolset. The list of things to install is pretty long and discouraging. I was not ready to go all the distance. Because typically these install sessions degenerate into install A to install B to install C dependency hell.

The win32 perl wiki proved to be useful (http://win32.perl.org/wiki/index.php). There is one distribution called CamelPack. Camelpack install activestate perl and dev-c++ plus nmake tool. Just use the camelpack installer with a net connection ON. The installer does everything for you. At the end of it I was able to install all the 3 modules using CPAN.

Few caveats
  • You may need to set LIB and INCLUDE env variabled
  • The camelpack installer will install activestate perl in location c:\perl, it did not ask me for a location. That was a problem because i already had one copy of activestate perl installed.
  • I am not sure if my install works for complicated modules. I was not able to install DBI. I just fetched DBI using ppm.

Friday, October 20, 2006

Outlook conference room booking

This is how we book our conference rooms. You click the calendar link in outlook panel. Then you create a new appointment. Fill in the details of new appointment and click on invite attendees. From the attendee screen, select the name of your conference room. (like _bangalore) In the To address list put all the recipient names as well. Schedule the appointment by clicking on the schedule tab. here you can see if the conference room is already booked for meeting or not. Finally, send the invite. The new invitation should appear on your calendar. enjoy!

Access gmail INBOX from perl

Gmail provides pop3 access. You can set your gmail box for pop access using the settings link. They have detailed step by step guide for most of the clients. First I tried to access my gmail pop3 mail box using Net::pop3 module.(http://search.cpan.org)

No luck and I was wondering what is happening because the same program worked with other pop3 account. It took me a while to grasp that gmail is using pop3s (pop3 over SSL ) and net::pop3 has no SSL support ( I could be wrong , I did not dig very deep). But since gmail is such a nice and popular mbox there were plenty of links dealing with my issue.

My first try was to use GNU stunnel with Net::pop3 module. (http://www.stunnel.org) Stunnel can accept normal socket requests and forward as secure socket. I did stunnel install on windows XP. grab and install the windows MSI exe. Then copy the 2 DLLs (libeay and libssl) to your systems/win32 folder. And change the stunnel.conf file with accept and connect parameters. issue the command $stunnel --install to install stunnel as a windows service. Once stunnel is configured and running on your machine, you can use the localhost stunnel port for Net::Pop3. stunnel will then forward your requests over SSL.


schematics is perl Net::pop3 => normal => stunnel => SSL => gmail

However I could not get it to work. I tried creating and testing the localhost stunnel port from outlook but again no luck. maybe i was missing something with stunnel. I tried connecting using telnet and do a HELO but again no luck!!

I have a mac os x box at home. However before trying stunnel on that I just typed gmail cpan and out came GMail::Checker module. This module is a wrapper around gmail access. It took approx. 2 mins to run a sample program using Gmail::Checker on my mac os x box. ActiveState does not have Gmail::Checker module. So I really do not know how can I run my program on windows XP box. cygwin port of perl maybe ?

Thursday, October 19, 2006

oracle import and export tool

my wife always asks what do i do in office. well if she asks me today i would say that I keep doing the same things over and over again. we had an issue with moving data between two oracle databases this morning. At the end of it i still do not know what i did. Ganesh as usual , came to rescue!!. There is simply no tool that would let you move data between two databases. If i hear oracle enterprise manager named as a tool I would just laugh! There was one tool bundled with HsqlDB for data transfer. I am not sure if it takes care of constraints etc or not.
Anyways we did it with oracle import and export tool. Three things to keep in mind when you do it/>
  • (A) exp user/passwd@TNS , export users, give the dump file some name
  • (B) make sure same tablespace exists in the target database
  • (C) The target user has the DBA privilege. if not then grant DBA privilege to user.
C:\sw\orainstant>sqlplus /nolog
SQL> connect sys@remotedb as sysdba
Enter password:
Connected.
SQL> grant dba to rajeev;
Grant succeeded.


Thursday, October 12, 2006

first entry from new workplace

I had to think very hard to come up with a nice blog title. Finally i settled on the most obvious. Performancing is a good tool, no doubt about it. I have joined my new workplace. when you move to a new place you miss your old machine more than anything. my old dell laptop had a million of things installed and configured. I really need a tool that can post my mahcines image to internet before i move onto next machine. first 2 -3 days on the job are always wasted in getting your machine up and ready that too with most of the services available online. There was a time when you had to backup your old emails and bookmarks as well.
Not anymore.
Most of my digital life is online thanks to sites like esnips, yahoo, writely and gmail. However moving between machines still poses a challenge of install and configuration for programming related tools. First task that i have is to setup tools and environment for everyone else to follow. That was easy. Only new thing that i encountered was myeclipse plug-ins but they have nice step-by-step tutorials for every feature. The product is a portal kind of thing. I am going to concentrate more on backend (oracle) now.
© Life of a third world developer
Maira Gall