Archive for September, 2009

Tweeting from PHP Comments Off

Thanks to fabien Potencier for this hint :

Twitter is everywhere nowadays. Odds are eventually you will want to tweet from PHP. No need to use one of the numerous PHP Twitter libraries, as tweeting is as simple as using the PHP built-in file_get_contents() function:
function tweet($message, $username, $password)
{
$context = stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => sprintf("Authorization: Basic %s\r\n", base64_encode($username.':'.$password)).
"Content-type: application/x-www-form-urlencoded\r\n",
'content' => http_build_query(array('status' => $message)),
'timeout' => 5,
),
));
$ret = file_get_contents('http://twitter.com/statuses/update.xml', false, $context);

return false !== $ret;
}

Pretty easy, no? Using the tweet() function is of course a piece of cake:
tweet(‘From PHP, yeah…’, ‘fabpot’, ‘Pa$$’)

;

source : http://fabien.potencier.org/article/20/tweeting-from-php

Tags: devloppement, PHP, twitter

Réinstallation complète de macosx, comment bien configurer son environnement Comments Off

Suite à un crash de disque dur (paix à son âme) je profite de cette install tout fraîche de macosx 10.6 pour bien configurer mon environnement.

Pour mémo:

  • Autoriser l’accès SSH sur la machine (pref système > partage > session à distance)
  • créer un fichier /.profile
  • créer un dossier ~/bin
  • dans ~.profile, personnaliser le PATH comme suit :export PATH=~/bin:$PATH
  • mettre dans ~/bin les liens symbolique et script utiles
    1. contrôle d’itunes (http://gist.github.com/184838)
    2. contrôle du volume (http://gist.github.com/184840)
    3. cd ~/bin && ln -s /Applications/MAMP/bin/php5/php php
    4. ln -s /Applications/MAMP/Library/bin/mysqladmin mysqladmin
      ln -s /Applications/MAMP/Library/bin/mysql mysql
      ln -s /Applications/MAMP/Library/bin/mysqldump mysqldump
    5. etc …
  • virer les applications hadoc de /usr/bin (php au hasard)

Bon évidemment l’idéal aurait été de faire un Rsync du dernier backup sur la lunxbox mais bon c’ets moins marrant ;-)

Tags: Apple, bonne pratiques, gist, Macosx, MAMP, mysql, PHP, rsync, script, SSH, sysadmin, tips