Dec 20, 2010

BMW Logo - in Afterimage Effect

BMW continue to surprise us with their commercials. This time they have used the afterimage effect to let you enjoy the BMW logo with your closed eyes :)



I actually think, that BMW does the best commercials. I mean, they don't show some dancing robots stuff or other bullshit like that...
They advertise exactly what one BMW customers awaits from BMW products!!!

Dec 17, 2010

So Much Snow in Germany

Usually there is no much snow in Hessen, Germany. But this time it is something amazing :)




Dec 16, 2010

Google bodybrowser

Anar here...

I've just came across a very interesting stuff from Google labs, it's called Google maps Google bodybrowser.
Check it out!  It's pretty awesome, I would say.

Great Job, Google Team!


Be advised, it requires WebGL. 
I'm a Mac user and actually thought, that WebGL is supported already in the latest Safari, since WebKit supports it. But I didn't managed to get it working even by setting it explicitly in user defaults:
defaults write com.apple.Safari WebKitWebGLEnabled -bool YES

I therefore had to download Google Chrom beta. But it's definitely worth it ;)

Dec 10, 2010

Dec 9, 2010

Transformers: Dark of the Moon Trailer

The official trailer of upcoming T3 was released ;) In HD, by the way.
Go! Go! Go! Michael Bay!

Nov 18, 2010

Rage

Anar here... This time from my iPhone. I'm on the way currently, but still want to share something interesting with all of you ;)

Today id Software has released a great game for iOS devices - RAGE. The game provides a really incredible performance and game play - as always id Software games do...
I've just came across John Carmack's article about the development of that game. He shares some thoughts, which I found very interesting to read. Well enjoy: http://bethblog.com/index.php/2010/10/29/john-carmack-discusses-rage-on-iphoneipadipod-touch/

Sent from my mobile. Please excuse the brevity, spelling and punctuation.

Antimatter atoms produced and trapped at CERN. Part 2.

Now a video:

Nov 17, 2010

Antimatter atoms produced and trapped at CERN

Anar here...  with some cross-posting :)

PR21.10
17.11.2010
Antimatter atoms produced and trapped at CERN
Geneva, 17 November 2011. The ALPHA experiment at CERN[1] has taken an important step forward in developing techniques to understand one of the Universe’s open questions: is there a difference between matter and antimatter? In a paper published in Nature today, the collaboration shows that it has successfully produced and trapped atoms of antihydrogen. This development opens the path to new ways of making detailed measurements of antihydrogen, which will in turn allow scientists to compare matter and antimatter.
Antimatter – or the lack of it – remains one of the biggest mysteries of science. Matter and its counterpart are identical except for opposite charge, and they annihilate when they meet. At the Big Bang, matter and antimatter should have been produced in equal amounts. However, we know that our world is made up of matter: antimatter seems to have disappeared. To find out what has happened to it, scientists employ a range of methods to investigate whether a tiny difference in the properties of matter and antimatter could point towards an explanation.
One of these methods is to take one of the best-known systems in physics, the hydrogen atom, which is made of one proton and one electron, and check whether its antimatter counterpart, antihydrogen, consisting of an antiproton and a positron, behaves in the same way. CERN is the only laboratory in the world with a dedicated low-energy antiproton facility where this research can be carried out.
The antihydrogen programme goes back a long way. In 1995, the first nine atoms of man-made antihydrogen were produced at CERN. Then, in 2002, the ATHENA and ATRAP experiments showed that it was possible to produce antihydrogen in large quantities, opening up the possibility of conducting detailed studies. The new result from ALPHA is the latest step in this journey.
Antihydrogen atoms are produced in a vacuum at CERN, but are nevertheless surrounded by normal matter. Because matter and antimatter annihilate when they meet, the antihydrogen atoms have a very short life expectancy. This can be extended, however, by using strong and complex magnetic fields to trap them and thus prevent them from coming into contact with matter. The ALPHA experiment has shown that it is possible to hold on to atoms of antihydrogen in this way for about a tenth of a second: easily long enough to study them. Of the many thousands of antiatoms the experiment has created, ALPHA’s latest paper reports that 38 have been trapped for long enough to study.
"For reasons that no one yet understands, nature ruled out antimatter.  It is thus very rewarding, and a bit overwhelming, to look at the ALPHA device and know that it contains stable, neutral atoms of antimatter,” said Jeffrey Hangst of Aarhus University, Denmark, spokesman of the ALPHA collaboration. “This inspires us to work that much harder to see if antimatter holds some secret.”
In another recent development in CERN’s antimatter programme, the ASACUSA experiment has demonstrated a new technique for producing antihydrogen atoms. In a paper soon to appear in Physical Review Letters, the collaboration reports success in producing antihydrogen in a so-called Cusp trap, an essential precursor to making a beam. ASACUSA plans to develop this technique to the point at which beams of sufficient intensity will survive for long enough to be studied. 
“With two alternative methods of producing and eventually studying antihydrogen, antimatter will not be able to hide its properties from us much longer,” said Yasunori Yamazaki of Japan’s RIKEN research centre and a member of the ASACUSA collaboration. “There’s still some way to go, but we’re very happy to see how well this technique works.”
 “These are significant steps in antimatter research,” said CERN Director General Rolf Heuer, “and an important part of the very broad research programme at CERN.”
Full information about the ASACUSA approach will be made available when the paper is published.
For further information on ALPHA experiment, please read here:
http://cerncourier.com/cws/article/cern/30577
Contact:
CERN Press Office
press.office@cern.ch
+41 22 767 34 32
+41 22 767 63 33
[1] CERN, the European Organization for Nuclear Research, is the world's leading laboratory for particle physics. It has its headquarters in Geneva. At present, its Member States are Austria, Belgium, Bulgaria, the Czech Republic, Denmark, Finland, France, Germany, Greece, Hungary, Italy, the Netherlands, Norway, Poland, Portugal, Slovakia, Spain, Sweden, Switzerland and the United Kingdom. India, Israel, Japan, the Russian Federation, the United States of America, Turkey, the European Commission and UNESCO have Observer status.

Nov 15, 2010

Tomorrow at 10EST time

The Apple's home page is showing now a very promising message :)

www.apple.com



www.apple.de

So, is that iTunes on the Cloud will be presented? Or my be some news from an iTunes + iOS devices integration... Let's see :)

Oct 29, 2010

valgrind and the "failed to start tool 'memcheck'..." error

I've just decided to update valgrind with the latest version and got the following error:
"failed to start tool 'memcheck' for platform 'amd64-linux': No such file or directory"

It looks like the error is pretty much famous. I saw it also on some machines we use at work. I actually desperately needed valgrind, therefore decided to find out what the problem is.

Checking $PATH and $LD_LIBRARY_PATH didn't help - everything was fine. But what really helped is this message, which I should have read before installing valgrind :)

Important!  Do not move the valgrind installation into a place
different from that specified by --prefix at build time.  This will
cause things to break in subtle ways, mostly when Valgrind handles
fork/exec calls
(valgrind's README file)

But you know, I didn't really moved the installation. What I did was just configure and make, but after that I reconfigured it with prefix and didn't issued "make distclean" before reconfiguring :)

So, the recipe is simple. 
If you do "./configure" -- > "make install", than it should be just fine.
But if you do "./configure" -- > "make" -- > "./configure --prefix=..." -- > "make install", than most probably you will get this error message, see the subject.

Well you built valgrind and changed your mind later with the prefix, than don't forget to "make distclean" the source.

Hope it helps and you will not loose hours looking for reasons of the error ;)

Sep 27, 2010

"country of purchase"

Anar here...

Finally it has just happened. If you bought an iOS devise (iPhone for example) in one EU country, you can use your warranty rights in another EU country!!!
Brussels, 25 September 2010, Antitrust: Statement on Apple's iPhone policy changes (Reference:  IP/10/1175    Date:  25/09/2010):
...One focused on the "country of purchase" rule, whereby repairs service is only available in the country where the iPhone was bought, which made the exercise of warranty rights difficult for consumers who had purchased an iPhone in another EU/EEA country than their home country. The Commission had concerns that this rule could amount to territorial restrictions aimed at dissuading European consumers from buying iPhones outside their country of residence and so leading to a partitioning of the market...
Previously, if people buy an unlocked iPhone in Italy while being residents of Germany, for example, they will be refused to get it fixed by warranty in Germany. They were forced to send devices to Apple Service in Italy (by providing home addresses in Italy) :(

Now it seems to be over and the cross-border warranty repair is now allowed. Let's see...

Sep 20, 2010

Xcode + AStyle

Anar here...

You know, I think there are many people, who find the auto-formatting of source code in Xcode is really terrible :( I mean, it is very weak (in terms of configuration) for such a descent development environment, which XCode actually is.

Since a very long time I use AStyle (Artistic Style) to format my code. It actually does remarkable job and it is an extremely tunable tool. You can adjust it almost for all, if not for all, indentations schemas...

I have already posted a long time ago a recipe of how to setup astyle for eclipse. Now, it is time to use it in XCode.

I use a user script menu to add my own script, which will than trigger the astyle command to format a source code for me.

Use the User Script menu to add a new script. You should add your script to a section "Text", the type of the script should - a shell script.
Next is the properties of the script:
Input: Entire Document
Directory: Selection
Output: Replace Document Contents
Errors: Display in Alert

And the content of the script:

#!/bin/bash

# I pass selected file instead of a selection, because astyle 1.24
# fails to parse struct with access modifiers. It just hangs instead.
# I also use a tmp file in order to avoid annoying Xcode message, that
# source file was changed outside of Xcode.

# Important: there must be always a new line at the end of the source file.
# Next time I provide a fix for that.


TMP=`mktemp -t xcode.XXXXXXXXXX` || exit 1

cat << 'EOFEOFEOF' > "$TMP"
%%%{PBXAllText}%%%EOFEOFEOF

astyle --options=<***PATH_TO_YOUR_ASTYLE_RC_FILE***> $TMP &>/dev/null

echo -n "%%%{PBXSelection}%%%"
cat $TMP
echo -n "%%%{PBXSelection}%%%"

rm $TMP

Restriction: Be advised, there must be always a new line at the end of the source file!

BTW, don't forget to change that <***PATH_TO_YOUR_ASTYLE_RC_FILE***> to a real path to your astyle resource file ;)

The script above is actually a second version of my script. The first one was much simpler:

#!/bin/sh

echo -n "%%%{PBXSelection}%%%"
/usr/bin/astyle --options=<***PATH_TO_YOUR_ASTYLE_RC_FILE***> <&0 echo -n "%%%{PBXSelection}%%%"
But this version didn't work for me with astyle 1.24. This is why in the second version of the script:
I pass selected file instead of a selection, because astyle 1.24 fails to parse struct with access modifiers. It just hangs instead. I also use a tmp file in order to avoid annoying Xcode message, that source file was changed outside of Xcode.
Finally, just assign some shortcuts (I prefer Options + Command + L) to you script and voilà...

Sep 16, 2010

BASH: pipe command output and track the error codes

Anar here...

I've just came across a problem in on of the projects I work on.
I have a bunch of commands in a "pipe line"... something like the following.

command 2>&1 | command2 | command3

Now, what I want is to check the exit code of the first command. If I would use the "$?" than it will return the exit code of the last command, which is not what I need.

The solution is to use bash's PIPESTATUS, which will return an array of exit codes of each command in a line ;)
See what man bash says:
PIPESTATUS
An array variable (see Arrays below) containing a list of exit status values from the processes in the most-recently-executed foreground pipeline (which may contain
only a single command).
So, if I apply the solution to my example above I get something like that:

command 2>&1 | command2 | command3

if (( ${PIPESTATUS[0]} != 0 )); then
echo "something is wrong..."
fi
"In UNIX there is always a workaround" ;)

Jun 12, 2010

MacBook Pro SuperDrive won't read any dvd - ejects.

Anar here...

Actually with a good news :) at least for me.

The Problem.

This story started about a year ago. My MacBook Pro 15", late 2008 model, started to complain when writing DVDs. So, he refused some of medias :( I didn't actually pay any attention to it, since I am not burning much. I just tried to use good Verbatim disks, that all.

Some months later, my laptop started to refuse to read some DVD. That was a kind of disturbing... I looked in internet and found a verrrrryyyy long thread on Apple Discussion forum with the similar issue, and all kinds of suggestions how to fix.
I, personally, think, that there you find just similar symptoms, which actually come from different problems/errors. This is why I was very careful, when reading the thread...
Anyway I tried couple of solutions from that thread - none worked for me. Problem persisted.
Well, since I didn't have time (a lot of work) to send my laptop to Apple store to fixe the issue, I decided to give up and just ignore it. Some discs can't be read... not a big deal :)

Now my laptop is 1.6 year old and last Friday I needed to check some important backups (on DVD-R) and.... my mac just refused to read any of the disks!
So, I tried to check some of other DVDs... He just refused to read ANY of them. It spins a disk for a moment and ejects it...
What the FUCK, I thought!!!

The Solution.

NOW, the solution, which actually worked for me.

I could't believe that SuperDrive just got broken. I mean, common... ;)
So after some investigation and googling around, trying all possible solutions I came up to a conclusion, that it is most probably the dust on the lens, which "damaged" my SuperDrive. I mean, that was the only "bug", which can be fixed without sending the laptop to warranty. :)

Now, since that was the weekend and I could'n get a CD cleaner from anywhere... I decided to use some simple "solution". :)

I used a business card and a cleaning cloth, which comes with the mac or iPhone. I switched off the laptop. I wrapped the cloth around the business card and while holding the ends of the the cloth I very gently dived it for a couple of centimeters in the optical drive, pushed and pulled a bit. I cleaned on the left side of SuperDrive, since the lens should be at the left hand side.
This dirty and free trick actually worked. It took me a minute of "cleaning", after that my Mac reads everything I pop in ;) What a miracle :)

Now, I think, my problem is solved. At least I didn't fined any DVD which I can't read now. I also tried to write couple of DVDs. Worked perfectly.
I mean, I know, that I need to get my superDrive cleaned properly and I will do that some time later, but as a short term fix that was a quick solution, I guess :)


Jun 11, 2010

Linus Torvalds: C++ is a horrible language. Part 2.

Long time ago Linus Torvalds has expressed himself on C++.
Today I found another posts of his on the subject.
...And I really do dislike C++. It's a really bad language, in
my opinion. It tries to solve all the wrong problems, and
does not tackle the right ones. The things C++ "solves"
are trivial things, almost purely syntactic extensions to
C rather than fixing some true deep problem...
Linus
Check the whole thing out. I find also this very interesting opinion.
I mean, just check the whole thread there out and look for Linus' posts. I think this is worth a read. Not really news but nicely expressed...

Jun 9, 2010

Automate version numbering using Git

Anar here...

Since the time I moved from SVN to Git, I was looking for a convenient and automated way to build version numbers for my projects. Same as always, it appears to be very easy with Git ;)

So, coming to the subject. Every time I make a stable release, I create a tag object in git with "git tag -a vX.Y".
Now using "git describe --abbrev=4 HEAD" I can get a canonical version number, something like this: vX.Y-NN-SSSS, where: vX.Y is the latest tag, NN is a number of commits since the tag and SSSS is object's hash or just vX.Y if I would check out an exactly released tag.

The possible workflow could be the following:
  1. Check that project's git repo. is accessible. This is a normal case for developers builds (see #2). If it is a user who runs the build from projects's source tarball, than the repo will be inaccessible (see #3).
  2. If the repo is accessible, use "git describe" to get an annotated version number. Process some needed customizations of the version string (for example, change '-' to '.' and remove leading 'v'). Write the version string to a version file, which will be distributed in source tarballs.
  3. If the repo is inaccessible, just read the version string from the version file or use a default one.
Simple is that...

It is much easer now to maintain versioning. Every stable release, which is done after a tagging, will be named as a tag name. For example, if you have tagged v2.2, than this algorithms will return a "2.2" as a version of the project. But all nightly releases or patch releases will get additional info, like "2.2-110-gede7". Using this information you can also easily find out what exactly were changed by asking git log or git describe and giving them a version string as a parameter.

There is no need now to have 3 sections in a version string when tagging: Major.Minor.Patch. Since all patch releases will get a patch (commit) counter automatically, like: "2.2.110.ssss" and accordingly a stable release will be just "2.2".

Well I use cmake as a build system for my projects, it was therefore easer for me to implement the algorithm in the CMakeLists.txt - a build rules file. One can do the same using an external shell script or something like that.
This is what I wrote on short notice:
if( EXISTS "${CMAKE_SOURCE_DIR}/.git" )

execute_process(COMMAND git describe --abbrev=4 HEAD
COMMAND sed -e "s/-/./g"
OUTPUT_VARIABLE POD_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
# remove leading "v"
string(REGEX REPLACE "^v(.*)" "\\1" POD_VERSION ${POD_VERSION})
execute_process( COMMAND bash -c "echo \"${POD_VERSION}\" > ${CMAKE_SOURCE_DIR}/etc/version" )

else( EXISTS "${CMAKE_SOURCE_DIR}/.git" )

execute_process(COMMAND cat ${CMAKE_SOURCE_DIR}/etc/version
OUTPUT_VARIABLE POD_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)

endif( EXISTS "${CMAKE_SOURCE_DIR}/.git" )
This implementation returns X.Y for stable releases and X.Y.Z.SS for patch releases and nightly builds.

UPDATE: By the way, I've just came across a GIT-VERSION-GEN script, which is used in the Git distributions. It does exactly this task, but a bit differently. It's very much recommend to check it out.

Jun 2, 2010

How to merge two independent git repositories. Part 2.

As I first mentioned in "How to merge two independent git repositories" the Git is an extremely flexible and useful tool for tracking source code ever.

Recently I came across a topic in an official Git manual, which perfectly describes how to merge one repo into another, including a history merge. This method called the subtree merge. So, check it out.

It is a bit the same way I used in "How to merge two independent git repositories", but I find the official way is more elegant as it gives a possibility to merge a repository in a subdirectory of another repository and it is a safer method in general.

I tried it already and happy so far ;)

May 21, 2010

Clang++ Builds Boost!

Anar here...

I am a bit cross-posting... again... :) But this is a great news, I would say.
Should I say more than this:
This morning, Clang++ had its first fully-successful Boost regression test run, passing every applicable C++ test on the Boost release branch [*]. According to today's results, Clang is successfully compiling more of Boost than other, established compilers for which Boost has historically been tailored (through various workarounds and configuration switches). In fact, Clang's compiler configuration in Boost is completely free of any of Boost's C++98/03 defect macros.
Read it here.

Mar 24, 2010

Robot Touchscreen Analysis

A bit of cross-posting...

Guys from the MOTO made a re-test of Touchscreen Analysis and this time using a robot ;)
Guess who won the latest tests?

But of course.... iPhone wins again.

Mar 15, 2010

News on C++0x

There are some results from the latest C++ committee meeting in Pittsburg.

  1. The final draft was excepted and it looks like the final standard will come in 2011. ;)
  2. Export templates were thrown out of the language :( EDG - was the only who really implemented it and they proposed to remove this feature.
  3. ..EDG reports that their experience in the field has been that nearly no one actually uses the feature, and that it would be right (and okay with EDG) to deprecate or remove it...

  4. Exception specifications has been deprecated. Finally... :D Now also a new keyword "noexcept" is added. Which will remove run-time overhead of exception specifications and will let compiler to better optimize the code in compile time.

See for more details a Trip Report: March 2010 ISO C++ Standards Meeting, from THE Guru Herb Sutter.

Mar 3, 2010

malloc/free interception on Mac OS X

There is a very easy way to hook malloc/free calls on Linux and on other systems, which support the GNU C library. Simply because the GNU C library lets you modify the behavior of malloc, realloc, and free by specifying appropriate hook functions.

Now, how about hooking malloc/free calls on Mac OS X?

Actually it appears to be also not a difficult task in some terms.
The very simple way of changing the behavior of malloc, calloc, realloc, and free routines is to implement your own zone (you have to be very careful with this one) or one can override calls of the default zone, which is automatically created for each process.
Let's try the second one.

We assume, for example, that we want to track all allocations and deallocations in a given application on Mac OS X.
The first step to achieve our goal consists of asking for our default zone structure. The following statement is doing that:
malloc_zone_t *zone = malloc_default_zone();
Don't forget to check for errors, and check that you got your zone.
The next step is to save default zone's callbacks to some tmp storage. You can either save this zone to a static malloc_zone_t variable (save the entire structure):
...
static malloc_zone_t original_zone;
...
original_zone = *zone;

or you can save each callback, you need to override, to a tmp variables:

system_malloc = zone->malloc;
system_free = zone->free;

the same you can do for calloc and realloc and company...

The final step is to override default hooks with custom ones:

zone->malloc = &my_malloc;
zone->free = &my_free;

which could look like the following:

void *(*system_malloc)(malloc_zone_t *zone, size_t size);
...
void (*system_free)(malloc_zone_t *zone, void *ptr);
...
void my_free(malloc_zone_t *zone, void *ptr)
{
malloc_printf("free(zone=%p, ptr=%p)\n", zone, ptr);
system_free(zone, ptr); // or if you save the whole zone: (*original_zone.free)(zone, ptr);
}
and so on...

In my_free, my_malloc and my_whatever, we can call some of our custom code to track allocations/deallocations and (if needed) we call the default function accordingly to let default zone do its job.

Snow Leopard
There is on thing you should know if you want to run your malloc hook on the Snow Leopard. According to Apple's C library malloc.c, implementing free hook is not enough to handle all frees.
Check the implementation of the free function from the library:

void
free(void *ptr) {
malloc_zone_t *zone;
size_t size;
if (!ptr)
return;
zone = find_registered_zone(ptr, &size);
if (!zone) {
malloc_printf("*** error for object %p: pointer being freed was not allocated\n"
"*** set a breakpoint in malloc_error_break to debug\n", ptr);
malloc_error_break();
if ((malloc_debug_flags & (SCALABLE_MALLOC_ABORT_ON_CORRUPTION|SCALABLE_MALLOC_ABORT_ON_ERROR)))
abort();
} else if (zone->version >= 6 && zone->free_definite_size)
malloc_zone_free_definite_size(zone, ptr, size);
else
malloc_zone_free(zone, ptr);
}

As you can see, one should also override/hook a newly added call for malloc_zone_free_definite_size:

system_free_definite_size = zone->free_definite_size;
zone->free_definite_size = my_free_definite_size;

I would also use a condition before using free_definite_size. I prefer cmake, I therefore have something like that in my CMakeLists.txt:


#
# Check that malloc_zone_t has the free_definite_size memeber
#
if(APPLE)
include(CheckCSourceCompiles)
check_c_source_compiles("
#include
void main () {
malloc_zone_t zone;
zone.free_definite_size = NULL;
}
" APPLE_MALLOC_ZONE_FREE_DEFINITE_SIZE)
endif(APPLE)

and in the source code:

#if defined(APPLE_MALLOC_ZONE_FREE_DEFINITE_SIZE)
if (zone->version >= 6 && zone->free_definite_size)
{
system_free_definite_size = zone->free_definite_size;
zone->free_definite_size = my_free_definite_size;
}
#endif

That's It.
This technique works on Mac OS X 10.5-10.6. Enjoy!

Feb 23, 2010

The climate "catastrophe"

Anar here...

I am currently participating in ACAT 2010 in India, Jaipur.
Last night we had a welcome dinner by LNM Institute of Information Technology, Jaipur.The organization and the food were really perfect. The weather also prepared a very entertaining surprise for us ;) Check up the video:


Feb 18, 2010

StarCraft II is in Beta

An amazing news I found today ;)
Blizzard has just started to seed a beta of StarCraft II: Wings of Liberty. This is the game, which is, I believe, in the wish list of many many people :)