Monday, December 26, 2011

Qt/KDE based viewer of CHM files


Install viewer for the files with .chm extension:

$ su -c "yum install kchmviewer"

Project site: http://www.kchmviewer.net/

Wednesday, December 21, 2011

Questions from Oracle Java Olympic 2011 (in Russian)

В какой коллекции операция удаления первого элемента занимает наименьшее время?
  • ArrayList
  • LinkedList
  • Stack
  • Vector

Какой оператор используется для инвертирования значения переменной типа boolean?
  • !
  • ^^
  • NOT
  • <>
  • invert

Как уничтожить объект в Java?
  • вызвать Runtime.getRuntime().gc()
  • присвоить null всем ссылкам на объект
  • этого нельзя сделать вручную
  • вызвать метод finilize() у объекта
  • вызвать деструктор у объекта

Monday, November 21, 2011

gnome-shell extension: move Thunderbird indicator to the top panel

By analogy with moving Skype indicator to the top panel, I created extension, which allows to move Thunderbird indicator from system tray to the top panel:


0. Download archive from here.

1. $ tar -zxvf thunderbird_to_status_bar_v2.1.tar.gz

2. $ mv thunderbird.status@gnome-shell.rdiachenko.org ~/.local/share/gnome-shell/extensions

3. Type 'r' in Alt+F2 prompt to restart Gnome shell

4. Install gnome-tweak-tool:

$ su -c "yum install gnome-tweak-tool"

5. Press Alt+F2 and type in 'gnome-tweak-tool'

6. Choose 'Shell Extensions' and switch on 'Thunderbird Status Icon Extension':


7. Type 'r' in Alt+F2 prompt to restart Gnome shell

More useful extensions here: http://roman-ivanov.blogspot.com/2011/11/fedora-16-useful-extensions-for-gnome.html

gnome-shell extension: move Skype indicator to the top panel

Moving Skype indicator from system tray to the top panel:


0. $ cd ~/.local/share/gnome-shell/extensions

1. $ mkdir skype.status@gnome-shell.rdiachenko.org

2. $ cd skype.status@gnome-shell.rdiachenko.org

3. Create file 'metadata.json' with this content:

{
     "description": "Integrates Skype Client into the status bar",
  "name
": "Skype Status Icon", 
  "shell-version": [ "3.0.2", "3.2", "3.4" ],
  "uuid": "skype.status@gnome-shell.rdiachenko.org",
  "version": 2.0
}

Saturday, November 19, 2011

gnome-tweak-tool: customize fonts, themes, shell extensions, enable desktop and window's buttons (minimize, maximize)

gnome-tweak-tool is a nice simple tool for customizing fonts, themes, shell extensions...

To install it, enter the following command:

$ su -c "yum install gnome-tweak-tool"

To run it, press Alt+F2 and type in 'gnome-tweak-tool'. Simple selecting the options performs the changes. 

Some changes may require logging out and logging back in: type 'r' or 'restart' in Alt+F2 prompt to restart Gnome shell and see the changes.

Wednesday, November 16, 2011

I choose Deluge instead of Transmission

After my "Fedora 16: Installation notes (Part 2)" post I received this comment with several questions. In this post I'll try to answer on the last question: "What are the benefits to use Deluge over Transmission?".

In my first version of Fedora 10 Transmission didn't work properly, so I found a working application with a handy GUI. It was Deluge. As it was my first familiarity with linux, Deluge was an excellent decission.

What about its benefits over Transmission? In my point of view, Deluge has more convenient GUI than Transmission, and for the most users it is a key factor. Nevertheless, I made some search and found the following pros/cons:

Tuesday, November 15, 2011

Blogger: add Google +1 button, Facebook Like button and Tweet button for the whole blog

Add this gadget into the blog:


Script for adding Tweet Button:

<script src="//platform.twitter.com/widgets.js" type="text/javascript"></script>
<a href="https://twitter.com/share" class="twitter-share-button">Tweet</a>


For more information visit this site: https://dev.twitter.com/docs/tweet-button

Monday, November 14, 2011

org.eclipse.swt.SWTException: Invalid thread access

Recently, I've faced with SWTException error when was trying to insert a new TableItem into the SWT Table from another thread. Reading java doc about TableItem class I found out, that with creation a new instance of this class, SWTException may occurred:

Throws SWTException: if not called from the thread that created the parent

It means that I can't create a TableItem instance in the thread which is distinct from that one, in which Table was created.

I wrote a simple program to reproduce my problem: it's a window with one button and with a table which has a single column. When pressing the button a new thread is started. In this thread there's a cycle in which 5 table items are created with timed out = 1 sec.

Here's a code snippet, which represents a first attempt:

Saturday, November 12, 2011

Monitor configuration via xrandr

xrandr - primitive command line interface to RandR extension.

$ xrandr

Output:
=======================================================================
Screen 0: minimum 320 x 200, current 1280 x 1024, maximum 8192 x 8192
VGA-1 disconnected (normal left inverted right x axis y axis)
DVI-I-1 connected 1280x1024+0+0 (normal left inverted right x axis y axis) 376mm x 301mm
   1280x1024 60.0*+ 75.0
   1280x960 60.0
   1152x864 75.0
   1024x768 75.1 70.1 60.0
   832x624 74.6
   800x600 72.2 75.0 60.3 56.2
   640x480 72.8 75.0 66.7 60.0
   720x400 70.1
HDMI-1 disconnected (normal left inverted right x axis y axis)

=======================================================================

'+' - preferred mode;
'*' - current mode.

To change monitor resolution to 1280x1024 and refresh rate from 60 to 75 enter such command:

$ su -c "xrandr --output DVI-I-1 --mode 1280x1024 --rate 75"

xrandr wiki page: https://wiki.archlinux.org/index.php/Xrandr

Friday, November 11, 2011

Install Ant and Maven

Install Ant

Download ant from here: http://ant.apache.org/bindownload.cgi

$ tar -zxvf apache-ant-x.x.x-bin.tar.gz
$ su -c "mv apache-ant-x.x.x /opt/ant-x.x.x"


Open .bash_profile and add:

export ANT_HOME=/opt/ant-x.x.x
PATH=$PATH:$ANT_HOME/bin



Install Maven

Download maven from here: http://maven.apache.org/download.html

$ tar -zxvf apache-maven-x.x.x-bin.tar.gz
$ su -c "mv apache-maven-x.x.x /opt/maven-x.x.x"


Open .bash_profile and add:

export MAVEN_HOME=/opt/maven-x.x.x
PATH=$PATH:$MAVEN_HOME/bin


$ source ~/.bash_profile

Install Sun JDK6 on Fedora

Download Java JDK6 from here: http://www.oracle.com/technetwork/java/javase/downloads/index.html

Example: jdk-6u29-linux-i586-rpm.bin

1. $ chmod +x jdk-6u29-linux-i586-rpm.bin

2. $ su -c "sh jdk-6u29-linux-i586-rpm.bin"

3.1. $ su -c "alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_29/jre/bin/java 20000"

3.2. $ su -c "alternatives --install /usr/bin/javaws javaws /usr/java/jre1.6.0_29/bin/javaws 20000"

4. Check current java, javac versions:

$ java -version
$ javac -version


5. Now you can swap between OpenJDK and Sun/Oracle JDK versions

$ su -c "alternatives --config java"

6. $ nano ~/.bash_profile

Paste into this file the following strings:

export JAVA_HOME=/usr/java/jdk1.6.0_29
PATH=$PATH:$JAVA_HOME/bin


7. $ source ~/.bash_profile

Fedora 16/17: Installation notes (Part 3)

Enable 'Remove' function in Nautilus

By default you can't remove any file or folder by clicking 'Delete' button in Nautilus. To activate this function press Alt+F2 and enter 'dconf-editor'. In opened editor:

org > gnome > nautilus > preferences (enable_delete = true)


Now you can delete content from Nautilus pressing Ctrl+Delete.


Install Thunderbird

$ su -c "yum install thunderbird"


Install VirtualBox

0. $ su -

1. # cd /etc/yum.repos.d/

2. # wget http://download.virtualbox.org/virtualbox/rpm/fedora/virtualbox.repo

3. # yum update

4. yum install binutils gcc make patch libgomp glibc-headers glibc-devel kernel-headers kernel-devel dkms

5. # yum install VirtualBox-4.*

6. # usermod -a -G vboxusers your_user_name

Fedora 16/17: Installation notes (Part 2)

Install rpmFusion repository

$ su -
# 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

# nano /etc/yum.repos.d/rpmfusion-nonfree.repo

gpgcheck=0


Install GParted (good application for formating and partition)

$ su -c "yum install gparted gpart"


Install djviewer

$ su -c "yum install djview4"

Fedora 16/17: Installation notes (Part 1)

Install Chrome last stable version

$ sudo nano /etc/yum.repos.d/google.repo

[google-chrome]
name=google-chrome - 64-bit
baseurl=http://dl.google.com/linux/chrome/rpm/stable/x86_64
enabled=1
gpgcheck=1
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub

$ sudo yum install google-chrome-stable


Adding "Open Terminal" to Gnome Context Menu

$ su -c "yum install nautilus-open-terminal"

Fedora 16: BIOS Boot Partition problem

The problem that I encountered during Fedora 16 installation was that after rebooting, my computer was hovered on the state of initializing the hardware. I even couldn't enter the BIOS. I turned off the computer and disconnected  the hard disk on which new Fedora had been installed.

Now I was able to manipulate the BIOS settings. I set my flash with Fedora 16 as a first bootable device and started up the installation process again. I connected my hard disk and tried to re-install the system again. When I was creating new partitions I noticed the new one I had never seen before in previous versions of Fedora. It was BIOS Boot Partition.


Then I found out that my problem was that I hadn't created this partition which was required only 2 Mb of physical memory! I allocated the required memory for it and after installation, Fedora was successfully loaded.

Wednesday, November 2, 2011

Graph's visualization in Linux

A few days ago my friend show me a very simple and convenient program to visualize graphs - "graphviz". It's free and can be used in Linux, Solaris, Windows and Mac. For drawing graphs "graphviz" uses DOT language.

Let's create a simple graph. Open text editor and paste this code:

digraph SimpleGraph {
    rankdir=LR;
    node [shape=circle];
    ranksep=0.5;
    node [style=dashed];
    0 -> 1 [label="A"];
    node [style=solid];
    0 -> 2 [label="B"];
    1 -> 3 [label="C"];
    2 -> 1 [label="D", style=dotted];
    2 -> 3 [label="E", style=dotted];
    2 -> 4 [label="F"];
    3 -> 5 [label="G"];
    4 -> 5 [label="H"];
}

Wednesday, October 26, 2011

Log4j: NDC/MDC

Nested Diagnostic Context (NDC) and Mapped Diagnostic Context (MDC) are used in cases when we want to distinguish logs from multiple threads by marking each log with thread specific information. NDC and MDC provide possibility to store some contextual information for each thread. But there's a difference in the way they do it.

Each thread has it's own context. NDC uses stack for pushing information when entering thread's context and popping it when leaving that context. This information is attached to log and can be displayed by using '%x' Pattern Layout option.

MDC uses map to store context information. It means that there must be a unique key associated with each piece of thread information. The information is attached to log and can be displayed by using '%X{key}' Pattern Layout option, where the key is an association with a value in the map.

Here you can find Log4j Pattern Layout option's description: http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PatternLayout.html

Saturday, October 15, 2011

Friend's blog

You can also visit my friend's tech blogs and find some interesting information for you.

Roman Ivanov - http://roman-ivanov.blogspot.com/
Daniil Lopatin - http://daniil-lopatin.blogspot.com/

Tuesday, October 11, 2011

How to use SLF4J with Log4j


Today I will show you how to use SLF4J with Log4j on a simple example.

Let's start with Log4j. First, download log4j library and add log4j-1.2.16.jar into classpath.

Create log4j.properties file, which will contain log4j configuration and put it into project. It may look like this:

log4j.rootLogger=DEBUG, A1
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=[%c{1}][%p]: %m%n

Monday, October 10, 2011

Why I choose Linux...

There are a lot of debates about Windows and Linux. What is the best OS? Which one to use?...I won't answer these questions, because every person should make decisions on his own. I'll only share my experience in using both of these systems.

Two years ago I even couldn't imagine my life without Windows. At that time I, probably, knew nothing about Linux, except the word :) It was usually for me to re-install my system after a regular virus or this 'magic' blue screen...