Not My Idea — Snippets

Some code snippets about Linux / Php and Python

Using bpython with django – another way

Lakshman wrotes up a nice article introducing bpython, and gives some tips to integrate it with django.

Unfortunatly, the tip laksman proposed can’t use additional parameters. Here is another way to use bpython, with django. It makes somes changes into the files of the framework (that some people — myself included — calls an ugly hack, but, it works the right way).

To run django shell with bpython, just enter

django shell --bpython

And you’re done.

Here is the patch:

Index: shell.py
===================================================================
--- shell.py    (révision 11821)
+++ shell.py    (copie de travail)
@@ -6,8 +6,12 @@
     option_list = NoArgsCommand.option_list + (
         make_option('--plain', action='store_true', dest='plain',
             help='Tells Django to use plain Python, not IPython.'),
+        make_option('--bpython', action='store_true', dest='bpython',
+            help='Tells Django to use the bpython interpreter, not IPython.'),    
     )
-    help = "Runs a Python interactive interpreter. Tries to use IPython, if it's available."
+    help = """Runs a Python interactive interpreter. Tries to use IPython, if
+    it's available. Can use bpython with the --bpython option
+    """
 
     requires_model_validation = False
 
@@ -18,16 +22,22 @@
         loaded_models = get_models()
 
         use_plain = options.get('plain', False)
+        use_bpython = options.get('bpython', False)
 
         try:
             if use_plain:
                 # Don't bother loading IPython, because the user wants plain Python.
                 raise ImportError
-            import IPython
-            # Explicitly pass an empty list as arguments, because otherwise IPython
-            # would use sys.argv from this script.
-            shell = IPython.Shell.IPShell(argv=[])
-            shell.mainloop()
+            elif use_bpython:
+                # The user wants bpython
+                from bpython.cli import main
+                main(args=[])
+            else:
+                import IPython
+                # Explicitly pass an empty list as arguments, because otherwise IPython
+                # would use sys.argv from this script.
+                shell = IPython.Shell.IPShell(argv=[])
+                shell.mainloop()
         except ImportError:
             import code
             # Set up a dictionary to serve as the environment for the shell, so

And the entire file (for django 1.1.1 and trunk):

import os
from django.core.management.base import NoArgsCommand
from optparse import make_option

class Command(NoArgsCommand):
    option_list = NoArgsCommand.option_list + (
        make_option('--plain', action='store_true', dest='plain',
            help='Tells Django to use plain Python, not IPython.'),
        make_option('--bpython', action='store_true', dest='bpython',
            help='Tells Django to use the bpython interpreter, not IPython.'),    
    )
    help = """Runs a Python interactive interpreter. Tries to use IPython, if
    it's available. Can use bpython with the --bpython option
    """


    requires_model_validation = False

    def handle_noargs(self, **options):
        # XXX: (Temporary) workaround for ticket #1796: force early loading of all
        # models from installed apps.
        from django.db.models.loading import get_models
        loaded_models = get_models()

        use_plain = options.get('plain', False)
        use_bpython = options.get('bpython', False)

        try:
            if use_plain:
                # Don't bother loading IPython, because the user wants plain Python.
                raise ImportError
            elif use_bpython:
                # The user wants bpython
                from bpython.cli import main
                main(args=[])
            else:
                import IPython
                # Explicitly pass an empty list as arguments, because otherwise IPython
                # would use sys.argv from this script.
                shell = IPython.Shell.IPShell(argv=[])
                shell.mainloop()
        except ImportError:
            import code
            # Set up a dictionary to serve as the environment for the shell, so
            # that tab completion works on objects that are imported at runtime.
            # See ticket 5082.
            imported_objects = {}
            try: # Try activating rlcompleter, because it's handy.
                import readline
            except ImportError:
                pass
            else:
                # We don't have to wrap the following import in a 'try', because
                # we already know 'readline' was imported successfully.
                import rlcompleter
                readline.set_completer(rlcompleter.Completer(imported_objects).complete)
                readline.parse_and_bind("tab:complete")

            # We want to honor both $PYTHONSTARTUP and .pythonrc.py, so follow system
            # conventions and get $PYTHONSTARTUP first then import user.
            if not use_plain:
                pythonrc = os.environ.get("PYTHONSTARTUP")
                if pythonrc and os.path.isfile(pythonrc):
                    try:
                        execfile(pythonrc)
                    except NameError:
                        pass
                # This will import .pythonrc.py as a side-effect
                import user
            code.interact(local=imported_objects)

Hope it helps

Install PHP 5.3 + Apache on ubuntu 9.10 using dotdeb repositories, via apt-get

PHP 5.3 isn’t proposed by default within the default ubuntu 9.10 repositories.

Here are the steps needed to quickly install Apache + PHP 5.3 in an ubuntu linux environment.

All in two command lines :)

Just copy the two line above to get php 5.3 working :)

sudo su
cd /tmp && mkdir php53 && cd php53 && wget http://us.archive.ubuntu.com/ubuntu/pool/main/k/krb5/libkrb53_1.6.dfsg.4~beta1-5ubuntu2_i386.deb && wget http://us.archive.ubuntu.com/ubuntu/pool/main/i/icu/libicu38_3.8-6ubuntu0.2_i386.deb && dpkg -i *.deb && echo "deb http://php53.dotdeb.org stable all" >> /etc/apt/sources.list && aptitude update && aptitude install libapache2-mod-php5=5.3.1 apache2

Details

First, download dependencies, and install them.

sudo su
cd /tmp
mkdir php53 && cd php53
wget http://us.archive.ubuntu.com/ubuntu/pool/main/k/krb5/libkrb53_1.6.dfsg.4~beta1-5ubuntu2_i386.deb
wget http://us.archive.ubuntu.com/ubuntu/pool/main/i/icu/libicu38_3.8-6ubuntu0.2_i386.deb
dpkg -i *.deb

Add the dotdeb repository to our apt sources.list:

echo "deb http://php53.dotdeb.org stable all" >> /etc/apt/sources.list
aptitude update

Install apache + PHP5.3 !

aptitude install libapache2-mod-php5=5.3.1 apache2

And that’s it !
php53

Use CLI to traduct you sentencies !

In a tweet, I was asking if any tools exists to traduct sentencies directly from the command line. And « tw » (for translate word) is one ! (thanks @gabouel)

Install and use it :

cd /tmp
sudo apt-get install elinks curl gawk
wget http://mirror.cinquix.com/pub/savannah/twandgtw/tw-0.1.3.tar.bz2
tar -xvf tw-0.1.3.tar.bz2
cd tw-0.1.3
./configure
sudo make && sudo make install

Now, you can translate directly from the command line :

$ tw translate.google.com.fr-en "Salut, je m'apelle Alexis"
Hi, my name is Alexis

Yeah !

My vimrc profile

For some weeks, I’m now using vim to code, and to redact articles and documentation.

You can check out my currently used .vimrc, and follow it’s modifications on it’s hg repository.

How to remove all .svn folders recursively ?

SVN is really out of date (if you can, try mercurial or any other DVCS, please!), but if you have to use svn, you’ll probably encountred the .svn folder. It sticks in every folder of your arborescence.

Here is a tip to remove all theses .svn folders, hope this useful !

find . -name ".svn" -exec rm -rf {} \;

What do I read ? (RSS Feeds)

<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
    <head>
        <title>Alexis Metaireau subscriptions in Google Reader</title>
    </head>
    <body>
        <outline text="Clément Delafargue // Divarvel"
           title="Clément Delafargue // Divarvel" type="rss"
           xmlUrl="http://www.divarvel.fr/rss/" htmlUrl="http://www.divarvel.fr"/>
        <outline text="DLFP - Dépêches de page principale"
           title="DLFP - Dépêches de page principale" type="rss"
           xmlUrl="http://linuxfr.org/backend/news-homepage/rss20.rss" htmlUrl="http://linuxfr.org/news/"/>
        <outline title="patterns" text="patterns">
            <outline text="Not My Idea" title="Not My Idea" type="rss"
               xmlUrl="http://www.notmyidea.org/feed/" htmlUrl="http://www.notmyidea.org"/>
        </outline>
        <outline title="others" text="others">
            <outline text="David Kulak" title="David Kulak" type="rss"
               xmlUrl="http://www.davidkulak.com/feed/" htmlUrl="http://www.davidkulak.com"/>
            <outline text="Geekscottes" title="Geekscottes" type="rss"
               xmlUrl="http://www.nojhan.net/geekscottes/rss.php" htmlUrl="http://www.nojhan.net/geekscottes/"/>
            <outline text="Le webcomic" title="Le webcomic" type="rss"
               xmlUrl="http://www.maliki.com/rss.xml" htmlUrl="http://www.maliki.com"/>
        </outline>
        <outline title=".Net" text=".Net">
            <outline text="Blog de Julien Dollon"
               title="Blog de Julien Dollon" type="rss"
               xmlUrl="http://blogs.dotnet-france.com/juliend/syndication.axd?format=rss" htmlUrl="http://blogs.dotnet-france.com/juliend/"/>
            <outline
               text="CodeBetter.Com - Stuff you need to Code Better!"
               title="CodeBetter.Com - Stuff you need to Code Better!"
               type="rss"
               xmlUrl="http://feeds2.feedburner.com/codebetter" htmlUrl="http://codebetter.com/blogs/"/>
            <outline text="CodeUtopia" title="CodeUtopia" type="rss"
               xmlUrl="http://codeutopia.net/blog/feed/" htmlUrl="http://codeutopia.net/blog"/>
            <outline text="DotNetGuru.org" title="DotNetGuru.org"
               type="rss"
               xmlUrl="http://www.dotnetguru.org/backend.php" htmlUrl="http://www.dotnetguru.org/"/>
            <outline text="Elegant Code" title="Elegant Code" type="rss"
               xmlUrl="http://feeds2.feedburner.com/ElegantCode" htmlUrl="http://elegantcode.com"/>
            <outline
               text="InfoQ Personalized Feed for Unregistered User - Register to upgrade!"
               title="InfoQ Personalized Feed for Unregistered User - Register to upgrade!"
               type="rss"
               xmlUrl="http://www.infoq.com/rss/rss.action?token=Nd6yHNyrOmvDlyRNG3qlT51jtA2IDoTG" htmlUrl="http://www.infoq.com"/>
            <outline text="Le blog de L'ami Sami"
               title="Le blog de L'ami Sami" type="rss"
               xmlUrl="http://www.dng-consulting.com/blogs/index.php?blog=1&amp;tempskin=_rss2" htmlUrl="http://www.dng-consulting.com/blogs/index.php?blog=1"/>
            <outline text="Radenko Zec Blog" title="Radenko Zec Blog"
               type="rss"
               xmlUrl="http://feeds2.feedburner.com/RadenkoZecBlog" htmlUrl="http://blog.developers.ba/"/>
            <outline text="Sebastien.warin.fr"
               title="Sebastien.warin.fr" type="rss"
               xmlUrl="http://feeds.feedburner.com/sebastienwarin" htmlUrl="http://sebastien.warin.fr"/>
            <outline text="Thomas Lebrun" title="Thomas Lebrun"
               type="rss"
               xmlUrl="http://blogs.developpeur.org/tom/rss.aspx" htmlUrl="http://blogs.developpeur.org/tom/default.aspx"/>
            <outline text="Valtech Blog" title="Valtech Blog" type="rss"
               xmlUrl="http://blog.valtech.fr/wordpress/feed/" htmlUrl="http://blog.valtech.fr/wordpress"/>
        </outline>
        <outline title="django" text="django">
            <outline
               text="Biologeek : Ubuntu, bio-informatique et geekeries libres d'un bio-informaticien au quotidien."
               title="Biologeek : Ubuntu, bio-informatique et geekeries libres d'un bio-informaticien au quotidien."
               type="rss"
               xmlUrl="http://www.biologeek.com/journal/rss.php" htmlUrl="http://www.biologeek.com/"/>
            <outline text="Creaone.fr - Ingenieur multimedia IMAC"
               title="Creaone.fr - Ingenieur multimedia IMAC"
               type="rss" xmlUrl="http://blog.creaone.fr/feed/atom" htmlUrl="http://blog.creaone.fr/"/>
            <outline text="Makina-Corpus.Org" title="Makina-Corpus.Org"
               type="rss" xmlUrl="http://www.makina-corpus.org/feed/" htmlUrl="http://www.makina-corpus.org"/>
            <outline text="The Django community aggregator"
               title="The Django community aggregator" type="rss"
               xmlUrl="http://www.djangoproject.com/rss/community/" htmlUrl="http://www.djangoproject.com/community/"/>
            <outline text="The Django weblog" title="The Django weblog"
               type="rss"
               xmlUrl="http://www.djangoproject.com/rss/weblog/" htmlUrl="http://www.djangoproject.com/weblog/"/>
        </outline>
        <outline title="web" text="web">
            <outline text="eclaireur.net" title="eclaireur.net"
               type="rss"
               xmlUrl="http://feeds.feedburner.com/eclaireur" htmlUrl="http://www.eclaireur.net"/>
            <outline text="XHTML.net" title="XHTML.net" type="rss"
               xmlUrl="http://xhtml.net/rss.php" htmlUrl="http://xhtml.net/"/>
        </outline>
        <outline title="Zend" text="Zend">
            <outline text="BigOrNot [fr]" title="BigOrNot [fr]"
               type="rss"
               xmlUrl="http://bigornot-fr.blogspot.com/feeds/posts/default?alt=rss" htmlUrl="http://bigornot-fr.blogspot.com/"/>
            <outline text="Julien Pauli DevPHP blog"
               title="Julien Pauli DevPHP blog" type="rss"
               xmlUrl="http://blog.developpez.com/xmlsrv/rss2.php?blog=126" htmlUrl="http://blog.developpez.com/julienpauli/"/>
            <outline text="Zend Developer Zone"
               title="Zend Developer Zone" type="rss"
               xmlUrl="http://feeds.feedburner.com/ZendDeveloperZone" htmlUrl="http://devzone.zend.com/"/>
            <outline text="世界人のBlog" title="世界人のBlog" type="rss"
               xmlUrl="http://sekaijin.ovh.org/?feed=rss2" htmlUrl="http://sekaijin.ovh.org"/>
        </outline>
        <outline title="javaScript" text="javaScript">
            <outline text="Clever Marks" title="Clever Marks" type="rss"
               xmlUrl="http://feeds.clever-age.com/Clever-Age-Marks" htmlUrl="http://www.clever-age.com/veille/"/>
            <outline text="jQuery Blog" title="jQuery Blog" type="rss"
               xmlUrl="http://feeds.feedburner.com/jquery/" htmlUrl="http://blog.jquery.com"/>
        </outline>
        <outline title="Concerts" text="Concerts">
            <outline text="digitick.com : En Tournee"
               title="digitick.com : En Tournee" type="rss"
               xmlUrl="http://www.digitick.com/rss/flux/enTournee.xml" htmlUrl="http://www.digitick.com"/>
        </outline>
        <outline title="linux" text="linux">
            <outline text="Dotdeb" title="Dotdeb" type="rss"
               xmlUrl="http://www.dotdeb.org/feed/" htmlUrl="http://www.dotdeb.org"/>
            <outline text="GNOME Do Announcements"
               title="GNOME Do Announcements" type="rss"
               xmlUrl="http://feeds.launchpad.net/do/announcements.atom" htmlUrl="https://launchpad.net/do/+announcements"/>
            <outline text="Makina-Corpus.Org" title="Makina-Corpus.Org"
               type="rss" xmlUrl="http://www.makina-corpus.org/feed/" htmlUrl="http://www.makina-corpus.org"/>
            <outline text="Planet Ubuntu Francophone"
               title="Planet Ubuntu Francophone" type="rss"
               xmlUrl="http://planet.ubuntu-fr.org/feed/rss2" htmlUrl="http://planet.ubuntu-fr.org/"/>
            <outline text="Thomas.enix.org" title="Thomas.enix.org"
               type="rss" xmlUrl="http://thomas.enix.org/rss" htmlUrl="http://thomas.enix.org"/>
        </outline>
        <outline title="Java" text="Java">
            <outline text="Latest headlines from JavaWorld"
               title="Latest headlines from JavaWorld" type="rss"
               xmlUrl="http://www.javaworld.com/index.xml" htmlUrl="http://www.javaworld.com/"/>
            <outline text="Le blog de L'ami Sami"
               title="Le blog de L'ami Sami" type="rss"
               xmlUrl="http://www.dng-consulting.com/blogs/index.php?blog=1&amp;tempskin=_rss2" htmlUrl="http://www.dng-consulting.com/blogs/index.php?blog=1"/>
            <outline text="Valtech Blog" title="Valtech Blog" type="rss"
               xmlUrl="http://blog.valtech.fr/wordpress/feed/" htmlUrl="http://blog.valtech.fr/wordpress"/>
        </outline>
        <outline title="Symfony" text="Symfony">
            <outline text="Blog de Jérémy Barthe, développeur Web"
               title="Blog de Jérémy Barthe, développeur Web"
               type="rss"
               xmlUrl="http://feeds2.feedburner.com/jeremy-barthe" htmlUrl="http://jeremybarthe.com"/>
            <outline text="Clever Marks" title="Clever Marks" type="rss"
               xmlUrl="http://feeds.clever-age.com/Clever-Age-Marks" htmlUrl="http://www.clever-age.com/veille/"/>
            <outline text="Damien ALEXANDRE" title="Damien ALEXANDRE"
               type="rss"
               xmlUrl="http://blog.damienalexandre.fr/index.php?feed/rss2" htmlUrl="http://blog.damienalexandre.fr/index.php?"/>
            <outline text="Fabien Potencier" title="Fabien Potencier"
               type="rss"
               xmlUrl="http://feeds.fabien.potencier.org/aidedecamp" htmlUrl="http://fabien.potencier.org/"/>
            <outline text="Prendre un Café" title="Prendre un Café"
               type="rss"
               xmlUrl="http://feeds.feedburner.com/prendreuncafe" htmlUrl="http://prendreuncafe.com/blog/"/>
            <outline text="symfony Project Blog"
               title="symfony Project Blog" type="rss"
               xmlUrl="http://feeds.feedburner.com/symfony/blog" htmlUrl="http://www.symfony-project.org/blog/"/>
        </outline>
        <outline title="php" text="php">
            <outline text="BastNic's blog" title="BastNic's blog"
               type="rss" xmlUrl="http://feeds.feedburner.com/bastnic" htmlUrl="http://www.bastnic.info/index.php/"/>
            <outline text="Ben Ramsey" title="Ben Ramsey" type="rss"
               xmlUrl="http://benramsey.com/feed/" htmlUrl="http://benramsey.com/"/>
            <outline text="BigOrNot [fr]" title="BigOrNot [fr]"
               type="rss"
               xmlUrl="http://bigornot-fr.blogspot.com/feeds/posts/default?alt=rss" htmlUrl="http://bigornot-fr.blogspot.com/"/>
            <outline text="Clever Marks" title="Clever Marks" type="rss"
               xmlUrl="http://feeds.clever-age.com/Clever-Age-Marks" htmlUrl="http://www.clever-age.com/veille/"/>
            <outline text="Cyruss Blog" title="Cyruss Blog" type="rss"
               xmlUrl="http://cyruss.com/blog/rss.php" htmlUrl="http://cyruss.com/blog/index.php"/>
            <outline text="Damien ALEXANDRE" title="Damien ALEXANDRE"
               type="rss"
               xmlUrl="http://blog.damienalexandre.fr/index.php?feed/rss2" htmlUrl="http://blog.damienalexandre.fr/index.php?"/>
            <outline text="Fabien Potencier" title="Fabien Potencier"
               type="rss"
               xmlUrl="http://feeds.fabien.potencier.org/aidedecamp" htmlUrl="http://fabien.potencier.org/"/>
            <outline text="jansch.nl" title="jansch.nl" type="rss"
               xmlUrl="http://feeds.feedburner.com/ijansch" htmlUrl="http://www.jansch.nl"/>
            <outline text="Julien Pauli DevPHP blog"
               title="Julien Pauli DevPHP blog" type="rss"
               xmlUrl="http://blog.developpez.com/xmlsrv/rss2.php?blog=126" htmlUrl="http://blog.developpez.com/julienpauli/"/>
            <outline text="jy[B]log" title="jy[B]log" type="rss"
               xmlUrl="http://ljouanneau.com/dotclear/rss.php" htmlUrl="http://ljouanneau.com/blog/"/>
            <outline text="Karl Katzke" title="Karl Katzke" type="rss"
               xmlUrl="http://feeds.feedburner.com/KarlKatzke" htmlUrl="http://www.karlkatzke.com"/>
            <outline text="Not My Idea" title="Not My Idea" type="rss"
               xmlUrl="http://www.notmyidea.org/feed/" htmlUrl="http://www.notmyidea.org"/>
            <outline text="Pascal MARTIN (n+1).zéro"
               title="Pascal MARTIN (n+1).zéro" type="rss"
               xmlUrl="http://blog.pascal-martin.fr/feed/atom" htmlUrl="http://blog.pascal-martin.fr/"/>
            <outline text="PHP in Action" title="PHP in Action"
               type="rss"
               xmlUrl="http://www.reiersol.com/blog/rss.php?blogId=1&amp;profile=rss20" htmlUrl="http://blog.agilephp.com"/>
            <outline text="PHP::Impact ( [str blog] )"
               title="PHP::Impact ( [str blog] )" type="rss"
               xmlUrl="http://phpimpact.wordpress.com/feed/" htmlUrl="http://blog.fedecarg.com"/>
            <outline text="PHPPRO" title="PHPPRO" type="rss"
               xmlUrl="http://blog.phppro.fr/?feed/atom" htmlUrl="http://blog.phppro.fr/?"/>
            <outline text="Prendre un Café" title="Prendre un Café"
               type="rss"
               xmlUrl="http://feeds.feedburner.com/prendreuncafe" htmlUrl="http://prendreuncafe.com/blog/"/>
            <outline text="SitePoint Blogs » PHP"
               title="SitePoint Blogs » PHP" type="rss"
               xmlUrl="http://feeds.pheedo.com/sitepoint_blogs_category_php_feed" htmlUrl="http://www.sitepoint.com/blogs"/>
            <outline text="XHTML.net" title="XHTML.net" type="rss"
               xmlUrl="http://xhtml.net/rss.php" htmlUrl="http://xhtml.net/"/>
            <outline text="Zend Developer Zone"
               title="Zend Developer Zone" type="rss"
               xmlUrl="http://feeds.feedburner.com/ZendDeveloperZone" htmlUrl="http://devzone.zend.com/"/>
            <outline text="世界人のBlog" title="世界人のBlog" type="rss"
               xmlUrl="http://sekaijin.ovh.org/?feed=rss2" htmlUrl="http://sekaijin.ovh.org"/>
        </outline>
        <outline title="Python" text="Python">
            <outline
               text="Biologeek : Ubuntu, bio-informatique et geekeries libres d'un bio-informaticien au quotidien."
               title="Biologeek : Ubuntu, bio-informatique et geekeries libres d'un bio-informaticien au quotidien."
               type="rss"
               xmlUrl="http://www.biologeek.com/journal/rss.php" htmlUrl="http://www.biologeek.com/"/>
            <outline text="Makina Corpus" title="Makina Corpus"
               type="rss" xmlUrl="http://www.makina-corpus.com/rss.xml" htmlUrl="http://www.makina-corpus.com"/>
            <outline text="Makina-Corpus.Org" title="Makina-Corpus.Org"
               type="rss" xmlUrl="http://www.makina-corpus.org/feed/" htmlUrl="http://www.makina-corpus.org"/>
        </outline>
        <outline title="School" text="School">
            <outline text="SUPINFO Information Systems"
               title="SUPINFO Information Systems" type="rss"
               xmlUrl="http://sis.supinfo.com/feed/atom/" htmlUrl="http://sis.supinfo.com/"/>
        </outline>
        <outline title="Potes" text="Potes">
            <outline text="David Kulak" title="David Kulak" type="rss"
               xmlUrl="http://www.davidkulak.com/feed/" htmlUrl="http://www.davidkulak.com"/>
        </outline>
    </body>
</opml>

Using Scribe log server with PHP.

In a previous post, I was talking about howto install Scribe on a debian system.
Now, let’s talk about howto launch the server properly, and how to use it’s functionalities with PHP:

Starting Scribe

I’ve created the /usr/local/scribe/scribe.conf file, with this default content (it will configure scribe to listen port 1463 and write logs to /tmp/scribetest

port=1463
max_msg_per_second=2000000
check_interval=3

# DEFAULT
<store>
category=default
type=buffer

target_write_size=20480
max_write_interval=1
buffer_send_rate=2
retry_interval=30
retry_interval_range=10

<primary>
type=file
fs_type=std
file_path=/tmp/scribetest
base_filename=thisisoverwritten
max_size=1000000
add_newlines=1
</primary>

<secondary>
type=file
fs_type=std
file_path=/tmp
base_filename=thisisoverwritten
max_size=3000000
</secondary>
</store>

Now, start the server:

sudo scribed -c /usr/local/scribe/scribe.conf

Generate PHP classes

Goto your application path, then, create the thrift and scribe php classes:

/usr/local/bin/thrift -o . -I /usr/local/share/ --gen php /usr/local/share/fb303/if/fb303.thrift
/usr/local/bin/thrift -o . -I /usr/local/share/ --gen php /source/to/scribe/if/scribe.thrift
cp /source/to/thrift/lib/php/src includes -r
mkdir -p includes/packages/fb303
mkdir -p includes/packages/scribe
mv gen-php/FacebookService.php gen-php/fb303_types.php includes/packages/fb303/
mv gen-php/scribe_types.php includes/packages/scribe/
mv gen-php/scribe.php includes/
rm -rf gen-php

Use libraries

<?php
$GLOBALS['THRIFT_ROOT'] = './includes';

include_once $GLOBALS['THRIFT_ROOT'] . '/scribe.php';
include_once $GLOBALS['THRIFT_ROOT'] . '/transport/TSocket.php';
include_once $GLOBALS['THRIFT_ROOT'] . '/transport/TFramedTransport.php';
include_once $GLOBALS['THRIFT_ROOT'] . '/protocol/TBinaryProtocol.php';

$msg1['category'] = 'keyword';
$msg1['message'] = "This is some message for the category\n";
$msg2['category'] = 'keyword';
$msg2['message'] = "Some other message for the category\n";
$entry1 = new LogEntry($msg1);
$entry2 = new LogEntry($msg2);
$messages = array($entry1, $entry2);

$socket = new TSocket('localhost', 1463, true);
$transport = new TFramedTransport($socket);
$protocol = new TBinaryProtocol($transport, false, false);
$scribe_client = new scribeClient($protocol, $protocol);

$transport->open();
$scribe_client->Log($messages);
$transport->close();

Sources

Enjoy :)

Howto install « Scribe » (The Facebook log system) on Debian

Here is a simple HOWTO for installing Scribe Server

The quick way

You can install Scribe with all its dependencies by simply copy/paste this line on your terminal.

sudo apt-get install libboost-dev=1.38.1 flex bison libtool automake autoconf pkg-config && wget -O thrift.tgz "http://gitweb.thrift-rpc.org/?p=thrift.git;a=snapshot;h=HEAD;sf=tgz" && tar -xzf thrift.tgz && cd thrift &&./bootstrap.sh && ./configure && make && sudo make install && cd contrib/fb303/ && ./bootstrap.sh && sudo make && sudo make install && cd ../../../ && wget -O scribe.tgz "http://downloads.sourceforge.net/project/scribeserver/Scribe/Scribe%20version%202.01/scribe-version-2.01.tar.gz?use_mirror=freefr" && tar -xvzf scribe.tar.gz && cd scribe && ./bootstrap.sh && ./scribe/configure && sudo make && sudo make install && cd ..

The Detailled way

Resolve dependencies (including Thrift + fb303)

apt-get install libboost-dev=1.38.1 flex bison libtool automake autoconf pkg-config
wget -O thrift.tgz "http://gitweb.thrift-rpc.org/?p=thrift.git;a=snapshot;h=HEAD;sf=tgz"
tar -xzf thrift.tgz
cd thrift && ./bootstrap.sh && ./configure && make && sudo make install
cd contrib/fb303/
./bootstrap.sh && sudo make && sudo make install

Get Scribe code & compile it

wget -O scribe.tgz "http://downloads.sourceforge.net/project/scribeserver/Scribe/Scribe%20version%202.01/scribe-version-2.01.tar.gz?use_mirror=freefr"

Extract / Install

tar -xvzf scribe.tar.gz
cd scribe
./bootstrap.sh
./scribe/configure
sudo make && sudo make install

Hope it helps !

Select All text in VIM

To select All text in visual mode in VIM, try ggVG in normal mode

ggVG

from daily VIM

.NET related Feeds

Here is a list of interesting feeds about .Net (in OPML format):

It’ll be useful at least for Heaven :)

<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
    <head>
        <title>About .NET</title>
    </head>
    <body>
        <outline title=".Net" text=".Net">
            <outline text="Blog de Julien Dollon"
               title="Blog de Julien Dollon" type="rss"
               xmlUrl="http://blogs.dotnet-france.com/juliend/syndication.axd?format=rss" htmlUrl="http://blogs.dotnet-france.com/juliend/"/>
            <outline
               text="CodeBetter.Com - Stuff you need to Code Better!"
               title="CodeBetter.Com - Stuff you need to Code Better!"
               type="rss"
               xmlUrl="http://feeds2.feedburner.com/codebetter" htmlUrl="http://codebetter.com/blogs/"/>
            <outline text="CodeUtopia" title="CodeUtopia" type="rss"
               xmlUrl="http://codeutopia.net/blog/feed/" htmlUrl="http://codeutopia.net/blog"/>
            <outline text="DotNetGuru.org" title="DotNetGuru.org"
               type="rss"
               xmlUrl="http://www.dotnetguru.org/backend.php" htmlUrl="http://www.dotnetguru.org/"/>
            <outline text="Elegant Code" title="Elegant Code" type="rss"
               xmlUrl="http://feeds2.feedburner.com/ElegantCode" htmlUrl="http://elegantcode.com"/>
            <outline
               text="InfoQ Personalized Feed for Unregistered User - Register to upgrade!"
               title="InfoQ Personalized Feed for Unregistered User - Register to upgrade!"
               type="rss"
               xmlUrl="http://www.infoq.com/rss/rss.action?token=Nd6yHNyrOmvDlyRNG3qlT51jtA2IDoTG" htmlUrl="http://www.infoq.com"/>
            <outline text="Le blog de L'ami Sami"
               title="Le blog de L'ami Sami" type="rss"
               xmlUrl="http://www.dng-consulting.com/blogs/index.php?blog=1&amp;tempskin=_rss2" htmlUrl="http://www.dng-consulting.com/blogs/index.php?blog=1"/>
            <outline text="Radenko Zec Blog" title="Radenko Zec Blog"
               type="rss"
               xmlUrl="http://feeds2.feedburner.com/RadenkoZecBlog" htmlUrl="http://blog.developers.ba/"/>
            <outline text="Sebastien.warin.fr"
               title="Sebastien.warin.fr" type="rss"
               xmlUrl="http://feeds.feedburner.com/sebastienwarin" htmlUrl="http://sebastien.warin.fr"/>
            <outline text="Thomas Lebrun" title="Thomas Lebrun"
               type="rss"
               xmlUrl="http://blogs.developpeur.org/tom/rss.aspx" htmlUrl="http://blogs.developpeur.org/tom/default.aspx"/>
            <outline text="Valtech Blog" title="Valtech Blog" type="rss"
               xmlUrl="http://blog.valtech.fr/wordpress/feed/" htmlUrl="http://blog.valtech.fr/wordpress"/>
        </outline>
    </body>
</opml>