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 ;)