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

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.

Windows 7 fail

I’ve recently got access to MSDNAA. That’s MSDN Academic Alliance. This program for universities allows students to get Microsoft tools free of charge for personal use.

My dream was to have licensed version of Microsoft Windows. In post-soviet countries, it’s really that hard to use one. But with msdnaa my dream came true.

I’ve downloaded client application (<500kb). This one is downloading iso-image of the item, I’ve chosen on microsoft.com. Finally, it downloaded 2,3 Gb Windows 7 Professional Retail x86 iso-file.

Unfortunately, I had no free dvd-r at that moment, and my dvd-drive was in such a horrible state, that it could hardly read any dvd. I don’t even mention it’s ability to write smth :/ But lightscribe works as it should :)

So, I’ve downloaded Microsoft ISO2USB tool. This one allows users to burn their iso to usb-drive, and install OS from it. Unfortunately, it failed. That one needed some extra libraries, which I couldn’t find.
I found one third-party tool, which did that for me.

I’m rebooting my system… and there it is! Windows 7 installation!
Unfortunately, right after first screen, my setup failed :) It couldn’t find any drivers for my lapton, so with the message “Insert dvd/choose location of drivers” all my dreams fainted.
I’ve been trying lot’s of solutions. But nothing could help me.
The only outcome, I’ve faced was: several new partitions on hard-drive, no OS at all.

Right at that moment, I’ve found my Ubuntu 10.10 CD. That’s the only non-brain-damaging solution! It installed from the first time. No pop-alerts! Easy as abc! Even after logging into my braid new ubuntu installation, I wasn’t satisfied enough. I had a valid Win7 Pro key! I had no Win7 Pro. That’s ridiculous.

I thought, the only place in internet, where I can find valid iso-image of Win7 can be somewhere in torrents! I’ve logged into one of the most popular torrent sites out here and quickly found Genuine Win 7 Retail.

But there where no Pro. Only Ultimate revisions. Somewhere, I’ve read, that Ultimate installation has all the versions inside: from Starter to Ultimate, except Enterprise. And yes! You just have to remove or modify
/isoimage/sources/ei.cfg file! That definitely cool :)

I’ve downloaded win 7 ultimate, changed that ei.cfg with the one from the image, which I’ve got from msdnaa. Finally I’ve got working Windows 7 Professional installation image. The only problem was, that I installed Ubuntu, and got too accustomed to it. Moreover, my dvd-drive wasn’t working correctly :) I’ve downloaded Virtual Box and installed Windows 7 Pro inside it. It completed successfully and passed validation test with the key provided.

Currently, I’m working under ubuntu, and waiting for the moment, when I’ll suddenly kill my system with “rm -rf /” :) Then, I’ll try installing Win7 once more :)

Have a nice day ;)




Hosted by EOMY.NET