Dec 28, 2007

Syntax highliting in blogspot posts

So far Blogspot doesn't support syntax highlighting and "verbatim" mechanism, which could help to post C++ (or other languages) source code blocks.
I will try to summarize in the following post workarounds I found on the subject. This post should help to:
  1. make posts with blocks of source code (C++ for example) in it,
  2. enable syntax highlighting of source code blocks,
  3. add a word wrapping for source code blocks.
Let us start!

#1
You will need google-code-prettify, which does the main job of enabling source code blocks in you posts.
Please edit your HTML template by adding the following lines to the end of your "head" HTML block:

<!-- google-code-prettify -->
<link href='http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css' rel='stylesheet' type='text/css'/>
<script src='http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js' type='text/javascript'/>

Also you need to change your "body" tag to the following:

<body onLoad='prettyPrint()'>


#2
To post source code blocks your will need to process HTML escaping of this block, this can be done with the help of the following tool (Quick Escape). What is quick escape? It's a tool that lets you quickly paste in HTML and for that to be converted to escaped characters which can be pasted back in to your HTML source code so that it renders on screen.
Now you can put the results between

<pre class="prettyprint">
<!-- Put your source code here -->
</pre>
tags.

#3
Now you need to enable a word wrapping mechanism for "pre" HTML tags. Put the following css code to your HTML template somewhere at the beginning, where you have your page defaults:

pre {
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
white-space : normal;
}


#Example:
(Here you see a C++ code inserted into the blog post using the method above)
/**
*
* @brief A partial specialization of SCaller template with #MiscCommon::NullType.
* @brief Used to implement calls of commands \\b without a Return object.
*
*/
template<class _Parent, class _LogFun>
struct SCaller<_Parent, _LogFun, MiscCommon::NullType>
{
void call( _LogFun _log_callback, MiscCommon::NullType */*_ret_val*/)
{
_Parent *pThis = reinterpret_cast<_parent>(this);
pThis->command( _log_callback );
}
};

Eclipse CDT spell check

It seems that very soon we, users of Eclips CDT, will finally get spell check enabled for C++ source. See Eclipse bug 190512.

Buildbot

For one of my projects I've been using Buildbot for quite some time already. So far it satisfies all my needs in distributed builds of my continues integration process. Here you can check the web interface of the builds out.
Well, Buildbot very simple in installation and configuration, supports SVN and, what is very important, it supports distributed builds. Check out my configuration file (master.cfg) and my custom css.
A summery of the Features Buildbot 0.7.6 provides:
  • run builds on a variety of slave platforms
  • arbitrary build process: handles projects using C, Python, whatever
  • minimal host requirements: python and Twisted
  • slaves can be behind a firewall if they can still do checkout
  • status delivery through web page, email, IRC, other protocols
  • track builds in progress, provide estimated completion time
  • flexible configuration by subclassing generic build process classes
  • debug tools to force a new build, submit fake Changes, query slave status
  • released under the GPL

Dec 19, 2007

Qt 4.4 Sneak Preview

The Qt 4.4 sneak preview has been released!
We are pleased to announce that the technical preview of Qt and
Qtopia Core 4.4.0 are now available. Qt and Qtopia Core 4.4.0 technical
preview presents a number of new features for testing and feedback,
including:

* Integration with WebKit
* Multimedia framework based on the KDE Phonon project
* Enhanced XML support
* Concurrency framework
* Interprocess communication framework
* New help system

For more information on the new features scheduled to be released with
Qt 4.4, please visit the Qt 4.4 Sneak Preview page;

http://trolltech.com/products/qt/whatsnew/qt44-preview

Linus Torvalds: C++ is a horrible language

Linus expressed his self and his thoughts about C++ language in this topic (the full thread).
Very entertaining to read.
I also found a couple of polite comments from Andrei Alexandrescu on the subject.

Nov 19, 2007

Fedora 8 and cURL

Yesterday I've discovered that one module of my project doesn't work, namely, it was a file upload using cURL library. The module suppose to upload files to an https url without checking of peer (insecure upload). I set parameters like CURLOPT_SSL_VERIFYPEER and CURLOPT_SSL_VERIFYHOST to 0. But I got an error in anyway:
Exception: couldn't transfer the InputSandbox file:
"***" to "https://***". Http error code: 0
Curl error: peer certificate cannot be authenticated
with known CA certificates.
Everything was perfectly working for a year or so. But after I have moved to Fedora8 my unit tests of the module started to fail.
I spent several hours and finally found the seed of the problem. If you get similar error while having insecure transfer, that would most probably mean, you are facing an Issue described here and here and here (Bug 387991). It has something to do with cURL with NSS as the SSL engine (instead of OpenSSL).
If you face this problem, one of the solution would be to rebuild cURL with OpenSSL support or wait until developers of Fedora and cURL fix it.

Nov 15, 2007

initializing vector with ostream_iterator

To someone it could be useful :)
When you try to compile the following code:


vector<int> v( istream_iterator<int>(cin), istream_iterator<int>() );


you actually end up with several error messages. Here g++ compile (for example), will follow the standard, and will identify the definition of v as a forward declaration of a function accepting two istream_iterator parameters and returning a vector of integers.

  • #1. Solution which works for g++ 4.1< (the extra set of parenthesis for the last argument of vector's ctor)
     vector<int> v( istream_iterator<int>(cin), (istream_iterator<int>()) );


but this doesn't really works with g++3.2

  • #2. Solution for g++ 3.2> - actually a general solution, which should work always:

typedef istream_iterator<int> in_iter;
in_iter b(cin);
in_iter e;
vector<int> v( b, e );

Bjarne Stroustrup's FAQ

I've just found a very nice FAQ from the FATHER of C++. I read it long time ago, but there are a lot of new staff added.
No comments - "mustread!"(c)

Nov 10, 2007

Useful Eclipse plug-ins for C++ Developers

With this post I would like to share my preferences of plug-ins for Eclipse.
Most of the time I do a C++ development (mostly under Linux). Since I came from Windows world and I was using the best development environment ever made - MS Visual Studio :) I wanted to find something similar in the Linux world. I tried emacs, KDevelop and Eclipse. I wont compare all of them, probably I will do that some time later, I will just conclude that I choose Eclipse and CDT.
Well, currently I am suing the following useful plug-ins:
Also I don't use the original code formating mechanism of Eclipse CDT, rather I use AStyle as an external tool, which is much more powerful. Here I have an instraction for you how to use AStyle in Eclipse:
  • Select the dropdown button for "External Tools", then click on "Externals Tools..."
  • Select "Program" in the Configurations window then click the New button
  • For the "Name" call it "AStyle", for the "Location" put the full path and filename for AStyle (i.e. /usr/bin/astyle)
  • For "Arguments", put the AStyle arguments to get the code formatted to your style. I like ANSI style and 3 spaces for indentation, hence, the arguments would be "--style=ansi -s3" (no quotes) or use --options=####
  • Now put your cursor at the end of the "Arguments" and click the "Variables" button and then select the resource_loc" and click OK
  • Your arguments should look like "--style=ansi -s3 ${resource_loc}" (no quotes)
  • Now click the "Refresh" tab, and click the check-box "Refresh resources upon completion" and then click the "The Selected Resource" radio button.
  • Click the "Apply" button then the "Close" button.

Nov 9, 2007

Fedora 8 and Compiz

Yet another problem with the new Fedora 8 :(
When Compiz is enabled after the reboot (or close/open session) each new window appears without the window title. A restart of Compiz (re-enable of it) helps...

Fedora 8 and KNetworkManager

Yesterday when I get my new Fedora 8 installation ready I found out a very very very upsetting thing - I used KDE (as I always do) but nm-applet appears in my tray :( Unfortunately I also found that KNetworkManager is just a wrapper for nm-applet. VERY BAD news!

Here we get some official explanation:
Since knetworkmanager does not work with the version of NetworkManager available in this release, the KDE Live images use nm-applet from NetworkManager-gnome as a replacement. The gnome-keyring-daemon facility saves passwords for these encryption technologies. The knetworkmanager package in this release is a script that calls nm-applet. The knetworkmanagerpackage will be updated to provide a KDE frontend when a compatible version is available.

Nov 8, 2007

Fedora 8 is out

Today, just right know the Fedora 8 has been released :)
http://fedoraproject.org/

Guess what I am going to do with my Fedora 7 installed on my laptop :) Now I know how I will spend this evening...

Nov 1, 2007

The First!

This is my First post to my First blog :)

to be continued...