Apr 15, 2009

Development under Mac OS X

Since long time already I have been not posting here... :( So, let's try to reload this blog...

With this post I am going to start a series of posts about development under Mac OS X. I will post about something I find interesting, difficult to implement, and some tricks I developed or just googled. :) Hope it helps to someone or at least it will help me to order my experience on that field.

Well, let's start from the environment.
I consider myself to be an experienced Windows and Linux developer. This stuff I do for many years already.
With Mac I met about five(!) moths ago. I mean, I knew it exists and I even worked briefly on it some years ago, but the truth is that, most of my projects were related to Windows or Linux.

I met Mac and that was love at first sight ;) As soon as I started to work on it I immediately suffered from the filling that I want to start an application development project under Mac and use it in my daily work... really!

As the hardware I use a new MacBook Pro, 15''



The only thing I can say is - WOW! It is a fucking amazing piece of hardware! Apple did a terrific job on this one.
I am just in love with the new trackpad device and the new keyboard of MacBook. No more words... Just get this laptop and enjoy!

BTW, I still do a lot of Linux development. In order to continue to do that on my Mac I use VMware Fusion. It works like a charm. One screen is a full screened Fedora 10 guest, another is a MS Windows XP guest and all under control of Mac OS X. ;)


The OS I am using is Mac OS X Leopard.
As the development environment I decided to use XCode (v. 3.1.2). Well, I am a bit disappointed with XCode and I tell you why. Mainly because of two thinks I see missing.
  1. A terrible SVN support. For example, I didn't find a way to set SVN properties on files. Also SVN plug-in sometimes living its own live and could be doing something, which blocks all version control operations on files in XCode. I didn't find a better way to just stop that plug-in by restarting XCode.
  2. No way to define custom formating rules. Formating preferences are very weak: a couple of checkboxes and that's it... If you do Objective-C development, then in a couple of weeks you will used to default formating and syntax coloring XCode does. But anyway, I would prefer to have a bit more flexible formating settings.
I think XCode is a very new and fresh product and Apple is developing it very fast (you can tell that from new thinks you get every new release). So I believe we will see soon a strong competitor to MS Visual Studio and to Eclipse. So far I would say MS VS is the best, at least for C++ development.

Anyway I would give a big plus to XCode and the best mark just for its very good integration with Objective-C and Cocoa. In combination with Interface Builder, which is by the way just the best GUI builder I have ever seen, XCode does all you need for application development.

James Bond will return... I mean, I will continue posting on that subject ;)

Sep 30, 2008

Qt got rebranded

Trolltech web site got a rebranding and there was also a Qt 4.4.3 release dedicated to the rebranding only.
Qt 4.4.3 is a rebranding-only release. In all other aspects, it is the
same release as Qt 4.4.2. It maintains both forward and backward
compatibility (source and binary) with Qt 4.4.2, 4.4.1 and 4.4.0.


In June 2008 Nokia acquired Trolltech ASA to enable the acceleration of their cross-platform software strategy for mobile devices and desktop applications, and to develop its Internet services business. On September 29, 2008 Nokia renamed Trolltech to Qt Software.

Jul 29, 2008

Google Code Jam 2008 - Alien Numbers

As many of your may know Google Code Jam 2008 has been recently launched.
I found some free time and decided to have a look at the tasks of this competition. Just out of curiosity... :)

Today's morning I solved the first task - "Alien Numbers".
The task is just for practice and has almost nothing to do with the real competition. I mean, it is a simple problem, but it was very interesting to solve it as fast as possible :)
Problem

The decimal numeral system is composed of ten digits, which we represent as "0123456789" (the digits in a system are written from lowest to highest). Imagine you have discovered an alien numeral system composed of some number of digits, which may or may not be the same as those used in decimal. For example, if the alien numeral system were represented as "oF8", then the numbers one through ten would be (F, 8, Fo, FF, F8, 8o, 8F, 88, Foo, FoF). We would like to be able to work with numbers in arbitrary alien systems. More generally, we want to be able to convert an arbitrary number that's written in one alien system into a second alien system.

Input

The first line of input gives the number of cases, N. N test cases follow. Each case is a line formatted as

alien_number source_language target_language

Each language will be represented by a list of its digits, ordered from lowest to highest value. No digit will be repeated in any representation, all digits in the alien number will be present in the source language, and the first digit of the alien number will not be the lowest valued digit of the source language (in other words, the alien numbers have no leading zeroes). Each digit will either be a number 0-9, an uppercase or lowercase letter, or one of the following symbols !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~

Output

For each test case, output one line containing "Case #x: " followed by the alien number translated from the source language to the target language.

Limits

1 ≤ N ≤ 100.

Small dataset

1 ≤ num digits in alien_number ≤ 4,
2 ≤ num digits in source_language ≤ 16,
2 ≤ num digits in target_language ≤ 16.

Large dataset

1 ≤ alien_number (in decimal) ≤ 1000000000,
2 ≤ num digits in source_language ≤ 94,
2 ≤ num digits in target_language ≤ 94.

Sample

Input
4
9 0123456789 oF8
Foo oF8 0123456789
13 0123456789abcdef 01
CODE O!CDE? A?JM!.

Output
Case #1: Foo
Case #2: 9
Case #3: 10011
Case #4: JAM!


The following is my solution in C++, be advised and don't blame me, there are many missing checks, I know that, and safety procedures. That is because I tried to solve this problems and get result as fast as possible. So, here you go with the solution I came up first.

#include <fstream>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

typedef vector<int> IntVect_t;

size_t to_num( const string &_base_set, const string &_val)
{
size_t NumRes(0);
size_t PositionPower(1);
string::const_reverse_iterator iter = _val.rbegin();
string::const_reverse_iterator iter_end = _val.rend();
for(; iter != iter_end; ++iter)
{
NumRes += _base_set.find(*iter) * PositionPower;
PositionPower *= _base_set.size();
}
return NumRes;
}

int main(int argc, const char* argv[])
{
ifstream f(argv[1]);
if( !f.is_open() )
return 1;

string outfile(argv[1]);
ofstream f_out( (outfile+".out").c_str() );

size_t nCase;
f >> nCase;
for(size_t i = 1; i <= nCase; ++i)
{
string _src;
string _dest;
string _to_convert;
f >> _to_convert >> _src >> _dest;

IntVect_t pos_dest;
size_t NumRes = to_num( _src, _to_convert );
for(; NumRes > _dest.size()-1;)
{
pos_dest.push_back( NumRes % _dest.size());
NumRes /= _dest.size();
}
pos_dest.push_back( NumRes );

f_out << "Case #"<< i <<": ";
IntVect_t::const_reverse_iterator iter = pos_dest.rbegin();
IntVect_t::const_reverse_iterator iter_end = pos_dest.rend();
for(; iter != iter_end; ++iter)
{
f_out << _dest[*iter];
}
f_out << endl;
}
return 0;
}

Jun 12, 2008

StatSVN 0.4.0

A new version of StatSVN has been released. See changes.
Download StatSvn 0.4.0.

 
New Features:

o Added support for an XML export of the main reports, just use option -xml,
based on patched proposed by Nilendra Weerasinghe. Thanks to Nilendra
Weerasinghe.
o Applied patch for [ 1639462 ] Added TRAC Support. Fixes 1639462. Thanks to
Jean-Francois Burdet.
o Applied patch to StatCVS to show the Head Revision (had to change it to
hide it for CVS as it does not make sense for CVS). Fixes 1932689. Thanks
to Martin Majlis.
o Performance enhancement. If SVN 1.4 is available, do one diff per revision
instead of one diff per file per revision. Added -force-legacy-diff option
to retain previous functionality.
o Applied patch to StatCVS to add Affected files count per commit. Thanks to
Martin Majlis.
o Applied patch to StatCVS to add Revision number on commit page. Fixes
1839303. Thanks to Martin Majlis.
o I have added a validation mechanism that checks the Repository object once
the log is parsed, if root is null, it will terminate the execution.
o I have added a small project attribute which makes it more obvious which
cache belongs to what project in the repositories.xml and xml cache files.
Fixes 1687928.
o Added support for tags-dir as a way to specify 'top' directory where the
tags are stored, defaulted to "/tags/". Fixes 1692245.
o Added support for a '-anonymize' command line option, to anonymize
committer names. Fixes 1743119.

Fixed bugs:

o Changed RSS to use the common one:
http://feeds.feedburner.com/ObjectlabOpenSourceNews

Changes:

o The RepoMap and LOCChurn reports have been promoted to StatCVS and hence,
removed from the StatSVN source tree.