Posts Tagged ‘Dev’

Posted by Tatyana at 4 March 2010

Category: Java

Tags: , , ,

I had some difficult time understanding all the roles regarding EJB3. Here is an easy-to-remember description of these roles that I found here.

Imagine a factory producing computers:

Bean Provider:
Chip manufacturer. On the chip, there will be a label with “Warranty void if removed” the chip has the logic and the label sets a Role. If you are not authorized to repair it, warranty voids. (i.e. you cannot access the internal chip if you are not in the role of “Warranty Repair Person”.)

Application Assembler
Mainboard assembler. It takes various chips and puts them on the mainboard. If any additional resistor or cable are required, it will put everything togheter to have something that is some kind of working unit but requires additional assembling.

EJB Server Provider
The EJB Server provider is the Computer Case manufacturer providing a case with a power supply. Is a container for the mainboard

Deployer
As every computer case is different and power voltage vary country by country, the Deployer makes sure to adapt the mainboard to the working environment. In this case adjusts the Voltage on the power supply, and connects the cables. At the same time he will define who are the person allowed to repair it (i.e. provide a list of authorized repair centers)

Persistence Provider
the persistence provider could be the network card company that provides the driver to connect to a network.

System Administrator
Is the person in charge to install the operating system and do necessary configuration changes to the OS to connect to the server, and will make sure to monitor that everything is working fine.

More about Enterprise Java Beans 3.0 and Sun Certified Business Component Developer (SCBCD) certification here.

Popularity: 1% [?]

Posted by Tatyana at 25 February 2010

Category: Dev, Java, Memorable

Tags: , , , ,

The book by Robert C. Martin “Clean Code” is a really very useful material for all programmers. You can disagree with him sometimes (as I do), but it still provides some useful notes that helped me to place my programmer experience and knowledge where they belong. Here I’ll provide some key notes that I did while reading the book and that I’d like to memorize.

What you as a programmer SHOULD DO:

1. Give everything meaningful, searchable and pronounceable names.
2. Use names that other programmers can understand. Remember that the code is for programmers, not customers.
3. Functions should be small and smaller than that.
4. Functions should do one thing. They should do it well. They should do it only.
5. The ideal number of arguments for a function is zero. Max 3.
6. Prefer exceptions to returning error codes. Create informative error messages.
7. Prefer meaningful names to comments.
8. Write JavaDoc only for public API’s.
9. Format your code. While working in a team use a single formatting style.
10. Test your code with clean tests. Remember that test code is just as important as production code.
11. Test just one concept per test.
12. Test should follow the FIRST rule:

    Fast -  tests should be fast.
    Independent - tests should not depend on each other
    Repeatable - tests should be repeatable in any environment
    Self-validating – the test should have a boolean output
    Timely - write unit tests before the production code.

What you as a programmer should AVOID:
1. Avoid encoding
2. Avoid duplicate code. Watch out not only duplicate functions but also duplicate functionality.
3. Avoid noisy, redundant, uninformative comments. Remember that one of the more common motivations for writing comments is bad code.

Popularity: 2% [?]

Posted by Tatyana at 16 February 2010

Category: Java

Tags: , , , , ,

Here is a very useful java conversion table that I’ve created while preparing for the Sun Certified Java Programmer exam.

primitives conversion

Java primitive conversions table

In addition to it here are a complete overview of the Golden rules of widening, boxing & varargs:

1. Primitive Widening > Boxing > Varargs.
2. Widening and Boxing (WB) not allowed.
3. Boxing and Widening (BW) allowed.
4. While overloading Widening + vararg and boxing + vararg are mutually exclusive of each other.
5. Widening between wrapper classes not allowed
6. Widening+varArgs & Boxing+varargs are individually allowed (but not allowed in overloaded version of method)
7. Boxing+Widening is preferred over Boxing+Varargs.

More explanation here.

Popularity: 3% [?]

Posted by Kent at 20 December 2009

Category: Dev, c++

Tags: , , ,

Open Visual Studio command prompt.

Go to the folder you installed the source files in.

Execute configure with the wanted options.

S:\Qt\2009.04\qt>configure -debug-and-release -fast -no-webkit -opensource

This is the Qt for Windows Open Source Edition.

You are licensed to use this software under the terms of
the GNU General Public License (GPL) version 3
or the GNU Lesser General Public License (LGPL) version 2.1.

Type '3' to view the GNU General Public License version 3 (GPLv3).
Type 'L' to view the Lesser GNU General Public License version 2.1 (LGPLv2.1).
Type 'y' to accept this license offer.
Type 'n' to decline this license offer.

Do you accept the terms of the license?

Wait.

Then execute nmake and wait.

“configure” command line options

Usage: configure [-buildkey <key>]
 [-release] [-debug] [-debug-and-release] [-shared] [-static]
 [-no-fast] [-fast] [-no-exceptions] [-exceptions]
 [-no-accessibility] [-accessibility] [-no-rtti] [-rtti]
 [-no-stl] [-stl] [-no-sql-<driver>] [-qt-sql-<driver>]
 [-plugin-sql-<driver>] [-system-sqlite] [-arch <arch>]
 [-D <define>] [-I <includepath>] [-L <librarypath>]
 [-help] [-no-dsp] [-dsp] [-no-vcproj] [-vcproj]
 [-no-qmake] [-qmake] [-dont-process] [-process]
 [-no-style-<style>] [-qt-style-<style>] [-redo]
 [-saveconfig <config>] [-loadconfig <config>]
 [-qt-zlib] [-system-zlib] [-no-gif] [-qt-gif] [-no-libpng]
 [-qt-libpng] [-system-libpng] [-no-libtiff] [-qt-libtiff]
 [-system-libtiff] [-no-libjpeg] [-qt-libjpeg] [-system-libjpeg]
 [-no-libmng] [-qt-libmng] [-system-libmng] [-no-qt3support] [-mmx]
 [-no-mmx] [-3dnow] [-no-3dnow] [-sse] [-no-sse] [-sse2] [-no-sse2]
 [-no-iwmmxt] [-iwmmxt] [-direct3d] [-openssl] [-openssl-linked]
 [-no-openssl] [-no-dbus] [-dbus] [-dbus-linked] [-platform <spec>]
 [-qtnamespace <namespace>] [-qtlibinfix <infix>] [-no-phonon]
 [-phonon] [-no-phonon-backend] [-phonon-backend]
 [-no-webkit] [-webkit]
 [-no-scripttools] [-scripttools]
 [-graphicssystem raster|opengl]

Installation options:

 You may use these options to turn on strict plugin loading:

 -buildkey <key> .... Build the Qt library and plugins using the specified
 <key>.  When the library loads plugins, it will only
 load those that have a matching <key>.

Configure options:

 The defaults (*) are usually acceptable. A plus (+) denotes a default value
 that needs to be evaluated. If the evaluation succeeds, the feature is
 included. Here is a short explanation of each option:

 -release ........... Compile and link Qt with debugging turned off.
 *  -debug ............. Compile and link Qt with debugging turned on.
 +  -debug-and-release . Compile and link two Qt libraries, with and without
 debugging turned on.

 -opensource ........ Compile and link the Open-Source Edition of Qt.
 -commercial ........ Compile and link the Commercial Edition of Qt.

 -developer-build ... Compile and link Qt with Qt developer options
 (including auto-tests exporting)

 *  -shared ............ Create and use shared Qt libraries.
 -static ............ Create and use static Qt libraries.

 -ltcg .............. Use Link Time Code Generation. (Release builds only)
 *  -no-ltcg ........... Do not use Link Time Code Generation.

 *  -no-fast ........... Configure Qt normally by generating Makefiles for all
 project files.
 -fast .............. Configure Qt quickly by generating Makefiles only for
 library and subdirectory targets.  All other Makefiles
 are created as wrappers which will in turn run qmake

 -no-exceptions ..... Disable exceptions on platforms that support it.
 *  -exceptions ........ Enable exceptions on platforms that support it.

 -no-accessibility .. Do not compile Windows Active Accessibility support.
 *  -accessibility ..... Compile Windows Active Accessibility support.

 -no-stl ............ Do not compile STL support.
 *  -stl ............... Compile STL support.

 -no-sql-<driver> ... Disable SQL <driver> entirely, by default none are
 turned on.
 -qt-sql-<driver> ... Enable a SQL <driver> in the Qt Library.
 -plugin-sql-<driver> Enable SQL <driver> as a plugin to be linked to at run
 time.
 Available values for <driver>:
 mysql
 psql
 oci
 odbc
 tds
 db2
 +                         sqlite
 sqlite2
 ibase
 (drivers marked with a '+' have been detected as
 available on this system)

 -system-sqlite ..... Use sqlite from the operating system.

 -no-qt3support ..... Disables the Qt 3 support functionality.

 -no-opengl ......... Disables OpenGL functionality

 -platform <spec> ... The operating system and compiler you are building on.
 (default %QMAKESPEC%)

 -xplatform <spec> .. The operating system and compiler you are cross
 compiling to.

 See the README file for a list of supported operating
 systems and compilers.

 -qtnamespace <namespace> Wraps all Qt library code in 'namespace name {...}
 -qtlibinfix <infix> Renames all Qt* libs to Qt*<infix>

 -D <define> ........ Add an explicit define to the preprocessor.
 -I <includepath> ... Add an explicit include path.
 -L <librarypath> ... Add an explicit library path.
 -l <libraryname> ... Add an explicit library name, residing in a
 librarypath.

 -graphicssystem <sys> Specify which graphicssystem should be used.
 Available values for <sys>:
 *                         raster - Software rasterizer
 opengl - Using OpenGL accelleration, experimental!
 -help, -h, -? ...... Display this information.

Third Party Libraries:

 -qt-zlib ........... Use the zlib bundled with Qt.
 +  -system-zlib ....... Use zlib from the operating system.
 See http://www.gzip.org/zlib

 -no-gif ............ Do not compile the plugin for GIF reading support.
 +  -qt-gif ............ Compile the plugin for GIF reading support.
 See also src/plugins/imageformats/gif/qgifhandler.h

 -no-libpng ......... Do not compile in PNG support.
 -qt-libpng ......... Use the libpng bundled with Qt.
 +  -system-libpng ..... Use libpng from the operating system.
 See http://www.libpng.org/pub/png

 -no-libmng ......... Do not compile in MNG support.
 -qt-libmng ......... Use the libmng bundled with Qt.
 +  -system-libmng ..... Use libmng from the operating system.
 See See http://www.libmng.com

 -no-libtiff ........ Do not compile the plugin for TIFF support.
 -qt-libtiff ........ Use the libtiff bundled with Qt.
 +  -system-libtiff .... Use libtiff from the operating system.
 See http://www.libtiff.org

 -no-libjpeg ........ Do not compile the plugin for JPEG support.
 -qt-libjpeg ........ Use the libjpeg bundled with Qt.
 +  -system-libjpeg .... Use libjpeg from the operating system.
 See http://www.ijg.org

Qt for Windows only:

 -no-dsp ............ Do not generate VC++ .dsp files.
 *  -dsp ............... Generate VC++ .dsp files, only if spec "win32-msvc".

 -no-vcproj ......... Do not generate VC++ .vcproj files.
 *  -vcproj ............ Generate VC++ .vcproj files, only if platform
 "win32-msvc.net".

 -no-incredibuild-xge Do not add IncrediBuild XGE distribution commands to
 custom build steps.
 +  -incredibuild-xge .. Add IncrediBuild XGE distribution commands to custom
 build steps. This will distribute MOC and UIC steps,
 and other custom buildsteps which are added to the
 INCREDIBUILD_XGE variable.
 (The IncrediBuild distribution commands are only added
 to Visual Studio projects)

 -no-plugin-manifests Do not embed manifests in plugins.
 *  -plugin-manifests .. Embed manifests in plugins.

 -no-qmake .......... Do not compile qmake.
 *  -qmake ............. Compile qmake.

 -dont-process ...... Do not generate Makefiles/Project files. This will
 override -no-fast if specified.
 *  -process ........... Generate Makefiles/Project files.

 -no-rtti ........... Do not compile runtime type information.
 *  -rtti .............. Compile runtime type information.

 -no-mmx ............ Do not compile with use of MMX instructions
 +  -mmx ............... Compile with use of MMX instructions
 -no-3dnow .......... Do not compile with use of 3DNOW instructions
 +  -3dnow ............. Compile with use of 3DNOW instructions
 -no-sse ............ Do not compile with use of SSE instructions
 +  -sse ............... Compile with use of SSE instructions
 -no-sse2 ........... Do not compile with use of SSE2 instructions
 +  -sse2 .............. Compile with use of SSE2 instructions
 +  -direct3d .......... Compile in Direct3D support (experimental - see
 INSTALL for more info)
 -no-openssl ........ Do not compile in OpenSSL support
 +  -openssl ........... Compile in run-time OpenSSL support
 -openssl-linked .... Compile in linked OpenSSL support
 -no-dbus ........... Do not compile in D-Bus support
 +  -dbus .............. Compile in D-Bus support and load libdbus-1 dynamicall
 y
 -dbus-linked ....... Compile in D-Bus support and link to libdbus-1
 -no-phonon ......... Do not compile in the Phonon module
 +  -phonon ............ Compile the Phonon module (Phonon is built if a decent
 C++ compiler is used.)
 -no-phonon-backend . Do not compile the platform-specific Phonon backend-pl
 ugin
 *  -phonon-backend .... Compile in the platform-specific Phonon backend-plugin
 -no-webkit ......... Do not compile in the WebKit module
 +  -webkit ............ Compile in the WebKit module (WebKit is built if a
 decent C++ compiler is used.)
 -no-scripttools .... Do not build the QtScriptTools module.
 *  -scripttools ....... Build the QtScriptTools module.
 -arch <arch> ....... Specify an architecture.
 Available values for <arch>:
 *                         windows
 windowsce
 boundschecker
 generic

 -no-style-<style> .. Disable <style> entirely.
 -qt-style-<style> .. Enable <style> in the Qt Library.
 Available styles:
 *                         windows
 +                         windowsxp
 +                         windowsvista
 *                         plastique
 *                         cleanlooks
 *                         motif
 *                         cde
 windowsce
 windowsmobile

 -loadconfig <config> Run configure with the parameters from file configure_
 <config>.cache.
 -saveconfig <config> Run configure and save the parameters in file
 configure_<config>.cache.
 -redo .............. Run configure with the same parameters as last time.

Qt for Windows CE only:

 -no-iwmmxt ......... Do not compile with use of IWMMXT instructions
 +  -iwmmxt ............ Do compile with use of IWMMXT instructions (Qt for
 Windows CE on Arm only)
 *  -no-crt ............ Do not add the C runtime to default deployment rules
 -qt-crt ............ Qt identifies C runtime during project generation
 -crt <path> ........ Specify path to C runtime used for project generation.
 -no-cetest ......... Do not compile Windows CE remote test application
 +  -cetest ............ Compile Windows CE remote test application
 -signature <file> .. Use file for signing the target project
 -opengl-es-cm ...... Enable support for OpenGL ES Common
 -opengl-es-cl ...... Enable support for OpenGL ES Common Lite
 -opengl-es-2 ....... Enable support for OpenGL ES 2.0
 *  -phonon-wince-ds9 .. Enable Phonon Direct Show 9 backend for Windows CE

Popularity: 14% [?]

Posted by Kent at 11 June 2009

Category: Dev, Tip

Tags: , ,

mdadm --assemble /dev/md0 /dev/sd[abcd]1

Popularity: 3% [?]

Posted by Kent at 21 February 2009

Category: Dev

Tags: , , ,

If you’re on a system as a user and with no means of installing custom libraries or updating libraries for your custom program, you can load your own libraries with this simple command.

$ ./executable
./executable: error while loading shared libraries: libcurl.so.4: cannot open shared object file: No such file or directory

Use ldd to find out what missing libraries you have:

$ ldd executable
        linux-gate.so.1 =>  (0xa942d000)
        libncursesw.so.5 => /lib/libncursesw.so.5 (0xa93e9000)
        libcurl.so.4 => not found
        librt.so.1 => /lib/tls/i686/cmov/librt.so.1 (0xa93df000)
        libssl.so.0.9.8 => /usr/lib/i686/cmov/libssl.so.0.9.8 (0xa939d000)
        libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0xa9399000)
        libz.so.1 => /usr/lib/libz.so.1 (0xa9384000)
        libcrypto.so.0.9.8 => /usr/lib/i686/cmov/libcrypto.so.0.9.8 (0xa9241000)
        libsigc-2.0.so.0 => /usr/lib/libsigc-2.0.so.0 (0xa923b000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xa9148000)
        libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0xa9123000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xa9118000)
        libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xa8fc9000)
        libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0xa8fb0000)
        /lib/ld-linux.so.2 (0xa942e000)

Copy over your libcurl.so.4 to the system and invoke your custom executable with:

$ LD_PRELOAD=./libcurl.so.4:./libexecutable.so.11 ./executable

Separate different libraries with a colon (:).

Popularity: 3% [?]

Posted by Kent at 30 January 2009

Category: Dev, Tip

Tags: , , , , ,

This is a brief guide on how to set up Subversion with Trac on Apache with commit-mails sent with SVN::Notify Perl module.

First of all, we need to install some software.

# emerge -av subversion apache

When everythin has installed fine, continue.

Create a repository somewhere.

# cd /var/svn/
# svnadmin create test
# ll
drwxr-xr-x  6 root   root   4.0K 2009-01-30 12:56 test

Change the permissions to apache:apache and rights 770:

# chown apache:apache test -R && chmod 770 test -R
# ll
drwxrwx---  6 apache apache 4.0K 2009-01-30 12:56 test

Our repository root is at /var/svn/test and our Subversion root is /var/svn.

Two more files are needed if you are doing HTTP Authentication, /var/svn/htpasswd and /var/svn/authz.

Create the htpasswd file with htpasswd2.

# htpasswd2 -c htpasswd username

The authz file looks like this (with the defaults).

[groups]
# harry_and_sally = harry,sally

[/]
username = rw
* =

# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r

Our next step is to configure Apache to work with Subversion.

Open up/etc/conf.d/apache2 and make sure APACHE2_OPTS contains “-D SVN -D SVN_AUTHZ -D PHP5 -D DAV”.

If you’re doing a SVN repository with authentication, I’d advise you to use SVN over SSL (HTTPS).

If we want to use svn.example.com as our Subversion repository URL, our Apache config should look like:

<VirtualHost *:443>
    ServerName svn.example.com
    #Include /etc/apache2/vhosts.d/default_vhost.include
    ErrorLog /var/log/apache2/ssl_error_log

    <IfModule log_config_module>
        TransferLog /var/log/apache2/ssl_access_log
    </IfModule>

    <Location />
        AuthType Basic
        AuthName "Subversion repository and Trac"
        AuthUserFile /var/svn/htpasswd
        Require valid-user
        SSLRequireSSL

        DAV svn
        SVNParentPath /var/svn/
        BrowserMatch "SVN" redirect-carefull
        AuthzSVNAccessFile  /var/svn/authz
        SVNListParentPath on
    </Location>

    DocumentRoot "/var/www/localhost/htdocs"
</VirtualHost>

If everything is successful, you’ll be able to access your subversion repository at https://svn.example.com/test.

Final touch is the Perl module SVN::Notify. Fire up CPAN.

# cpan

cpan shell -- CPAN exploration and modules installation (v1.9301)
ReadLine support enabled

cpan[1]> install SVN::Notify
cpan[2]> install HTML::Entities

Enter your SVN hooks directory.

# cd /var/svn/test/hooks

And copy the post commit template to post commit.

# cp post-commit.tmpl post-commit
# vim post-commit

Make sure the following lines are present:

REPOS="$1"
REV="$2"

export LANG="nb_NO.UTF-8" # optional
/usr/bin/svnnotify --repos-path "/var/svn/test" --revision "$REV" --svnlook /usr/bin/svnlook --sendmail /usr/sbin/sendmail --to mail@example.com --from svn@example.com --with-diff --reply-to no-reply@example.com --linkize --handler HTML::ColorDiff --smtp localhost --svn-encoding "UTF-8"

Whenever someone does a commit, a mail with the colored diff is sent out to the recipients.

Popularity: 100% [?]

Posted by Kent at 5 January 2009

Category: Ikke interessant

Tags: , ,

No shit, it’s real name is Magic Voodoo Controller.

There’s so much stuff going on behind the scenes and no clear connection between the Model, View and Controller. But it works, somehow.

Popularity: 2% [?]