Luca's forge

Experiments from the land of open source

[Drupal7] Speed Up Simpletest Tests Usign Live Database

If you want to speed up Drupal Simpletest bootstrap a simple trick is to use the live database instead of the sandbox enviroment created by Simpletest. To do this simply override setUp and tearDown methods as reported below:

1
2
3
4
5
6
7
8
9
10
<?php
class SampleTest extends DrupalWebTestCase {
  function setUp() {
    $this->setup = TRUE;
  }

  function tearDown() {
  }

  //Your test here...

Please note now you are using the live database… so eventual fake contents created by unit tests must be removed manually ;)

[Drupal7] How Display Block Programmatically

If you want to display a block in your template:

1
2
$block = block_load($module, $delta);
print render(_block_gAet_renderable_array( _block_render_blocks( array($block) )));

where:

$module Name of the module that implements the block to load.

$delta Unique ID of the block within the context of $module. Pass NULL to return an empty block object for $module.

Reference links:

How Enable the PHP Tidy Extension for MAMP

  1. Download the PHP source in according with your environment:
    $ php -v
    PHP 5.2.11 (cli) (built: Dec 12 2009 13:19:08)
    
  2. Extract in a temporary folder
    $ cd ~ && tar zxvf php-5.2.11.tar.gz && cd php-5.2.11
    
  3. Patch the ext/iconv/iconv.c file remove the lib on #define iconv libiconv so that the code reads like this:
    #ifdef HAVE_LIBICONV
    #define iconv iconv
    #endif
  4. Patch the ext/tidy/tidy.c file moving the line 34: #include “tidy.h” to line 24 of tidy.c so that the code reads like this:
    #ifdef HAVE_CONFIG_H
    #include "config.h"
    #endif
    
    #include "tidy.h"
    #include "php.h"
    #include "php_tidy.h"
    
    #if HAVE_TIDY
    
    #include "php_ini.h"
    
  5. Instruct the system to build universal binaries, that will work on both 32 and 64 bit systems by entering the following commands in the terminal console:
    $ MACOSX_DEPLOYMENT_TARGET=10.6
    $ CFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp"
    $ CCFLAGS="-arch i386 -arch x86_64 -g -Os -pipe"CXXFLAGS="-arch i386 -arch x86_64 -g -Os -pipe"
    $ LDFLAGS="-arch i386 -arch x86_64 -bind_at_load"
    $ export CFLAGS CXXFLAGS LDFLAGS CCFLAGS MACOSX_DEPLOYMENT_TARGET
  6. Configure & make
    $ LIBS=-lresolv ./configure --with-tidy=shared && make
  7. Copy the module in MAMP
    $ cp ./modules/tidy.so /Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20060613/
  8. Enable the module in the /Applications/MAMP/conf/php5/php.ini adding the following line in the extension section:
    extension=tidy.so
  9. Restart the webserver
  10. Check with php_info() if the tidy extension is loaded correctly ;-)

Reference Links:

Drupal 6: How Create a Node With CCK Fields Programmatically

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php

require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
module_load_include('inc', 'node', 'node.pages');

$node = new stdClass();

//Set up default values, if required.
node_object_prepare($node);

//Specify the content type
$node->type = 'profile';

//Specify an author for the node
$node->uid = 1;

//Add the title
$node->title = 'Test';

//Add the CCK fields data
$node->field_name[0]['value'] = 'Name';
$node->field_surname[0]['value'] = 'Surname';

//Save the node object into the database.
node_save($node);

//Debug the created node
print '<pre>';
print_($node);
print '</pre>';

Installing JBoss Eap 4.3 on Red Hat 5.3

Requirements

  • JDK 1.5 or 1.6
  • Installer Jboss eap 4.3 or higher

Installation

Create jboss user

~# adduser jboss && passwd jboss

Update ~/.bashrc

#JAVA Settings
export JAVA_HOME=/usr/java/latest
export PATH=$JAVA_HOME/bin:$PATH

#JBOSS Settings
export JBOSS_HOME=/home/jboss/EnterprisePlatform-4.3.0.GA_CP07/jboss-as
export JAVAPTH=$JAVA_HOME/bin
export JBOSS_CONF=default
export JBOSS_HOST="0.0.0.0"

Install JBoss eap

~$ java -jar enterprise-installer-4.3.0.GA_CP07.jar

Follow the graphic installer and complete the installation.

Set up as service

As root:

ln -s /home/jboss/EnterprisePlatform-4.3.0.GA_CP07/jboss-as/bin/jboss_init_redhat.sh jboss
ln -s /etc/rc.d/init.d/jboss /etc/rc3.d/S84jboss
ln -s /etc/rc.d/init.d/jboss /etc/rc5.d/S84jboss
ln -s /etc/rc.d/init.d/jboss /etc/rc4.d/S84jboss
ln -s /etc/rc.d/init.d/jboss /etc/rc6.d/K15jboss
ln -s /etc/rc.d/init.d/jboss /etc/rc0.d/K15jboss
ln -s /etc/rc.d/init.d/jboss /etc/rc1.d/K15jboss
ln -s /etc/rc.d/init.d/jboss /etc/rc2.d/K15jboss

Edit the $JBOSS_HOME/bin/jboss_init_redhat.sh to allow loading the user profile:

#Add this line before any script content
. /home/jboss/.bashrc

Test

As root:

~# service jboss start

Now JBoss should be available at: http://YOUR_ADDRESS:8080