Install Gringo

Install Gringo

Yesterday, my first Android application was finally published on Google Play. Gringo is a simple shooter game that I developed for Android devices in my spare time. I realized this project using AndEngine framework.

In this game you must shoot to the bandits by touching the screen and avoid to hit the ladies. The game speed increases with the passing of time and you will need to improve your reflexes, next you can submit your highscores.

All the graphics was created by Sy Marchio (www.picsy.it)

Thanks to

, , ,

If you need to write PHP command line scripts and you need to print some errors on STDERR you can use the following code.

, ,

You normally need to work on develop or feature branch

Create a new repository

mkdir myproject
cd myproject
git init
touch README.md
git add -A
git commit -m "First commit"

Create develop branch

git branch develop
Create new branch named develop

git branch
Show current branches

develop
* master

You are currently working with master branch
git checkout develop
You are currently working with develop branch
git push --all

Push new branch to remote repository

git push origin develop

First develop commit

git add -A
git commit -m "First commit"
git push

Create a release version from develop

When develop branch becomes stable, you need to merge develop modifications with master branch.
git checkout master
git pull
git merge --no-ff develop

merge develop modifications to master branch. The –no-ff options avoid fast forward commit method
git tag -a 1.0
add new tag called 1.0
git push --tags
push tags to the remote branch
git push
git checkout develop

Hotfix

The hotfix branch is used to fix bugs on master branch. Modifications needs to be merged into master and develop branches.
git checkout -b hotfix-1.0.1 master
Create a new branch and switch into.

Add your changes.

git add -A
git commit -m "Fixed some bugs"
git checkout master
git pull
git merge --no-ff hotfix-1.0.1

Merge with master

git tag -a 1.0.1
Add a tag

git checkout develop
git pull origin develop
git merge --no-ff hotfix-1.0.1

Merge with develop/em>

git branch -d hotfix-1.0.1
Delete hotfix branch

git push –tags
git push
Push tags and modifications

Create a feature branch

git checkout -b myfeature develop
git push origin myfeature

Write the code of the new feature
git checkout develop
git pull origin develop
git merge --no-ff myfeature
git push
git branch -d myfeature
git push origin :myfeature

Pull remote branch
git branch -a
Show all branches

git checkout -b develop origin/develop
Create a local branch from origin/develop

Links
http://nvie.com/posts/a-successful-git-branching-model/
http://book.git-scm.com/3_basic_branching_and_merging.html
http://help.github.com/git-cheat-sheets/
http://gitguru.com/2009/02/18/branching-strategies-overview/

,

I assume you have properly installed and configured Zend Server CE from the repository.

First of all you need to install automake:

sudo apt-get update && sudo apt-get upgrade
sudo apt-get install automake

Install Xdebug with PECL as root:

# pecl install xdebug

Note: if you don’t have PECL in your path you can prepend the absolute path before the command

# /usr/local/zend/bin/pecl install xdebug

Now you must edit php.ini file.

sudo nano /usr/local/zend/etc/php.ini

Add these lines at the end of file:

; Xdebug
zend_extension = /usr/local/zend/lib/php_extensions/xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000

Note: Xdebug is incompatible with theZend Debugger extension. To disable this component you can log into Zend Server control page at https://localhost:10082 and navigate to tab Server Setup > Components then turn off Zend Debugger. Remember to click the Restart PHP button to apply the changes.

Links:

If you recently upgraded PHP to version 5.3.0 or higher, you have probably encountered a message like this:

Deprecated: Call-time pass-by-reference has been deprecated in filename.php

Use & when you call a function foo(&$var) generates the warning message.

Remember that in 5.3 version of PHP only Call-time pass by reference is deprecated but not Passing by reference.

See the example below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// normal passing by reference
function functionA(&$var) {
    $var++;
}
 
// call-time passing by reference
function functionB($var)
{
    $var++;
}
 
// correct call
functionA($var);
 
// deprecated
functionB(&$var);

If you can’t edit existing code, for example, third-party software, you can use these work-arounds:

  1. Turn off error messages: is always a good idea hide any type of error message in a production site. You can use error_reporting(0) function or if you want you can use the @ symbol before any statement. This is not a good solution of this problem.
  2. Allow call-time pass-by-reference in your php.ini file: in your php.ini file you can set allow_call_time_pass_reference = on but this is a temporary solution only until the next version.

Resources:

, ,

Spreadsheet Excel Writer is a PEAR package that allows you to generate Excel documents.

When we try to generate an new Excel document using UTF-8 string we ran into a display error.

There is a simple way to fix this problem. See the example below:

$workbook = new Spreadsheet_Excel_Writer();
$workbook->send("file.xls");
 
// add this row
$workbook->setVersion(8);
 
$worksheet =& $workbook->addWorksheet("My worksheet");
 
// add this row
$worksheet->setInputEncoding("UTF-8");
 
$workbook->close();
, ,

Often we need to operate with objects that sometimes we have to use as an array.
For example we can get an attribute from an object:

$attr = $myObject->attr;

or by array access from the same object

$attr = $myObject['attr'];

We can set data simply like an array or directly.

, ,

Se vogliamo iniziare a conoscere il fantastico mondo di Zend Framework sarà necessario creare un ambiente di sviluppo adatto alle nostre esigenze. In questa guida vedremo come configurare la nostra distribuzione Ubuntu per poter lavorare in locale con tutti gli strumenti necessari.

Lo scopo di questo tutorial è quello di ottenere un sistema di sviluppo per Zend Framework

Configurazione del sistema operativo

Quello che noi vogliamo ottenere è un server LAMP configurato ah hoc per le nostre applicazioni web. Per prima cosa installiamo MySQL:

sudo apt-get install mysql-server mysql-client

Se vogliamo rendere accessibile il server MySQL dall’esterno dobbiamo modificare il file /etc/mysql/my.conf

sudo nano /etc/mysql/my.conf

e commentare la linea

#bind 127.0.0.1

Questa configurazione del sistema utilizzerà Zend Server CE che comprende la propria versione di PHP e le librerie vere e proprie di Zend Framework. Fortunatamente Zend ha messo ha disposizione i repository contenenti tutti i pacchetti per le varie distribuzioni di Linux tra cui Debian/Ubuntu. Seguiamo quindi le indicazioni fornite aggiungiamo il nostro repository al file /etc/apt/source.list.

deb http://repos.zend.com/zend-server/deb server non-free

Read the rest of this entry

, , , , ,

La gestione di un menu e delle relative pagine è molto semplice grazie alla classe Zend Navigation.
Il manuale di Zend Framework spiega molto bene come utilizzare questo componente. In breve il principio di funzionamento consiste nel creare oggetti pagina (Zend_Navigation_Page) che a loro volta possono contenere altre pagine. Questa struttura dati verrà poi data in pasto alla classe Zend_Navigation che si occuperà di mettere a disposizione tutti i metodi necessari per la gestione del menu.

Possiamo creare un metodo privato all’interno del nostro Bootstrap per inizializzare il menu e renderlo disponibile agli helper nella view.

protected function _initNavigation()
    {
        $this->bootstrap('layout');
        $layout = $this->getResource('layout');
        $view = $layout->getView();
 
        // create pages
        $pages = array(
                array(
                        'label'         => 'Home',
                        'module'        => 'default',
                        'controller'    => 'index',
                        'action'        => 'index',
                        'order'         => -100 // first page
                ),
                array(
                        'label'         => 'Posts',
                        'module'        => 'default',
                        'controller'    => 'posts',
                        'action'        => 'index',
                        'visible'       => true,
                        'pages'         => array(
                                array(
                                        'label'         => 'Add',
                                        'module'        => 'default',
                                        'controller'    => 'posts',
                                        'action'        => 'add'
                                )
                        )
                ),
                array(
                        'label'      => 'Administration',
                        'module'     => 'admin',
                        'controller' => 'index',
                        'action'     => 'index',
                        'resource'   => 'mvc:admin', // resource
                )
        );
 
        // create container from array
        $navigation = new Zend_Navigation($pages);
        Zend_Registry::set('Zend_Navigation', $navigation);
        $view->navigation($navigation);
    }
, ,

WP-Syntax è il plugin che utilizzo per evidenziare i codici che inserisco nei miei post. Da subito ho notato un problema che deriva dall’editor integrato di WordPress. Infatti al momento dell’inserimento del codice all’interno dei tag <pre></pre> tra il passaggio da modalità “Visuale” o “HTML” i caratteri speciali vengono convertiti in entità HTML, come per esempio i carattetri <> vengono tradotti in &lt; &gt;

Cercando velocemente su Internet ho subito trovato una soluzione immediata, ovvero un workaround che utilizza la funzione htmlspecialchars_decode di PHP.
Modificando una riga del file wp-syntax.php si risolve il problema.

    //$geshi = new GeSHi($code, $language);
    $geshi = new GeSHi(htmlspecialchars_decode($code), $language);

Nota: la funzione htmlspecialchars_decode è disponibile solo per le versioni di PHP superiori o uguali alla 5.1.0. Per le versioni precedenti è possibile simularla in questo modo:

if (!function_exists("htmlspecialchars_decode")) {
    function htmlspecialchars_decode($string, $quote_style = ENT_COMPAT) {
        return strtr($string, array_flip(get_html_translation_table(HTML_SPECIALCHARS, $quote_style)));
    }
}

Fonte: http://blog.felho.hu/escaping-problem-with-wp-syntax-wordpress-plugin.html

, , , ,