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:

Monday, December 7, 2009

Compiler Construction: Phase One (Backus–Naur Form)

I had a project of compiler construction a few days ago. It is more interesting than I imagined. There would be a language (suppose it is Simple Programming Language). I need to build the BNF,lexical analyzer and the parser. My friend Wasi built the BNF according to the specifications given to us.

Here is the BNF file

"Name"    = 'SPL'
"Version" = '2009'
"Author"  = ''Mir Sajal'
"About"   = 'Simple SPL'
"Case Sensitive" = False
"Start Symbol" =


<Character>::= {letter}
<Digit>::= {digit}
<CharacterOrDigit>::= {alphanumeric}
NewLine ::= {CR}{LF}|{CR}


<Identifier>::= <Character><CharacterOrDigit>*
<Number>::= <Digit>*|<Digit>+"."<Digit>+
<Negative;>::= "-"
<NumberConstant>::= <Negative><Number>|<Number>
<CharacterConstant>::= "'"<Character>"'"
<Constant>::= <NumberConstant>|<CharacterConstant>
<Value<::= <Identifier>|<Constant>|"("<Expression>")"
<Term>::=^lt;Value>|<Value>>"*"<Value>+|<Value>"/"<Value>+
<Expression>::= <Term>|<Term>"+"<Term>+|<Term>"-"<Term>+
<Comparator>::= "=" | "><" | "<" | ">" | "<=" | ">="
<AndOr>::= AND | OR
<Check>::= [<Not>]<Expression><Comparator><Expression>
<Conditional>::= <Check>|<Check><AndOr><Check>+
<Program> ::= <Identifier>";"<Block>"ENDP"<Identifier>"."
<Block>::= [DECLARATIONS<DeclarationBlock>]CODE<StatementList>
<IdentifierList>::= <Identifier>|<Identifier>","<Identifier>+
<DeclarationBlock>::= <IdentifierList> OF TYPE<Type>";"
<Type>::= CHARACTER | INTEGER | REAL
<StatementList>::= <Statement>|<Statement>";"<Statement>+";"
<Statement>::= <Assignment> | <If> | <Do> | <While> | <Write> | <Read>
<Assignment>::= <Expression> "->" <Identifier>
<If>::= IF <Conditional> THEN <StatementList> ["ELSE" <StatementList>] ENDIF
<Do>::= DO<StatementList>WHILE<Conditional>ENDDO
<While>::= WHILE<Conditional>DO<StatementList>ENDWHILE
<For>::= FOR<Identifier>IS<Expression>BY<Expression>TO<Expression>DO<StatementList>ENDFOR
<Write>::= WRITE<OutputList> | Newline
<Read>::= READ<Identifier>
<OutputList>::= <Value> |<Value>","<Value>+

Monday, August 3, 2009

A Sample Process Calling Example

I used gnokii to send sms. So I need to execute the command from my code.

/usr/bin/gnokii --sendsms 8801712273933

So at first, I installed gnokii in my Ubuntu 9.04. Then
I copied the gnokiirc file from /etc to my home folder and renamed it to .gnokiirc
I opened the file and did some change to it. I was using my Siemens SK65 with a data cable.
I did some tweaking to my .gnokiirc file. All # signs indicate comments. I removed hash sign from some lines. Those lines are:


port = /dev/ttyUSB0
model = AT
initlength = default
connection = serial

As my model isn't supported officially by Gnokii so I added a hash sign before the "model = " line.
Then
I run this command in my console.

gnokii --identify


The output is something like this:
GNOKII Version 0.6.26
IMEI : 354784000367194
Manufacturer : SIEMENS
Model : Gipsy Soft Protocolstack
Product name : Gipsy Soft Protocolstack
Revision : 50,"OFFICIAL","2005

Then I wrothe C file sample.c












When I run this file, a new process is opened and gnokii --sendsms command is executed.After sending the SMS the process gonna close. The phone number in the code is the receiver of the message.
For more info, log into www.gnokii.com

Courtesy : Burhan Uddin


Algorithmic Aspects of Shadhinota (English to Bengali Dictionary)



The most crucial part of building a dictionary is to make an efficient searching technology. There are several ways to keep the words ….May be SQL database, XML data or simple text file. I prefered the text files to keep my data. I want to build a simple desktop utility for general users. I don't expect a general user should install a database software in order to use my dictionary. I aint very good at XML stuffs. So one way is open for me, that is to use text files.

But the main problem of using text file is to maintain the efficient algorithm. I used a simple concept for searching the desired words. Here we go now....

At first I used 26 directories for 26 letters of English alphabet. Every directory has some text files...suppose ab.txt, ac.txt,a.txt......etc. Here ab.txt has the words a, absent,abstract.... every words having the prefix of “ab". Now when I enter a word in my dictionary, at first it goes to the corresponding directory according to the first letter and next it goes to the corresponding text file. Now the second problem arises. One word can be used more than one time in a text file. For example:

The pattern of the text file may be like this
Word Meanings

Country Homeland,Motherland,Home..........

…....
…....
…....

Home House, Place of Accomodation ....

My dictionary searches the word and if it finds the word in the file then print the consecutive words and stop printing when it finds new line. But if same word is used more than once the total process get messed. So I need to distinguish the searched words from others. They need to be unique. I simply added a numeric character before every searched word. Now the text file will be like this

Word
Meanings
2Country Homeland,Motherland,Home..........
…....
…....
…....
2Home House, Place of Accomodation ....

Now every searched word has a unique identity. There could be approximate 26*25 files in 26 directories. A tree like hierarchy will be made and searching the words will be done via the traversing the file hierarchy.

Friday, July 31, 2009

Little bit about my Dictionary (Part One)


I made a small English to Bengali dictionary based on Qt4. In this post I gonna describe the environment setup process for it. I was so excited cause it was my first opensource desktop project.

Properties of the project:
Primary language: C++
Primary toolkit: QT4
Primary IDE: CodeBlocks with MinGW,QDevelop
Objective: Open Source cross platform English to Bengali Dictionary.
Setting Up the Environment:
OS: Windows XP
#install codeblocks-8.02mingw.I used C:\Program Files\CodeBlocks path
use gcc as default compiler
#install qt-win-opensource-4.4.3-mingw I used C:\Qt4 path
#install Qdevelop (optional)
Setting up environment variables:
Right click on My Computer and open properties box. Click on the advanced tab and go to
Environment Variable option.On user variable area click on New button and set the following
environment variables.

Variable name: PATH
Variable Values: C:\Qt\4.4.3\bin;C:\Program Files\CodeBlocks\MinGW\bin;
Variable name: QMAKESPEC
Variable Values: win32-g++
Variable name: QTDIR
Variable Values: C:\Qt\4.4.3

You may need to restart windows.
Go to Start menu..Run...cmd
Give the command:

qmake -v
make -v
gcc -v

Go to C:\Program Files\CodeBlocks\mingw\bin and create a batch file named make.bat
file: make.bat
contained text:

@echo off
mingw32-make %*

run that batch file from cmd.
then u will have to type make instead of mingw32-make
***In Windows You must Enable Unicode based Bengali.You can use a Bangla Keyboard Utility
which supports Unicode.***
OS: Linux
Install g++,QT4 with your package manager or from source code.
Compiling Shadhinota:
Command line compilation:
go to source folder from command line and give the following command:

qmake -project
qmake
make

Compiling using Qdevelop:
Open Qdevelop
Click on Project menu
select Open Project and open the *.pro file of Shadhinota's source directory.
Use Build or Rebuild option from Build menu.
Run the executable from the source folder.
Under Windows:
copy the mingwm10.dll,QtCore4.dll,QtCored4.dll,QtGuid4.dll from codeBlock/mingw/bin
and Qt4.4.3/bin directory to your executable's directory for portability.

In the next post I will write about the GUI part of Shadhinota and the algorithm
used in this software.