Archive for the 'it' Category

Shutdown, Reboot, Suspend or Hibernate with user priviliges via D-Bus

Some distros don’t allow you to
shutdown -r now
from terminal without superuser password.
Shutdown/Reboot/Suspend/Hibernate with user priviliges in Linux is possible via D-Bus. You just need consolekit and upower packages installed.

Here are the commands:

Operation D-Bus command
Suspend dbus-send --print-reply --system --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Suspend
Hibernate dbus-send --print-reply --system --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Hibernate
Reboot dbus-send --system --print-reply --dest=org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart
Shutdown dbus-send --system --print-reply --dest=org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop

Just paste them in your beloved terminal emulator and press enter :)

BlackBerry hidden key combinations

I’ll collect all the hidden key combinations in BlackBerry in this post.
Sort of wiki-page.

Combination Where Purpose
ALT+LGLG Ribbon (screen with apps) Open BlackBerry Event Log
SHIFT+BUYR Options>Status Show data/voice usage
?123+M,M, Ribbon (screen with apps) Open BlackBerry Event Log on touchscreen devices

Флеш

Дуже порадували коменти в неті до цієї новини про флеш
http://liza-bam.livejournal.com/1231845.html

I received my OCPJP certificate

Oracle Certified Professional, JAVA SE 6 Programmer

OCJP Certificate

I successfully passed Oracle Certified Professional Java Programmer Exam (formerly SCJP) a month ago. That was my birthday present. I passed right one day before my 20-th BD.

For everyone, who is willing to pass it I’d recommend just 2 things:

  1. ExamLab for SCJP 6.0 – the best mockup tests for this exam! Free, cool and deep explanations, lot’s of tests. If you can score ~60-70% in this app, you would possibly pass OCJP with a high score (~80-90%).
  2. SCJP Sun Certified Programmer for Java 6 – the so-called K&S book (Katherine Sierra and Bert Bates). If you read all the book, you’ll definitely increse your java knowledge. The best book. 100% coverage.

Have fun!

Crappy legal java code

JavaThat was hard evening.

After reading some java books, right before I went to sleep, some java code came to my mind…


class ${public void _($ $4){}}
class $<_, $, $_> {$ _;<_> $($ _){}<$> $($ _,$ $_){_=$_;}}

And that’s not the upper bound. You can enchant it the way you want, creating crazy valid useless (or even useful?) POJOs :D

wait() and notify()

Thread Synchronization

Excerpt from old “Exploring Java” book.
It clearly states, what wait(), notify(), notifyAll() are used for and what they do.

With the synchronized keyword, we can serialize the execution of complete methods and blocks of code. The wait() and notify() methods of the Object class extend this capability. Every object in Java is a subclass of Object, so every object inherits these methods. By using wait() and notify(), a thread can give up its hold on a lock at an arbitrary point, and then wait for another thread to give it back before continuing. All of the coordinated activity still happens inside of synchronized blocks, and still only one thread is executing at a given time.
Continue reading ‘wait() and notify()’

Rutorrent + rTorrent on Debian Server

ruTorrent logoOnce, I’ve installed it myself.
Yes, in the way, everyone did this: checkout, compile with xml-rpc support, install web-server, bind everything together and enable some security.
It worked great, but after some updates, it broke up. Don’t know what happened exactly, I was a bit busy at that time.

Several weeks ago, I desperately needed torrent client, but in that environment, no applications could be installed. It was a great disappointment to find out, that me own rTorrent is down on the server. So I tried to perform mentioned actions again, but with no luck.

Right at that moment, I found out about an AWESOME!!! script, which does everything you need! It just installs

  • rTorrent
  • ruTorrent
  • your favourite web-server
  • FTP
  • Webmin

It binds everything together, and it just works!

Here’s the MAGIC link to the documentation:
http://forums.rutorrent.org/index.php?topic=608.msg4427
Everything is pretty strait-forward and troubleless.

Hint: run the downloaded script inside screen session. Script, itself, runs several minutes. It configures and compiles everything. So, please, be patient. If you have poor ssh access, it would be much better to reattach to the running screen process, after connection failure or something.

The only thing, I had to modify afterwards, was a web-server’s port, ’cause my ISP blocks port #80.
As I’ve chosen lighttpd, as my webser, I had to modify lighttpd config file
nano /usr/share/lighttpd/lighttpd.conf
and set
server.port = 1234

Enable Nimbus Look-And-Feel

Always forget how to enable it.
So put it in my blog to reference that quickly.

        try {
            for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (UnsupportedLookAndFeelException e) {
        } catch (ClassNotFoundException e) {
        } catch (InstantiationException e) {
        } catch (IllegalAccessException e) {
        }

Nimbus is really a nice and must-use vector look-and-feel.
Just compare it to the old metal:

Here you can get more information about Nimbus Look-And-Feel
http://download.oracle.com/javase/6/docs/technotes/guides/jweb/otherFeatures/nimbus_laf.html

ALT+SHIFT

Recently I took part in an online Battle of the Brands http://thebattleofbrands.com/en

Both of the contestants are familiar to me since my childhood.

To cut the long story short, let me introduce this 2 awesome key combinations:

  • [ALT]+[SHIFT]
  • [CTRL]+[SHIFT]
As you probably guessed both of them are used to switch keyboard layout in PCs.
The heading of the topic yells my choice: [ALT]+[SHIFT]

I’ve been using CTRL+SHIFT barely for 7 years. Since I was introduced to the PC. I can recall in my memory, that second or third lesson during computer courses back in 2001 was how to set up your Windows 98 to use it smoothly. The first issue to fix in the standard Win98 installation was to change ALT+SHIFT into CTRL+SHIFT. I still can’t get it why it was done? CTRL+SHIFT was used everywhere. I can hardly find any reason for this choice nowadays.
Possibly, that’s because people use mouse a lot. This sound a bit unclear, but I’ll make a point.
What do people use to select seldom words in Word/Notepad? Yeap, a mouse! But there’s a better choice: CTRL+SHIFT+(left/right arrows). You don’t have to move your mouse around and precisely click it twice over the word. Moreover, what should you do to select 2 words in a row? double click is a waste of time here. It selects only one word per time.
How do people navigate through all the tabbed interfaces – browsers, preference windows? Again, with a mouse! Mouse is not a choice if you need to get the office job done quickly. Keyboard is much quicker. The main key combination to navigate through tabs is CTRL+TAB (forth ->) and CTRL+SHIFT+TAB (back <-). The second one intersects with our keyboard layout combination. So it was unfairly forgotten. This OS feature often is not used at all! Since I discovered it I forgot about mouse while browsing through tabs. It greatly sped up my navigating.
The crux of the matter is that barely nobody wants to use their keyboard efficiently. They dream of it, but do nothing to improve their keyboard skills. Keyboard has much to offer! So go and get over it!

 

Understanding BlackBerry EventLog

Recently, I’ve been digging deeply into BlackBerry EventLogs.

Every row in EventLog consists of several parts.

The first element is error-level (a,d,E,..) of this log entry.

The next one is application’s name (e.g. net.rim.udp, System…)

And finally here comes the message.I was interested in this tiny letters shown at the begining of every log event:

#BlackBerry Event Log (cpt)
#PVer: 5.1.0.177
#AVer: 5.0.0.938
a net.rim.ippp - RXCd 11 - 9/23 22:31:29
a net.rim.ippp - RXCd 32 - 9/23 22:30:27
W net.rim.ippp - RXnp - 9/23 22:30:15a net.rim.ippp - RXCd 11 - 9/23 22:30:15
d net.rim.ippp - TXSt 0 - 9/23 22:30:15
a net.rim.ippp - TXca - 9/23 22:30:15


Maybe, this knowledge will be usefull for someone.

Letter API name Description
a ALWAYS_LOG Always log event, regardless of severity.
d DEBUG_INFO Debug information level event.
E ERROR Error level event.
I INFORMATION Information level event.
S SEVERE_ERROR Severe level event.
W WARNING Warning level event.



Hosted by EOMY.NET