Saturday, April 30, 2011

Ubuntu 11.04 a.k.a. Natty Narwhal

This week  I got time to upgrade my personal server which was running Ubuntu 10.10 to the new version 11.04 a.k.a. Natty Narwhal. The process wasn't really difficult as many years ago when it used to take hours! and a lot of CD's.

This time I just launched the Update Manager and the notification for the new version was already there and asking if I wanted to install it. You just need to run this command:
sudo update-manager -d

New Upgrade :)

Rlease Notes

Preparing upgrade

I pressed upgrade and after asking for the root user it started the whole process. It removed a lot of old packages and replace others with the new version. One think I really like it is that I made some modifications to some config files and the upgrade tool asked me if I wanted to preserve the old ones or replace them with the new ones. This was great because I was afraid I had to re-do that work again.
Summary of things to do
The whole process might have taken around 2 hours mostly because the Ubuntu servers were so busy with all the installations that sometimes it was really slow to download the packages needed. The traffic must have been really heavy.
Installing new version
Some Clean up
At the end everything was fine but since it is a server I couldn't run the new UI Unity it seems I have to configure my graphics card and makes sense since Unity uses Compiz to run so I might need to take some more time to fix it, either way I like the classic UI.
New Scroll UI
Another new things are the new Ubuntu Software Center , Ubuntu One which lets you synchronize everything between computers and everyone gets 2GB for free, it also lets you stream your music. I need to try this one although 2GB is not too much.
Ubuntu Control Center
Ubuntu One
Talking about software it comes with Nautilus 2.32.2, GNOME 2.32.1, Firefox 4.0, Shotwell 0.9.2, Empathy 2.34.0, Banshee 2.0, LibreOffice 3.3.2, Evolution 2.32.2, Gwibber 3.0.0.1, Xorg Server 1.10.1, X.Org 7.6, Totem 2.32.2, Compiz 0.9.4, GDM 2.32.1, GRUB 1.99 RC1, Mesa 7.10, New artwork, Linux kernel 2.6.38.3, Compiz Fusion 0.9.4 and many more. They did replace OpenOffice with LibnreOffice.
LibreOffice
You can read the complete set of new features in its official page. I like Ubuntu and I would like it more once I am able to configure and run Unity.

Enjoy the new version :)

Monday, April 25, 2011

A Century with IBM

This year IBM celebrates its 100th birthday! pretty impressive indeed. IBM is one of the biggest and oldest tech companies in the world and this commemorative video shows some of their achievements during this time.

I was born in 1981 and the very first time I touched a computer wasn't until I turned 7 I think. It was a old 386 running DOS 5 and the mouse was just introduced to personal computers. I was the younger student I remember that :) since then I moved to Logo, Turbo Pascal, C++, Java and long list of technologies and I love it Computers have been my addiction since that day :)


You can fin more information about IBM's 100 birthday in its web page where they show a lot more information about all this years.

Enjoy the Video :)

Saturday, April 23, 2011

Building Android Projects from Command Line

I have been spending a lot of time with Android and I am making really good advantages with my app :) even though it is taking a lot of weekends and nights. It is difficult to make progress when you have a full time job that sometimes looks like a 2 full time jobs.

I think I noticed that sometimes using eclipse to build your project and deploy it into the emulator takes a lot of time and I already talk about how slow the Android Emulator is and some ways to it make less slow. One of them is to use command line to create your apk and then install it into the emulator or device.

First, you need to create the build.xml file so you can use ant. To do this you might need to update your root directory project to do that you can execute:

@chambras:~/AndroidWorkSpace/my-app$ android update project -p .
Updated local.properties
Added file ./build.xml

Once the build file is added you can build your app in debug mode. Just open the command line and write:
ant debug
This will create your debug apk inside your project bin/ folder and looks like [your_project_name]-debug.apk
The next step is to install the apk in the emulator and to do that you just need to do this:

adb install [path_to_your_apk].apk

or if you have multiple emulators or devices running you can execute adb devices so you will see all the devices connected and emulators running and then you can execute:

adb -s emulator [emulatorid] install [path_to_your_apk].apk
If you want to install it in your device:

adb -d install [path_to_your_apk].apk
In order to make this process fast I would recommend adding the platform-tools/ and tools/ folders to your PATH if you are using windows. If you are using Ubuntu or Mac you can do this:

sudo ln -s /path/to/android/tools/android /usr/bin/android
sudo ln -s /path/to/android/platform-tools/adb /usr/bin/adb
These will create symbolic links to those tools so you can execute them form anywhere. Here is more information about building android projects and here on how to use your device.

Happy coding :)

Thursday, April 21, 2011

How to test Google Analytics for Android

Time ago I wrote how to integrate Google Analytics into your Android application. The integration and usage it is pretty simple but the testing part is really terrible. I said that time that you can see the data in your Google Analytics account only after almost a day you posted the events. This was ridiculous, waiting one day to see your results and data just to check it is fine was just a waste of time so started digging and fingig out where these data is stored because it must have some kind of storage so later when you dispatch the data the framework looks for this data and posts it online.

Indeed, my supposition was true. As it turns out when you configure you Google Analytics account in your android application, it creates a new DB in your package folder. Inside this Data Base there are a bunch of tables but the one that stores your page views and events is named events. If you want to test the data you are collecting, these are the steps you need to do:

adb shell
cd data/data/<your.package.name>/databases
sqlite3 google_analytics.db
This last command will open the Google Analytics data base and once there you can see all the tables by executing .schema. So every time you record a page view or event a new row will be inserted in the events table. This table has a lot of columns but you can execute .schema events to see all of them and its data types so you can query the ones that you care about to test your application.

Happy coding.

Friday, April 15, 2011

Page Speed

Do you want to know how good and fast is our web site? Well this tool is for you Google Page Speed is a tool that fetches your site's contents ( HTML, JavaScript, CSS, images, etc) live, using a webkit-based renderer and gives the analysis it found and also recommendations split in high, medium and low. It also gives you a score where 100 is the best.

It is really good and it gives you detailed recommendations on how to improve and what to change to make your web site faster. One more thing that I like it is that gives recommendations for desktop and mobile which is good if you want to optimize your web site for your mobile users.

You can also use Page Speed in Chrome and FireFox and if you want to try new things you can configure mod_pagespeed in your Apache web server ( currently only working with version 2 ).


It is still in labs but really a good tool if you want to polish your web site and make it faster :)

Wednesday, April 13, 2011

Happy 20th birthday Linux

On April 10th Linux turned 20 and the Linux foundation created a video explaining its origins and how Linux has impacted us and the open source community around the world.

I started using Linux like 10 years ago. My first distribution was Mandrake 8.0 when installing used to take hours and depending on your hardware compatibility most of the things might work or not specially your graphics card, sound system and modem. It was a pain and at least 3 to 5 CD's depending on what you wanted but at the end used to felt good! :)

Now Linux is heading the server space. Most of the web uses Linux as primary servers and you can see it everywhere, mobile ( android ), in your TV ( TiVo, Google TV) , etc. I like Linux a lot I have a Ubuntu server in my apartment which let's me have access to my home network from everywhere. I wish i could use it more in my daily work but i do not see that coming :( at least I am trying to have it for my personal hobbies.

Here is the video i really recommended it it is really good. Enjoy it!

Sunday, April 10, 2011

How to enable fast scrolling in Android

Fast Scrolling in Android happens when you have a lot of items in your screen and you need to scroll fast. When it is activated you well see an small box coming from the right of the screen and when you drag it up or down it goes really fast. You can see this in your contact list, email or any application that has a lot of data and is sorted alphabetically.

There are 2 ways to enable this functionality in your application:
By adding the property in your XML layout file:


    <ListView
        android:id="@id/android:list"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:fastScrollEnabled="true" />

or by adding it in your java code:

      getListView().setFastScrollEnabled(true);

Both of them work the same the only trick is that you need to have at least 35 items in your ListView in order to see the fast scrolling box. You can see the end result in the image.



Hope it helps some one, happy coding :)

Wednesday, April 6, 2011

Using conditionals before adding columns to a table in SQL server

Working with databases is not as easy as it looks like, specially if you are working with production databases. When a database is production you need to be very careful with the changes you make, adding, removing tables, columns, changing data, etc. Once a database is in production you use incremental scripts in order to push new updates into it.

These incremental scripts need to handle everything and they do not have to have any errors and must be able to run multiple times if it is needed. One thing I keep seeing in lots of incremental scripts are the lack of verification before they are executed. The other day I asked one of my developers to add one column to a table and also to write the respective incremental script and UI controller.

This is what I got:

ALTER TABLE [table] ADD [column_name] VARCHAR(10) DEFAULT [defaultvalue];



There are a couple of things i do not like about this script but one of them was the lack of verification. If you execute this one time it will work but if you try to execute it more than once it will fail because the column is already there and you are trying to add it again.

In SQL server there is a schema which stores all the information about your tables, schema, columns everything and in order to verify if something is already in your DB, you can query that schema and then based on the results you can execute your scripts.

By doing that I ended up with this new script:

IF NOT EXISTS ( SELECT * FROM Information_Schema.ColumnsWHERE table_name='ois_incident'AND column_name = 'EntryMethod')BEGIN
   ALTER TABLE
oishealth_dev.OIS_Incident
  
ADD EntryMethod VARCHAR(10) DEFAULT 'ZPIC'END;


Now this script can be executed multiple times and you can be sure it will never fail .

happy coding :)

Friday, April 1, 2011

Getting Started with Spring Roo

Couple of weeks ago I started viewing some videos about GWT and App Engine to start developing the Web part of my project and while watching it I saw how Ben Alex showed Spring Roo for the very first time integrating it with GWT so I decided to give it a chance.

I downloaded the latest version and also their IDE Spring Suite Tools just to take a look. Usually I do not trust code generators because I do not know what they are doing and I like to have control over my code all the times that way is a lot better to maintain it. Either way I tested and I read some of its documentation.

My first impression was that it is good!!! it really takes care of all the code that could be easier to generate like Data persistence objects, Tests, Entities, and even web controllers. It took couple of minutes to create an entire application with data persistence, web interface and set of tests.

But not everything was good when I tried to generate the GWT interface it took a lot of time and only supports version 2.1 at the end I was able to create the application and then open it in their IDE and deploy to App Engine since the command line to do it with maven did not work, maybe a bug, maybe it was me but i did not have time to do more research so I took the easy path. The application is now in App Engine and works fine so my next step was to check the code and see how Spring Roo generates it.

This was the hard part besides the tool classes and files there were a lot!!! of files that I couldn't understand. It  seems that integration with GWT is still buggy although the normal generation using JSP was pretty good.

The project is open source and very active and I am sure they will improve I am seeing a good future I will keep using for the obvious things but not yet for UI.

Here a nice video where Ben shows the capabilities of Roo enjoy it! and here is the Google IO presentation


happy coding :)