Category Archives: Uncategorized

How to translate a drupal module

  1. Download and install the Translation Template Extractor (POTX).
  2. Use POTX to extract from the installed module a .pot template, that is, a file that includes the untranslated strings in english.
  3. Download and install POEdit, the most common string translator.
  4. Use POEdit to create, from the extracted .pot template, the French version of the strings, a file with the .po extension.
  5. Use the locale module to import the new .po file so that the module’s interface appears in french
  6. Create a translations within your the folder of your module, e.g. example/translations
  7. As a base for other translations, place the .pot file (example.pot) which you created in step 2. above within the translations folder. example/translations/example.pot
  8. Place the extracted .po from step 4. there as e.g. fr.po for a french translation, too. example/translations/fr.po

Clever way to manage drupal install files

Since you can only have an implementation of hook_install() per module, it becomes tedious to manage large quantities of code. So I thought of a scheme to manage the code and keep it structured.

So I am dividing the functionality in update functions (implementations of hook_update_N()) and make a call to those functions from the implementation of hook_install().

I also write “downgrade” functions which have the format
/* Implements hook_install(). */
function module_install() {
module_update_7001(); // enables the freetouch theme
module_update_7002(); // creates the article and page content types
module_update_7003(); // creates the free software content type
}

/**
* Implements hook_uninstall().
*/
function module_uninstall() {
module_downgrade_7001(); // restores the theme to bartik
module_downgrade_7002(); // removes the page and article content
module_downgrade_7003();
}

Developing on Drupal with minimal usage of the admin interface

I decided recently to start one Drupal project where changes to the structure of the website are specifically made code-wise. This means that all the content types and every setting will be made by writing code. The admin interface will only be used for adding content to the website. And I am going to document every aspect I learn about Drupal.
The project I am talking about is replace.software. I am going to rewrite the whole website and learn along the way new techniques of approaching Drupal.

Setting up Key-based SSH login in CentOS

For this tutorial I’ll be using the latest CentOS version, which is CenOS 6.4.

The first step is to generate a key if you don’t already have one. This can be achieved running:

ssh-keygen

and following the on-screen instructions.

If you already have a pair of keys, just append your public key in the

~/.ssh/authorized_keys

Now make the authorized keys readable only to the user:

chmod 600 ~/.ssh/authorized_keys

Now test your key-based login, and if it works then proceed to disabling password login.

Edit the sshd config file and change the following:

nano /etc/ssh/sshd_config

Protocol 2
PasswordAuthentication no
UsePAM no

Now save the config file and restart the sshd server to apply the new settings. service sshd restart Now enjoy key-based authentification

service sshd restart

My Linux workstation setup

I made this article to gather a list of the tools I use, and I strive to update it as often as possible. It’s main purpose is for me to have a quick reference over the tools and configurations I need to setup whenever I have to get a new system customized.

Since I was mostly around Gnome-based environments I use quite a few Gnome-based software.
Internet & Browsing:
Firefox
Chromium
Opera
Deluge
Office:
LibreOffice Pack usually I need just Writer, Impress and Calc
PDF Shuffeler
Artha
Multimedia: – VLC
Totem
Clementine
TV-Maxe
Studio:
OpenShot
Gnome Subtitles
Server Maintance:
Filezilla
RealVNC
Development: 
Eclipse IDE,
Eclipse + PDT,
gedit
MySQL Workbench
XAMPP
Meld
Chat & Communication:
Skype
Evolution
Graphics:
Gimp
Shutter
Shotwell
Management:
GcStart Collection Manager

Setup MySQL server on CentOS 6

I’m going to show you how to easily set up a MySQL server on your CentOS box.

First you need to install the required packages
yum install mysql mysql-server

Then start up your newly installed sql server
service mysqld start
Configure your server by running
mysql_secure_installation
Then follow:
Enter current password for root (enter for none): { Press Enter }
Set root password? [Y/n] { Press Y }
New password: { Type your password of choice }
Re-enter new password: { Your password again }
Remove anonymous users? [Y/n] { Press Y }
Disallow root login remotely? [Y/n] { Y is recommended, make other users for remote login}
Remove test database and access to it? [Y/n] { Y if you don’t need any test data }
Reload privilege tables now? [Y/n] { Y to clean up and applay the changes }

All done!  If you’ve completed all of the above steps, your MySQL
installation should now be secure.
Now your basic configuration is ready.

What to do after a fresh installation of Fedora

Ok, so you have successfully installed Fedora on your machine, now you might want to make it ready for your needs so you could use the following for inspiration. I am not going to debate ethical issues of installing / using non-free software so if you don’t agree with some of my recommendations just don’t apply them.

1. Install flash player

Unfortunately a great extent of out today web is still dependent on Flash, although Flash seems to die in the near future you might still need it.

So add the following repositories from adobe:

rpm -ivh http://linuxdownload.adobe.com/adobe-release/adobe-release-i386-1.0-1.noarch.rpm
rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY-adobe-linux

and for x64

rpm -ivh http://linuxdownload.adobe.com/adobe-release/adobe-release-x86_64-1.0-1.noarch.rpm
rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY-adobe-linux

Then install the flash player:

yum install flash-plugin nspluginwrapper alsa-plugins-pulseaudio libcurl

2. Enable mp3 support and install all the media codecs

Fedora does not come with out-of-the-box support for mp3 and other popular codecs due to licence issues. If you don’t want to use non-free codecs like gstreamer ugly plugins then you should use VLC to play every media format.
To install VLC:
yum install vlc

To enable codecs support system-wide:
Activate RPM Fusion repository:

yum localinstall --nogpgcheck http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm

Then install the ugly plugins:

yum install gstreamer-plugins-*

3. Install skype
If you are a regular skype user you might need it to keep in contact with your friends and family.
Unfortunately skype is 32-bit only application and if you run a 64-bit Fedora you need some 32-bit dependencies in order to run it:
Install the dependecies for 64-bit systems first:

sudo yum -y install libXv.i686 libXScrnSaver.i686 qt.i686 qt-x11.i686 pulseaudio-libs.i686 pulseaudio-libs-glib2.i686 alsa-plugins-pulseaudio.i686

Now you can proceed to skype’s download page and get the latest 32-bit package for Fedora .

4. Install dropbox

Fortunately dropox releases rpm packages for both 32-bit and 64-bit Fedora. All you have to do is head to their website and grab your rpm package

5. Install your favorite software
On my must-have software list is:
libreoffice-writer
libreoffice-calc
libreoffice-impress
clementine-player
chrominum-browser
gcstar

6. Update
Do a system update

7. Install 3rd party drivers
If you need to install 3rd party drivers you might want to google for some tutorials on how to do it for your specific driver

Reduce the DPI below 100% in Windows

This is a handy trick on how to reduce the DPI below 100% (below 96dpi). So all you’ll need is to adjust a registry value to match your needs.

Open regedit and browse to HKEY_CURRENT_CONFIG\Software\Fonts\LogPixels

Now change the Decimal value with anything under 96 (i think it should be over 70 though… I use 82). Log off to apply the changes and you’re done.

Why would you need the DPI below 100%?
Well reasons could be many, mine are:
– to be able to see the date next to the time while having a small taskbar
– to avoid scrolling horizontally
– to have more place on the screen