Monday, December 28, 2009

Liferay: include JSP into Velocity templates

I am working on a Liferay's theme. Hooray, no more moronic pain in ass because of Velocity templates. Velocity templates now are mainstream when you're building a Liferay's theme and zero (yes, zero) documentation of how to use other template system. JSP that just works great, is easy to use, well integrated in your favorite IDE with all the documentation and autocomplete stuff, and you already know them well. So let's Liferay developers eat their Velocity, while we go tradition stuff.

Anyway, to add some JSP page into your theme, simply do like this:

$theme.include($themeServletContext, "/elements.jsp")

This example assumes that you have a file, called "elements.jsp" and it is located in the root of your theme (i.e. accessible from the URL like "http://yourhost/your-theme-name/elements.jsp").

Tuesday, December 08, 2009

JNLP and Stupid Parameters

To limit a time of headbanging solving weird JNLP descriptor behavior while passing properties to your app, remember that they are called "secure", i.e. starts from "jnlp." or "javaws." prefix. That means that <property name="foo" value="bar"/> won't work, while <property name="javaws.foo" value="bar"/> will.

Read them with System.getProperty("javaws.foo"); — as usual.

Sunday, December 06, 2009

Brain-dead laptop design by Dell

I mean... Just see it yourself how to change coin-cell battery in their 1525 Inspiron thing. Why would you do that? Because if the battery gone, your laptop won't boot at all (another utterly stupid brilliant bit of design by greatest Hell Dell).

Friday, December 04, 2009

Stop DHCP screwing up your Mac OS X hostname

I'v got Snow Leopard, but DHCP is screwing my hostname all the time to something very random. Another thing that /etc/hostconfig goes away, while System Preferences in the Sharing tab does not sets hostname as hostname. Thus all older recipes are not really applicable anymore, once you're on Snow Leopard (I love changes). The cure is how to setup your hostname to, e.g. "Zeus" (that's mine one) like this (terminal and sudo privileges are required):
sudo scutil --set ComputerName zeus
sudo scutil --set HostName zeus
sudo scutil --set LocalHostName zeus
That's it (no reboot really required).

Monday, November 30, 2009

SmartGWT + Liferay

One picture is better than 128K words:

Yep, it works as expected. How to do this? Same as you would do any GWT-based portlets, just use SmartGWT as widget set transparently.

Saturday, November 21, 2009

Java, Image Processing and OSX

A little annoying thing happens, when you do image processing in Java, using Apple OS X: although your code supposed to run in background, you still notice some additional process, that triggers Quartz and something appears on a Dock.

To cure this, you need to run AWT head-less. To do this, add a system property in your main() right before anything else:

System.setProperty("java.awt.headless", "true");

Wednesday, November 18, 2009

Linux User Books


Linux User Books, originally uploaded by I.S.B.M..

Japanese books about Linux. Found at Open Source summit at Tokyo.

Friday, October 09, 2009

java.io.IOException: Not enough space

Seen that?
Caused by: java.io.IOException: error=12, Not enough space
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.(UNIXProcess.java:53)
at java.lang.ProcessImpl.start(ProcessImpl.java:65)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:452)

Yes, I hate this too. First of all, that's not what you think. It means not enough swap, because your Java suddenly wants lots of GB of memory. When Java launches fork, it starts a new VM as a fork from current process. Thus for a short period between fork and exec, there is two instances of your stuff. That's temporary though. Exactly at this moment your system cries for a lack of swap.

Now, how to cure this on Solaris as long as you're using old UFS. Simply add some space as a file to a swap:
mkfile 500m /opt/var/my.swap
swap -a /opt/var/my.swap
Uhm, OK. That's old way... But that won't work on ZFS as this file system can not use files for a swap. :-) To use this with ZFS, make another ZFS filesystem in your rpool. That's how I am using in my OpenSolaris global zone:
zfs create -V 2G rpool/additionalswap
swap -a /dev/zvol/dsk/rpool/additionalswap
To see the result, issue swap -l command and it will show you that new FS has been added to your swap, something like this:


swapfile dev swaplo blocks free
/dev/zvol/dsk/rpool/swap 182,1 8 2095096 1823456
/dev/zvol/dsk/rpool/additionalswap 182,3 8 4194288 4194288

Now you're safe. :-)

GlassFish + OpenDS = No Pain

You want LDAP and appserver work with it. But you also remember all the voodoo bloody massacre you've experienced, once you've tried to setup OpenLDAP and now looking to shoot its developers. Calm down, go an elegant and easy way instead.

My config is pretty much simple OpenDS on an OpenSolaris zone. Nothing special for OpenSolaris zone — just setup it as usual and configure OpenDS as you would do on a global zone. That's my scenario:

  1. Login to your OpenSolaris global zone and install OpenDS from IPS:

    pfexec pkg install opends

  2. Now, login to your zone where OpenDS is supposed to run and add an user, who will use it. In my case it is "opends" user (and a same group) and I've decided to put it separately, where entire OpenDS instance is:

    pfexec useradd -md /opt/opends/home opends

  3. I've also decided that OpenDS instance is running in /opt/opends/instance folder. So run configuration against "opends" user and that folder like this:

    pfexec /usr/opends/configure \
         --instancePath /opt/opends/instance \
         --userName opends \
         --groupName opends


  4. Great. Now is a time to finish it. :-) Login as "opends" user and run "setup" command. Please note, it will try run Swing GUI for you, so either SSH into your box with X11 forwarding or use command line mode ("--cli" option) and follow these few simple instructions (setup DN, admin password, port etc):

    /usr/opends/setup --cli

  5. There is no fifth step — your LDAP is up and running. Need more info about details and such? Here: https://docs.opends.org/wiki — depending on your version...

OK, we have LDAP done in four steps. Now we want GlassFish use it as realm. That's also elegant:

  1. Login into your GlassFish admin console (by default on 4848 port).
  2. Go to Configuration → Security → Realms and add one just straight-forward as it is:
    1. Set name to "OpenDS", let's say.
    2. Use class: com.sun.enterprise.security.auth.realm.LDAPRealm
    3. Set JAAS context as "ldapRealm"
    4. Set Directory to "ldap://your.host:port". If you're using SSL to make things thrice slower while no much change to security itself (because it is an internal network), then use scheme "ldaps://...". :-)
    5. Use your base DN that you've put to your LDAP, e.g.: dc=your,dc=host,dc=com or something like this.
    6. And then use your group whenever it is: ou=groups,dc=your,dc=host,dc=com etc.
  3. There is no third step.

Easy, is it? :-)

Thursday, October 01, 2009

IT Market Nowadays


Here I just thought how job specification would look like, if IT guys would need to drive a regular city bus. :-)


Job Specifications

City bus driver from 9:30AM to 3:30PM.

Job Type

contract, part time.

Salary

Negotiable, but no more than $1000 per month.

Requirements

Bicycle skydiving, motorcycle, car and truck licenses, repair and maintenance knowledge, tramway and trolley-bus at least 5 years experience. Additionally, ultra-high demolition excavators such as Caterpillar 385D operation, haulage and earthmoving equipment on off-road vehicles experience, military armored bulldozer D9, rocket launcher truck and tank Abrams driving at least 1 year experience.

Successful candidate also should have knowledge flying F16, PhD in engine manufacturing and engineering, license for shooting magnum .44 gun and must have at least 5 (five) jumps with a parachute.

Having 500 hours flight as a crew captain with Boeing 747 is a plus. Being an astronaut team leader with at least month in a space is a plus. Knowing some specific details about Apollo 13 and landing on a Moon is a plus, but not that much necessary, however it might affect salary negotiations.

If you are interested, we are waiting you for an interview. You will have 10 interviews, 4 tests and 2 brainbench in a gym.

Other notes

You must not be married.

Wednesday, September 23, 2009

Google Web Toolkit + JSR 168 portlets

I want GWT. No, not JSF or other stuff like Struts (uugghh!) with JavaScript libraries, where you also have to care about sort of XML configs, JSP etc etc etc. Forget it. Use GWT.

But Enterprise wants portal with portlets (and me too). So how to make a "standalone" portlet in a nice .war file, while using GWT and such for this? I use GlassFish server and NetBeans IDE, so my sharing here towards these components only. Here is how I managed this to work:
  1. Get Portlet Container Driver from OpenPortal for a start and follow the instructions to let it get working on your GlassFish (simply run configurator jar and point directory and domain).
  2. Install Portal Pack in your NetBeans IDE.
Now, how to create a portlet with GWT:
  1. Create a new project, called "Java Web Application" in your NetBeans with GWT and PortalPack support enabled. Nothing else is needed for our example.
  2. Let's say, the name of our project is "GWTPortlet" and let's say it is in "net.maryniuk.portlet" package.
  3. NetBeans will generate for you a skeleton for your portlet. It is all what you actually need from non-GWT part.
  4. Create GWT client, that should be in "net.maryniuk.portlet.client". It will add some JavaScript and meta tags to "welcomeGWT.html" file, which you can find in "Web Pages" folder. Get these two tags (javascript and meta) and put them into "GWTPortlet_view.jsp" file, that you can find in "Web Pages/WEB-INF/jsp" folder.
  5. Change path in JavaScript tag the way it find generated JavaScript by GWT. For example, if your tag looks like: <script src="foo.js">, then change it to <script src="/GWTPortlet/foo.js">.
  6. Add a <div id="foo"></div> tag with an ID (in our example "foo") somewhere inside that JSP page.
  7. In your GWT entry point, change RootPanel.get()... to RootPanel.get("foo")... so then GWT can lookup an element with an ID "foo" and place itself there.
  8. Build your project. You're done — subdirectory "dist" contains your .war file with GWT portlet!
  9. Now just deploy it inside your Portlet Driver and see the result.

Here how it looks like for me:

Later on, after you sure your portlet works as expected, you can deploy it on Liferay or Sun Webspace:

Sunday, September 20, 2009

ORM sucks. Hibernate sucks even more.

For years, I already have my own opinion about ORM. The opinion is built on a quite a number of various trials, different practices, multiple measures and just a real life. Thus it sounds this way: ORM sucks big time and should not exist. Why? Shortly, because of noise ratio is tremendously high, while good factor is miserably low.

Being with a time, I would expect them get better. But what happens actually? Take a look at one of them: Hibernate — a powerful, high-performance Java persistence mechanism wannabe. I will tell you honestly: it sucks so much that any decent C++ developer would just hate Java as in whole. This thing just emphasizes whole Java "heaviness" and "bulkiness" that normally scares all tech people who are not just "an average Joe".

Hey, just look at all its glory: https://www.hibernate.org/116.html! Especially take a spot at the moment, when it keeps recreating collection. Now, how you gonna apply "Defensive Copy", once you have immutable objects? Think about of it. Or, take a look how even a silly CRUD application would suffer, once you've got "not-very-recent" object from the session! And the workaround for this? — right, get the object again just to make sure it is recent version...

What I am doing? I am using plain JDBC drivers with a little wrapper that does all the hassle and dirty jobs for me behind the scenes, leaving no XML to me at all. Footprint of the thing is very small and I've got it running on an embedded stuff as well as on a GlassFish cluster.

P.S. No, you're not gonna change any corporate RDBMS from one to another, like you would change your socks. But stuff, like JaQu would help a lot, once support all required dialects.

Friday, September 11, 2009

Upload file in SmartGWT

Upload a file to a server from your browser is not a big deal. But how to do it, if you have:
  • SmartGWT (a Google Web Toolkit with a SmartClient library)
  • It is LGPL, so no proprietary extension on a place
  • You don't want to use ExtGWT just only for one single upload function and thus risk your project won't really work on older browsers that are still might be in use.
  • You want it nicely done at background with a clean callback, of course. :-)
Here how you do it:
  1. In com.smartgwt.client.widgets.form.DynamicForm, set it to multipart by passing it Encoding.MULTIPART.
  2. Create an internal iframe, using com.google.gwt.user.client.ui.NamedFrame and call it, let's say "foo" (sure no better name came into my head now, LOL). Make it 1x1 pixel width and set visibility to false. It is not actually a thing user needs to see.
  3. Now use setTarget("foo") method to let your DynamicForm use that it as a target.
  4. Also use setAction(url-to-your-processing-servlet) to let DynamicForm actually send stuff there. You can do it like ("upload" — is your servlet accessible):
    .setAction(GWT.getModuleBaseURL() + "/upload");
  5. Now, add mouse click handler to your IButton and use submitForm() method out of DynamicForm instance object. It will send the form and that iframe we created earlier will receive a result. This way we achieve upload in background.
  6. Add a native JavaScript method, that will be seen normally in the loaded page, so parent windows can simply call it. That's exactly what do we need, when upload has been finished. More how to add JavaScript native methods, refer to GWT documentation about JSNI.
Now, time to write our Servlet for file upload. Great Java that comes with power station to your computer, yet has zero API to process multipart forms. This is just frustrating. But here is a cure: Apache File Upload library. Read the API how to use it. But generally, you simply iterate over fields and once you've got a filename out of the stream, you have the file. In this way you can send lots of files at once.

Your servlet should call back our method, we've defined in step #6. You simply set content type to text/html, write some simple html and a JavaScript that would call parent on window load — this way your iframe will call your client back. You may pass anything you want and respond anything. In my case it just closes upload dialog and says job done.

That's it. Implementation is up to you — use imagination... :-)

Sunday, September 06, 2009

Bye-bye, Apache. I won't miss you.

You've got an Enterprise Application Server — a GlassFish. At some cases it outperforms Apache, at some cases it is just equal. Yet, you out of luck to use it fully, just because you need running it on a port 80/443. You do not want to run GlassFish as a root user. On the other hand, running Apache or nginx (or whatever else) in front of it as a proxy is an ugly hack and unnecessary component in a front.

Interested to get a cure for this? OpenSolaris is your answer. :-)

Here what you need to do:
1. Wipe away your FreeBSD or Linux because these are impotent to do so (also good riddance anyway because at least for starter, Solaris Zones and ZFS and D-Trace just rules).
2. Install OpenSolaris (if you still want Linux — well, fsck your ext3 and just skip this blog entry).
3. Add a user, let's say "appserv", and disable login.
4. Modify its permissions this way:

usermod -K defaultpriv=basic,net_privaddr appserv

Now "appserv" user has permissions to run GlassFish on a 80/443 port, while be completely non-root. That's all, folks!

One more thing: Apache on your Linux usually runs from root anyway, then just drops privileges. It is much more secure, if your GlassFish runs within Solaris Zone and not as root from the very beginning.

Friday, July 03, 2009

Hadoop on OpenSolaris Zone

Of course there is no point to run a cluster on a single machine. :-) But there is a point to run a Hadoop node within a Solaris container (zone) in order to isolate it from other stuff. To make it run, nothing really special:
  1. Setup a Solaris zone as you always do.
  2. Make sure that storage for Hadoop data is on LOFS and pointing to a real device.
  3. Redirect hadoop.tmp.dir to your storage.
As for version 0.20, having redirected temporary directory elsewhere, it will also drag everything else, including data. Thus better do at least the following layout:
  1. hadoop.tmp.dir$STORAGE/tmp
  2. dfs.name.dir$STORAGE/name
  3. dfs.data.dir$STORAGE/data
That's it, you've got the picture.

Sunday, May 31, 2009

Japan OpenSolaris User Group



Just return from Japan OpenSolaris user group. Excellent photos are on Jim's blog. I regret that I did not take my camera and did not make any photos, except of a few artifacts that I've got there: a bunch of very cute metallic stickers "Powered by OpenSolaris" to replace "Powered by Windows Vista" with "Powered by OpenSolaris". :-(

Very nice people, doing good stuff and, in fact, are not using Linux or Windows on their desktops presenting OpenSolaris, unlike FreeBSD guys that happens very typically to them. :-) There was few Macs and one M$ Windows, but still all the stuff was shown from VirtualBox (even Mac guys use VirtualBox, instead of Parallels or VmWare).

Next month Mike Sullivan will probably talk about ZFS and NAS.

Monday, May 25, 2009

Getting User Credentials in GlassFish

Well, LDAP is great, we all know that. Others might consider other realms to authenticate-and-then-authorize. But one thing really bothered me when it is not very great in case I still need user's credentials to pass them elsewhere after realm has been passed. E.g. I want to execute some business objects for that specific user etc. More over, there is no standard JSR for it (and this just pisses me off). Of course, these credentials are unable to find in a regular servlet HTTP request, because we are not using basic authentication, like a putting credentials into an URL. So, here is a deal: an user logs into your system and after that your code wants to use the same credentials to get things from elsewhere, but you do not want (or can not) run SSO for some reasons — hence you have no service ticket to some certain enterprise segment.

How to get user's credentials then, without messing around with custom realms? In a GlassFish, the recipe is as follows:
  1. From GlassFish lib/ directory add appserv-rt.jar library to your class path in order to get all com.sun.enterprise.* become available in your application.

  2. Get a subject:
    import com.sun.enterprise.security.auth.login.PasswordCredential;
    import javax.security.auth.Subject;
    import javax.security.jacc.PolicyContext;
    import javax.security.jacc.PolicyContextException;

    ...

    Subject subject = null;
    try {
    subject = (Subject) PolicyContext
    .getContext("javax.security.auth.Subject.container");
    } catch (PolicyContextException ex) {
    ...
    }
  3. From the subject, get an iterator from private credentials object:
    Iterator iter = subject.getPrivateCredentials().iterator();
    while (iter.hasNext()) {
    PasswordCredential credential = (PasswordCredential) iter.next();
    ...
    }
  4. Now you can get PasswordCredential object that contains: a) realm name as getRealm(), b) user ID as getUser(), c) password as getPassword().
That's it.

Monday, May 18, 2009

Sun Studio


20090515046, originally uploaded by trochej.

Here how Sun Studio looks like... :-)

Saturday, May 09, 2009

Cheap, Fast, Right: everything at once.

Recently I thought where/how to get a file-server, other services possible and a backup solution for my home that:
  • Is low voltage. So I don't need to pay 24" LED monitor price per a week year.
  • Is silent. So I will not get sick of the regular noise and won't suffer from sea sickness. :)
  • Is scalable. I want to add more disks in a future and/or replace them.
  • Is cheap. Thus I can afford more, once I need.
On the market there is available quite interesting piece of hardware: Asus EeePC Box. Engadget.com tagged it and you can find lots of explanation about the hardware itself. Shortly, it is Intel Atom N270 (1.6 GHz, FSB 533) processor, has DDRII 1 GB RAM (upgradable up to 2 GB), 2.5" size hard drive 80 GB capacity, 945GSE + ICH7M Chipset, on-board Intel GMA 950, 1600 x 1200 maximum graphic resolution. For network it has built-in 10/100/1000 Mbps LAN and 802.11n WLAN. It has 4 USB slots, one Mini SD slot and for sound Azalia ALC888 Audio Chip is used.

Installing an Operating System
Here in Tokyo, it comes with a Splashtop Linux which is kind of cool: you can use Skype and a Web right after two seconds later power has been turned on. And also an instance of a Japanese Windows XP with a worm inside right out of the box. :-)

In my case, as an OS I want to use OpenSolaris. Since machine has none of CD/DVD drive and I have none of USB one, installation was a bit tricky. Here is a sequence:
  1. Get at least OpenSolaris 111a build as USB image and make a bootable USB memory stick. If you are Solaris user, install SUNWdistro-const package and use usbcopy command to let it take your USB image and put into USB memory stick with a GRUB. Please note that filesystem should be ZFS. Due to a bug, UFS won't boot with memory sticks and you will get only a GRUB prompt.
  2. In BIOS, find your USB storage (appears as a hard drive) and select it as a primary drive, so in this way it will appear in a boot sequence menu. Select it and boot Solaris from USB drive, choosing VESA driver, otherwise monitor will be black due to frame buffer compression won't work with Intel card this time.
  3. In BIOS also turn off Splashtop Linux thingy, remove boot pause, remove logo on boot, enable quick boot, select appropriate bus speed etc. IOW, turn the machine to a regular PC without these bells and whistles.
  4. Process installation, blowing away everything on a disk (it is NTFS with Windows XP, originally).
  5. Remove USB memory stick, change boot sequence back to HDD and start your newly installed OpenSolaris.
That's basically it. Everything should work fine, including sound card.

Using static IP
OK, reader might be a n00b. :-) Here I shortly describe how it is done:
  1. Add a nameserver(s) to /etc/resolv.conf.
  2. Switch system to use DNS instead by renaming /etc/nsswitch.dns as /etc/nsswitch.conf.
  3. Restart DNS service:
    svcadm restart svc:/network/dns/client:default
  4. Use static IP by editing /etc/nwam/llp. For example, in my case, a physical device is "rge0" and was configured as "rge0 dhcp". I wanted internal IP to be 192.168.1.2, so I changed this to: "rge0 static 192.168.1.2/24".
  5. Restart network service:
    svcadm restart svc:/network/physical:nwam
  6. pfexec svcadm enable svc:/network/physical:default
  7. Add default router:
    pfexec vi /etc/defaultrouter
  8. ...and use it:
    pfexec svcadm restart network/routing-setup
List of all your network devices: ifconfig -a.

Compile MPlayer (for fun) :-)
I mean, why not? The thing has excellent sound card, why not use it? This one bit tricky (hello to Linux community), but nothing really special. Shortly:
  1. Install the following packages: SUNWgcc, SUNWgmake, IPSgawk (from a Blastwave) and SUNWxorg-headers.
  2. export PATH=/usr/gnu/bin:/opt/csw/gnu:/usr/bin:/usr/X11/bin:/usr/sbin:/sbin
  3. Get an MPlayer source: http://www8.mplayerhq.hu/MPlayer/releases/MPlayer-1.0rc2.tar.bz2
  4. Extract, configure, compile and install (use gmake instead of make):
    tar jxf MPlayer-1.0rc2.tar.bz2
    cd MPlayer-1.0rc2
    ./configure --prefix=/opt/mplayer/
    gmake
    gmake install
...and of course, you will miserably fail on first time gmake run, because Solaris's linker won't peacefully eat -rdynamic parameter, that is used to resolve symbols in the executable itself, when using dynamic loading. Well, simply delete this parameter from configure.mak file and link it successfully.

Yeeeah! :-)
P.S. Do not bother me and yourself why there is no decent package for MPlayer. I don't know, maybe a licence issues. If you cry about a package, then provide one.

Add Blastwave package repository (optionally)
I've added it, but don't use that much, since it blows my hard drive with duplicate packages. Just some packages only:
pfexec pkg set-authority -O http://blastwave.network.com:10000/ Blastwave
Some packages are good and MPlayer is also there. But if you willing installing from the packages, you will end up with a quite a big amount of duplicate software that you're already have on a disk.

Ready to go!
Now use your imagination. For example, I have few zones created on it for various services, like file server, backup, monitoring my home network that has more than 10 assets online and a jukebox.
Surprisingly, OpenSolaris on Atom CPU 1.6GHz with only 1GB RAM does all these tasks very well. And not just that: during these operations, it also happily plays a movie full-screen without any troubles.

Friday, May 08, 2009

Asus Eee PC Box B202

I've got my Asus Eee PC Box B202 for my mini project at home. Price here in Japan cost for me ¥39,800 + Bluetooth keyboard and a mouse. There are many reviews about the box, so I just wanted to share things that nobody usually talking. :-)

Packaging entirely sucks. It is ripped off from Apple packaging, but as usually it happens, copied wrong. They copied even matt paper and tried to put as minimum as possible graphics on it. Still, they screw it up, having lack of feeling of any kind of style, poor cutting quality etc. However, the price tells everything: they're done it by an axe, I understand... that's fine. But the most funny is a size. I took photos of the thing, so everybody can consider it themselves how "green" it is and how "well" it fits to the whole global warming question, wasting space of transportation, fuel for airplanes etc. Also it is damn heavy, in compare to MacBook package. I have no idea how it rendered to be that heavy, but I was quite surprised, dragging the thing to the home.

The Eee PC Box is a small Intel Atom-based machine with 1GB of RAM, 80GB 2.5" hard drive disk (16GB SSD would be much better here, by the way) and 1.6GHz CPU Intel Atom processor. CPU itself is not any fast. The beauty of the machine is a size and low voltage. It is very quiet (I mean silent), great for all this file-server thing in the small office or home. This machine is also really great for a disk-less thin client terminal. The size is like a regular O'Reilly book:


It is even smaller than my aluminum MacBook:


Now funny things begin. I still have a package box from my MacBook. I've got this in a shop exactly like this, as you might see in a photo (left). And that's how internal package of the Eee Box looks like (it is also thicker):


You think it is finished? No way. They put this box in another, external box that looks like this (why?? why??). The box is so big that you additionally can put a bottle of wine, pack of donuts and a small color printer:


And I also got a set of input devices: a Bluetooth keyboard and a mouse. Both are... well... cheap, you know... and I am not gonna use it anyway, since I have lots of keyboards at home. But... but... look at that size of package!! It is literally twice wider than the machine itself ("We don't know about Times New Loman existence for Engrish part for mice combos"):


...and, surprisingly, thrice thicker than the machine itself! Would I expect there five keyboards and a dozen of mouses?


Of course, by an old-good tradition, I took these stickers on a flush cistern of my toilet and now the natural excrement disposal place is labeled to be designed for a Windows XP. :-)


No way, the Eee PC box is gonna run OpenSolaris instead.

Tuesday, May 05, 2009

OpenSolaris zone: "One more thing..."

Here with OpenSolaris you do not want to create native zone, but ipkg one, using a standard /zones/foobar dataset. And, of course, it will not work for you, complaining about zone path dataset:
ERROR: Error: no zonepath dataset.
That's because /zones must be a ZFS. To fix a bones, remove and add it to the ZFS pool instead:
rmdir /zones
zfs create -o mountpoint=/zones rpool/zones
Then proceed with a regular zone setup, using zonecfg. Zones also works now perfectly with VirtualBox, version 2.2.2.

Tuesday, April 14, 2009

Just a stupid trick to make your WiFi faster on OSX: set delayed_ack to zero (default is 3).


sudo sysctl -w net.inet.tcp.delayed_ack=0

Nasty, but works. :-)

Monday, March 23, 2009

PirateBay and a trial

the prosecution plead for banning the essence of the internets, the links.

To ban the links? What does prosecutions smoke? Must be a really good sh!t...

Thursday, March 19, 2009

Monday, March 16, 2009

Mercurial and Terminal.app on Mac OS X

Get a latest Mercurial from here and... bang!


Traceback (most recent call last):
File "/usr/local/bin/hg", line 25, in
mercurial.util.set_binary(fp)
File "/Library/Python/2.5/site-packages/mercurial/demandimport.py", line 75, in __getattribute__
self._load()
File "/Library/Python/2.5/site-packages/mercurial/demandimport.py", line 47, in _load
mod = _origimport(head, globals, locals)
File "/Library/Python/2.5/site-packages/mercurial/util.py", line 93, in
_encoding = locale.getlocale()[1]
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/locale.py", line 460, in getlocale
return _parse_localename(localename)
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/locale.py", line 373, in _parse_localename
raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8

Yes, because it is Terminal.app, it is not XTerm. Apple had a years to add Spotlight, but had zero time to fix a bug, that is for years around: bad locale handling. To fix the bones, add into .profile this explicitly:


export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

...or foo_BAR about your other locale.

Ad on my GMail

Today I've checked my e-mail on GMail account and found this ad:
Great. Soon there probably will be something like a "Crack Adobe Photoshop just for 90 days joining our adult site!" or just a trivial classic? Well, Google is just for indexing any kind of content, after all...

Friday, March 13, 2009

Google Chrome or "We will get it right in a third version"

Chrome versus Browsers
Testing some software on MS Windows that is installed on my VirtualBox (of course), I've remembered about Google Chrome existence. I had no much chance to take a look at it earlier, but now I just wanted to see how this, supposed to be GUI-breathtaking innovative browser ever, fits in a real life. Obviously, Firefox is not any GUI-fanciness opponent as it's user interface always wants to be much better and, recently, rendering engine needs to be much better as well. Therefore I tried to see what I would love more: Chrome for my Mac (does not exists yet, but lots of dust and rumors around) or stick to Safari 4?

Global Menu
Apple has menu all the time at top of the screen, so you just "forgetting" about it and never pay attention much, thus can focus on your application. Now both, MS and Google, recognized that embedding menu bar into an application is ugly and annoying, after all. MS removed menu in IE8, making users puzzled finding all the settings. By the way, after long bloody battle with Gnome guys that mostly does not realizes it, finally happy Ubuntu users may try unstable alpha version in Gnome Tweaks but it does not works yet right for everything. KDE guys, however, successfully copied this feature from Apple long time ago.

So, no menus in Chrome too. At all. If you had installed Chrome: forget about menus. Wait, they are, but hidden...

Categories. No, sections. Well, never mind...
Google made it simpler (they think so): in a Chrome they put all the menu under one button, with an "Document" icon. Wait... under two buttons — other for settings and preferences.

So to open new tab, you click "Documents" and... and find there is no such item to create new tab! Ah, it is under icon with a monkey wrench, that represents "Settings". Oops, these actually are not really just a settings, but a pile of "everything else" that does not fits elsewhere.

I guess, third button is probably still coming in a next version, once Chrome will get some more features? Which icon it will be?.. A hammer?..

Where are my windows?
You have tabs for your websites. However, you have also a separate windows. You make a window and fill it in with a similar content. For example, I have 10 tabs in my window that are related to C++ documentation. Another window is for my pr0n social networking. Yet another is to something else, etc. Now, how I can easily switch between them by one click, selecting exactly what I need, without looking at WinXP's dock?

Maybe useful preferences
Let's see the preferences. It is common that in MS Windows you should mostly use mouse to find them, no short-cut available. But it is fair enough: click wrench and here they are. So what we see there? One picture is worth 128K words (I have Firefox, Opera and MSIE installed already):

WTF? Who the hell asked you to make a Chrome as a default browser?!! This is quite opposite to Safari (Google, do you see the combo box?):
I am in Japan, so when I search, Google is trying to show its smartness and forwards me to google.co.jp, searching over Japanese content. OK, I go to Google, set "Google in English" with a hope Chrome will remember cookie or so. No, it won't: search still searches over Japanese Google. OK, I click on a wrench, open Options, on "Default Search" I click "Manage", change Keyword "google.co.jp" to "google.com". Save. Now it should search in English, right? NO! It still searches over Japanese content! Well, I am OK to go to just google.com and just search it there as it is in a traditional way — that works fine...

And by the way, how to turn off Java applets in a Chrome that makes me full-screen-always-on-top-and-undecorated canvas that is impossible to close, then shows me an advertisement?..

Tabs
When you have them like a five or two, you can say they are just awesome. But let's look what happens in a real life:
Can you spot where is an Apple Store and do not mix it with Apple Developers community right away, just without using a magic crystal ball?.. Maybe Sergey Brinn and a Sauron from The Lord Of The Rings story can. But I can not. Hey, but how about Apple's way instead?

JavaScript and all the Ajax hype
I am definitely not a fan of Ajax. However, Google folks are. That's OK, God bless them. Wait, but what's this?
How this released thing suppose to bring "best Ajax experience" to user's desktop? Wait, how about this Beta instead?

Conclusion
Think different?! I'd be happy if most people would just think. What I really respect Apple for: they release only what they really had thinking through. I wish we have much more companies around like them.

So... My request to dear Google is to do not bring your shoddy work to Mac unless it is really worth to look at and unless it is at least equal to previous Safari 3 by usability.

*Please*

Java Swing: Rounded Corner Rectangle

I've decided to make labels small and standard, as in OS X. Well, hands down: drawing things right on 2D canvas still bad, e.g. rounded corners rectangle looks like an array of random pixels around. Here is how it looks like:



Too bad. I dislike it... Therefore I used raster instead and I've got very clean visuality. Here you go:

P.S. Oops, alpha is wrong, label is too dark as should be. :-)

Thursday, March 12, 2009

Carousel for UI: Pros and Cons

I've played around with Swing 2D a little bit. Then I thought: OK, if images can be viewed in carousel, maybe it is good idea to show running applications? Like a shrink to thumbnails and show as minimized windows, sort of a'la OS X exposé? Here is how this thing looks like:

Yup, it works: you click on any other window that is not in a center or use arrow keys "←" or "→" and you move to another one.

Used as a dashboard. Completely bad idea, probably. It looks like "Wow!!" to user, however after 3 minutes user realizes it is a pain to use, because what he is suppose to see right away in front of his eyes is actually covered. Dashboard supposed to show you information right in a moment you spot it.

Used as a menu. Only for stuff, like Apple TV. I've built one for myself, using Freevo at my home, getting a cheap-small-macmini-like PC and putting it behind my TV. For such sort of software, where user wants to relax and see fancy transitions on a very big screen with five menu items — this is a good choice to use carousel view.

Used for multimedia. Well, Apple did that in iTunes and iPods. Me — shrugs. I don't use it and none of my friends I know. Somebody might like to grep over a pile of album cover pages and visually trying to catch one like "Yeah! That's it!". But I prefer have a convenient powerful search instead, typing: "Met<ENTER>" and get for me "Metallica" playing right now.

For something else? Maybe could be done as miniature composition for a minimized windows, like OS X stacks or something. But still it looks ugly, frankly. Because these windows will never be fixed WxH pixels, and thus will never look slick in this way...

Where to put this to make it really useful for people? I have to think more, seems like... :-)

Tuesday, March 10, 2009

Bastardizing Java Swing on OSX

Everybody knows: Java Swing on Apple OS X is in a stone age times and looks still ugly enough even on co-called native look and feel (do not mention Metal, please, I am drinking coffee now). Not just that, but Apple also playing quite funky games, screwing LaF all around. So what is OK for Java 5, is not really OK for Java 6. I even frozen to think what is coming with Java 7...

Recent development version of NetBeans 6.7 has better look and feel on OSX. But if you take a look more closely, you will find it is still far away from what should be actually done.

I've tried myself to play with it. Again, Swing by architecture outperforms SWT, that is still (and probably forever) is using Carbon, instead Cocoa. But that's very bad news to those, who is using it: Carbon probably gone in Snow Leopard. Swing, on the other hand, has a destiny to be permanently fake maker, drawing everything by itself.

Well, anyway. Focused and passive window looks like this for me in Java 5 and Java 6 for Leopard — notice also a scrollbar... :-)

Cool? No! I am actually very disappointed by... Apple. They're completely screwed Java 6 made it even worse than Java 5 (maybe because Java 6 was entirely handled by Apple?). Apple should push Java in front as a flagship product, but they're stick to Objective C, unfortunately (who the hell needs it on OpenBSD, for example?).

On one hand, the future of Java on Apple (and not only), however, is not that much dark anymore: it is at least open source (kudos to Sun). On the other hand, knowing how open source bazaar applies to projects — that's why X11 still sucks on desktops big time, no matter what you use there: KDE or GNOME (GUI No One Might Enjoy)...

Will see and contribute, right? :-)

Monday, March 09, 2009

NetBeans as a platform for software

I've just bit played with a NetBeans as a platform for my own plugins, created some and see how it works. I'd say, quite nice stuff, technically way better than Eclipse and overall impression is pleasant. You could use it for various desktop stuff, especially if you need IDE-like software and it is now. For example, if you want some management or monitoring system for enterprises that looks for doing business (read: looks damn ugly). Mostly it is very cool if you want to extend your system with various plugins etc. E.g. have UML modeling, but also have your own workflow builder etc.

However, if you ask me about software art or something serious, I would tell you that I would not use it for my projects (although I seriously considered NetBeans once).

Why?
  • It is too much "IDE-ish". Even an attempt to "make it right" as Blue Marine project [1] still contains too vivid smell of plugin-based platform. To get rid of it smell you need to remove a lot of things. It will suck more blood from your body that you just do it all yourself from the scratch.
  • Too heavy for JNLP. Even with one single "Hello World" plugin — almost 20MB.
  • You need do unnecessary wrapper-works and other hacks-n-tricks in order to use Swing-X components. Why?..
  • I don't like its Plugin Manager from user point of view (nothing wrong with it itself — works perfectly).
  • Plugin mechanism is too heavy and can be simplified to much lighter incarnation. It gets better, but still there is way too much XML.
Personally, I vote for minimalism or, if possible, extreme minimalism. I love to remove everything, unless it is just impossible remove everything else. With NetBeans, still, you have some persistent bits that I would love get rid of it for ever.

One curious thing: an author of Blue Marine complained that first attempt was actually done on a solution from scratch and he was completely unhappy with it, therefore he revealed NetBeans for himself. In fact, I am opposite... — the World is that different! :-)

_______________
1. Frankly, I have just zero idea who needs this thing on Windows with Google Picasa, on Mac with iPhoto and on Linux with F-Spot... Well, but anyway somebody has a fun, right?

Sunday, March 08, 2009

Usability From Redmond

I've just installed Microsoft Vista (fouling my holy CV) to make sure Java Swing GUI looks nearly as close as possible to this taste-less Mac OS X cloning failure. OK, one thing makes me happy: it is a virtual machine (easier to delete it all).

One moment that gave me good laugh how these M$ folks are trying to think about usability. OK, I do not need those ritzy widgets, maybe I even do not need anymore that quite big ribbon at the right side that serves them. So what I did: tried to close by clicking either "->" button or just dragging it away. Right?..

Wrong! Vista "knows better". They probably spent one more million dollars on a research how to handle what user wants to do and then suggest "right way". In my case, Vista asked: "Do you want to close side-bar?" — and offered me a "right way" how to do that. Of course, it is Microsoft way: you need to right-click on it, select an item from menu "Close side-bar" that is messed up with other items barely readable small font and then get a confirmation bubble that side-bar is closed.

Brain dead. Just brain dead. You've got it, Redmond, as you deserve the most: brain dead.

Friday, March 06, 2009

OpenSolaris 2008.11 on Virtual Box

I've just installed OpenSolaris (AKA "Slowlaris") on my new MacBook, using VirtualBox (screw you, VmWare!).

Overall, everything fubar, exactly as expected: now it finally boots from GRUB and does not hangs as before, trying to use AMD on Core Duo; network is OK and won't suck anymore, as it did in "Nevada" build; video barely works in a simple mode and VBox Additions won't help you out of the box.

To fix video working full-screen and seamless mode, it is needed to be manually fixed, by simply removing away all of those display resolution modes from /etc/X11/xorg.conf file and also setting up virtual machine with 64Mb of video memory.

Second step is audio that won't work anyway anywhere, unless you manually debug it again (as described above). First, throw away slim_install package, a waste of space dependency that keeps root of all evil: SUNWaudiohd package. After those two gone, get OSS driver for Slowlaris and install it (pkgadd -d package-file.pkg):
Open Sound System installation complete
You can use osstest command to test audio playback in your system.
It may be necessary to reboot the system before all devices get properly detected by the system.
Installation of OSS was successful.
Damn great! Unix follows now the most popular trends, exactly like in good-old WinNT times: install a driver, reboot the system...

P.S. Sound still sucks on Solaris big time and also randomly crashes (/usr/sbin/soundoff and /usr/sbin/soundon cures current random crash). Well, never mind, I don't need sound during packaging software and, besides, I use iTunes on my Mac anyway... :-)

Tuesday, March 03, 2009

Swing and Hibernate (feedback)

I've found an example how to use Hibernate in Swing.

Not to mention weird existence of HQL entity in general, you have to use it for the very trivial SQL request. Why?.. Oh, that's a "short-cut" to automatically generate very inefficient and wrong SQL query, I see.

You also need a pile of XML to configure your ORM. Then you need another pile of XML to map your database stuff to the objects through these entities. Ah, right, you also need those excellent entities themselves just to hard-design your application, thus making it rock-stubborn against any minimum changes, removing any possible flexibility without whole recoding and recompilation. After all at the end, you also need to hard-code your QUERIES_BASED_ON_VARIOUS_CRITERIA (look at the code in the example to understand what I am talking about).

*Sigh*... It is just all pathetic... Disappoints even more, than that anyone could expect. Hey, folks, wake up! ORM supposed to make life easier, not harder!.. Therefore, if ORM concept does not makes your life any easier but generates a mess of general hodgepodge, maybe quite correct logical conclusion would be to do not use it at all?

Legacy databases solves legacy problems. We need new databases and new approach to the data management. Thus having it simple and understandable: keep sets away from objects.

Moral: Keep it simple, stupid.

Monday, February 16, 2009

Java + Groovy

If you do not need a blazing rocket-science performance, but just need to toss up some prototype or even production software in Java platform, but you really-really-really do not waste time on Java language verbosity, you may consider using Groovy as a dynamic language extension to the Java platform.

Let's do something silly, but to see how the things are interacting between each other. For example, let's read our "/etc/passwd" into a list and display a first element of it from a plain Java, omitting an empty lines and/or commented ones. :-) Here how it is done in NetBeans IDE:
  1. Make sure Groovy support is in your NetBeans 6+. Usually it is there out of the box, but maybe some plugins must be installed. Check it by Plugin Manager, navigating to "Menu→Tools→Plugins" and see maybe you need some tweaks in Preferences for Groovy specifically.
  2. Create new Java Application project. Let's call it "JavaAndGroovy".
  3. In your package, called now "javaandgroovy" create a Groovy Class. Since it is an example, let's call it "Grovample".
Great. Now is a time to read the file with one codeline, as a text and return a list of the lines. Here you go:
package javaandgroovy

class Grovample {
def readfile(filename) {
List data = []
for (line in new File(filename).readLines()) {
line = line.trim()
if (line && !line.startsWith("#")) {
data.add(line)
}
}

return data
}
}
Now, to use this class in the plain Java, just... use this class! Like this:
package javaandgroovy;
import java.util.List;

public class Main {
public static void main(String[] args) {
List passwd= (List) new Grovample().readfile("/etc/passwd");
System.out.println("Lines: " + passwd.size());
if (passwd.size() > 0) {
System.out.println("First line: \n" + passwd.get(0));
} else {
System.err.println("Well, you're on Windows. :-P");
}
}
}
As a result, I am getting the following output:
Lines: 40
First line:
nobody:*:-2:-2:Unprivileged User:/var/empty:/usr/bin/false
Now, let's look how the distribution looks like. Press "Clean and Build" button or simply navigate to your project directory in the terminal and run "ant" command. In a "dist" subdirectory, here is the following tree:
.
./JavaAndGroovy.jar
./lib
./lib/groovy-all.jar
./README.TXT
File "groovy-all.jar" has a weight of 2.7Mb. Not so small for very tiny apps, but not so big for bigger ones. You might consider put this lib in your GlassFish somewhere, in order to do not deploy it every time with your WAR/EAR. :-)

Keep in mind: Groovy is significantly slower than plain Java. Really slow. Check out it how much slower. Still, it does not means that we can not use Groovy for many-many tasks around and simplify our Java code.

Happy Grooving! :-)

Sunday, January 25, 2009

Beast 666


Beast 666, originally uploaded by I.S.B.M..

In this Sunday, on a street I saw very weird car, made out of various different parts. That's was a real beast! :-)

Wednesday, January 21, 2009

Why Ajax is evil

"Ajax or not Ajax?"

Making my yet another Swing app on Java, I've been thinking on an answer to a question:

Honestly, what the hell Ajax thing is so special, so many people
are rushing in to use it just right everywhere?

So much time went away since ESR wrote his excellent "HTML Hell" page. I am just wondering who is reading this?..

I found this Ajax thing is not just mostly bad idea, but actually it is that evil. To the company of public resources it is not yet that much harmful, but for the enterprise it is. Because it simply has no future, whilst your enterprise is already poisoned by this stuff, probably. Hence you have to support it or spend some more money to rewrite your project. Here a list of main issues (too lazy to write much):
  • There is no real integration with a desktop, but through a web browser. Hence, your application acquires all the limitations.
  • While Ajax website is more fun to use, yet you're nearly have to pray for your browser worked properly with a particular website.
  • Issues with off-line and on-line modes. To write entire application in a JavaScript that sits in a memory of the browser is not really a thing you want to go.
  • Your browser is not working as designed: history issues, refresh will destroy everything etc. Of course, there are (expensive) workarounds to avoid state loss on refresh, but history won't work anyway.
  • Google won't index your website much, once your HTML has nearly one tag, like: <script>EntireWebsite.build()</script>
  • There are no real widgets, except standard HTML ones. There is an emulation of such.
  • It suppose to deliver only an user interface. However, in practice it often takes place much wider scope, thus interfere with other paradigms.
  • Quirky, full of hacks and tricks JavaScript code and CSS stylesheets. Once browser's vendor changes something that breaks your page, you have to fix it.
  • It is very expensive ("time" equals "money", you know) because of its heterogeneity. Typical Ajax application is a hodgepodge of various stuff: XML, CSS, HTML, JavaScript and a thing on a server-side (call it yourself: Java, Python, PHP, Ruby... whatever).
But the main issue with Ajax is:

There are NO standards!

Very "good" at enterprises, right? You might say: there IS a standard specs: ECMA Script, CSS, XHTML etc. Yes. You're completely right till the point of... different browsers differently spits on those specs. Look at the reality: today we have 21th century, while the best open source browser (Firefox) can not hit even 80% of Acid 3 test! What browser is the most popular at a regular Windows box and how much percents this thing can hit of Acid 3 test?..

When you select a technology for your online perfume shop, then maybe you have to think how often your site random people are going to use. At that time Ajax DHTML stuff with plain alternative would be OK. However, if it is an enterprise under controlled network, I doubt any browser is the best Virtual Machine for scripting.

The future is quite different. If you increment that O'Reilly's buzzword one more time up to "Web 3.0", you will find that there is just no Ajax. There is JavaFX. There is Java Swing and a Java Web Start. There is Adobe Air and all the rest of Adobe multimedia streaming magic. There is even Microsoft Silverlight that works pretty well. But there are no Ajax...

If tomorrow there is no Ajax, maybe you should not bother much with it, but go to the next level? Thus, before you rush to follow everybody's hype and bubble just "to be as everybody else", better really think about it twice. Or more.

"I hate what you just saying, it's all lame!"

OK, dear social networker, to raise a finger on a problem is not a big deal, I agree with that. Thus some solution should be proposed. I could drop you a few lines why I would choose Java Swing + web services versus Ajax stuff at enterprise. As well as why I would choose JavaFX, if I need funky RIA for fun. Keep in mind for yet your perfume shop can be just as damn great without any Ajax thing, you know... — simply look at Amazon.com and take it as an example for yourself. :-)

Here you go:
  1. You anyway want to go SOA, no matter what type of UI you have in a front.
  2. Java Swing has a rock solid internal standards and runs identically on various platforms.
  3. Swing is homogeneous. Your employees can be specific to Java only and do not need to know a mixture of various stuff and be proficient in each.
  4. You can make whatever hell widgets you want with any possible shapes and behaviour, because the whole thing is just a plain canvas, that simply listens to input events, after all.
  5. You can use only Ruby or only Python as well (JRuby or Jython), if you really like to do so.
  6. You can create Swing GUI literally in minutes in front of your customer's or manager's eyes, using NetBeans and Matisse editor.
  7. You still have clear MVC and you distinguish what is business data, and what is just a way to deliver it to user.
  8. You have clear desktop integration.
  9. Your internal company network is highly controlled, so you do not need to worry something is randomly missing on random machines (otherwise fire your system administrators ASAP because they are just morons).
  10. ...I can continue this list till you fall asleep. :-)


If I would have say what is the future of Ajax, then I would say:
Ajax is a very expensive way to pimp your business network resource and this way of data delivery will eventually die on web applications market.

Have a fun!

Thursday, January 15, 2009

Me on Architects




“Trust me that looks good, I'm an architect!!!”

— Any pretentious architect, or any for that matter




I've been often asked very stupid strange question:

"Should architects write a code?"


Should father take care of his child as deeply as possible? Should surgeons operate? Should Rudolf Christian Karl Diesel be aware of principles of physics for analysis, design, manufacturing, and maintenance of his great engine?

Let me tell you something here. See, in IT world, actually, there is no such thing as "architect". There are software engineers. Some of them are so serious about software, that they're building their own hardware.

So what does they do? They do know what to expect from some certain hardware. They do also know how their and related software works and what to expect. They also do everything actually, hands on. Just close your eyes and imagine a senior architect of any (nuclear) submarine, just has no idea about very details in the machine room or navigation system and does not getting how it all works, what to expect from certain modules and what these little things does in different places inside the submarine. Remembering that everybody else will simply follow the instructions of such senior architect, how far this submarine will go, you think?..

However, all times in IT there are plenty of parasites like in my example above. Typically, they are heatseekers and speaks damn really a lot of buzzwords or (recently) simply abbreviations (often they turn to change a topic, if you ask about one some specific details). Since they say a bunch of cryptic words, everybody else thinks: "Oh, he is a God!". No, he is not. Not at all.

They mostly spending their time on (useless) meetings, making them as long as possible and as much as they can per a day: to blah-blah-blah is much easier than type-type-type-compile. Instead to code, they do prefer to draw boxes and join them with arrows in some drawing software or (better) on a board in front of those, who thinks he/she is a God. On top of this, they mostly have zero of real hands on experience. More advanced parasites can work only on prototypes and usually they deadly sticking exclusively to one single technology, making no steps forward to look around. One will bluntly repeat you: "Perl! Perl! Perl! Perl! Perl!", another: "Java! Java! Java! Java! Java!", yet another: ".Net! .Net! .Net! .Net! .Net!" and so on and so forth.

In real life, especially when company is big, they will avoid any real full-scale coding participation, but will switch to paperwork and e-mail broadcasting. More advanced will try to give a born to simply CGI scripts or similar prototyping.

Why it happens so? Obviously, because they are too dumb to learn something new, hence they do have ZERO CLUE what is going around and how industry is trying to break the walls. Thus they do not know current problems and are not passionate to SOLVE them once and forever, simply because they are not really a geeks. Therefore, as a consequence, only what they can do apart of saying abstract incomplete "just ideas", they WILL do dirty politics things, disturb real engineers with brain-less directives and environment changes, will go write [useless] documents with a stupid injunctions, make moronic rules, release crazy instructions, do not care about company, but simply suck money as much as possible, fill their LinkedIn.com profile with best recommendations from their friends they drinking with and then disappear, moving to another victim company.

But the company will continue to live with completely brainless bullshit solutions that are quite useless or in real full-scale enterprise. So if you are employer and someone call himself/herself "trained architect" and "prefer to design, rather to implement" — simply avoid such candidate as soon as you can, no matter what his BranBench results and a bunch of other certificates/diplomas says.

Shortly: either you provide or you are politician.

Have a good day!

Wednesday, January 14, 2009

X11 + Gnome with Bugs = Kick For Innovation (Part 2)

Running Linux Mint on xVM. Uhmm... Not that bad anymore as it was before!


Still window borders and bluish title bar on a standard JInternalFrame looks very bad (in my opinion), but this is not really what user will pay attention at. The only one thing left: remove Java logo icon on the left side of title bar.

Ah, and I've added fade-in and fade-out effects when my modded window appears and/or disappears. Not really important, but just feels more smooth.

Update: I had to go across the code a bit to make sure now it works as should be on Slowlaris (2008.11, running on the same xVM). Nimbus default theme from Gnome looks pretty clear and not that bad. Default Java 6, Update 10 is a pleasant thing. Yet I am not getting why there on JInternalFrame that small Java logo is rendered *twice* on a title bar: once crappy, with extra-garbage pixels (on left) and once pretty good, near the title actually. Well, probably must be a Sun advertisement of their flagship trend...

Here how it looks like (no change much from previous shot above):



P.S. Damn, anybody wants to make it works on Windows?... :-(

X11 + Gnome with Bugs = Kick For Innovation

In my Java-based backup software that I am working on now, in the GUI (Swing) I have to pop-up a history of a file that has to be restored. Everything should be very simple: you click on an icon of the file you want to restore, pop-up with a table appears. Then you select the date you need and this little window disappears, file gets restored.

Window originally was implemented as typical JFrame, undecorated, always on top. Works fine on Mac OS X with native LaF (of course! who wants that fugly Java Metal LaF to see!?).

But when it comes to X11 and Gnome... :-( For some reason "always on top" gets to be "always on bottom" or "always depends on Moon phase and Solar interference with UPS". If I call it "window.toFront()" it takes only once-per-entire-software-session, and then gets down again. To fix the thing, I had switched to JInternalFrame. But then I found that native GTK look and feel looks acceptable only on Mac OS X with native LaF or Quaqua.

But on typical Gnome, JInternalFrame looks just that nasty and horrible on several want-to-be-default themes, especially on Linux Mint and Linux Ubuntu. Borders are mangled and of course there is no shadow at all. Title bar of the window on some themes is one pixel narrower than entire window (or sometimes one pixel wider that makes entire border make a vertical gap per window). Dragging performance is usually crappy and slow, especially on Mac OS X.

Trying on OpenSolaris's default theme that looks like new Nimbus theme, overall impression is also could be quite better. Additionally, I've got some very strange errors, when I am adding a reference of the window to current working space.

Rule: if you are GUI designer/programmer, you are responsible for each pixel user see.

Change native LaF and go with Metal is "No-no-no, hell, no-no-no-no-no!!". The people, who was made Metal LaF has no taste, no understanding what style is, no feeling of beauty, use always an axe even to cut an orange and probably it's graphical design was made by a programmer at Sun that was working for Microsoft before... I've decided to make my own hack and here how it looks like (same everywhere):


It is completely glassy, translucent and smooth. I think, it looks much better, performs really fast and has no nasty bugs I faced before.

Great, time to go to sleep finally. :-)

Tuesday, January 06, 2009

Tokyo Winter


Tokyo Winter, originally uploaded by I.S.B.M..

I took this picture near my house right before New Year eve. Duh, no snow, no any feeling of a Christmas Tree and New Year celebration. And 16+ C temperature outside.

But isn't it great? :-)

Java and daemons

I have to say for Java is pretty much OK for daemons, if you want same daemon to be cross-platform out of the box and you do not mind a thing is eating like 30M of RAM or bit more. It is possible to achieve it, once some certain rules are kept strict. You have to remember: you will get entire Java VM instance for your daemon. Therefore before you go to this area, think twice: maybe C or C++ or even Digital Mars D are much better language choices for you?

You might want Java daemons in sort of cases, like:
  • You want to connect to RDBMS, but you can not use ODBC for some reasons or it is just impossible to install client on current OS. For example, you have OpenBSD but need to connect to Oracle. JDBC would work here just perfect. You will not get HotSpot on OpenBSD, but yet you can use Kaffe VM or Cacao VM or JamVM and GNU/Classpath. I tried them all, works almost great, but JamVM is just really meant to be small for embedded devices, hence performance is not that really great.
  • You have something very special inside and do not want to waste time porting your daemon separately to Solaris, to Mac OS X, to Linux, to IRIX, to AIX, to HP UX, to FreeBSD etc.
  • You do not want to waste your time banging your head into the wall, coding with C++, because you realized that library you need either does not exists yet and you have to DIY it or just very bad and you need make it good yourself, before you write your desired daemon.
  • etc.

Your daemon must be really small, simple and clean at implementation. To get that, you definitely have to throw away mostly all Java crappy design patterns. They sucks anyway. Forget about those stupid adapters, bridges, factories and other layered crap, but just do directly what you have to and think like you're coding almost in plain C.

Since Java sucks hard at system programming, because it's VM is almost like an OS itself, there is no such things as .fork(), unfortunately. Therefore, for plain Unix you might use init.d, using shell script with regular running in background task technique would do the trick. For Mac OS X you definitely want to use launchd and it is opposite: your script should not detach, otherwise launchd will think your daemon is dead. For Windows... well, there is daemon stuff from Apache Commons. They also have wrapper for Java on Linux, but as much as I tried, it works horrible and unstable, in my opinion. Additionally, you want to read this article.

The Windows thing... Well, honestly I dunno much what else you can use for Windows, since I am not big fan of this strange OS and have no one around: my servers are all Unix and for desktop I still prefer Mac. But there are must be some wrappers, registry keys for automatically booting it up on start-up or so and other things though...

Happy coding! :-)

Monday, January 05, 2009

Embedded Databases in Java

As I am developing "Better Time Machine :-) ©", I am looking for various embedded databases. Each database has good and bad sides. I even tried JDBM (ripped off from W3C Jigsaw and bit fixed inside — it is just few classes). All I need is very fast and embeddable engine (means, very small at footprint and memory consumption).

Here is a list of what I've tried (since software is written in Java, so I tried pure 100% Java solutions):
  • Apache Derby (AKA JavaDB)
  • Oracle Berkeley DB for Java
  • db4o for Java (sort of ZODB for Python, but much better)
  • W3C JDBM (ripped off from Jigsaw)
  • Some JNI wrappers around GDBM (JDBM and JavaDBM).
  • HSQLDB
  • H2
So shortly, you want to play with these rubber toys only in the case when your database is no more than just a storage for reasonable amount of data that is used by desktop application or a daemon or a server software (here be careful with concurrent access for write). In any other situation, you definitely want to go with a solid server database solution. Use PostgreSQL if you want good stuff for free, MySQL if you want to screw yourself or Oracle if you can buy.

If you want objects, use db4o. Very neat database. But footprint is not any small: about 30M. Think about it. You can also go with W3C JDBM, store entry key as a string and entire object as a byte array of serialized object. Crappy, but works well in some certain cases, if you do not need funky searches (otherwise go back to db4o).

If you want embedded SQL, then definitely H2. It is RDBMS from the same author of HSQLDB, just simply faster and better. It has lots of features and very nicely coded. Performance is very high, it supports very large databases, in-memory databases and works in server mode. Footprint is very small and it is 100% pure Java open source software. It also supports ORMs, if you need this thing. But I am not sure how you could install 120M of ORM, then make cumbersome XML mappings, then use weird HQL (as for Hibernate, for example) and stay happy because your database engine footprint is just 500K library... Go real stuff: use plain JDBC with few more codelines and plain SQL that you can write best! It will reduce size of your application hundred times and increase performance at least as twice, no mention perfect maintainability of code, since it is small, easy, simple and very well understandable to anybody.

Apache Derby is the last thing you need. It is actually IBM Cloudscape, if you remember one. Amount of bugs is so big and it coded so nasty, that to open source and change its name is the only way to hope someone will use it. At performance it is slowest and footprint is twice bigger than H2. Additionally, database might get easily corrupted or just suddenly stop booting. Apache Derby is "No Go" for you and you want to avoid it.

Happy New Year! :)

Update: Hooray, I have an alpha version of my "Better Time Machine © :-)" working! And it works really amazing for me: saves disk space, fast, customizable, yet very simple in use. I am going to put it on public domain, once I am sure it will not break your backups. :-)

Some more update: db4o is not 30Mb footprint, sorry. So do not think about it. :-)

Friday, January 02, 2009

Better Time Machine

I was very upset by an Apple Time Machine. Looks like Apple has no idea how to be loser-friendly. Suppose, you have a Mac and all your data Time Machine put in your external USB hard drive. Now your Mac is very dead. What you suppose to do with your hard drive?.. Your friend with Windows will not be able to read the drive. Your another friend with OpenSolaris installed with shrug and ask "You want me format this thing?". Well, yes, you can mount HFS+ in Linux if support of this file system is in certain distribution or if you install MacDrive third-party software on Windows. After that you will find something very same what rsnapshot does for years to everyone over the world. That's great, but still: how to backup my Linux desktop? How about those, who on Windows? — see, rsync is not very good idea and is not meant to work on Windows, although there is cwRsync thing.

The whole idea of backups is to restore your data AS SOON AS POSSIBLE WITH ANY DEVICE YOU HAVE. It might be Nokia Tablet or that useless Asus Eee PC with custom Linux or very limited Windows XP inside, it might be an OpenSolaris laptop (hell, why not?) etc.

So when I wanted to setup some backup solution for my heterogeneous desktops at my home to make same backups to one standard place, I did not find anything good on freshmeat.net and sourceforge.net as well. These things are usually too complicated and over-engineered or they're just closed source freeware with free licence. To buy a proprietary software by a geek with more than 10 computers at home?.. WTF?..

Shortly, it took for me 5 hours to write a core for my own thing, like Apple Time Machine, from very scratch. It supports any sort of Network Attached Storages without any nasty hacks (iTimeMachine comes in mind) as well as support flash memory cards, USB drives etc. It supports anything anywhere, because it is, simply saying, stores files into a folder you choose. Simply mount your writable share (or "map to a drive" in windozers language) and point software to it.

Backups are just regular ZIP files. Every more-less useful OS has unzip thing, even already dead BeOS or not-yet-born Haiku OS. So as long as you've mounted your drive or flash card to any device (let's say it is FAT32, readable by mostly everything on this planet), you're completely safe to read it by something else at any time with standard tools.

To save your space in storage, it makes incremental backups, of course. First time it makes full backup, storing everything to ZIP file. Compression is optional, but preferred to save your disk space, since smallest ZIP file with few bytes file inside takes nearly 4Kb. However, you may turn compression off, in the case if your machine does not really likes CPU load and you want just to store your files in one file, like a Tar. Again, on my MacBook 2.16GHz Intel Core 2 Duo it performs very nice with full compression and saves lots of space (unlike Apple Time Machine). Next backups contains only new or changed files. To restore all your environment, once your Mac died and you have none of pimp GUI, just simply unzip base ZIP file, then take latest update ZIP file and unzip on top of it, overwriting previous files from base ZIP. You're done!

I am going to put GUI on top of it and make it more fancy and easy to use for users. Basically, it will ask you what to backup where and that's pretty it. Everything else it will decide by itself automatically. To restore files, users will see something very similar to Mac OS X Finder and simply point to the missing file. I do not have finished concept of the GUI for file restore, but I want to do it very intuitive and simple.

Since all stuff is written in Java, it is already working on Linux, Windows and OpenSolaris as well. So for those, who needs personal backup system on other desktop — this stuff might be useful. I am going to keep it very tiny, throwing all the bloatware, that is very typical for Java programs. Will see what we will get finally... :-)

Ugghh... Apple... :-(