Friday, December 12, 2008

Personal Area Network (PAN)

Personal Area Network or shortly (PAN) is a communication network between a group of bluetooth-enabled devices (supporting PAN)

this network can be used between these devices in the same manner as local area connection i.e you can use it to transfer files between two devices or even more you can use it in a twisted way to enable one device to use other device internet connection after configuring a bridge between it and WLAN network

anyway it is a nice technique of communication, i liked it so much and tried to use it but i couldn't because my N80 doesn't support it. i suggest everyone to make use of this powerful facility

Sunday, October 5, 2008

How to name your command line windows??

if you are one of the people that use to open so many command line windows while working then you may have faced the problem knowing which one is opened on which task

for example, suppose you have a windows doing task X and another doing Y and another doing Z and so on. all have same default name added by windows when you open a command line window. Due to these similarities you always get lost getting to the window you want in one step

to get rid of this problem, use this small tip and name them with significant names using 'TITLE' command as follows

TITLE {{desired-name}}


that's it, now you can know which windows you have and select the one you desire in a fast way

Tuesday, September 23, 2008

Rails Console Tips & Tricks II

This is my second rails console tips & tricks. if you interested in reading previous tips and tricks read my first blog post regarding that matter.

This second part is about one command called "load" that is available in your Rails console. you can use this command to do many things as

1. to reload any file that was loaded when starting console and don't get reloaded when using "reload!" command such as files in your lib folder. to reload any file just write

load "#{RAILS_ROOT}/lib/{{file_name}}"


2. if you faced a problem such as "MySQL has gone away" just reload environment.rb once again as follows

load "#{RAILS_ROOT}/config/environment.rb"


3. also if you want to test a bunch of code in your console not just a single line of code, and want to be able to change part in it and rerun it once again then doing so in console is very time consuming and annoying so rather than doing so, you can write this code in a file and then

load "{{your-ruby-file}}"

Monday, September 8, 2008

Ruby Make Problem

Still in my early days using Linux and trying to compile ruby 1.9 on my machine in order to move my working environment to Linux

I downloaded ruby 1.9 source from ftp.ruby-lang.org and as stated in readMe file, i ran

./configure --prefix={{any-desired-path}}

successfully then ran

make

it took some time then i was faced with that error

executable host ruby is required. use --with-baseruby option.

What is that error? and what ruby?? i am compiling ruby how come i need it.


Anyway, i began searching for an explanation. i reached to a comment in one of the forums stating that this error can occur in these two cases

1. ruby isn't in the default path
2. ruby isn't installed

More investigation showed that i should have any previous version of ruby installed in order to use it with that make file as follows

./configure --prefix={{any-desired-path}} --with_baseruby={{full-path-to-ruby-executable}}

then run make command once again. And it worked finally

What a nice recursive world, "ruby is needed to compile ruby"

Thursday, September 4, 2008

configure: error: C compiler cannot create executables

In my first start to use ubuntu, i wanted to compile ruby on my machine

i downloaded ruby source and executed configure file to generate make file

./configure

i got this error

C compiler cannot create executables

although i have gcc latest version installed



after investigating this error i found that the solution was

sudo apt-get install build-essential


after doing so, everything worked fine

Tuesday, August 19, 2008

SVN Branches do HELP


Q: Have you heard about SVN branches ?
A: yes i have

Q: Have you used it before ?
A: no i didn't


if this scenario applies on you, then let me tell you why you should deal with SVN branches. I will try to prove my concept through a small scenario introducing 3 problems you might face while using SVN and how they can be solved with or without branches

Scenario


suppose you are working on a project and after a while you reached a stable state at which you decided to go live. after going live, you decided to move ahead and work on the next version of your project. while working on this version, a sudden problem occurred on your server and your online version was lost.


HOW WILL YOU RETURN IT BACK LIVE AFTER YOU STARTED DEVELOPMENT ON A NEW UNSTABLE VERSION?? This is problem 1.

hopefully you succeeded to do so, but later on, you found a bug and started fixing it but you can't leave your online version containing this bug until you finish development of the new version.


HOW CAN YOU COPY THIS BUG FIX TO THE ONLINE VERSION?? This is problem 2.

you also succeeded doing so, now suppose that problem 1 happened once more but this time after fixing problem 2.


HOW WILL YOU GET BACK ONLINE WHILE NO REVISION CONTAINS BUG FIXES MADE?? This is problem 3.

Without using SVN Branches


In problem 1, you will start looking at the repository revisions searching for the revision number at which you decided to go live in order to check it out again on your server and return online
accepted solution but considering the time and effort you took to do so i consider this solution a difficult one

In problem 2, you will fix the bug then select from your project the altered files and copy them one by one to your server without selecting any other files related to the new version you are working on. this solution will take a lot of time and effort and some errors might be expected while selecting files

In problem 3, i think you will have to work in your weekend in order to find the stable version and add it to bugs fixes that you have made

After SVN Branches


In problem 1, since you have created a new branch for the new version leaving your stable version as it is. all you need is to check it out again.


In problem 2, when you find a bug you will just commit all files you changed to your branch then start fixing that bug and commit the changed files then finally merge the difference between the last two revisions on branch with trunk


In problem 3, take what is in the trunk directly


I think it is now clear how helpful branches can be especially in a project that is expected to change from time to time which is actually common in a large of projects

Monday, August 18, 2008

Different encoding error

if you found yourself suffering with this error

ActiveRecord::StatementInvalid: Mysql::Error: #HY000Incorrect string value

don't cry or check your code looking at the data you save thinking that you might have left some bad characters around causing you this misery

all you need to do is to check the used database connection encoding against your db tables encoding, most probably you will find them different

if so then the solution is one of these two options
1) remove encoding field from specification and use default db encoding
2) change the encoding of your db tables to this encoding

once you do so, you will have a good life