Popular Posts

Tuesday, February 17, 2009

Adding PDF headers, footers, and watermarks in GNU/Linux

Recently I needed to add a header/footer to an existing PDF file. With some help from this link, I figured it out:
http://coding.derkeiler.com/Archive/Perl/comp.lang.perl.misc/2005-04/msg00151.html

First, use OpenOffice.org Writer (for example) to generate a single-page PDF file that has the needed header/footer/watermark.

Second, use pdftk's background option. Quoting from the man page of pdftk:

pdftk in.pdf background back.pdf output out.pdf

the back.pdf is the file you created that has the needed header/footer/watermark. The in.pdf is the file you need to apply header/footer/watermark to. The result, of course, is saved into out.pdf.

You can also use the dual option stamp instead of background. This will overlay the back.pdf on top of every page of in.pdf.

Sunday, February 15, 2009

Debian Lenny is out... at last!

Debian 5.0 (codenamed "Lenny") is out. Check:
http://www.desktoplinux.com/news/NS4199843436.html
It appears that Debian 5.0 (aka "Lenny") will soon take its big binocular eyes out into the wider world. The Debian project has completed the first release-candidate of Lenny's installer, which features much-improved support for ARM-based devices, along with much faster installation from "live" CDs



The next stable release of Debian is codenamed "Squeeze". Check:
http://www.debiantoday.com/debian-lenny-successor-gets-named/
Prepare yourself for Squeeze, that’s right the little green guy. Continuing with the Toy Story names the Debian project has decided to name the next release in the line up after the three eyed green alien who fears “the claw” at Pizza Planet in the movie Toy Story

Tuesday, February 10, 2009

Free Books on "Design Patterns in C++" and Qt

Today is my lucky day :)

I found two free books about Qt and Design Patterns.

The first book is
C++ GUI Programming with Qt 4

The first edition of this book could be downloaded _legally_ for free here:
http://www.qtrac.eu/C++-GUI-Programming-with-Qt-4-1st-ed.zip
http://www.qtrac.eu/marksummerfield.html


The second book is a magnificent one. It is the first book I see to explain C++ and Design Patterns in a Qt-ish style!

The book is free as in freedom! It is released online under the Open Publication License (OPL) here:
http://oop.mcs.suffolk.edu/opensource/

This is NOT a book, it is a complete PROJECT that I think people should actively contribute to... The bugzilla server for this project and many useful materials could be found here:
http://cartan.cas.suffolk.edu/moin/OopDocbook


For convenience, you can download the whole book compiled into chm format here:
http://lawand.wordpress.com/site-map/computer-science/e-books/introduction-to-design-patterns-in-cpp-with-qt-4/

Enjoy the cute Qt!

Thursday, December 25, 2008

union, struct, and bit fields in C and C++

It took me some long time to comprehend the issues involved in using unions, structs, and bit fields in C and C++.

First, for the definition of unions and structs, take a look at this link:
http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=/com.ibm.xlcpp8a.doc/language/ref/strct.htm

Unions could be used together with structs to reinterpret the same location in memory with different interpretations (similar in spirit to the C++ reinterpret_cast). For examples on this see:
http://www.anyexample.com/programming/cplusplus/example_of_using_union_in_cplusplus.xml

C++ extends the unions and structs, for example see:
http://www.yolinux.com/TUTORIALS/LinuxTutorialC++Structures.html

Bit fields are used to define special-sized integers. This is useful for packing data (e.g. flags) together into one memory location. This, however, is a bad habit and should be avoided as the compiler-generated code to access bit fields is usually inefficient! For more examples on this, see:
http://en.wikipedia.org/wiki/Bit_field
http://publib.boulder.ibm.com/infocenter/macxhelp/v6v81/index.jsp?topic=/com.ibm.vacpp6m.doc/language/ref/clrc03defbitf.htm
http://www.cs.cf.ac.uk/Dave/C/node13.html
http://www.daniweb.com/forums/thread55765.html
http://blogs.msdn.com/oldnewthing/archive/2008/11/26/9143050.aspx
http://osr507doc.sco.com/en/tools/ANSI_F.3.9_Structs.unions.html

Finally, unions and structs could be anonymous! You do not have to give a name to a union. In this case its members become directly accessible within the same scope. Wikipedia calls this "untagged union". For an example see:
http://www.velocityreviews.com/forums/t286529-union-with-anonymous-struct.html

Tuesday, December 23, 2008

Debugging, Profiling, Memory Leaks and more!

I have been searching for open source tools to assist in detecting memory leaks and application profiling. Also, static code analysis was another goal.

For static code analysis I found:
CppCheck (http://en.wikipedia.org/wiki/Cppcheck)

I used it to its full power by invoking (at the top level of the project):

cppcheck --recursive --all --errorsonly --style

Also, SPlint (http://en.wikipedia.org/wiki/SPlint) seems promising, though it is for C code only (no C++).

A comprehensive list of static code analysis could be found in Wikipedia:
http://en.wikipedia.org/wiki/List_of_tools_for_static_code_analysis

About application profiling, the GNU Profiler (gprof) does a good job. It is light-weight and has support in GCC. This is an excellent article about using gprof:
Of course, you can best visualize the output of gprof using the (kprof) KDE front-end.

Memory leak detection has many options. Of the best is using Valgrind(http://valgrind.org/). However, I found an interesting and promising feature that has been added to the gcc. This feature is called Mudflap. It is easy to use as a compiler flag and adds memory debugging support directly into your application using libmudflap. More interesting information could be found here:
http://gcc.gnu.org/wiki/Mudflap_Pointer_Debugging
http://gcc.fyxm.net/summit/2003/mudflap.pdf
It is so promising that it will be integrated into the QNX IDE:
http://qnxdevtools.blogspot.com/2008/02/mudflap.html
It can print the memory leaks on program exit via the (-print-leaks) option

Memory debugging tools are so many. There is a list on Wikipedia article:
http://en.wikipedia.org/wiki/Memory_debugger

The task of memory leak detection is achievable using lightwieght tools. These tools basically replaces the default C library malloc() and free() with special debugging implementations. Notable is mtrace(), the memory debugger built in the GNU C library:
http://en.wikipedia.org/wiki/Mtrace

A good article about memory leak detection in C++:
http://www.linuxjournal.com/article/6556

And finally, all what you can dream of are collected in one article, in the GRASS wiki here:
http://josef.fsv.cvut.cz/WIKI/grass-osgeo/index.php/GRASS_Debugging


Hope you find this useful!

Monday, October 13, 2008

Some stuff about finance and investment

This post may seem a bit strange. I had an opportunity to read some articles about some weird stuff of the financial world! Those guys of finance are crazy, and we are to blame that we leave our destiny in the hands of such a bunch of crazy financial people! Here are some links about possible ways of investment:

Saturday, October 4, 2008

Comics about SW Development

I saw this link posted by a friend, and I followed it. I'm posting it here because it is very realistic and happens to anyone working in the SW industry.

http://contikistrip.kjempekjekt.com/index.php?p=1

Saturday, September 27, 2008

Buffer Overflow Exploits

I have recently read the news about Google Chrome Buffer Overflow vulnerability (see this link). Admittedly, I was ignorant enough not to understand how a buffer overflow can cause severe security breaches! Wikipedia came to the rescue, as well as some research into the topic of Assembly-language programming. At last I can understand how SEVERE such an attack could be!

You can dig for it too ;-)
check the Wikipedia article,
http://en.wikipedia.org/wiki/Buffer_overflow

and the excellent book of Programming from the Ground Up, for much better understanding of Assembly:
http://savannah.nongnu.org/projects/pgubook/

Enjoy!

Thursday, August 21, 2008

GNU/Linux from eight miles high

This an excellent article released recently by embedded.com:

http://www.embedded.com/design/opensource/208404045?pgno=1

The article is a bit advanced. But anyone with good understanding of computer architecture should be able to go through it!

Friday, August 1, 2008

GUC Students' Blogs

Here are some blogs by students of the GUC. Currently they are all in Germany for their bachelor projects. I am really proud that I had a chance to work with such amazing and wonderful people! Enjoy:

http://husfahmy.blogspot.com/
http://thoughtsandtips.blogspot.com/
http://lewjee.blogspot.com/

Sunday, July 6, 2008

Add Circular Scrolling (and more!) to your laptop touchpad

From the Chinese Linux University!

http://www.chineselinuxuniversity.net/articles/13049.shtml

Add to /etc/X11/xorg.conf (or whatever your xorg.conf is at)

Section "InputDevice"
Identifier "Synaptics Touchpad"
Driver "synaptics"
Option "SendCoreEvents" "true"
Option "Device" "/dev/psaux"
Option "Protocol" "auto-dev"
Option "CircularScrolling" "on"
Option "CircScrollTrigger" "3"
EndSection

Be sure to have Synaptics added to the Server Layout

Section "ServerLayout"
Identifier "Default Layout"
Screen "Default Screen"
InputDevice "Generic Keyboard"
InputDevice "Configured Mouse"
InputDevice "Synaptics Touchpad"
EndSection

Tuesday, July 1, 2008

Dealing with Debian source packages

I found this interesting post, quoting:

apt-get build-dep glibc
apt-get source -b glibc

should work

or, if you already have the build-dependencies and source files
downloaded (.orig.tar.gz, .diff.gz, and .dsc):

dpkg-source -x glibc*.dsc
cd glibc-*
make -f debian/rules build

randolph
--
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/
The dpkg-source utility is found in dpkg-dev package.