Luca's forge

Experiments from the land of open source

Draw Arc Text With EaselJS

Today I’ve released a first version of easeljs-arctext, an EaselJS extension that allows drawing of text along arc path.

See below for sample code.

Sample code
1
2
3
4
5
6
7
8
9
canvas = document.getElementById("canvas");
var stage = new Stage(canvas);
//Draw the text "Text Arc" with font "20pt Arial", color "black" and radius 100
var text = new TextArc("Text Arc", '20pt Arial', '#000', 100);
text.textAlign = "center";
text.x = 200;
text.y = 300;
stage.addChild(text);
stage.update();

Comments or suggestions are welcome ;)

Ubuntu and LDAP: Force Authentication During a Bind Request

Default LDAP installation on Ubuntu server allows anonymous binding and directory access. If you want avoid this behavior you may set the olcRequires to authc using the ldif format with the following command:

1
$ sudo ldapadd -Y EXTERNAL -H ldapi:/// -f ldap_disable_bind_anon.ldif

where

(ldap_disable_bind_anon.ldif) download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
dn: cn=config
changetype: modify
add: olcDisallows
olcDisallows: bind_anon

dn: cn=config
changetype: modify
add: olcRequires
olcRequires: authc

dn: olcDatabase={-1}frontend,cn=config
changetype: modify
add: olcRequires
olcRequires: authc

[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: