Saturday, 21 April 2012

Rpm Package Management Quick Reference


An updated version of this article at: RPM Package Management Quick Reference

RPM tool


rpm tool deals with rpm packages directly, but cannot deal with packages placed in a repository. Zypper, Yum,... tools deal with repositories.


$rpm -q package_name #e.g rpm -q subversion Query if a package is installed.

$rpm -qf "*/bash" #find which package owns that file.

#rpm -e package_name #deletes a package.

$rpm -qi package_name # shows info about a package.

$rpm -ql package_name # list files contained in package_name


#rpm -i package.rpm # installs a rpm file package.

#rpm -i --force package.rpm # forces package.rpm installation.

#rpm -qpl foo.rpm # shows the files in foo.rpm file package.

$rpm -q --scripts foo # shows installation and uninstallation scripts for foo package.

$rpm -qR foo # shows which dependencies foo package requires.



ZYPPER (OpenSuse 10.3 and up)


#zypper install foo # installs foo package from repository.

#zypper remove foo # removes a package. e.g: zypper remove python-twisted-conch

$zypper info python-twisted-conch # shows package info

$zypper search python # searchs for packages matching python.

#zipper ref && zipper dup # refresh repositories and then update the system.


YUM (Fedora, etc)

How to set EMACS C STYLE to hack KAMAILIO code

Kamailio (former OpenSER) is a SIP proxy server, call router, and user agent registration server used in Voice over Internet Protocol and instant messaging applications. Kamailio is free software (GPL licensed).

In this post we are going to learn how to configure emacs to follow kamailio coding style guidelines.


KAMAILIO CODING STYLE GUIDELINES


From Kamailio documentation: http://sip-router.org/wiki/coding_style

As a resume:
  • Use tabs for indentation instead of spaces.
  • Set tab stops to 4 spaces.
  • Wrap lines that are longer than 78 characters (80 characters - two characters for window decorations).
  • Avoid C++ style comments (//)
  • Do not declare variables inside blocks.
  • Use the following style for function declarations
  • int func(int x)
    {
        /* body */
    }
    


EMACS C KAMAILIO CODING STYLE


We are going to create an emacs C coding style in order to comply with most of those rules.

Saturday, 14 April 2012

How to translate your web page using Google Translate tool


Google provides several useful tools to translate your web page. Then you can offer your page contents in more than sixty languages!

Our goal is to provide a drop down list where user will select target language and then the page will "automagically" translate into the desired language.

Translated page will appear in the same top window frame so not to distort your web page design layout.

Drop down list will show or hide depending on user browser default language.



USING GOOGLE TRANSLATE TOOL

Procedure to translate a web page is simple:

We will request a web page to Google Translate server, and it will return our web page already translated!


Request will have following structure:

http://www.google.com/translate_c?langpair=LANG1|LANG2&u=URL

where:
LANG1 is set to original language
LANG2 is set to target language
URL is the url we want to translate.


This is the same way as going to http://translate.google.com/?hl=en web page, and pasting there our URL web page.

NOTE: Google also offers to us this other tool: http://translate.google.com/translate_tools?hl=en but it introduces some problems maintaining the original formatting of the web page.



SELECTOR WITH LANGUAGE OPTIONS