Shaikh Sonny Aman’s Blog

previously www.mailtoaman.com

Life with a meaning

Posted on | September 26, 2008 | 2 Comments

I don’t know what it is — a life with a meaning. I cannot define it, neither you can. Instead, we all may have our definition of a meaningful life. Or, do we? Do you really know what will be a meaningful life for you? Do you know what you want - not at this moment, but overall in your life? which will give you feeling of completeness, a solemn joy of achievement?

I tried to find this answer from my childhood. When I was in grade two, I used to cry to my elder sister that as being the youngest I will left alone on the earth without them, my parents.. as they will die sooner generally. Wired thought of course, but on that time the meaning of my life was their affection, their presence.

 

I grew up gradually. I used to go to the village with my family traveling long way by bus and boat. The boat riding was the most favorite part of the journey. I used to enjoy the scenery along side the river, the paddy field, the rhythm  of the boatmen’s paddling through the blue water to an endless way… I wish I could be boatman and enjoy all the beauty that nature can reveal.

Reading and writing- became my next meaning to life when I was in high school. I found books are the only media that can make others experience and emotion live to me. 

Anyway.. now I think the meaning of life lies in some contribution to the community/communities I belong. Little or more doesn’t matter, can be a software, can be piece of knowledge, can be a little help to some of those who need, can be a research for the greater betterment… doing something which so not limited only to myself.

In the contrary, at the same time  I wish I could see the whole word. I could deny the state of being an ant in my house whose world is the peripheral of my walls. I wish could be as free.

I don’t know actually what want to mean.. what I am writing.. perhaps…

NetNewsWire - A great RSS feed reader for Mac

Posted on | September 24, 2008 | No Comments

I am new to the fantastic mac world and was searching for what “free” but fascinating apps are there. Googling for some time I came to a site called pure mac. From there I found the application NetNewsGator.

The screenshots and the features seemed awesome!

2 pane view of NetNewsWire

2 pane view of NetNewsWire

 

 

Among its numerous features the most interesting to me was the internal web page browser. From the preference tab you can also select to enable plugins, java and javascript!

You can create smart folders( mac users got the meaning I guess ) and you can choose your conditions from an existing pool.

 

Happy feeding ! ;)

Did not hesitate to download.

Snip first words from first n charecters using php

Posted on | September 9, 2008 | 2 Comments

Problem: You are writing a blogging software. Where on the first page you like to show the lates posts in a list but not their full content, only say first 200 letters. Porblem raises  when the last word is spans out of the 200 letter limit.

For example, say, 198th letter is ‘H’ which is the start of the word ‘Home’. So, if you take only first 200 letters, the text will endup with ‘Hom’, certainly thats unwanted.

What to do?

Ans:

One solution can be like this:

/**
*   @param text The Text from where to snip
*   @param n     The limit, 200 in the above example
*/

function getWordsInN($text,$n){
return substr($text = substr($text,0,$n)
,0,
strrpos($text,‘ ‘)
);
}

Lightwieght VOIP billing software using mysql,servlet and ajax

Posted on | July 7, 2008 | 4 Comments

Though I don’t like to do extra work beside my day job, but there are some people (and some offer :P)  whom I don’t like to refuse. Surely the work must be interesting.

Before some days,  one of my ex bosses gave a project to build a VOIP billing software. I was studying SIP protocol for a while and the offer seemed very interesting.

The task was simple though. It will just show the call history mainly.  But the challenge was to make it as light weight as possible and secondly there is no documentation about the data!

The reason behind making it light weight  is that the application will be hosted on the switch, i.e. the web server is running on the switch box. Well, I decided to use no flashy look at all, used plain css just the login prompt is made of ext-js. The pagination appears on top right is also ajax based.

Main problem was to find out the data. I have been given the credential to log on to the mysql server but they could not provide any information which table contains which data. The database was complex enough with more than 60 tables and the designer seemed to take extra care to put redundant data on different tables with similar name like “clients”,”client164″,”clientinfo” etc. And guess what, the actual log in infromation is in client164 table :P

Here are some screen shots:

Login page

Connecting in progress

Call log

GPS Tracking: Good side and the ugly side

Posted on | June 27, 2008 | 1 Comment


Perhaps many of us are well aware of GPS i.e Global Positioning system and its applications like GPS Tracking. GPS enabled gadgets can be regarded as a compulsory tool in many cases especially in field works, surveying, expeditions etc.  It can confirm you that you are never lost. My wife is a geologist and I often hear her saying how GPS Tracking is so important in her job.  In her current project they are using LiveWire Real, this little instrument helps them knowing everyone’s position in an wide area.

Besides, when I lost my car in last year, I decided to use some devices to protect car theft. Actually it is quiet impossible to avoid car theft, but I took a different measure. I installed T-Trac XS Internet GPS Car Tracking System in my car and really feeling secure. Now I can help the police to know the exact location of my car if I am unfortunate enough to have my car stolen again.

Surely these are some good side of GPS tracking. But I was very disgusted when I came to know that one my friend has presented his wife this pen. It is nothing but a small gps tracking device that can track his wife. Well some of you may find nothing wrong with this, but to me it is an example of mean mindness and mistrust. You can use such thing for your pet, but not for your partner.

Should you?

Learning Flex3 Task 3: Using function in script tag and in separate ActionScript file

Posted on | June 7, 2008 | No Comments

In the last example we have used some functionality against the click event of the button. Now we will encapsulate the code in a function and call it.

For embedding script we have to use a special tag in flex. It is the mx:Script tag. Inside the tag we will use a CDATA section to write the script codes. If any of us is not aware of what CDATA is, just to inform him/her inside CDATA no tag is parsed. You can write virtually whatever you like.

Let’s add a script tag into our application.

<mx:Script>

<![CDATA[

public function clearText():void

{

lblName.text = '';

txtName.text = '';

}

]]>

</mx:Script>

Calling this function is simple as you might guess:

<mx:Button id=”btn1″ label=”Clear All” click=”clearText()” />

Don’t forget to enter some comments, it’s a good practice.

The entire code will now look like:

<?xml version=”1.0″?>

<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml”>

<mx:Script>

<![CDATA[

/**

* clear text clears the text of the text and the label

* it is invoked from Button btn1;

*/

public function clearText():void

{

lblName.text = '';

txtName.text = '';

}

]]>

</mx:Script>

<mx:Panel title=”App 2″>

<mx:TextInput id=”txtName” text=”hello” />

<mx:Button id=”btn1″ label=”Clear All” click=”clearText()” />

<mx:Label id=”lblName” text=”{txtName.text}”/>

</mx:Panel>

</mx:Application>

But it’s not a good idea to write down logic and layout in the same file. Just like we use separate js files for JavaScript codes with html, we can also use a separate ActionScript file for the code and put the layout code in the mxml file.

Here I have created a file and pasted the function code into it. Saved the file as app2.as in the same folder of the main.mxml file. You can use any valid names for the ActionScript file with the extension .as since it is the default extension for ActionScript files.

We can now use this file as the source of the script in this way using the source attribute:

<mx:Script source=”app2.as” />

Prev: Learning FLex3 Task2 : First action and accessing component property
Start: Learning Flex3 Task1: IDE and basic application
Next:

Learning Flex3 Task1: IDE and basic application

Posted on | June 7, 2008 | No Comments

You know xhtml? Or have some knowledge on html or xml syntax with some javascript concepts? Yes? Cool, you will find flex3 with ActionScript is almost nothing more than developing a html page with javascript. As you know there are some built in libraries in javascript like Math, ActionScript with Flex has some extra libs present. That’s all.

Now, let’s get going.

Windows users can get the FlashDevelop software from www.flashdevelop.org/. It is a nice actionscript development environment. Linux users can Eclipse and get the instructions from http://www.communitymx.com/content/article.cfm?cid=F3ECF or can use SE|PY from sourceforge.net/projects/sepy/.

I am using FlashDevelop at present while writing this.

Here is a simple typical hello world application code:

<?xml version=”1.0″?>

<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml”>

<mx:Label text=”Hello world”/>

</mx:Application>

Code Break Down:

First line the xml header. The flex files are saved as msxml format which is nothing but an xml file. So, this header must be present

Then comes mx:Application. This starts the application. Anyone who is not familiar in xmlns or the Xml Name Space can think it as a prefix to the component. This prefix helps to distinguish the components. Say, you have made a custom label component of you own and named it too Label. Now how the compiler come to know that which one is your label or application label. So to meet this problem you can use your own namespace like xmlns:smarty=”xxxx”. Now on you can use your Label like smarty:Label.

Lastly, <mx:Label text=”Hello world”/>. This self explanatory statement adds a label in the application and sets the text “Hello world”. It is very similar to html tags, right?

Generally, we use Panel as container of all elements. It not only looks little better but also help organizing the UI elements.

<?xml version=”1.0″?>

<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml”>

<mx:Panel title=”App 1″>

<mx:Label text=”Hello world”/>

</mx:Panel>

</mx:Application>

Here is how it looks now:

FlashDevelop instructions:

1. Create a new flex3 project.

2. Save the code in the Main.msxml file.

3. Press F5. simple hah?

Download file Main.mxml

Next: Learning FLex3 Task2 : First action and accessing component property

Learning Flex3 Task2: First action and accessing component property

Posted on | June 7, 2008 | 2 Comments

Every person has his/her own way of learning. My way is to learn by example. I may understand some math rules but I will be more confident at exam if done some practice example using that theory. Similar to this, I can understand what a language can do by reading but I will be much more comfortable if you do some real codes using that language.

As you are accompanying me in this journey, I will rather emphasis on the code example than on theory. I will try my best to reveal all the strength of flex3 to you by examples.

In this lesson, we will use a button and perform an action when it is clicked.

Let’s see what we would do in html:

<input type=”button” value=”click me” onclick=”this.value=’clicked’” />

Now, this is what we need to do in flex3.

<mx:Button id=”btn1″ label=”click me” click=”{btn1.label=’clicked’}” />

Now, in flex this means the main movie which we can put aside for the moment. For the time being we can think that all UI components must be accessed with their ID.

Here we have seen another feature which is accessing properties of a component.

Besides accessing properties, we can also bind properties. We will use a text box, a label and a button to demonstrate binding components. We will also use a button to clear the text of the two components.

Here is the code:

<?xml version=”1.0″?>

<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml”>

<mx:Panel title=”App 2″>

<mx:TextInput id=”txtName” text=”hello” />

<mx:Button id=”btn1″ label=”Clear All” click=”{lblName.text=”;txtName.text=”}” />

<mx:Label id=”lblName” text=”{txtName.text}”/>

</mx:Panel>

</mx:Application>

We can see that on entering anything in the textbox automatically updates the label text.

Download file: Main.msxml

Prev : Learning Flex3 Task1: IDE and basic application
Start: Start
Next: Learning Flex3 Task 3: Using function in script tag and in separate ActionScript file

ASP.net C#: Easily switch between SQL server database and access by an abstraction layer

Posted on | April 20, 2008 | No Comments

Problem:

You are developing an asp.net application which runs on MS SQL server on the back end. You need to show a demo to a person who does not have MS SQL Server. You have to create or export to a access database.

or

Learning ASP.net,C# newly :)

Challenges:

You have to choose SqlConnection ,SqlCommand or OleDbConnection, OldeDbCommand for SQL Server or access respectively. Either you have to replace all or have to find out a way around for this.

My Way Around:

Creating an abstraction layer. I know there are many of such classes or modules present on the net. I searched on codeproject.com and find some nice and great data abstraction layers. If you are looking for a complete database abstraction layer, this post might not help you. Rather, it will help you showing how to develop a simple abstraction layer for different type of connection.

How to use:

DALFactory.StrConnection = ConfigurationManager.AppSettings["conn_string"];// How i’m using

DALFactory.DALType = DALFactory.SQL;// or ACCESS

DAL dal = DALFactory.GetDal();

dal.SetSql(”Select * from student where id=@id”);
dal.AddWithValue(”@id”,1);
IDataReader reader = dal.ExecuteReader();

Thats it :)

Here are the file:

dal.cs
dalfactory.cs
dalsql.cs
dalaccess.cs

PS: I think the naming is not proper.. DALAccesss should DALOle

How to create MS SQL Server 2005 unique key step by step example

Posted on | April 18, 2008 | 5 Comments

Looking at the title many of you may think what is the justification to write so basic stuff!

I admit. Honestly I also admit that I was searching for this over Google ! I am totally new to SQL server environment and also have no idea about its IDE. MySQL and PostgreSQL are the two DBMS which I have been using for long issuing the commands writing on the Linux console.

Anyway, here is how:

1. Connect to to the server and right click on the table you want add a unique key.

sqlserver-table-unique-key-1

2. Click modify

sqlserver-table-unique-key-modify-1

3. Right click on the design panel and select Indexes/Keys.

sqlserver-table-unique-key-select-indexes-keys

4. A dialog will open and click the Add button on the lower left.

sqlserver-table-unique-key-add

5. It will create a new entry on the list on the left panel of this dialog.

sqlserver-table-unique-key-name

6. Click the browse button (button with three dots ‘…’) on the right of the first item(Columns) in the list on the right panel.

sqlserver-table-unique-key-select-column

7. On clicking button a new dialog will appear with a list. This list items contains all the column names in a drop down combo box. Select the column you want to set unique from the drop down.

sqlserver-table-unique-key-add-columns

If you want have multiple columns together is unique, select the columns on the second row.

Say, besides the ID column, you also want to have names to be unique for each role type. So you have to select both the name and role columns.

It will automatically add a new row to give option for the third column which can left empty.

Click ok when done. It will close the dialog.

8.  Now, click on the combo right the the field named “Type“. Select Unique Key. And click Close not Add.

sqlserver-table-unique-key-end

That’s All ! You have successfully set up a unique in MS SQL Server 2005 :)

Sorry.. my previous hosting service crashed and all images are gone :(

keep looking »