Sunday, August 5, 2007

Converting videos to watch in mobiles

I tried several video converters to get my movies/videos into Motorola A1000 and Nokia E50 / N95. Here are the video settings that worked on a few of them:

3Gpp converter
is the best converter that i could find. It uses ffmpeg and other open source utilities under the hood. The original website of the producer is in Japan (http://www.nurs.or.jp/~calcium/3gpp/) and the default languague for the utility is Japonese (that can be easily changed in the main application window to english).

General: 3GPP+AAC General Setting with XviD encoder (this is set up with the 'setup' utility)
Setting: QVGA High Quality 15fps Stereo - produces video 320x240
Setting: QCIF High Quality 15fps Stereo - produces video 176X144 (works on A1000, E50 and N95)


Smartmovie:

Codec: Xvid
Bitrate: 224kbps
Screen size: 320x208
Sound: 22050hz, 40kbps, mono
Format: AVI

Cristal 2 mobile:
Codec: MP4V
Screen size: 320x208 / 18fps
Sound: MPGA 32000hz, 56kbps, mono
Format: AVI

Multimedia Studio
Codec: H263
Screen size: 176x144 / 12fps
Sound: MP4A 32000hz, 256kbps, stereo
Format: 3gpp or mp4


And while you are at it, have a look at this list of free converters that I just found. I haven't tried most of them thought, I'm pretty happy with 3gppConverter for now. :-)

Saturday, July 28, 2007

The Motorola A1000 smartphone

A few days ago I got an Motorola a1000. It is a smartphone that was first release in 2004.
This handset has a decent 320x208 pixels touch screen capable of 65K colors, one VGA camera and one 1.2 Mpixel camera. It comes with 32Mb ram (about 24 available) has bluetooth and an internal AGPS.
It runs on Symbiam UIQ.

The first thing I did after getting the phone was get some extra memory.
The largest micro SD (Transflash) that works in this handset is 1Gb. I currently use one from Sandisk and it works very well.
It also only works with the normal speed micro SDs. I tried the 2Gb Ultra II from Sandisk with no sucess and read in many forums that the 1Gb Ultra II doesn't work either.

Things I wanna do with the (already a bit ancient) a1000:

  • Browse the internet via Bluetooth (using my computer link)
    • Currently I'm having problems with the bluetooth setup
  • Watch movies
    • Smartmovie is an excellent movie player and converter, but is a bit overpriced.
    • Tried Cristal 2 Mobile which just made UIQ freeze
    • Tried TCPMP but the alpha version available is far from usable
    • Will stick to the original movie player on 3gpp format for now. 3gppconverter is a good converter from avi to 3gpp. The set that works best is 'qcif high stereo'.
  • Use as GPS
    • nhGPS works well but the phone's antenna is too weak
    • Still want to try the smartCom gps which is an navigation system
  • Listen to music
    • Bundled player is ok for now
  • Read pdf
    • The built in reader (picsel viewer) cannot resize pdf to the screen size
  • Read html
    • Picsel viewer does a fairly good job
  • Read word docs
    • Also here Picsel viewer is enough

Saturday, July 7, 2007

Configuring WPA in FC6

This blog has among other tips a easy recipe on getting WPA working with NetworkManager on FC6

Tuesday, June 5, 2007

Recycling the logs in Fedora 6

Recycling of the log files

In Fedora, most daemons save their logs in /var/log/. If they aren't periodically recycled (meaning throw away or archived), they can potentially grown until they fill the disk.

In order to avoid that, if your daemon doesn't already has it, create a file like this in /etc/logrotate.d/, or add it to /etc/logrotate.conf.

All Fedora official RPM packaged daemons already have this.

# recycles the log file for myDaemon and myOtherDaemon
/var/log/myDaemon.log /var/log/myOtherDaemon.log {
notifempty
size 300k
create 0600 root root
}

Note that the new file is being created as root. Change that if your daemon runs as another user or it wont be able to write to the file.

Sunday, May 6, 2007

Installing Plone CMS in Fedora Core 6

What is a Content Management System?
Traditionally web sites are maintained by a 'webmaster', he is responsible to getting new material, transforming it into HTML and publishing it to the site. The problem is that this setup is far from the ideal since webmasters, no matter what they had told you, are not gods. They tend to be the bottleneck on the process. CMSs allow for the users to edit the site contents without having to know anything about HTML or web servers. This very blog you are reading now is based in a CMS that allow people to create posts.

Installing Plone in FC6

The Plone package is available from the 'extras' repository for Fedora, run as root:

# yum install plone

This will install plone and it's dependencies (zope, etc).

After the installation you will need to start zope service. Zope is a application server (like Tomcat is, if you know it) that provides a framework for developing web applications. Plone was built on top of it and as such needs Zope to run.

# service zope start

To make it start automatically at boot time run:

# chkconfig zope on

The server will be available at http://localhost:8080/. If you navigate to this page with your browser you will see a page telling you have no administrative account for Zope.

To create an account

# zopectl adduser userName MyPass


After you log in with the new user an password you get the interface show in the right. From the pop up menu under the 'help' link, pick 'Plone Site' and add it.

Give it the name and description you want but be aware that Zope just accept characters from A-Z, for the title and description you can change it latter in Plone.



Your Plone installation is ready to use, if you picked 'plone' as the site title, navigate to http://localhost:8080/plone to access your newly created website.


The user ID and password for Plone are the same used in Zope.


More info:
http://fedorasolved.org/server-solutions/installing-zope-plone-on-fedora

Tuesday, April 24, 2007

SOA basics

If you haven't been living among the penguins in Antarctica for the last few years, you probably have already heard about Service-­oriented Architecture or SOA.
Nonetheless it is still a bit dificult to find a straightforward definition on what it is... So here it goes!

SOA is a standards based approach for building application modules – called services ­- in a way that facilitates the integration between different applications.

From a technological standpoint there is nothing new in SOA. It's main advantage when comparing to previous approaches (like CORBA) is the fact that it is based in Industry accepted standards and as such doesn't depend on a single vendor implementation and can be widelly adopted.

SOA applications can be composed by services built with different development platforms (such as .NET or JAVA) and available in completely different locations (lets say an application running in London call a service located in a server in Taiwan that at it's turn calls another service in New York).

Monday, April 23, 2007

Why to version control your projects?

If you have ever been involved in a group project in which the members work in the same set of files (like a software development project) you will probably have noticed the issues that appear almost immediately:
  • What is the latest version?
  • Is this or that feature already present?
  • Who did what?
  • Where have the changes I spent 10 hours working on last week gone?
  • How to conciliate my changes with everyone else's?
Some of these issues could be fought with a -very- well planned project, in which each member would have his responsibilities well defined and clear cut and little or no overlapping would exist with other member's part on the project.

In a typical software project this would mean at least a well defined set of classes and interfaces between them, a good UI prototype and very precise analysis documentation. Now, we know that in times of 'Agile development' this scenario isn't very common.

This kind of detailed planning takes time and resources that are often scarce.
On top of it, this theoretical 'isolation' of each member would be counter productive, since the developers would not benefit from the overall view of the application being developed and testing would become much harder to do during the development. It would not be a group project but individual projects brought together at some point.

Another option would be having someone to periodically (lets say daily) manually merge all the changes in a new 'base project' that would be used for further development. This is a time consuming task and very often requires deep understanding of the application being developed and technologies in use.

Well, there is a better way to do that and It's called version control systems. These systems are client-server applications that take care of serving the files composing a certain project to the people interested in it, pretty much like a shared network drive would do.
But unlike a regular network share, these systems keep historical data of the files stored there, meaning that once a file is sent to them, it will be there 'forever'. If the file is changed, the older version is archived and will be available at any time it's needed.

Version control systems also keep information on what changed from one version to another, who did the changes and helps on the process of merging new changes into the project.

The most popular version control systems are CVS (concurrent version system) and Subversion.
CVS is the most used but it's shortcomings had given space for the creation of Subversion, that is intended to work in a similar fashion but address CVS's failings.

Friday, April 20, 2007

What is Boirque?

Boirque was the name of the long-deceased dog of my also long-deceased grand-uncle.
He was an half-wild dog who spent most of his days in the jungle near to my grand-uncle's little farm, hunting.

I and my brothers used to amuse ourselves during our childhood holidays in Minas Gerais' country-side (BR) by feeding Boirque whole raw eggs, which he ate with much pleasure, breaking them inside his mouth.

I liked the dog and I like his name, which has no meaning in Portuguese, but might mean something in ancient Tupi-Guarani (the language of the once largest Brazilian Native tribe) or some African language.

In its after life, Boirque lends his name to my blog.

Wednesday, April 18, 2007

Subversion quick reference guide

These are some basic subversion commands used in day to day operations, they are meant to be used on the command line client, but the basic concept is the same on the GUIs. The commands are meant to be given in one line. The # means you are logged in as ROOT (or other user with RW access to the repository) and the $ means a regular user.

Creating a new repository

# svnadmin create /Path/to/repository

Initial import of files
In your workstation, change the current dir to the folder in which the files are located

$ svn import ./projectFolder/trunk/ https://www.myServerURL.com/repositoty/project/trunk/ -m "Initial import"

Checking out a project to the workstation
After the initial import, your source folder isn't yet a 'working copy'. You have to check out a fresh copy from the repository in order to use subversion commands on it.

$ svn co https://www.myServerURL.com/repositoty/project/trunk/ project

This will create a new folder 'project' in your current working dir with the project files. If you want, you can rename this folder normally, but to rename anything inside it, you must use subversion commands so the system is aware of your modifications. When you checkout a project, the SVN client creates a hidden folder '.svn' inside each directory of the project. This folder contains files used by Subversion to signal that this is a 'working copy' of some project under version control.

Sending changes to the server
In the directory where the modified files are located

$ svn commit -m "New method to count the weight of hypos in the Windows version"

Checking the revision log
From your project folder

$ svn log

To see the log of a project that is not in your workstation:

$ svn log https://www.myServerURL.com/repositoty/project/trunk/

Updating your local copy with the latest version on the server
From your project folder

$ svn update

This will bring your copy up to date with the latest version available.
Keep an eye on the letters that appear next to the name of the downloaded files:
  • A = Added. File added
  • G = Merged. Changes on the file on the server where added to your changes
  • C = Conflict. Some changes you made conflict with changes on the server.
  • U = Updated. Arquivo foi atualizado.

Updating a file (our the whole copy) to an older revision

From your project folder

$ svn update -r 999 fileName

999 is the revision number. To update the whole working copy:

$ svn update -r 999

Deleting and moving files and directories
From your project folder

Delete:

$ svn rm fileName

Rename:

$ svn mv OLDfileName NEWfileName

This will rename the file. To move it, add the destination directory name before the destination file name.

$ svn mv OLDfileName ../OtherDir/NEWfileName

The SVN command line client can't move more than on file at a time.
To do that you can use the shell (bash)

$ for I in *.txt; do svn mv $I ./newFolder; done

This will move all .txt files from the current folder to ./newFolder

Create a folder

$ svn mkdir folderName

The rm, mv and mkdir commands affect only your working copy.
To apply them to the server, execute a 'commit'.
If you want to execute them directly on the server, give the full URL to the file on the command line
(eg. https://www.myServerURL.com/repositoty/project/trunk/fileName)


Creating a TAG (to flag a release, for example)

$ svn copy https://www.myServerURL.com/repositoty/project/trunk/ https://www.myServerURL.com/repositoty/project//tags/1.0.42 -m "New version 1.0.42"

Listing project files and tags
Listing files in the 'trunk'

$ svn list https://www.myServerURL.com/repositoty/project/trunk/

Listing existing tags

$ svn list https://www.myServerURL.com/repositoty/project/tags/

Checking out a tag

$ svn co https://www.myServerURL.com/repositoty/project/tags/1.0.42

Checking the state of the working copy
The 'svn status' command allows us to see which files where modified locally and/or in the server and thus make our copy outdated.

Checking for files modified locally

$ svn status
or
$ svn status fileName

Checking for files modified on the server

$ svn status -u

Files preceded by a * where modified on the server. Use 'svn diff' with the full URL to see the changes.

$ svn diff https://www.myServerURL.com/repositoty/project/trunk/fileName


Creating an alias to an external project

We can create an 'alias' pointing to a folder in another project within our current project.
This is done using the 'svn:externals' propriety.
From your project folder:

$ svn propset svn:externals 'externalLib https://www.myServerURL.com/repositoty/OtherProject/trunk/libs/' myProject

Obs: The 'libs' folder can't already exist in the 'myProject' or the process won't work. It will be retrieved from the trunk of the 'OtherProject'

To edit a propriety value, use the command ‘propedit

$ svn propedit svn:externals myProject


List all currently set proprieties in a project

$ svn proplist dpz


The MERGE command

This command compares 2 revisions of the repository and applies (merges) the differences between them in a local copy.
From your project folder:

$ svn merge -r 700:751 https://www.myServerURL.com/repositoty/Project/trunk

This will retrieve all the changes happened between versions 700 e 751 in our project TRUNK and apply it in our ‘working copy’ in the current directory (that can be a branch).
The command will produce a list of the modified files. You should check the files, accept the changes and commit (or revert).

$ svn ci -m 'merge of r 700:751 from trunk to release branch'


You can get more detailed info in the chapter 4 of the 'Version control with Subversion' book:

http://svnbook.red-bean.com/nightly/en/svn.branchmerge.html

Sunday, April 15, 2007

Dinamically acessing controls in C# .NET

Have you ever needed to create / access controls in your C# .NET applications?
something like substituting the following code:


Button1.Text = "click-me;
Button2.Text = "click-me;
Button3.Text = "click-me;


by this:


for (int i=1 ; i <= 3; i++){
String btn = "Button" + i;
btn.Text = "click-me;
}


Well, if you try the code above in C# you will see that it won't work.
It's because 'btn' is still a string and not a Button Control.
Even if you try to make 'btn' a real Button it still won't be pointing to the control you created in the design mode of Visual Studio:


Button btn = new Button;


Will actually give you a new Button, with a different internal ID (clientID), pointing to a Button other than the one in your UI.

How can you solve this? You can place your Controls in a Hash Table with the Control ID as a key and the control as a value when you create them, you can use reflection or you can iterate between the controls in a page until you find the one you are looking for.

The following code snipet shows you how to retrieve a control by iterating in all the controls in a page. It receives the Control ID and the page (which is a control itself) and returns null or a control matching the given ID. The method is recursive, meaning it calls itself everytime if finds a new control.


// The calling code
// The Control has to be cast to a Button.
// 'this' is the current page and 'btn' the button name
for (int i=1 ; i <= 3; i++){
String btn = "Button" + i;
Button b = (Button) retrieveControl(this, btn);
b.Text = "click-me;
}



// retrieve a control from the active page
// the method iterates between the page controls until it finds the correct
// it calls itself everytime if finds a new control that may have inner controls
protected Control retrieveControl(Control c, string controlName)
{
for (int i = 0; i < c.Controls.Count; i++)
{
Control m = c.Controls[i];
if (m.ClientID != null)
{
if (m.ID.Equals(controlName))
{
return m;
}
else
{
Control x = retrieveControl(m, controlName);
if (x != null) { return x; }
}
}
}
return null;
}


Adding the controls to a Hash Table can be a better idea if you are also creating them dinamically.
Reflection is a powerfull tool that allows you to retrieve information from the assembly but for this purpose it may not be as clear as the code above.