Tuesday, November 23, 2010

CKEditor: Plugin And Toolbar Button For PRE, CODE, H1, H2, H3, H4, H5, H6, DIV, P Style Formatting

Hi all.

This small howto help you to create a plugin for CKEditor 3.4 and add a new toolbar button for p, h1, h2, h3, h4, h5, h6, pre, address and div style formatting.

1. Directory structure:
ckeditor/
    config.js
    plugins/
        button-pre/
            button-pre.png
            plugin.js

2. Create plugin.js:
(function(){
 var a= {
  exec:function(editor){
   var format = {
    element : "pre"
   };
   var style = new CKEDITOR.style(format);
   style.apply(editor.document);
  }
 },

 b="button-pre";
 CKEDITOR.plugins.add(b,{
  init:function(editor){
   editor.addCommand(b,a);
   editor.ui.addButton("button-pre",{
    label:"Button PRE",
    icon: this.path + "button-pre.png",
    command:b
   });
  }
 });
})();

3. Download a button-pre.png: CKEditor PRE plugin button.

4. Register the plugin and add a toolbar button. Modify config.js:
CKEDITOR.editorConfig = function( config )
{
 CKEDITOR.config.toolbar_Basic = [['button-pre', 'Bold', 'Italic', 'Underline' ]];
 config.toolbar = 'Basic';
 config.startupOutlineBlocks = true;
 config.extraPlugins = "button-pre";
};

Result:
CKEditor PRE plugin button sample

P.S. You can change pre with code, h1, h2, h3, h4, h5, h6, address, div and p tags.
P.P.S. This plugin also work with the code tag pretty good.

Tuesday, August 31, 2010

Project pkgs.org

Hello, friends!

Let me introduce my new Linux Packages Search project.

The project provides next features:
  1. Large, daily updated database with RPM and DEB packages for well-known repositories of the Fedora, CentOS, RHEL, Debian, Ubuntu, Mandriva and openSUSE distributions.
  2. Packages browser by distribution, repository, packages group with the filtering support.
  3. Detailed packages information (name, version, description, architecture, files, requires, etc.).
  4. HTTP/FTP/RSYNC mirrors lists for the packages downloading.
  5. Packages search by name, summary, description, requires, provides, files and directories.
  6. Effective site navigation.
  7. XHTML/CSS markup.
  8. RSS.

Project site: http://pkgs.org/

Saturday, May 15, 2010

Upgrading PostgreSQL 8.1 to 8.4 on CentOS 5.5

PostgreSQL 8.4 (postgresql84) is now included as a fully supported option in Red Hat Enterprise Linux 5.5/CentOS 5.5.

New features in PostgreSQL 8.4 include: parallel database restore, per-column permissions and new monitoring tools.

A data dump and restore using pg_dump is required for migration from the existing PostgreSQL 8.1 (supplied by the postgres package). Due to this requirement, postgres and postgresql84 contain package level conflicts and only a single version can be installed on a system.

To upgrade PostgreSQL, follow these steps:
  1. Create a backups directory:
    # mkdir /pgbak
    # chown postgres:postgres /pgbak/
    
  2. Dump only global database objects (roles and tablespaces), no databases:
    # su - postgres
    # pg_dumpall --globals-only > /pgbak/globals.sql 
    # pg_dump --create --oids --format=c --verbose --file=/pgbak/dbX dbX
    # exit
    
  3. Stop the database server:
    # /etc/init.d/postgresql stop
    
  4. Create full backup of database cluster (is not used in upgrading process):
    # mv /var/lib/pgsql/data /pgbak
    
  5. Upgrade PostgreSQL 8.1.6 to 8.4.2:
    # yum remove postgresql*
    # yum install postgresql84-server
    
  6. Initialize new database cluster:
    # /etc/init.d/postgresql initdb
    
  7. Restore configuration files modifications on /var/lib/pgsql/data/*.conf
  8. Start the PostgreSQL service:
    # chkconfig --level 35 postgresql on
    # /etc/init.d/postgresql start
    
  9. Restore global database objects (roles and tablespaces) and databases:
    # su - postgres
    psql -f /pgbak/globals.sql
    pg_restore --create -d postgres /pgbak/dbX
    # exit
    

Wednesday, May 5, 2010

ASUS P5Q Sensors Configuration on CentOS 5

1. Install ELRepo repository.
2. Update lm_sensors:
# yum update lm_sensors
3. Install coretemp kernel module:
# yum install kmod-coretemp
4. Detect available sensors:
# sensors-detect
5. Start lm_sensors service:
# /etc/init.d/lm_sensors start
6. Get sensors information:
# sensors
coretemp-isa-0000
Adapter: ISA adapter
Core 0:   +37°C (high = +100°C)

coretemp-isa-0001
Adapter: ISA adapter
Core 1:   +33°C (high = +100°C)

coretemp-isa-0002
Adapter: ISA adapter
Core 2:   +37°C (high = +100°C)

coretemp-isa-0003
Adapter: ISA adapter
Core 3:   +39°C (high = +100°C)

Hard Drive Temperature Monitoring on CentOS 5

To get a hard drive temperature, follow these steps:
  1. Install EPEL repository.
  2. Install the hddtemp package:
    # yum install hddtemp
    
  3. Execute hddtemp:
    # hddtemp /dev/sda
    /dev/sda: ST3750640AS: 46°C
    

Also you can get a hard drive temperature from hdd SMART table:
  1. Install the smartmontools package:
    # yum install smartmontools
    
  2. Execute smartctl:
    # smartctl -d ata -A /dev/sda
    ...
    ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
    194 Temperature_Celsius     0x0022   045   049   000    Old_age   Always       -       45 (0 17 0 0)
    

Tuesday, May 4, 2010

nVidia Drivers Installation on CentOS 5

To install nVidia drivers, follow these steps:
  1. Install ELRepo repository.
  2. Install the nVidia drivers:
    # yum install nvidia-x11-drv
    
  3. Change current video driver to nVidia. Edit /etc/X11/xorg.conf:
    Section "Device"
            Identifier  "Card0"
            Driver      "nvidia"
            VendorName  "nVidia Corporation"
            BoardName   "GeForce 8800 GT"
    EndSection
    
  4. Reboot the operation system:
    # reboot
    

Keyboard Localization on CentOS 5

If you would like to switch between more than one keyboard layout (for example English and Russian), edit /etc/X11/xorg.conf and restart X server.

Example:
Section "InputDevice"
        Identifier  "Keyboard0"
        Driver      "kbd"
        Option      "XkbModel" "pc105"
        Option      "XkbLayout" "us,ru"
        Option      "XkbVariant" ",winkeys"
        Option      "XkbOptions" "grp:shifts_toggle,grp_led:scroll"
EndSection

Here, XkbOptions allows you to toggle between keyboard layouts by simply pressing both Shifts. This will also toggle the Scroll Lock light on or off, thanks to the grp_led:scroll option. This is a handy visual indicator of which keyboard layout you are using at the moment.