Friday, 22 June 2012

Railsbuntu

Been a long time since I wrote a post....

I am now sending myself into a new adventure : Writing a technical book RailsBuntu .

This will be done base on an agile context (thanks to leanpub.com), where the readers can interact with me, and maybe some will join me as it s going along.

But first let me tell you that the book is not yet available and published, I have a lot of work to do to put my notes all together in order to make it readable, and it is taking more time than I thought.

I may release chapter by chapter and depending of the feedback than I got I may divert a little from the line that I have chosen.

Please feel free to comment and let me know if there is a point that you would like to see.

The target of the book is Rails on Rails on a Ubuntu Server. So I will first look at the admin side of the server to get the web platform ready and then add rails examples needed for particular aspect such emailing, ajax example, html layout etc...

A section on troubleshooting may be useful, where I can put problems that I(or you) have encounter during my coding experience.

Wish me luck and be patient with me (I also have a full time job)

Friday, 18 February 2011

New rails application with mysql

Following previous post I will create a new rails application with mysql as database server. (as before under ubuntu10.10)
First mysql dependencies:
user@Lap:~$ sudo apt-get install mysql-server libmysqlclient-dev

user@Lap:~$ gem install mysql2 --no-ri --no-rdoc
Building native extensions. This could take a while...
Successfully installed mysql2-0.2.6
1 gem installed

user@Lap:~$ rails new app -d mysql

this will create the directory app with all the necessary files


user@Lap:~$ cd app

create the database for the app (info for database in config/database.yml)
user@Lap:~$ rake db:create

user@Lap:~$ rails generate scaffold command execute:string
invoke active_record
create db/migrate/20110219000712_create_commands.rb
create app/models/command.rb
.........

user@Lap:~$ rake db:migrate
== CreateCommands: migrating =================================================
-- create_table(:commands)
-> 0.1622s
== CreateCommands: migrated (0.1624s) ========================================

user@Lap:~$ rm public/index.html

user@Lap:~$ nano config/routes.rb
# just remember to delete public/index.html.
root :to => "commands#index"
#note this is the new rails3 way to do it


user@Lap:~$ rails server


Reference: Video similar command examples with rails2


Install RVM and Ruby enterprise on ubuntu10.10

an quick way to install RVM the Ruby Version Manager:

user@Lap:~$ sudo aptitude install build-essential git-core curl

user@Lap:~$ bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
hoops.... this is not valid anymore, now:
user@Lap:~$ 
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)



From there you can install any version of ruby and different gemset.


Before using rvm command, you need to add this line to your .bashrc (at the end of the file)
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
Not any more! this is now included in the install(15/09/2011)

Then open new terminal type "rvm"


I like to use ruby enterprise (ree in short for rvm)
before to install ree let's install dependencies with the following command
user@Lap:~$ sudo aptitude install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev

Install ruby enterprise
user@Lap:~$ rvm install ree
Installing Ruby Enterprise Edition from source to: /home/user/.rvm/rubies/ree-1.8.7-2011.01
ree-1.8.7-2011.01 - #fetching (ruby-enterprise-1.8.7-2011.01)
....

use the install ree
user@Lap:~$ rvm use ree

then install the gem you want the usual way
user@Lap:~$ gem install name_of_gem
e.g
user@Lap:~$ gem install rails

Note: by default the gems are install in the global gemset but you are free to create different gemset with "rvm gemset create gemset_name"

Reference: RVM site

Friday, 25 July 2008

How to install eclipse+Qt 4+ MinGW

After trying to install Eclipse + QT integration +minGW with some trouble for the last 3 days I decided to put together a small guide to help newbies like me not to go through the same problems.
So you can follow the next step to install Eclipse under Windows vista with QT4.4.0 and minGW and its g++ libraries.

1. Download "Automated MinGW Installer" with filename “MinGW-5.1.4.exe” from http://sourceforge.net/project/showfiles.php?group_id=2435, Install MinGW-5.1.4.exe ( Notice you select and download “MinGW base tool” “g++ compiler”, and “MinGW make” during the installation)


Fig 1: MingGW installation.


Note: I selected the standard C:\MinGW\ path


2. Download "GNU Source-Level Debugger" from http://sourceforge.net/project/showfiles.php?group_id=2435, Filename is “gdb-6.8-mingw-3.tar.bz2” decompress it to the directory where you installed MinGW. (to decompress you may use the 7zip program) Please choose no when the decompression software asks you whether to cover the file with the same name.

Only the 2 files; gdb.exe and gdbserver.exe in the /bin/ have to be copied to the QT\4.4.0\bin\


3. Download "Qt/Windows Open Source Edition", filename “qt-win-opensource-4.4.0-mingw.exe” from http://trolltech.com/developer/downloads/qt/windows. Install it. It will put everything in C:\qt\4.4.0\

mingw message saying that it want to use mingw version 3, ignore the message. the version already install is newer and worked for me.



4. Download "Eclipse IDE for C/C++ Developers" filename “eclipse-cpp-ganymede-win32.zip” from http://www.eclipse.org/downloads/, decompress it to a directory no install involved, works directly from the exe file.



5. Download "Qt Eclipse Integration Downloads" with filename “qt-eclipse-integration-win32-1.4.0.exe” from http://trolltech.com/developer/downloads/qt/eclipse-integration-download, install it.

6. Set your system's Environment Variables.

Start\computer\system porperties\advanced system settings\ Environment Variables (under Vista)


Add C:\MinGW\bin and C:\Qt\4.4.0\bin to PATH
Add C:\MinGW\lib and C:\Qt\4.4.0\lib to LIB (create one if needed),
Add C:\MinGW\include and C:\Qt\4.4.0\include to INCLUDE (create one if needed),



Fig: Environment of vista.


Reboot your computer.(especially under windows XP or lower)
Note: If you forget this path the build of the debug libraries may give some errors.


7. In Start menu\All Applications\Qt by Trolltech v4.4.0 (OpenSource), please find Qt 4.4.0 (Build Debug Libraries) and execute it.

Note this will take around two hours on a celeron and few GBs on the hard disc where you installed Qt.



Fig: Building debug libraries and Qt\4.4.0\lib directory .


8. Now we are almost ready write a new Qt project in Eclipse. Just need to go to “Window\Preferences\Qt” to write the QT4 path “C:\QT\4.4.0\bin\” and “C:\QT\4.4.0\include\”


To run a program go to the main.cpp file select the green arrow \ run as local application.


Fig: Run eclipse with Qt project

It worked (this time) for me. It should work for you.

Have fun and all the best QTs