Tuesday, May 27, 2008

Install PHP pecl intl module for ubuntu 7.10 (PHP 5.2.3)

The "intl" extension (which gives you the ICU library, see http://www.icu-project.org and http://pecl.php.net/package/intl) requires PHP 5.2.4 or later.
Ubuntu 7.10 comes with 5.2.3. However the changes required are quite minor.

Note: all the following steps need to be done as root.

First make sure both php5 and php5-dev packages are installed.

Next go to /usr/lib/php5/build/ and replace the acinclude.m4 file with the one here:
http://cvs.php.net/viewvc.cgi/php-src/acinclude.m4?revision=1.387

(This is to get the [PHP_SETUP_ICU] macro, which was added in php 5.2.4)

Next, go to /usr/include/php5/main/ and open php_config.h and at the end add this line:

#define HAVE_PTRDIFF_T 1


Now you should be ready to do the install, which is as simple as:

pecl install intl


It will download a 150K file, and compile and install it.

At the end it says to add a line to php.ini. Assuming you want the intl extension in both the apache module and the cli version of php, then go to /etc/php5/conf.d/ and create a file called intl.ini and in that file put this single line:

extension=intl.so


A quick way to check it all worked is to type:

php -i | grep intl


If it didn't work you will see nothing. If it worked you'll see a line talking about "intl.default_locale".

Sunday, May 18, 2008

Controlling file associations in Gnome

Gnome, whether under redhat or ubuntu, is very hard to configure. Especially controlling the behaviour when you double-click on a file. However I may've got it cracked.

First, the easy way, is right-click a file, choose properties, and there is the open with tab. The setting there affects all files with that extension. (I still think that is one of those things that isn't even obvious once you know about it!)

But sometimes that is not enough. E.g. *.as files were associated with x-applix-spreadsheet, instead of my text editor. And then it then complains I'm trying to open a suspicious file.

Solution: I created this xml file as
/usr/share/mime/packages/actionscript.xml:


<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/x-actionscript">
<comment>Actionscript</comment>
<glob pattern="*.as">
</mime-type>
</mime-info>

Wow, that seemed to do the job!

sprouts on linux

I've been using sprouts for AS3 on linux as a way to get straight into developing without having to learn about the tools or libraries I need. I'm not sure I'll continue using it once I get into more serious work, as it is a bit opaque (i.e. as with just about any framework, it is easy to do things it does by default, and really difficult to do anything else) and is based on ruby which is not one of my favourite languages.

It has also not been very smooth to use and install, which is what the rest of this article is about.

I'm following the instructions on:
http://www.projectsprouts.org/getting_started.html

on ubuntu. I had ruby installed, and just installed the gem package
(i.e., sudo gem --help then worked). (I also needed to install the rake package.)

But the following line fails:

sudo gem install sprout
Bulk updating Gem source index for: http://gems.rubyforge.org
ERROR: While executing gem ... (Gem::GemNotFoundException)
Could not find sprout (> 0) in any repository

Ah, simply trying it again works. Note that it will ask about all the "required" dependencies. If they are truly "required" then no choice but to say "Y"?

$ sudo gem install sprout
Bulk updating Gem source index for: http://gems.rubyforge.org
Select which gem to install for your platform (i486-linux)
1. sprout 0.7.171 (mswin32)
2. sprout 0.7.171 (darwin)
3. sprout 0.7.171 (x86-linux)
4. sprout 0.7.171 (ruby)
5. Skip this gem
6. Cancel installation
> > 3
Install required dependency rubyzip? [Yn]
Install required dependency archive-tar-minitar? [Yn]
Install required dependency rails? [Yn]
Install required dependency rake? [Yn]
Install required dependency activesupport? [Yn]
Install required dependency activerecord? [Yn]
Install required dependency actionpack? [Yn]
Install required dependency actionmailer? [Yn]
Install required dependency activeresource? [Yn]
Install required dependency net-sftp? [Yn]
Install required dependency net-ssh? [Yn]
Install required dependency needle? [Yn]
Install required dependency open4? [Yn]



Next, this line fails:
sprout -n as3 SomeProject

Run "gem contents sprout" to see it has been installed in:
/var/lib/gems/1.8/gems/sprout-0.7.171-x86-linux/bin

It is not executable so:
cd /var/lib/gems/1.8/gems/sprout-0.7.171-x86-linux/bin/
sudo chmod +x sprout

You can temporarily add it to the path with:
export PATH=$PATH:/var/lib/gems/1.8/gems/sprout-0.7.171-x86-linux/bin

This now works:
sprout -n as3 test1


But:
cd test1
rake

fails with the line: "no such file to load -- sprout".


This seems to do the trick:
rake -I /var/lib/gems/1.8/gems/sprout-0.7.171-x86-linux/lib/


Q. Where do I set that so it is a global setting??


Another problem: when I double click a swf file it tries to open it in
movie player. I try to connect to flashplayer, but that name does not
exist in /usr/bin.
Q. Where has the standalone flash player been installed??

Monday, May 12, 2008

fl.motion.easing open source

I've been trying out TweenLite (http://blog.greensock.com/tweenliteas3/), but it relies on the fl.motion.easing package, which is only available to paying Adobe customers.

However the actual code is by Robert Penner under a BSD-license: http://www.robertpenner.com/easing/

Based on the suggestion here (http://www.actionscripts.org/forums/showthread.php3?t=144172) ) I've taken the AS2 code and made an AS3 version, under the same BSD license. I cannot believe that no-one else has done this before, but if they have I certainly couldn't track it down.

TODO: put the zip file up here.