tutorials

A tutorial is a method of transferring knowledge and may be used as a part of a learning process. More interactive and specific than a book or a lecture; a tutorial seeks to teach by example and supply the information to complete a certain task. [read more at http://en.wikipedia.org/wiki/Tutorial]

  • CedThumbnails has been updated to version 2.6.0 and contains 4 new features and correct 1 bug for Joomla 2.5. For existing users the update will display in the Extensions Managerunder Updates. If you do not have this currently installed, you can click the link below and install like you are use to via the Extensions Manager.

  • subversion.logo

    If you are using Subversion/CVS, you might have come across the issue where multiple developers working on a set of files are committing without any comments.

    Subversion’s hook scripts provide a powerful way to associate actions with repository events. For example, the pre-commit hook allows you to check — and possibly abort — a transaction before it actually gets committed. I will provide you now two easy Unix bash scripts  that avoid bad developer behaviors:

    • The first one “checkCommentNotEmpty.sh” is for checking that nobody submit an empty SVN commit comment
    • The second one “checkCommentSyntax.sh” is able to enforce SVN commit comment pattern using regular expressions

    Creating and Installing a Hook Script

    Your Subversion repository already has some template hook scripts. For example, the pre-commit template is in PATH_TO_REPOS/hooks/pre-commit.tmpl. These templates contain instructions on what the hook script does and what parameters it can expect.

    You can hook your own script on the following events

    • start-commit Before the commit transaction starts
    • pre-commit After the commit transaction starts but before the transaction is committed
    • post-commit After the commit transaction completes
    • pre-revprop-change Before a revision property is changed Repository Path,
    • post-revprop-change: After a revision property is changed Repository Path
    • pre-lock: Before the lock being acquired
    • post-lock: After the lock being acquired

    You’ll find examples in the hook directory named

    • post-commit.tmpl
    • pre-unlock.tmpl
    • post-lock.tmpl
    • pre-commit.tmpl
    • start-commit.tmpl
    • post-revprop-change.tmpl
    • pre-lock.tmpl
    • post-unlock.tmpl
    • pre-revprop-change.tmpl

    If you cant find them, brute force your server to locate them

    # find / –name pre-commit

    or

    # locate pre-commit

    On Debian you will find them at

    /data/svn-repos/{yourRepository}/hooks

    Create a file pre-commit with that content, nothing force you to put a huge bash script in pre-commit. In my example below, I prefer to divide pre-commit checks in multiple files. The pre-commit hook gives you a way to catch the transaction before it becomes a revision. Subversion passes this hook two parameters:

    1. the path to the root of the repository
    2. the transaction identifier
    #!/bin/sh
    set -e
    /data/svn-repos/{yourRepository}/hooks/checkCommentNotEmpty.sh "$1" "$2"
    /data/svn-repos/{yourRepository}/hooks/checkCommentSyntax.sh "$1" "$2"

    Note that after installation, every commit will run these two scripts. Check your permissions, scripts have to be runnable for the user (www-data on debian)

    Avoid empty comment in SVN commits

    Save this file in /data/svn-repos/{yourRepository}/hooks/checkCommentNotEmpty.sh

    #!/bin/sh
    REPOS="$1"
    TXN="$2"
    SVNLOOK=/usr/bin/svnlook
    
    if [`$SVNLOOK log -t $TXN $REPOS` != ""]; then
      echo "" 1>&2
      echo "*** Your commit has been blocked because you did not give any log message or your log message was too short." 1>&2
      echo "Please write a log message describing the purpose of your changes and then try committing again." 1>&2
      exit 1
    else
      exit 0
    fi

    Example in Eclipse, if you break the rule

    noEmptySVNCommitComment

    Enforce SVN commit comment pattern using regular expressions

    Save this file in /data/svn-repos/{yourRepository}/hooks/checkCommentSyntax.sh

    This script use Bash script REGEX capabilities, I check against what could be a typical JIRA issues entry

    If any developer try to use a commit statement not starting with for example PRODUCT-xxxx, the commit will be blocked.

    #!/bin/sh
    REPOS="$1"
    TXN="$2"
    SVNLOOK=/usr/bin/svnlook
    regex="PRODUCT-[0-9]*"
    
    if [[ `$SVNLOOK log -t $TXN $REPOS` =~ ${regex} ]]; then
      exit 0
    else
      echo "" 1>&2
      echo "*** Your commit has been blocked because you give an invalid commit comment" 1>&2
      echo "Please make your commit comment start with PRODUCT-XXX" 1>&2
     exit 1
    fi

    Example in Eclipse, if you break the rule

    checkSVNCommitCommentWithRegularExpressions

    Want more?

    You can automated code reviews with Checkstyle using pre-commit script and so Stop rule-breaking code before it enters your code base!

    References

    hook_scripts" target="_blank">http://subversion.tigris.org/tools_contrib.htmlhook_scripts List of some Hook scripts examples written in python/bash

  • Came across this excellent collection of resources (https://github.com/marcelgsantos/learning-oop-in-php) to learn object-oriented programming and related concepts for PHP developers. A lot of tutorials on OOP Fundamentals, OOP Advanced, Object Oriented Design, Design Patterns, Refactoring, Architecture, and more.
  • Docker is a powerful tool for managing containers and run-time environments and, besides its many advantages, Docker can also be handy to keep your server tidy and secure.

    Docker allows to run operating systems, applications and tools in so called Containers. A #Container is an isolated environments that represents a autonomous host on its own – a bit in the same way a Virtual Machine does. Yet, Docker Containers are much lighter. They do not start an entire full-blown operating system for each Container instance. Instead, Docker uses Linux kernel isolation mechanisms to run applications on the top of the host’s operating systems, yet keeping them isolated.

    The Ethereum Go (language) team builds a Docker image of a “geth” node as part of their continuous build chain. Their Howto is more then enough to run your full node, mine below is just an enhanced example with volume, name, .. nothing fancy.

    # i want to persist the blockchain in a volume

    docker volume create --name=ethereum-data

    # and limit cpu usage to 20% of all 8 cores --cpus=".2", give a name to container, more command line options

    docker run --cpus=".2" -d -p 8545:8545 -p 30303:30303 \
    --name=ethereum-node \
    -v ethereum-data:/root/.ethereum ethereum/client-go \
    --rpc --rpcaddr "127.0.0.1"

    to stop and recreate the container

    docker stop ethereum-node && docker rm ethereum-node

    to go inside the container

    docker exec -it ethereum-node bash

    to test the RPC api

    curl -X POST --data '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}' localhost:8545

    or 

    curl -H "Content-Type: application/json" -X POST \
     --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["latest", true],"id":1}' http://127.0.0.1:8545

    see 
    https://ethereum.gitbooks.io/frontier-guide/content/rpc.html 

    You may want to register your node at The Ethereum (centralised) network status monitor , in that case just follow https://github.com/ethereum/wiki/wiki/Network-Status 

    My Ethereum node is now running at http://ethereum.galaxiis.com

    A better status page is in development using PHP with RPC

  • Official version of nginx for Ubuntu Precise is 1.1.19 but the latest available stable version is 1.2.2 (Changes), In this post I will present you how to update to the latest available version.

    vi /etc/apt/sources.list

    and add depending on your Ubuntu version either

    For Ubuntu 10.04 Lucid:

    deb http://nginx.org/packages/ubuntu/ lucid nginx
    deb-src http://nginx.org/packages/ubuntu/ lucid nginx

    For Ubuntu 12.04 Precise:

    deb http://nginx.org/packages/ubuntu/ precise nginx
    deb-src http://nginx.org/packages/ubuntu/ precise nginx

    Now you can run

    apt-get update

    When using the public nginx repository for Ubuntu, you’ll get this error

    W: GPG error: http://nginx.org lucid Release: The following signatures 
    couldn't be verified because the public key is not available: NO_PUBKEY ABF5BD827BD9BF62

    First of all this is only warning and you can ignore it, if you know what are you doing and in case you prefer to add public key, used for signing packages and repository, just run:

    gpg -a --export 7BD9BF62 |  sudo apt-key add -

    or

    wget http://nginx.org/packages/keys/nginx_signing.key
    cat nginx_signing.key | sudo apt-key add -

    apt-get update should now run fine, however after running an

    apt-get install nginx

    you may still get this kind of error:

    dpkg: error processing /var/cache/apt/archives/nginx_1.2.2-1~precise_amd64.deb (--unpack):
     trying to overwrite '/etc/logrotate.d/nginx', which is also in package nginx-common 1.1.19-1
    dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
    Errors were encountered while processing:
     /var/cache/apt/archives/nginx_1.2.2-1~precise_amd64.deb

    just remove nginx-common and retry

    apt-get remove nginx-common

    More at http://wiki.nginx.org/Install

  • Trying to combine JSF and JSP is like trying to shoehorn a foot into a glove: it's possible, but it's really just a stopgap measure until something better comes along. In this article, JSF enthusiast Rick Hightower introduces you to what he likes best about Facelets: easy HTML-style templating and reusable composition components.

    Facelets has several compelling features:
    • Templating (like Tiles)
    • Composition components
    • Custom logic tags
    • Expression functions
    • Designer-friendly page development
    • Creating component libraries

    Read the tutorial at IBM developerworks HERE
  • Essential for any advanced Linux users or Linux sys-admin Smile

    The color coded Legend / Keys helps provide guidance for your experience level.

    •   Green = Essential
    •   Yellow = Basic
    •   Orange / Blue = Advanced
    •   Red = Expert

    vim_cheat_sheet_for_programmers_print

    Links

    All credits to http://michael.peopleofhonoronly.com/vim/

  • There's a new version of Xdebug released which fixes a major bug where inspecting static properties caused Xdebug to crash in XAMPP 1.8.0.

    Unfortunately, you’ll need to update manually the version of Xdebug shipped with XAMPP to Xdebug 2.2.1 rather than 2.2.0:

    Simply download the correct Xdebug binary (VC9 threadsafe PHP 5.4 VC9 TS (64 bit) (MD5: 81cacc87168c99c7f65ba202dc12c4b2)) and copy it in your XAMPP installation at xampp\php\ext\php_xdebug.dll

    restart Apache and you can continue debugging!