1. WP 2.6.2 posts revisions & Twitter Updater

    October 5, 2008 by jerome

    * Tlktlk is using the Twitter Updater plugins. It’s quite a nice plugin, really usefull to do automated posting to a twitter account.
    But for a reason I didn’t quite grok, the twitter account was updated even when editing (save post) and/or (maybe) trough the autosave function of the new 2.6. On a few other blogs I decided to desactivate it since it was creating twits based on revision not accessible to general plugin and resulting in a 404.

    This afternoon I had a look in the WP Codex page for Actions’ Hook and I tried to replace the hook from the plugin (line 108: twitter_updater.php) and posted a new event on the blog; so far it seems it worked like a charm:


    add_action ( 'publish_post', 'vc_twit');
    //add_action ( 'save_post', 'vc_twit');


  2. Magpie & Feedburner - the 404 issue

    September 30, 2008 by jerome

    I just had some troubles for a few days trying to figure out why some of my feed were disappearing from Magpie when the website was using feedburner’s services ; the problem was coming from user agent - feedburners apparently has some troubles answering application with a ‘weird’ name.
    The solution I found (here) is to declare Magpie useragent as being something more traditionnal:

    define('MAGPIE_USER_AGENT', 'Mozilla/5.0 (Windows; U; Windows NT 5.1;
    en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1');

    * Magpie is a RSS parser for PHP; it allows for quick prototyping. It is super simple and easy to use. It is a very nice way for using similar concepts as the Yahoo Pipes RSS parser in custom code.


  3. next bigger interger

    August 12, 2008 by pierre

    I’m working on PDF templates using FPDF, the templates are based on a grid and I had to find how much of the grid’s units different images are using, e.g. if an image width is 1.3 units I need to make 2 units space for it in the the grid.

    In other words I needed to “round” a floating point number, but always to a bigger number so the round php function would not be usefull :

    echo round(1.2); // 1
    echo round(1.6); // 2

    Then I thought that what I wanted was the “next bigger integer”, and it felt in place : change the float to an integer and add one.

    echo ((int) 1.2) + 1; // 2
    echo ((int) 1.6) + 1; // 2

    This is super simple but it seem to me a good exemple of how formulating what you want to do in english can help when programming.


  4. (can’t) insert uploaded images in WP 2.5+

    July 3, 2008 by jerome

    With Wordpress 2.5 came a new way of handling files upload: the image gallery. Very neat and simple to use. One single issue made it so far a pain in the bum for me: for some reason, some times, it was impossible to use the button ‘Insert into Post’.

    Firebug was indicating that the AJAX call was left with no answer - it is apparently related with server configuration - this happen all the time and it’s a real problem when developing on a shared hosting machine; I had these issues on a shared hosted account at IX web hosting and I still have to test on a DreamHost account to see if it solves this issue there too.

    I finally found out a solution for my WP 2.5.1 installation:
    Thanks to Otto42 on the WP forum, after following the whole discussion - i had to edit my .htaccess and add the following lines.

    <IfModule mod_security.c>
    SecFilterEngine Off
    SecFilterScanPOST Off
    </IfModule>

    The ‘.htaccess’ file provides additional configuration instruction to the Apache server, specific for the files accessed in the same directory where it is located - in this case it should be the root directory of your WP installation, if you have no .htaccess file you can just create one and call it this way, with the dot in front of the name: it means the file will be hidden using http, but you still can see it trough ftp - when downloading this file, if your are on a Mac OS X, the file will not be listed in the directory, but it still is there, it is just hidden.

    * Please note that disabling mod_security apparently opens wide door to comment and referrer spam, and possibly nastier attack of other forms.


  5. Electronest Projects & see through pages

    June 8, 2008 by jerome

    empty_page.jpg

    Inspired by a few research and a certain trend we decided to give see-through website a first go and this weekend, we finally managed to group a few works and an archive links list on two pages: Electronest Websites Work Selection and Electronest’s Projects Archive; these page simply use an iframe objects to display other’s websites. Some of the many problem we usually faced when presenting our online portfolio, are:

    1/ it’s bad to have a huge list of links - no one is going to ever click on each links; it’s better to keep track with reality and we reduced the quantity by focusing on just a few websites.
    2/ visual concision - no images and not a list either, but a simple drown menu which stays in the corner. you’re two click away from any content at any given time.
    3/ browsing efficiency - you don’t have to open in a new window, or to browse back to the page if you decided to see a bit more of the showcased websites.
    4/ un-obstrusiveness - you can remove the navigation at any given time to explore further in an de-clustered window.
    5/ the most interesting bit: you see the real thing.

    This way still requires certainly a lot of improvements - but it is a very effective and straight to the point way to share a few things we liked to work on and it gives a good overview of our online work.
    For a more complete picture of all our activities, we developed a prototype following the same principle of the see through website, but we expanded the list to a 88 elements list - our beta archive for the past 4 years, which is approximatively 22 projects per year.

    projects_list.jpg

    The page is made of 2 main elements: an iframe and a navigation form. The navigation form is simply made of a select element where option’s values are giving the url of the listed elements. The javascript we are using on this page remains quite simple:

    - in the form’s OnChange:

    document.getElementById('where_to_go_next').src = this.options[this.selectedIndex].value;
    where “where_to_go_next” is the ID of the iframe

    - in the link to remove the iFrame and reload the selected page:

    the_local_form = document.getElementById('author_list'); window.location=the_local_form.options[the_local_form.selectedIndex].value
    where “author_list” is the Select ID inside the form; the value being set from the Selected option (value="http://..."), we can access it to define the new location of the window DOM element.


  6. 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

  7. (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


  8. 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.


  9. 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.


  10. 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.