Archive for November, 2009

My First Interview

Hai

Today i attend one technical interview.

i applied my resume to   ” Artha42 Technology Solutions Pvt. Ltd.,  ”  via   mail to them.

interview was conducted 2 hours for me alone. two persons are interviewed me.

they asked many question in ruby.

first they were seen my resume and asked about my projects.

and they downloaded my sms framework project from http://www.code.google.com/p/gnusms .

they told me like explain about each and every lines of  my project.

and

they gave many simple mathematical questions ,and  i solved those in ruby programming.

Interview Questions :

mathematical problems :
1) consider one circle. the given points are centre (x,y) and its radius(r). user will give the third point (x1,y1). you need to findout whether the third point is placed inside circle or outside circle or on  the circle ? write program to solve this.

2) we have one array, that contains  numbers from 1 to 100 by mixed. and that array also having only one duplicate number. how will you find out that duplicated no without sorting or using any inbuild fns.

3) programming question :

we have one Class A. It contains some methods.

how can we write one method which is belong to that Class A.

this is not inheritance concept.

it is like plug-in concept.  we have inbuild class. for that we are going to write some methods. how will u append the methods to that class A.

we no need to rewrite the Class A. just we have to do , appending some methods to Class A , by writing some modules.  how about this in ruby?

4) database design:

we have few tables . we have users and groups. user may belongs to many groups as well as group having many users. i.e many to many relationship.using tables, how can u design this kind of database. u may use primary and forgin key concepts.
it should be efficiency.
for eg:

user table contains fields like user_primary_no , user name, gruoup_id (forgin key)

group table contains fields like group_primary_no,group name , user_id.

In this case,  each field can store only one value.
one user may belongs_to many group. one group may have many users. how can we design for this.

( i solved few problems  by  inefficient way. solved few problems by efficient manner ).

this is my first interview.

here i learned a lot. i m very weak in OO concepts and in database.

so need to study a lot .. , i ll prepare ….

i understood the difference among curriculum and our own program and company program standards.

i need to increase my programming standard  into company level.

nice experience.

அருளாளன் . த

Advertisements

Automatic Birthday Remainder Using Ruby & Notify-Bin

Automatic Birthday Remainder Program

Hi , This Program runs works as Birthday Remainder in our local system . Just try this !

It will display our friends name and photo in desktop like notifier whenever u switch on ur system on.

It will remaind u on,

1) Today’s B Day

2) Tomorrow’s B Day

Installation :

—————

To Notify :

$ sudo apt-get install libnotify-bin

To Ruby :

$ sudo apt-get install ruby

$ sudo apt-get install rubygems

$ sudo gem install activesupport

Datebase :

———-

In this “database” file which having friends name, dob , image_path.

You can edit and add new line in order of name , dob , image_path with separated by comma.

database file:

Arulalan,01-01,~/birthday_remainder/Arulalan.jpg

Dhastha,31-12,default

Conditions:

1) first field must have name

2) second filed have dob. It is date and month order only. date ( from 01 to 31 ) & month ( from 01 to 12 ).

The date and month are separeted by minus symbol(-).

eg: 09-05 ( 9th day , May month )

3) third field have the image location path. This image will be displayed on monitor ( notify )

create ond directory “ birthday_remainder” in ur home folder.

U can set path like this. eg : ~/birthday_remainder/Arulalan.jpg ( If u stored the image in this folder ) or u can set any image path

If u dont have image then set the third field as “default” eg: Dhastha,31-12,default

This “default” option will invoke inbuild image path. this inbuild image is stored in “birthday_remainder” folder itself. path is : ~/birthday_remainder/cake.jpeg

you may add any no of lines in this database file.

bday.rb:

#!/usr/bin/env ruby

require “rubygems”

require “active_support”

sleep(10)

file=File.open(“database”,”r”)

file.each do |bday|

bday=bday.chomp!

bday=bday.split(/,/)

name=bday[0].to_s

dob=bday[1].to_s

image_path=bday[2].to_s

if image_path==”default” then

image_path=”~/birthday_remainder/cake.jpeg”

end

dob=dob.split(/-/)

current_time=Time.now

month=current_time.month.to_s

day=current_time.day.to_s

if month.to_i <10 then

month=”0″+month

end

tomorrow=1.day.from_now.to_s

tomorrow=tomorrow.split(/ /)

p tomorrow

if dob[1]==month then

if dob[0]==day then

system(“notify-send ‘BirthDay Remainder’ ‘Today #{name} Birthday’ -i #{image_path} -t 3000”)

sleep(10)

system(“notify-send ‘BirthDay Remainder’ ‘Did U wished #{name} Birthday ?’ -t 0”)

end

if dob[0]==(tomorrow[2]) then

system(“notify-send ‘BirthDay Remainder’ ‘Tomorrow #{name} Birthday’ -i #{image_path} -t 3000”)

sleep(10)

system(“notify-send ‘BirthDay Remainder’ ‘Did U Purchased Gift For #{name} Birthday ?’ -t 0”)

end

end

mon=[“Jan”,”Feb”,”Mar”,”Apr”,”May”,”Jun”,”Jul”,”Aug”,”Sep”,”Oct”,”Nov”,”Dec”]

today=Time.now.to_s

today=today.split(/ /)

today[1].to_s

x=mon.index(today[1]).to_i

y=mon.index(tomorrow[1]).to_i

if (x+1==y or tomorrow[1]==”Jan” ) and dob[0]==”01″ then

system(“notify-send ‘BirthDay Remainder’ ‘Tomorrow #{name} Birthday’ -i #{image_path} -t 3000”)

sleep(10)

system(“notify-send ‘BirthDay Remainder’ ‘Did U Purchased Gift For #{name} Birthday ?’ -t 0”)

end

end

Change Permission :

——————-

here , you must make “birthday_remainder” folder in ur home folder and paste this bday.rb and database file and corresponding images .

$ sudo chmod -R 777 ~/ birthday_remainder/

Adding into Start Up Application :

———————————-

In ubuntu 9.10 version :

1) Go to “System” -> “Preferences” -> “Startup Applications”

2) Click “Add” button

3) Now click “Browse” button and comes to home folder-> birthday_remainder folder-> bday.rb ( select bday.rb )

4) In Name field , type as ” Birthday Remainder”

5) Then click “Add” button

* u can enable (check box )or edit or remove whatever u add in startup application

Logout or Restart :

——————-

Now u can see the bday remainder in ur desktop.

How to check :

————–

If u wanna to check this program , then u change the dob of database file into curent date.

this prog will remaind u today’s and tomorrow’s b day….

* It will remaind u in all calender days like 28,29,30,31 & leap year.

Tomorrow B Day Remainder

Today B Day Remaindser

 

u can get this program and guide lines as document from here :

Link : http://www.slideshare.net/arulalan/automatic-b-day-remainder-program

 

 

Have a fun !

அருளாளன் . த

Send Gmail From Ruby Script

Hi.

Now we are going to see , how to send e-mail from Ruby Script.

fro that we need to install ,

$ sudo apt-get install ruby

$ sudo apt-get install rubygems

$ sudo gem install tlsmail

gmail.rb

require ‘rubygems’
require ‘tlsmail’
require ‘time’

$a=[‘tarulalan@gmail.com’,’tshrinivasan@gmail.com’,’jemenisuresh@gmail.com’]
$a.each do |to_mail|

content = <<MESSAGE_END
From: Arulalan <tarulalan@gmail.com>
To: #{to_mail}
Subject: SMTP e-mail test

This is a test e-mail message….

hi da.. how r u .. i m fine… now i sending this mail from ruby scrpt…… This body of our mail

MESSAGE_END

Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
Net::SMTP.start(‘smtp.gmail.com’, 587, ‘gmail.com’, ‘tarulalan@gmail.com’, ‘my passwd’, :login) do |smtp|
smtp.send_message(content, ‘tarulalan@gmail.com’, “#{to_mail}”)
end

end

# End Of Program

in this Prog , $a is an array and u can add many email id  to send mail.

and in this program tarulalan@gmail is my mail id.. you can replace with ur  gmail id.  🙂

அருளாளன் . த

SMS Frame Work using Gnokii , Ruby & CSV – Sending Bulk sms

SMS Frame Work Using Command Line Argument

Hai Friends,

Now we r going to see , how to send bulk sms using  Ruby and Gnokii and CSV.

CSV means Comma Separated Value.

In contact list file , just open and edit at any time.

we need to install following packages.

# To install Ruby

$ sudo apt-get install ruby

# To install Gnokii ( send sms from mobiles )

$ sudo apt-get install gnokii

Connect mobile and system:

To connct the mobile and sys ON the bluetooth in mobile and system,for system use bluetooth dongle no need of any drivers for bluetooth dongle.

In system the bluetooth sysbol apper as

note:

*in bluetooth symbol click and get preference and select “service”

In this sysmbol right click and select “Browse device” and select the u r mobile and click “connect” ,and accept the msg in mobile and give any passky and click ok,now the mobile and system paired successfully.

Now goto terminal type,

$ sudo gedit /etc/gnokiirc

gnokiirc(/etc)-gedit file opened and change the settings as follows

* in 27th line default present like

* #port = aa:bb:cc:dd:ee:ff

* change port = aa:bb:cc:dd:ee:ff and we want the mobile id or address to get(when mobile and sys connected only) type in terminal like

* $ hcitool scan

* it gives some address and copy this .

* Paste in the 27th line like port = aa:bb:cc:dd:ee:ff change port = “u r mobile address”

* enable model = AT in 51th line disable #model=6110

* put like because v use bluetooth connection # connection = serial in 90 th line

* remove # from connection = bluetooth in 101 st line.

note:

*the id of mobile change depend on mobile model

*don’t use china and goriya.. mobiles or try….

*get preference from bluetooth symbol and enable input service and disable serial service

*Use Ubuntu 8.04 for bluetooth it is compatable…

send sms and enjoy:

go to terminal for send single sms to single number

type

$ echo “ Hai My Dear Friend , Have A Good Day “ | gnokii –sendsms mobileno

# gnokii (double minus symbol ) – – sendsms  9994332225

Press Enter .

now send succeed !…

How to send sms to many numbers by automatically :

Just follow three steps:

Step 1:

Open text editor.

Type the contact person name and type comma ( , ) and followed by contact number and press Enter.

Repeat this process upto we need to add contacts to send sms.

Eg:

Kanchi_Lug_Contacts

Arulalan,9994332225

Raj Kumar,9940857450

Dasthageer,9994685704

.

.

.

xxxxxxxx,9876543210

I saved the text as “Kanchi_Lug_Contacts”. And While type last contact person number in your list, Pl dont press Enter.

Step 2:

save the follwing program as “sms_csv.rb

#!/usr/bin/env ruby

msg=ARGV[0]
file_name=ARGV[1]

p “ur contact book name is : #{file_name} \n”

file=File.open(“#{file_name}”,”r”)

file.each do |contact|

contact.chomp!

contact_detail=contact.split(/,/)

system(“echo    ‘#{msg}’   | gnokii –sendsms  ‘#{contact_detail[1]}’ “)

print ” msg sent to  #{contact_detail[0]}  :  #{contact_detail[1]}    \n ”

sleep(10)

end

file.close
print ” Msg Sent To All  Members Successfully \n”
print “Bye\n”

#End of Prog

Step 3:

Change the permission to this program by,

$ sudo   chmod    777    sms_csv.rb

Step 4:

Now u can send sms by easy way.

$ ./sms_csv.rb    ” Hai  Friend , Good Morning . Have a nice day ! ”     kanchi_Lug_Contacts

here, u can call the program “sms_csv.rb”  as script . ( no need to run in terminal by $ ruby sms_csv.rb )

and using command line argument , we can can pass the message and contact file name to send sms.

Enjoy with Ruby , Gnokii and CSV.

 

You can download this blog as pdf from here

http://www.slideshare.net/arulalan/sms-frame-work-using-gnokii-ruby-csv-command-line-argument

அருளாளன் . த