Friday, November 26, 2010

Ruby on Mint ;)

Ruby develoment:

To create new application , install ruby and gem and webrick from apt with this command

sudo gem install rails

install sqlite3 and its dev file from apt.

then create a sample application,

rails create blog

cd blog

rails server

Here rails generate controller home index

To edit configuration go to

app/views/home/index.html.erb

give this command:

rm public/index.html

Now, you have to tell Rails where your actual home page is located. Open the file config/routes.rb in your editor. This is your application’s routing file which holds entries in a special DSL (domain-specific language) that tells Rails how to connect incoming requests to controllers and actions. This file contains many sample routes on commented lines, and one of them actually shows you how to connect the root of your site to a specific controller and action. Find the line beginning with :root to, uncomment it and change it like the following:

Blog::Application.routes.draw do #... # You can have the root of your site routed with "root" # just remember to delete public/index.html. root :to => "home#index"

The root :to => "home#index" tells Rails to map the root action to the home controller’s index action.

Now if you navigate to http://localhost:3000 in your browser, you’ll see Hello, Rails!.

For routing add get part

Blog::Application.routes.draw do

get "say/hello"

get "say/goodbye"

get "home/index" receive

Friday, May 28, 2010

EyeOS !!!! cloud in your local machine

My home cloud

EyeOS is an Open Source web desktop operating system written in PHP and AJAX. The main problem of setting up EyeOS is running the sql queries, cause there are several files containing sql commands. To set up EyeOS, you've to edit the settings.php file in mail directory and edit this portion according to your configuration.

// STORAGE
define('SQL_CONNECTIONSTRING', 'mysql:dbname=eyeos;host=127.0.0.1');
define('SQL_USERNAME', 'user');
define('SQL_PASSWORD', '123456');

you have to write your user name instead of "user" and your desired password will replace "123456".

Open mysql console and create a database named eyeos
Then go to /server directory/eyeos/eyeos/extras and open Calendar.sql from Calendar directory.
Run the queries in mysql console. If error is poped, then its okay, we've to come back to this queries after finishing other queries. Then openEyeosEventsNotification.sql file from Eyeos
EventsNotification directory.Remember, if any query shows error, don't be nervous, we will run them after executing other queries. Silmilarly run the queries of EyeosPeopleSQL.sql, EyeosTags.sql, EyeosUMSQL.sql, languageAdmin.sql, MailApplicationSQL.sql from EyeosPeopleSQL, EyeosTags, EyeosUMSQL, LanguageAdmin, MailApplicationSQL directories. Now it's time to get back to unexecuted queries of previous files.Run those queries and ready to use the cloud in your PC.


Run the eyeos from server and click on the New User link, register yourself and ready to take the taste of web desktop.


Screen shot of EyeOS

Friday, May 14, 2010

JDBC MySQL snippet

I'm working on my database project. Here is a tips to connect java with MySQL in Ubuntu. I downloaded MySQL Java connector with Synaptic. The downloaded file is mysql-connector-java-5.1.10.jar and located at /usr/share/java path. I copied that file to my java home's /jre/lib/ext directory, which is /usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/ext

I created a database with this command in mysql :

create database test;
create table Name (FirstName char(10),LastName char(10));
insert into Name values ("Md. Rezaur","Rahman");

Now I used this code to test my connection:


import java.sql.*;

public class JdbcExample1 {

public static void main(String args[]) {
Connection con = null;

try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection("jdbc:mysql:///test", "sajol", "123456");
if(!con.isClosed()){
System.out.println("Successfully connected to MySQL server...");
Statement s = con.createStatement ();
s.executeQuery("select FirstName,LastName from Name");
ResultSet rSet = s.getResultSet();
int count = 0;
while (rSet.next ())
{
String FirstName = rSet.getString ("FirstName");
String LastName = rSet.getString ("LastName");
System.out.println (" First Name = " + FirstName+ ", Last Name = " + LastName);
++count;
}
rSet.close ();
s.close ();
System.out.println (count + " rows were retrieved");
}
}

catch(Exception e) {
System.err.println("Exception: " + e.getMessage());
}
finally {
try {
if(con != null)
con.close();
} catch(SQLException e) {}
}
}
}

Monday, May 10, 2010

Lexical Issues

I was given some sample source files and instructions to build a lexical analyzer. Though it is not a complete project but this flex file works pretty good job to identify the lexicon. Here is the lex file and the generated files: