jmelly

Aller au contenu | Aller au menu | Aller à la recherche

mercredi 6 janvier 2010

Default values for hibernate3 on NOT NULL column

In a data driven environment, to avoid duplicating "DEFAULT" annotation in column entity which have DEFAULT values defined in SGBD, hibernate has this annotation:

@org.hibernate.annotations.Entity ( dynamicInsert = true, dynamicUpdate = true )

This will ensure that no explicit null insert/update will be generated thus violate the NOT NULL constraint.

mercredi 7 janvier 2009

Logitech MX310 Linux X11 (xorg) configuration

For those who want to configure mouse wheel + back/forward buttons (I've been looking around the solution for 3 years...):

Section "InputDevice"
        Identifier      "Configured Mouse"
        Driver          "mouse"
        Option          "CorePointer"
        Option          "Device"      "/dev/input/mice"
        Option          "Protocol"    "ExplorerPS/2"
        Option          "ZAxisMapping"        "6 7"
        Option          "ButtonMapping"        "1 2 3 4 5"
        Option          "Emulate3Buttons"     "false"
EndSection

mardi 16 décembre 2008

Rkhunter hidden processes warning

Copy pasted from http://ubuntuforums.org/archive/index.php/t-796192.html for personal archive

If the processes are truly hidden, then yes it's probably something you should worry about. But it's possible that you've got a false positive situation.

When rkhunter tells you that there are hidden processes, try to cd to the /proc/<pid> directory for the process (where <pid> is one of the process ID numbers output by rkhunter). If you can't cd into the directory, then the process isn't really hidden, it was just in the middle of exiting when the rkhunter check ran and rkhunter was confused and you probably have nothing to worry about.

If you do manage to cd into the /proc/<pid> directory, then it's likely you have a problem. Interesting things to do once you're in the /proc/<pid> directory include:

1) "cat cmdline" should give you the name the process is running under

2) "sudo cat environ | perl -pe 's/\000/\n/g'" gets you the environment variable settings for the process

3) "sudo ls -l fd" shows you what files the process currently has open

4) "sudo ls -l cwd" shows you the current working directory of the process (which could be interesting if the process was started by the attacker from their rootkit installation directory)

There's plenty of other cool stuff you can do with the various bits of information under /proc, but the above should be enough to help you figure out what the process(es) are doing and how much trouble you're in.

jeudi 13 novembre 2008

Symfony 1.1 : i18n with MySQL

As having searched for a while to find the right solution, here are the steps to enable i18n over MySQL with Symfony 1.1

Configuration (factories.xml)

Edit or create "factories.xml" in global config directory or any app directory as following (replace with your db)

all:
  i18n:
    class: sfI18N
    param:
      source: MySQL
      
prod:
  i18n:
    param:
      database: "mysql://user:pass@host/db"
      debug: off
    cache:
        class: sfFileCache
        param:
          automatic_cleaning_factor: 0
          cache_dir:                 %SF_I18N_CACHE_DIR%
          lifetime:                  86400
          prefix:                    %SF_APP_DIR%

dev:    
  i18n:
    class: sfI18N
    param:
      database: "mysql://user:pass@host/db"
      debug: on
      untranslated_prefix: "[T]"
      untranslated_suffix: "[/T]"
    cache:
        class: sfNoCache

This will activate i18n with MySQL. But the the database tables must be added

DB schema (translation_schema.xml)

This content can be found in "\lib\symfony\i18n\sfMessageSource_MySQL.class.php" :

<?xml version="1.0" encoding="UTF-8"?>
<database name="propel" package="lib.model" defaultIdMethod="native">
        <table name="catalogue">
                <column name="cat_id" type="integer" required="true"
                        primaryKey="true" autoincrement="true" />
                <column name="name" type="varchar" size="100" />
                <column name="source_lang" type="varchar" size="100" />
                <column name="target_lang" type="varchar" size="100" />
                <column name="date_created" type="timestamp" />
                <column name="date_modified" type="timestamp" />
                <column name="author" type="varchar" size="255" />
        </table>
        <table name="trans_unit">
                <column name="msg_id" type="integer" required="true"
                        primaryKey="true" autoincrement="true" />
                <column name="cat_id" type="integer" />
                <foreign-key foreignTable="catalogue" onDelete="cascade">
                        <reference local="cat_id" foreign="cat_id" />
                </foreign-key>
                <column name="id" type="varchar" size="255" />
                <column name="source" type="longvarchar" />
                <column name="target" type="longvarchar" />
                <column name="comments" type="longvarchar" />
                <column name="date_created" type="timestamp" />
                <column name="date_modified" type="timestamp" />
                <column name="author" type="varchar" size="255" />
                <column name="translated" type="integer" />
        </table>
</database>

You can add this content to your "schema.xml" or create a new one (what I've done). Anyway there is no yaml version so if you only have a schema.yml either you'll have to translate the xml other you can create a new file named *****schema.xml with the content shown above.

To take the new schema in account you'll have to execute :

  • php symfony propel:build-sql
  • php symfony propel:insert-sql (warning this will erase all data)
  • php symfony propel:build-model
  • php symfony cc

Base data

The "catalogue" table must be filled with the languages you want to translate: Catalogue table content

Then you'll be able to add translation units in trans_unit table: Translate content

That's all folks

After understanding this, it is not complicated but as there are various outdated information on the net, it's hard to get the right solution. I've also discovered that only "name" column of "catalogue" table is relevant to find the translation (and "source" column of "trans_unit" table). The "source_lang" and "target_lang" is not used as shown in the sfMessageSource_MySQL.class php file:

public function &loadData($variant)
  {
    $variant = mysql_real_escape_string($variant, $this->db);

    $statement =
      "SELECT t.id, t.source, t.target, t.comments
        FROM trans_unit t, catalogue c
        WHERE c.cat_id =  t.cat_id
          AND c.name = '{$variant}'
        ORDER BY id ASC";

I hope anybody could find this information useful...

mercredi 29 octobre 2008

Le pourquoi du comment

Ce blog a pour but de diffuser diverses informations le plus souvent orientées sur le développement d'application en informatique...

Bonne visite