Category Archives: Software

Everything about software

Install Oracle JVM in Arch Linux

Unfortunately OpenJDK gives me headaches (eclipse crash in PDT and java applets not starting) in everyday work and I had to switch to OracleJDK (at least for now).

OpenJDK is a dependency on multiple Arch Linux packages so just installing Oracle’s JDK wasn’t enough.

First had to remove icedtea-web

sudo pacman -R icedtea-web

Then build Oracle JRE AUR package,

Before installing OracleJRE I had to remove openjdk6 manually and ignore dependencies:

[argy@Freak jre]$ sudo pacman -Rdd openjdk6

Install OracleJRE

sudo pacman -U jre-7u2-1-i686.pkg.tar.xz

Build and Install JDK AUR package:

sudo pacman -U jdk-7u2-1-i686.pkg.tar.xz

Logout and Login so the PATH gets updated and we are ready to go.

UPDATE: Actually Eclipse crashing had nothing to do with OpenJDK or PDT, but an issue with the installed xulrunner. Workaround available here: 6.1 Autocompletion and javadoc render crash

Resources:

Switch keyboard layout holding windows key

I find really useful to switch keyboard layout while holding a key. That way I can easily type an English while writing in Greek. Left Windows key is good option for me as I don’t really need it on my Arch Linux powered laptop.

Can be easily setup in /etc/X11/xorg.conf.d/01-keyboard-layout.conf:

Section "InputClass"
        Identifier "keyboard-layout"
        Driver "evdev"
        MatchIsKeyboard "yes"
        Option "XkbLayout"  "us,gr"
        Option "XkbOptions" "grp:alt_caps_toggle,grp:lwin_switch"
EndSection

A full list is available in /usr/share/X11/xkb/rules/xorg.lst

Take Screenshots on LXDE

Edit the following in ~/.config/openbox/lxde-rc.xml:

   

<keybind key="Print">
      <action name="Execute">
        <command>screenshot-desktop.sh</command>
      </action>
    </keybind>
    <keybind key="A-Print">
      <action name="Execute">
        <command>screenshot-window.sh</command>
      </action>
    </keybind>

To take a full desktop screenshot:

#!/bin/bash
DATE=`date +%Y-%m-%d\ %H\:%M\:%S`
xwd -root | convert - "$HOME/Desktop/Screenshot-$DATE.png"
notify-send "Desktop screenshot saved!" "A descktop screenshot was saved on your Desktop as:\n Screenshot-$DATE.png" -i /usr/share/icons/Tango/scalable/devices/camera.svg

screenshot-desktop.sh

To take the current window screenshot:

#!/bin/bash
 activeWinLine=$(xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)")
 activeWinId="${activeWinLine:40}"
 activeWinTitle=$(xwininfo -id $activeWinId | grep 'Window id:' | cut -d"\"" -f2)


COUNTER=0
FILENAME="$HOME/Desktop/$activeWinTitle-Screenshot.png"

while [ -f "$FILENAME" ]; do
  let COUNTER=COUNTER+1
  FILENAME="$HOME/Desktop/$activeWinTitle-Screenshot-$COUNTER.png"
done


 import -window $activeWinId "$FILENAME"

notify-send "Window screenshot saved!" "Windows screenshot was saved on your Desktop as:\n $FILENAME" -i /usr/share/icons/Tango/scalable/devices/camera.svg

screenshot-window.sh

Setup an Apache Pivot project in Eclipse

Apache Pivot logoApache Pivot is an open-source platform for building rich web applications in Java. I was looking for a modern UI toolkit and Pivot is exactly that. I’m willing to give a try so I tried to setup some Pivot projects in Eclipse. It actually comes with an Eclipse plugin that simplifies development of Pivot applications.

So here is a quick guide to setup Eclipse for the development of Pivot applications
Continue reading Setup an Apache Pivot project in Eclipse

Create W32 7-Zip sfx in Linux

7-Zip tool

7-Zip allows you to create a self extracted binary archives with the -sfx switch. But in the Linux version of 7-Zip the SFX created is a Linux binary.

So if you run the following command in a Linux box and try to run test.exe in Windows you’ll get a “Program too big to fit into memory” error.

7z a -sfx test.exe test.txt

That’s because the binary is a GNU/Linux binary.

$ file test.exe
test.exe: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, stripped

The -sfx switch in Linux will try to use 7zCon.sfx module by default and will create a Linux binary console file.

If you want to create a W32 self extracted binary in Linux you have to pick the 7z.sfx module from the windows 7-Zip version and put it in the 7z directory.

In Ubuntu you can copy 7z.sfx in the following directory:

/usr/lib/p7zip/

After done this you can use the -sfx7.sfx switch to create a W32 binary SFX file.

e.g.

7z a -sfx7.sfx test.exe test.txt

and you get that

$ file test.exe
 test.exe: PE32 executable for MS Windows (GUI) Intel 80386 32-bit

Invalid date because of DST

We are all familiar with the daylight saving time. Once every year we are happy that we earn a sleeping hour and once the exact opposite.

So what pushed me to blog about it?

squared circles - Clocks I had to hack a small bash script at work, so it will accept a date command line argument, to export that date reports. Piece of cake, right?

Done quickly with this simple hacking and thought to add some user input validation. Why not validate user input with the date tool? If date believes a date is invalid, then it is.

And ready to go! User request asked to use this small script and export for him three past dates reports.

  • 03/01/10
  • 03/02/10
  • 03/03/10

More valid dates than ever! Except from 03/03/10 that date believed it’s invalid!

How this can be possible! What’s so special about 03/03/10.

Googling around brought to my notice, that if you don’t specify to date that you want UTC ( -u ) it will work with your local system timezone and daylight saving times. So date 03/03/10 00:00:00 could really be invalid? It could if the DST for Eastern Standard Time was happening that day and time.

Although, this could be a great explanation for my problem, that wasn’t the case. I was using a really old version of cygwin’s date (probably not even a GNU version), that was just buggy and was reporting invalid date even with -u switch.

I may end-up in an dead end. But next I will be really careful when  using local times 🙂

Web Develop or Just Browse with Firefox

Firefox Add-onsThere are two grate add-ons for Mozilla Firefox, that is a must for every web developer. I’m almost sure you know them.

Guessed right!

These are great tools even for non full time web developers. But they can impact your every day Internet browsing experience, by making Firefox more sluggish or just because they “pollute”  your beautiful interface. In other cases, everyday add-ons that make your browsing experience easier ( ads blockers, socialization stuff, … ) may harm your development process.

Considering all these, and because disabling each time the relative add-ons isn’t so convenient, I thought of using different Firefox Profiles for each job.

Profiles, are available from the early ages of Mozilla browser, but never found a reason to use it. It’s main reason of existence is to allow different users, use their own personal settings in the browser, but this is almost handled by OS’s multi-user capabilities.

What if the same person has multiple roles? Maybe a profile for each role could help.

  1. So, I popped up Profile Manager and created a new Development profile.
  2. Installed my development add-ons. Setup my interface and bookmarks to development needs.
  3. A special Firefox Developer shortcut.
firefox -p Developer -no-remote

That’s it!  A small inconvenience, of this setup is that if I run my Development profile Firefox first  and then try my default profile from it’s shortcut, a new Development profile Firefox tread will pop up. That’s because the default Firefox shortcut doesn’t use the -no-remote argument. But you can just add it your self 🙂

If only I could change my new profiles application icon  🙁

according to this, it doesn’t seem possible: https://support.mozilla.com/en-US/forum/1/559678