1. php.ini locations

    May 30, 2008 by pierre

    Once it is compiled, PHP can be configured using a file called “php.ini”.

    If you are using PHP as a server module (mod_php in Apache) this file is read when the server is started, this implies that you need to restart the server to update the configuration. But using php via CGI or command line interface, it is read each time a script is executed.

    You can have several php.ini files and it is searched in an ordered orthodox serie of locations. Thanks to this feature you can have specific configurations of PHP per level of directory trees on your server. In some systems though (we just experienced this on a Site5 shared hosting account) you can somehow bypass this list (I don’t know exaclty how you do this) and have php.ini files setting the defaults for only the folder that contains it. In other words each php.ini files can then only affect scripts that are in the same folder.

    For example if you are using a script to upload files bigger than than upload_max_filesize you can reset this limit in a php.ini file but it then has to be in the same folder as your uploading script. In this situation if you are using a framework like Code Igniter or CakePHP the code that is executed when you upload a file will be scattered in many files and directories. We thought and googled hard for a cleaner solution (please comment if you know a better way!), but we ended up duplicating the php.ini file in all the application and framework core dirs so that our settings are applied correctly.

    To do this from the command line, cd to the top dir containing the php.ini file and do something like:

    for i in `ls -aR | grep \: | cut -f 1 -d :`; do if [ -d $i ]; then cp php.ini $i; fi; done

  2. (re) Enabling the past

    May 26, 2008 by jerome

    sangbleu.png

    A few days ago, I had to modify the SangBleu WordPress theme for Maxime. Maxime finally wanted to give access to the recent archives pages. The SangBleu theme has been built on top of Naked Wordpress Theme; Naked is a drastically simplified theme with just the strict minimum DOM architecture. As such it is very easy to develop your own CSS - which is not the case with the standard Kubricks theme: too many intricated elements in the DOM structure, producing a super huge and complex stylesheet.

    You can download the Naked theme from http://bealers.com/wordpress-naked/; it is definitely a must-have if you’re going to develop some small project and need flexibility as well as simplicity.

    The problem I faced was a bit silly: the posts_nav_link was not behaving correctly - I changed at some point the MySql bits form the origianl theme: the Loop was not a standard one, but a simple MySql request on the database.

    $querystr = "	SELECT wposts.*
        FROM $wpdb->posts AS wposts
        WHERE wposts.post_status = 'publish'
        AND wposts.post_type='post'
        ORDER BY wposts.post_date DESC LIMIT 0,20
     ";
    
    $pageposts = $wpdb->get_results($querystr, OBJECT);
    
    if ($pageposts): ?>
    <ol id="posts">
    				setup_postdata($post);
    [...]
    			endforeach;
    [...]
    endif;</ol>

    This MySql bit does not query any paged items. To manage to get the paging back, I had to re-modify the way the theme is requesting the posts from the database. In order to have the pagination for past posts enabled, I simply did a copy/paste from the Kubricks theme. So, I replaced the above by the following:


    if (have_posts()) :
    while (have_posts()) : the_post();
    [...]
    endwhile;
    endif;

    In Wordpress you can control the pagination on a page with multiple posts (like index.php) using the template tag: posts_nav_link. This tag takes 3 parameters, the first one being the string inserted at the beginning, the last two parameters being quite obvious…
    posts_nav_link(’ · ‘, ‘previous page’, ‘next page’)
    In order for it to work, you need to have a Loop on the page which is going to query the posts using a paged information.

    On a single post page, you can also use the next_post_link() and previous_post_link() to display links to the individual next/previous post.

    * http://codex.wordpress.org/Template_Tags/posts_nav_link


  3. Text to speech solutions

    May 25, 2008 by pierre

    I did some reasearch on text-to-speech solutions for a project we are doing. I was looking for a solution to produce speech samples from short text streams, and cache them. The clips cannot be generated all in one go (they need to be updated sometimes) but it does not need to be all dynamic (most of it will be cached when it’s served).

    The first solution that I considered was using the Mac OS builtin text-to-speech system. It has an applescript and a command line interface, so it would be possible to pull all the text that we want to convert, generate many samples, and move them from a local machine where they need to be.

    For example, at the command line, this is the “say” command synopsis :

    say [-v voice] [-o out.aiff | -n name:port ] [-f file | string ...] 

    So you can try:

    say fitter happier

    and this will save it to a file:

    say -o fredsays.aiff we are now in the year two thousand

    I was discussing this with Tommi and the conversation made me realise that the Mac voice is a bit iconic, it part of our audio culture, you ear it and you know it’s Fred from Mac voices. A short Fred playlist : “Fitter Happier” on Radiohead’s OK Computer, “The Analyst” on Arpanet’s “Wireless Internet”. BTW listen to the newest voices that they introduced with Leopard… Fast Darwin transform in the uncanny valley.

    So, the Mac text-to-speech system is allready a quite good solution for what we want to do. The main problem will be to keep the content and the audio in sync. For now we don’t have access to a Mac OS X server, that means that we would need to update the sounds of the system we’re building from a local computer. Ideally this would be done by batches, something like a “generate and upload all new sounds” script that we would need to run each time there is a significant content update.

    To get around this we would need to integrate the text-to-speech service in the content strorage and administration system. There would then be callback functions on some fileds; and when those fields are created or modified we would ping a “speech server” to get the content as audio in return. There are two parts in this project: getting the speech server to run, writting the API calls to get the samples to cache when some data is created/modified.

    The ideal solution here would be a webservice that run the server and provide an API. Text-to-speech is a well explored domain, and there are several tools in the main programming languages (Java, C++) to build a speech server on a unix machine without too much difficulties. So there are plenty of companies who sell this kind of services, and a few free webservices (vozMe and SpokenText to name two) but the free ones does not seem to have documented stable APIs (I found a pirate one) so we cannot go this way.

    To setup our own server, I found that the open source Festival seems to be the tool of choice of a lot of people, it is available thru several linux package managers and it has a PHP client, called pvox (from 2008), this would round the API corner. So it seems a good choice.

    To conclude: I’m looking into installing Festival w. pvox in one of our servers, and the Mac solution is our backup strategy.


  4. Friendfeed IM reader quick hack

    May 24, 2008 by pierre

    Tommi recently showed me a service called Friendfeed, it is an rss aggregator for everything that you post on a bunch of online services and your personal rss feeds. It is very well integrated with those services and building a profile is quick. You can then subscribe to other people profile, and see an overview of their updates in a “friends” tab on the main page.

    We were recently discussing about this site with Jérôme and he mentioned that it would be nice to have it in IM, I did a quick search of existing solutions or possibilities.

    Post: there is posting bot provided by imified for Friendfeed.

    Read new posts: you can use an IM feedreader, I tried with inezha.com. Once you have an account on inezha (anothr), you can subscribe to your “friends” activity feed (the feed’s link on Friendfeed is in the page header or at the bottom of the friends tab) and regularly receive IM updates of the content that appears in this feed.

    These are two immediate solutions, it worked ok in a few minutes. The output of inezha.com bot is a bit ascii-arty but I guess it won’t be difficult to have something more minimal for ex. preprocessing the Friendfeed feed in yahoo pipes.

    A more complete solution would be to use the Freindfeed API. There are wrappers in Python and PHP for it. It has a read method (/api/feed/home) for your homepage view (friends updates) and one (/api/share) for creating new entries. I know three python jabber modules, words, based on the twisted framework, and then there is xmpp.py and jabber.py. I think the most lively one is xmpp.py (last updated in 2007). Php has a xmpphp package.


  5. Web interface internship

    May 21, 2008 by pierre

    We are working on a web dev project art directed by The Digital Club for a secret art world site. We did wearebuild.com for them, this will be similar in some aspects, a bit bigger.

    We will be looking for somebody to help on the testing, bugs reporting and hopefully fixing front, from mid-june to mid-july.

    It will involve bug reporting software, Firebug, HTML pages, CSS, Javascript (jQuery) code. It will involve Internet Explorer on a daily basis, you’ve been warned!

    Benefits are :
    - free lunch & transportation
    - working on “big” dev. project with us, getting to know each other
    - getting to know maybe not top wizzardy, but quite advanced DHTML and cross browsers techniques
    - copying as much code snippets as you want and as security concerns allows

    It could be done from afar, but looks like it would be a lot easier lo(ndon)cally.


  6. Fontlab 5, Python and Robofab setup

    May 17, 2008 by pierre

    This is a small summary more than a proper “how-to”, about setting up FontLab 5, Python and Robofab on a Mac running OS 10.5. I hope that if your install is not working this might help you.

    Currently FontLab installer will put python 2.3 in your “Frameworks” directory. This is where all python versions should live in a standard setup (/Library/Frameworks/Python.framework/Versions), if you “cd” to this dir you should see python 2.5 there too.

    The path to python version 2.3 seems hardcoded into FontLab 5, there is a note on the FontLab website that explains how to trick it to use 2.4 or 2.5. This is mainly usefull if you are working with python in general and want to use modules that are in your 2.5 install without duplicating them otherwise using 2.3 is fine.

    To install robofab you will need to copy it where python (the version you are using with FontLab) can see it, in other words you need to copy Robofab in python “module search path“: a list of directories that python search for aditional modules to load.

    Currently there are two installers provided with robofab which will do this for you. The first one is a mac installer from Erik van Blokland. The second one is a install.py script that you can get from the current SVN repos.

    If you want to do this manually, find out where python look for modules, either by echoing the PYTHONPATH env. variable, or running this code:

    from distutils.sysconfig import get_python_lib
    print get_python_lib()

    and copy Robofab in the relevant folder. Then you need to restart FontLab and you can try to:

    import robofab


  7. webpages and webapps

    May 10, 2008 by pierre

    I started using online applications like Gmail, Flickr and Bloglines when they were published in early 2004. Around that time I started to look into web programming and what could be done with CGI scripts or PHP & MYSQL, and it’s also when Ruby on Rails was first released. Today I’m living in google mail, reader and docs, watch closely the market of webapps, and develop some at work and in my leisure time. In the recent years I learned quite a lot about the techniques that these apps are built on, on the interface side: patterns for Javascript, the DOM and XML, as well as on the backend side: db models, caching etc…

    Yet more and more I’m finding myself pushing for simple declarative text files and bare html solutions: I’m dreaming of static webpages or jpg directly displayed in the web browser window… I’m not saying that we should build webpages and stop building webapps, but I think webapps have been doing such an impression on me that I started seeing every sites projects as a a webapp. Like if suddenly ink on paper was printed books all around and no manuscripts anymore, no scribbled napkins notes, etc…

    All this to say that these days I enjoy a lot re-discovering all that can be done just by pushing a few html element and some content in a plain text file.

    Inspiring sites:

    http://okmij.org/ftp/
    http://www.ftarri.com/index.html

    Examples of webpages we did with Jérôme recently:

    http://electronest.com
    http://textasplayground.net