Ressources documentaires pour Mandriva Linux et les Logiciels Libres

Billets dans la catégorie Tips

Install Twitter Bootstrap under Mageia using Bower

twitter_bootstrapTwitter Bootstrap is an HTML, CSS, and JS framework for developing responsive, mobile first projects on the web. It was developped by twitter and being released as open source in 2010.

The best way to install Twitter Bootstrap and allow to manage update is to use a Bower manager :

  • Install Node.js : urpmi nodejs
  • Install git : urpmi git
  • Install bower : npm install -g bower
  • Move to your project directory : cd /var/www/myproject
  • Create a default config for bower to install your stuff under inc : vi .bowerrc

    [js]

    {
    "directory": "inc/",

    "analytics": false
    }

    [/js]

  • Install Twitter Bootstrap : bower install bootstrap
  • To check your package list and if updates are available you just have to do in your project directory : bower list
  • To update a package : bower update mypackage

And now you’re done 🙂

References :

Bower pour les nuls

Don’t hesitate to browse Bower packages list

Using Parse-Dia-SQL to generate SQL from UML Dia diagram and how to install it under Mageia

dia2sql_1It can be tedious when designing an application ( and not using frameworks like Symfony ) to design your database and then create corresponding SQL scripts. Thanks to Parse-Dia-SQL you can design your database using Dia and then generate corresponding SQL script for your database.

Ubuntu users just need to install libparse-dia-sql-perl package.

Windows may download Parse-Dia-SQL installer directly from Dia homepage : http://dia-installer.de/parse-dia-sql/index.html

Now let’s see how to install Parse-Dia-SQL under Mageia :

  • Install minimal set of dependencies. To found corresponding Mageia packages, use urpmf –provides –literal. For example to found Html::Lint, just do : urpmf --provides --literal 'perl(Html::Lint)'
  • Install corresponding minimal set of dependencies for http://search.cpan.org/dist/Parse-Dia-SQL/ : urpmi perl-base perl-Log-Log4perl perl-XML-DOM perl-HTML-Lint perl-Text-Table perl-Text-Aligner perl-Test-Exception
  • Install CPAN : urpmi perl-devel make
  • Now install Parse-Dia-SQL from CPAN : cpan /Parse-Dia-SQL/
  • parsediasql should be installed now in /usr/local/bin/
  • Now to create a SQL file from your Dia diagram, just do : parsediasql --file db_model_file.dia --db dbtype
    • Supported values for dbtype are : mysql-innodb, mysql-myisam, postgres ( for PostgreSQL ), db2, oracle, sqlite3, sqlite3fk, mssql and html

Now to create your UML model with Dia, use Dia’s UML shapes :

  • SQL table are UML Class
  • To mark an attribute as being a primary key, set Visibility = protected
  • To add NOT NULL and DEFAULT xxx to your attributes, first add the default value and then the NULL or NOT NULL  in Value field. For example to have DEFAULT CURRENT_TIMESTAMP NOT NULL on your SQL file, just add CURRENT_TIMESTAMP NOT NULL in Value field
  • Additional indexes can be create in [Operations] tab where :
    • Operation Name = Index name ( e.g table_col_idx )
    • Operation Type = Index type ( INDEX or UNIQUE INDEX )
    • Parameters =  Index columns ( one parameter name for each column name in the index )
    • Stereotype: Index type — For PostgreSQL, you can choose other than btree ( hash, gist, gin ). Please note that GIN indexes may be useful for JSON datatype
  • Foreign-keys constraint are done with UML aggregation tool ( line with a diamond at one end ) in which in its properties you are going to specify foreign-key direction and columns

Please note that for PostgreSQL no need to use typemaps for autoincrement columns, just put SERIAL as attribute type 🙂

Links:

Automatic SQL generation using Dia

Database design with Dia

Utilisation de Dia2SQL ( Fr )

Using Dia to Interact With tedia2sql ( Parse-Dia-SQL is a fork of tedia2sql to support latest Dia version, documentation for tedia2sql is relevant for Parse-Dia-SQL too )

Parse-Dia-SQL homepage

 

Select best Ubuntu mirror from CLI

Sometimes your Ubuntu mirrors may not be up-to-date or may be down. To check Ubuntu mirrors status, don’t hesitate to consult : https://launchpad.net/ubuntu/+archivemirrors.

Now here is a handy little script that allow to select a mirror with the lowest latency available : apt-select.

To install it :

  • If you are using Python 2 ( if not use python3-bs4 instead ) : sudo apt-get install python-bs4
  • Download code from github : wget --no-check-certificate https://github.com/jblakeman/apt-select/archive/master.tar.gz -O - | tar -zx
  • cd apt-select-master
  • Start script and select best mirror ( sources.list will be save in script dir ) : ./apt-select.py
  • Don’t hesitate to check sources.list content : view sources.list
  • Update system sources.list : ./update.sh
  • Update APT database : apt-get update

Enjoy !!! 🙂

PostgreSQL tips : quickly add a surrogate key column

Suppose that you want to add a surrogate key to a table in PostgreSQL to help you quickly identify each rows in a unique way. You can do this easily and quickly by just adding a SERIAL type column. When adding a SERIAL type column to an already filled table, PostgreSQL will automatically fill the column with some values.
To ensure your surrogate key uniqueness, don’t forget to add the UNIQUE constraint : on top of that this will create an index, thus speeding up your join queries on this column.

[sql light= »true »]ALTER TABLE mytable ADD COLUMN id SERIAL UNIQUE;[/sql]

PLUS »

Upgrading from Mandriva 2010.1 to Mandriva 2011 TP/Cooker

With the migration of Mandriva from rpm 4.6 to rpm 5.x, upgrading from a previous Mandriva release is not straightforward. So here are some tips to have a smooth upgrade :

  1. Install the perl-URPM 3.37 package available in main/testing repository ( 32 bits link, 64 bits link )
  2. remove all your current media : urpmi.removemedia -a
  3. add cooker media : urpmi.addmedia --distrib --mirrorlist 'http://api.mandriva.com/mirrors/basic.cooker.$ARCH.list'
  4. upgrade your Mandriva installation : urpmi --auto-update

If you have issues and error message like Unable to open /usr/lib/rpm/rpmrc for reading then it means that perl-URPM have not been updated and the rpm database conversion is not complete. Indeed part of the conversion of the rpm database is handled by perl-URPM, so if the new version is not installed, then your database end up not being completly converted. So to do this, you will have to download the latest perl-URPM version in cooker repository, extract its content with rpm2cpio, and then initiate the conversion :

  1. download the perl-URPM 4 and urpmi packages in cooker main/release repository in /tmp/rpm5
  2. as root, go the previous directory : cd /tmp/rpm5
  3. extract perl-URPM content with rpm2cpio in the current /tmp/rpm5 directory : rpm2cpio perl-URPM-4*.rpm | cpio -idmv
  4. extract urpmi package content with rpm2cpio in the current /rpm/rpm5 directory : rpm2cpio urpmi*.rpm | cpio -idmv
  5. in the /tmp/rpm5 initiate the rpm database conversion : perl -I. -Murpm -e 'URPM::DB::convert("/", "btree", 1, 1)'
  6. now install the urpmi and perl-URPM package : rpm -Uvh *.rpm
  7. You can finish to upgrade your system : urpmi --auto-update

Normally you system should be updated to the latest cooker release. Happy testing !!! 🙂

Music tagging made easy with MusicBrainz

I must admit that I have a big collection of music files. Tagging correctly theses files take a long time, and the queue of files waiting to be tagged is becoming quite big. Whereas this was optional before, I do appreciate now to have the album covert art as it can be displayed when listening to my music on my Androïd based phone ( Acer Liquid Metal ). So I decide to look for a solution allowing to automatically tag my musics files, and if possible automatically recognize the song, and also fetch the album covert art. I found the solution while reading the latest Amarok 2.4 release note. Amarok is a very good music player developed for the KDE desktop under Linux, but which can be used in others D.E and Operating System : please feel free to visit the Amarok download page 🙂

In the Amarok 2.4 release, they added music tagging using MusicBrainz. Whereas i had already heard about MusicBrainz, I had never really check what MusicBrainz was offering as features. So I decide to take a look at the MusicBrainz Wikipedia page … What can I say ? MusicBrainz is just awesome especially thanks to the acoustic fingerprinting feature ( PUID ) which allow to recognized a song from its acoustic fingerprint : no need to worry about tags or  filename, just feed it with the music file, and it will detect the song and filled the tags. MusicBrainz allows also to retrieve the album covert art. Last but not least, MusicBrainz service is free and people can contribute their data to increase and improve the database !

Ensure about the fact that Amarok was using the acoustic fingerprint feature, I decide to consult the MusicBrainz enabled applications page. There were many Linux applications listed like Amarok, Audacious, Banshee. However the most interesting one was MusicBrainz Picard : a python based application, supported by MusicBrainz, cross-platform ( Windows, Mac, Linux ), supporting acoustic fingerprint recognition and of course … free.

MusicBrainz Picard application screenshot

Installing MusicBrainz Picard under Linux Mandriva is very easy using urpmi : urpmi picard. To start the application, you just need to launch the picard binary, or use the entry menu in Sound & Video -> More -> MusicBrainz Picard. Here are some advices to a smooth experience :

  • Enable covert art retrieval support, by activating  the corresponding plugin in Options -> Options -> Plugins.
  • Enable automatic scan in Options -> Options -> Generals ->[ ] Automatically analyze new files.
  • Display by default the album covert art in the right lower part of the main window in View -> Covert art.

Now you just need to add a file or a directory, and Picard will scan. On the right pane, you will have the estimated album names ( Picard view is album oriented ). When clicking on the album name, you will see the list of songs for the albums, and your files will appeared with a green or orange rectangle at the front. Double-click on the song ( or right click -> Details ) to display its properties, the album covert art ( if found ). You have the possibility if you want to edit the metadata. To save the change, select the song or the album, and then do right click -> Save or CTRL+S.

Happy tagging !

PLUS »

Modifier l’utilisation du swap

Par d

Utiliser le dictionnaire avec OO 2.0 de cooker

Si vous

Catégories

My Tweets