2010-08-09

Administrator ethics

Whenever the sudo command is used the first time on a Linux box (this is the command to run things with administration/root permissions, the following text is shown:
We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things:
  1. Respect the privacy of others.
  2. Think before you type.
  3. With great power comes great responsibility.
Whenever I read this, I must say: I like that. And it is applicable to far more than just IT...

2010-08-05

Screencast recording on Ubuntu 10.04 (and 9.10)

Creating screencasts is not only modern - often a short 2-minute video can be more helpful as a 2 page documentation.

There are two major screencast recording tools available in Ubuntu. That said, I always had troubles with them because I do want sometimes different behaviour or I had issues with the sound. I want to give a very short overview to make it more easy for you to choose the right tool in the right moment and to get the output you want:
  • gtk-recordmydesktop
    +
    Very easy interface
    + Works out-of-the-box
    - Option to follow mouse available and keeps the mouse always in the center of the frame (I think, this disturbs, when watching the video).
    - Cannot export/save as MPEG-4 or AVI or anything else - just .ogv (the open format)
     
  • XVidCap
    + Can produce different formats (MPEG-4 is the default, but you can switch to .ogv also)
    + Option to follow mouse available and keeps the frame steady until you move the mouse near the frame border (this way it is more easy for the user to follow the video instructions - you should only make sure that the border of the video is not to near to your primary working area otherwise you get a similar effect as with gtk-recordmydesktop)
    - The GUI is slightly less intuitive
    - Using the package from the Ubuntu 9.10 or 10.04 repository does not bring you sound support (at least not when trying to create MPEG-4). You have to install the .deb package manually by downloading it from sourceforge (current version is yet 1.1.7 - although the same version seems to be in the repository, that is a different one and does not work - strange, but fact).

I basically use both applications. When I produce local screencasts for end-users that I just save on their local machine for later reference I use gtk-recordmydesktop and just leave it as ogv. That used to work even when Skype + TeamViewer is running and I did the recording remotely. It even recorded my sound coming through Skype! When I want to upload a video to YouTube (or vimeo and others), XVidCap is better because it immediately produces MPEG-4 which fits better for YouTube and similar services (I tried uploading an ogv file from gtk-recordmydesktop to YouTube which failed to replay correctly - indeed it is not mentioned on the appropriate help page).

Especially for the case(s) you prefer gtk-recordmydesktop you might need to convert the created video to the finally desired format. I have seen many ways (reading blog posts and watching screencasts), e.g. using WinFF, VLC Media Player and using Devede. Using Devede was the only one that worked for me (see http://vodpod.com/watch/3665200-converting-your-ogv-files-to-mpeg4-).

In any case you should have the ubuntu-restricted-extras installed (using synaptic package manager or sudo apt-get install ubuntu-restricted-extras) for doing video or audio stuff. I would also install ffmpeg.

I also usually have to put the sound input to a high level otherwise when replayed on several machines (e.g. notebooks or external monitors with poor speaker power), even putting the volume to highest level brought only low level sound.

Final note: It might be necessary to quit Skype (if you have it running) to avoid sound or video juddering.

Related post: Ubuntu 10.04 with docking station.

2010-08-02

Ubuntu 10.04 with docking station

After installing Ubuntu 10.04 I lost proper dual monitor handling for my use case. Basically I want to use my notebook on the road as is and in the office I want to put it into the docking station while having the lid always closed.

Ubuntu 10.04 Lucid Lynx does not handle this properly any more. I found out that also in 9.10 it was probably pure luck for me because I upgraded from 9.04 and had some fixed entries in the xorg.conf.

But anyway, the xorg.conf file is legacy and there is now gdm with xrandr.

I found out that many have the same use case as I have and have problems. Some solutions are particular to NVidia cards, but I have an Intel. Thanks to Nylex in the Linuxquestions-Forum + Ubuntu XOrg documentation, I could find the solution:

I had to put this into the file /etc/gdm/Init/Default before the line starting with /sbin/initctl (why the TV1 is there also look below in update 3):
xrandr | grep "HDMI1 connected "
# 0 is returned on success
if [ $? -eq 0 ]; then
xrandr --output HDMI1 --mode 1680x1050 --rate 60 --primary --output LVDS1 --off --output TV1 --off --output VGA1 --off --output HDMI2 --off --output DP1 --off --output DP1 --off --output DP2 --off --output DP3 --off
else
xrandr --current | grep "VGA1 connected "
if [ $? -eq 0 ]; then
xrandr --output VGA1 --mode 1680x1050 --rate 60 --primary --output LVDS1 --off --output TV1 --off --output HDMI1 --off --output HDMI2 --off --output DP1 --off --output DP1 --off --output DP2 --off --output DP3 --off
else
xrandr --current | grep "TV1 connected "
if [ $? -eq 0 ]; then
xrandr --output LVDS1 --mode 1440x900 --rate 60 --primary --output HDMI1 --off --output TV1 --off --output VGA1 --off --output HDMI2 --off --output DP1 --off --output DP1 --off --output DP2 --off --output DP3 --off
fi
fi
fi

What it does is: Using xrandr it probes whether an external monitor is attached (whether HDMI or VGA) and if so it turns off the LCD display of the laptop so it is not used. You need to adapt the resolution to fit your needs.

[Update]
I had some cases when (maybe because of timing at startup) it did not work (sometimes it worked after gdm service restart then but not always) added --preferred and --primary to the xrandr call above and I added the script below to System->Preferences->Startup applications:
#!/bin/sh
xrandr --current | grep "HDMI1 connected "
# 0 is returned on success
if [ $? -eq 0 ]; then
sleep 5s
xrandr --output HDMI1 --mode 1680x1050 --rate 60 --primary --output LVDS1 --off --output TV1 --off --output VGA1 --off --output HDMI2 --off --output DP1 --off --output DP1 --off --output DP2 --off --output DP3 --off
else
xrandr --current | grep "VGA1 connected "
if [ $? -eq 0 ]; then
sleep 5s
xrandr --output VGA1 --mode 1680x1050 --rate 60 --primary --output LVDS1 --off --output TV1 --off --output HDMI1 --off --output HDMI2 --off --output DP1 --off --output DP1 --off --output DP2 --off --output DP3 --off
else
xrandr --current | grep "TV1 connected "
if [ $? -eq 0 ]; then
sleep 5s
xrandr --output LVDS1 --mode 1440x900 --rate 60 --primary --output HDMI1 --off --output TV1 --off --output VGA1 --off --output HDMI2 --off --output DP1 --off --output DP1 --off --output DP2 --off --output DP3 --off
fi
fi
fi


[Update 2]:
It still did not work 100%. Sometimes when I moved the mouse outside the desktop it was gone so I found the laptop monitor being still active (so I could move windows over there and they were gone). I could immediately notice that after login when the workspace icons on the bottom right were displayed with increased width. It helped, explicitly turning of LVDS1 display (the laptop screen) in the script (see appropriate options in the updated script above).
[Rest of update 2 removed because of update 3]

[Update 3]:
It turned out that (occasionally) on boot it recognized another monitor to be active, after first being the LVDS1 it happened also being the TV1 (occassionally) - and I don't know why because I never attached a TV to it. Anyway, I have added the options to turn that off explicitly also to the scripts (see updated gdm default script portion and startup script above).

Apart from that sometimes occassionally a re-evaluation of available displays might be triggered by an application (e.g. opening and closing the laptop lid or manually calling xrandr without parameters or starting arandr or other applications when started the first time). Such a re-evaluation can also occur right after graphical login and then your initial gdm xrandr modifications are forgotten. Therefore it helps having that script at hand (I have it in /opt) and added to the gnome menu under "Other" to run it when necessary on demand.

Apparently also a timing issue remained (I assume that because of the fact, that the startup applications are started in no particular order and all asynchroneously). However, adding a line with "sleep 5s" to the script (only to the additional script and not to the gdm init!!!) helped. I currently use a 10 seconds delay (subject to change maybe) but in your case less might be sufficient or more might be required (for me 5 seconds was not enough to make it work each boot).

For you it might be necessary to switch additional displays explicitely off (as I did with TV1 for example).

Oh, and BTW:
In System->Preferences->Power Management make sure that lid closed action is "Blank Screen". I made a lot of tests with setting to nothing (only possible via gconftool-2) but after all maybe the above setting is the better one.

If in your case the resolution(s) are not set correctly you can do this here in this script also. Use man xrandr or look at https://wiki.ubuntu.com/X/Config/Resolution#Adding%20undetected%20resolutions for more information on the appropriate xrandr commands.
I noticed some flickering and login screen displayed in lower resolution, so I added --mode 1680x1050 to the xrandr call in both cases (in both scripts) which is the resolution of my external monitor.

Honestly, using this script, I feel better than previously on Ubuntu 9.04 or 9.10 where I got it to work by accident after moving around monitors in the config (although in reality they were positioned the other way round). As I found out today, I wasn't either the only one with that experience (see http://ubuntuforums.org/showthread.php?t=1110407) although I am used to be the non-standard user. - With my use case of having the lid closed all the time when in the docking station I am by far not alone as I noticed and some either downgraded to 9.10 because they did not get it to work.

Many, many thanks again to Nylex and the Ubuntu documentation team!

Related links:
Related posts: Ubuntu 10.04 with docking station part 2, Firefox change default page format, Ubuntu 10.04 Experiences, OpenOffice and LibreOffice starts slow.

2010-07-16

Java applications on the desktop

When it comes to discussions about programming languages on forums and newsgroups, one argument against Java is that there are quite no Java applications for the desktop.

This is definitely not true. I have looked what Java applications I am using (or used a lot in the past), and here is a list:
And of course, if you are a developer programming in Java, JavaFX, C++, PHP, Python or Scala for example, then you probably use NetBeans or Eclipse - both very popular IDEs (integrated development environments) are written in Java.


There are many, many Java desktop applications out there, look for example at javadesktop.org. You can see the wide area where Java is used on the desktop at geertjans blog here for example or at the NetBeans site here.

One advantage of using Java at the desktop is that you can choose between two core different ways: Swing or SWT. While SWT tries to use the OS specific widgets (to look more like the original OS and be faster), Swing does render everything itself. So SWT is a little bit faster and looks more like OS, but Swing is more flexible (more widgets available) and you can easily use different look and feel / themes (there is also an OS like). In both cases you can develop modern Java desktop applications that look nice and integrated with your OS.

The disadvantage of using Java on the desktop - I will be honest - is startup speed. Once started, SWT and Swing applications behave fast - probably not as a native Gnome application for instance but really - it's fast enough for the user. That startup time is still an issue you will notice mostly, if you write small tools as Java desktop applications. For larger ones it is less annoying because those you don't open and close all the time. If you open the application and tend to keep it open you will have no problem. If you open and close the app frequently then it may become an issue. Same applies for small commandline tools - writing those in Java is maybe not the best option. Anyway, really annoying is only the first start of the first Java application after reboot when the Java runtime is not in the cache yet. NetBeans for example (which is a big Java application) needs 12 seconds on my machine (a year old) when the Java runtime is already in the cache. Freemind is a smaller application and takes only 5 seconds to startup which is acceptable.

If you look also at server-side then ... what should I say .... the world is full of Java applications - too much to cover here (and of course for many websites or web applications you often can't really say from outside what is used behind the scenes).

Related post: Popular Java myths, The future of Java.

2010-07-15

Get reliable local IP address in Java 6

It is strange: I consider myself still being new to Java, but when I search for particular sample code, that should be written thousand times before, I sometimes find only samples that do only half the job or miss important details.
So happened for getting the local IP address(es) of the machine you are running on. I experienced for example performance issues retrieving the IPs when running with a mobile internet stick (point-to-point device).

My example code can be found here: http://pastebin.com/5X073pUc

If you want just one address, that is probably the best fitting then you probable want to use this example: http://pastebin.com/PLAcTXac

Related post: Dynamic method invocation in Java 6.

The small software vendors

Especially these days companies are very careful in choosing their vendors. This certainly also applies for software.

I do get some considerations from customers which I do not really consider being always relevant or true:
  • "We prefer to buy from large software vendors, because as an international company, we need the availability of support in different countries."
    Especially software support can be available all over the world because there is no need to actually sit there. With chat, voice- & video communication plus remote desktop tools support can be done all over the world from a single location.
    Further, a large company could have plenty of people sitting in plenty of countries, but this does not mean that all those people have (the same level of) good knowledge of the software. Honestly, those who really know the product, are always the developers and the people who communicate most with them.

  • "A small software vendor is more likely to fail and go bankrupt and then we have invested in a dead product."
    First, present time shows that even a large company can fail (maybe except banks ;-) ).
    Second, bankrupty is not the only case leading to a dead product! It happens more often that a product is simply discontinued and this happens for products of bigger vendors also. In bankrupty case, if a product is good there will be other companies taking over the product - especially if money can be made from supporting the product. But if nobody is interested any more in the product your situation is worse.
    Third, if you ensure that you have access to the source code (even if only in bankrupt case - which would be sufficient and cheaper in most cases), you always can hire people working on the product implementing the features YOU need (this is a big advantage of Open Source).

  • "At small software vendors the deep know-how is bound to a few people only which also means a higher risk for the customer."
    Nowadays companies do not invest in having a lot of backup resources. This also affects developers. And I have experienced dependency on a few people also at big companies. Just because the company is bigger does not necessarily mean they have more smart people there working on the same stuff. It is more important that the team is continuously motivated and people like to work for the company employing them. A stable and motivated team at the vendor is the key for lasting long-term support of your product.

And last but not least let's not forget about a few advantages of choosing smaller vendors:
  1. Usually more flexible organization.
  2. Better and more direct contact with tech people.
  3. Cheaper - big companies often have a big head of administration and more levels of managment - all those want to be paid.
  4. What a small customer is for a big vendor can be a big customer for a small vendor. So the small vendor is more likely to listen to your needs.
  5. If you are a big company and somehow get too dependent from a very small company, you could take over more easily.
And BTW: There are more smaller vendors than big ones, so the set of applications to choose from is significantly higher if you consider also the small vendors.

Related posts: Small Business Boom, Scope of IT projects, Paying for free and Open Source, IT Outsourcing, IT projects cost explosion, The Open Source idea.

      2010-07-01

      Small Business Boom

      If boosted by the economic crisis or not, in my neighbourhood I can observe more and more people becoming self-employed building their real own company or just getting freelancers.

      What this usually brings is more flexibility and a low budget - at least at the beginning.

      Classical style of IT then:
      • Internet ADSL connection to home office
      • E-Mail (along with spam filtering) hosted at the Internet provider
      • Single notebook or desktop PC with some backup strategy or a dedicated server + desktop pc + laptop (something like this). Newer Internet provider modems are even shipped with an option to plugin an external harddrive that is directly offered as a network storage service for connected (W)LAN-devices.
      • All-in-one printer-scanner-fax devices for doing those most important office operations dealing with paper where still necessary. Usually small and compact devices do not occupy too much space and can handle the small amount of paper in a modern office.
      • Contacts are saved in the address books of the used email-client, in some cases additional simple local XLS files or Access databases are used or also free online services (but only surprisingly seldom - I guess people do consider their business contacts as a company secret and do have privace concerns).
      • Office application package is intensively used for writing letters (where still needed), contracts, agreements, invoices and the like.
      • PDFs are created from the office documents written or scanned documents are saved in PDF format for (long-term).
      • Sector or branch specific software applications (e.g. banking or insurance agency tools) move more and more in the direction of being online services (web applications) rather than applications that need a local installation.
      • With a smartphone they can answer emails also while on the road which is crucial for a one- or two-man/women show.
      • Appointments are managed in the smartphone with the smart phone's own application, Google Calendar or in a classical pen & paper style (what is actually used is mostly depending on people in the company and branch).
      I can see such constructs from 1 to 3 or 4 people in my local area. Some of them are considering a move to Linux and I already helped a few building their home-office-desktop on Linux. And lately there are coming more and more asking for Linux...

      Related posts: Why Linux?, Going Linux, Why I switched to Ubuntu, The small software vendors.