mike.williamson

Editing JNLP files – gotcha!

Posted by: mikewilliamson on: January 16, 2010

I have been playing with some JavaFX stuff for a little while now and finally gotten to the point where I am trying to deploy my first program. I was a little naive inn thinking this was going to be an easy process and have been forced to have a good hard look at jnlp files. It turns out that most of your apps deployment options are controlled by editing the XML in that file. After a little reading about the different fields I set to tweaking them to see if I could get the effect I was looking for. After making my changes I crossed my fingers and relaunched my app.

No change.

Check my syntax,

No change.

Try some variations.

No change.

No change.

No change.

Try to effect any change whatsoever by editing fields I know are working like <vendor>Mike Williamson</vendor>.

No change.

A little poking around reveals that Java is thoughtfully caching the jnlp file and has been totally ignoring all my changes since the first time I loaded the app. Thanks Java. I’ll appreciate that someday.

Under windows go to Control Panel > Programs and open the java control panel. Under Temporary Files settings click “delete files” as shown below and suddenly everything works. Yay!

clearing-java-cache

Setting up terminal windows for Rails development

Posted by: mikewilliamson on: December 18, 2009

Even though Netbeans make things like the Rails development log and the database connections pretty easy to get to, I still have a pretty strong preference for the command line. When I am coding I almost always have a few terminal windows open and stretched nice and big; generally one for mysql, one for the Rails development log and often a third for the Rails console in case I want to experiment with the code I am writing.

The down side to this set up is just that; the set up. Every day I type in the same stuff… mysql -u root blah blah blah.

So last night, after an ill advised post dinner coffee, I set about scripting my morning Rails ritual and on the way learned a bunch about the terminal.

Gnome terminal is the proper name for the program that resides under Applications > Accessories > Terminal. A quick look at the man pages give a pretty nice set of options to play with but I found they required a bit of trial and error to get right.

Cut and paste the ones you want into custom launchers.

Launching Mysql and getting a prompt on a specified database:

gnome-terminal  -e “mysql -u root -ppassword -D myapp_development”

Thats no typo! There can’t be any space between the -p option above and the actual password!

Launching a window with the Rails development log (with a specified Rail environment):

gnome-terminal  –working-directory=/home/mike/projects/myapp -e “script/server -e mikes”

That one is great for me because I am rapidly becoming sick of typing in stuff for custom Rails environments. Now I don’t need to!

Those are pretty fun, but the ultimate in convenience for me would be to have a single tabbed terminal window with everything. So why not combine the two into a single command?

gnome-terminal –geometry=174×46+50+50 –tab-with-profile=Default –title=”Mysql” -e “mysql -u root -ppassword -D myapp_development” –tab-with-profile=Default –working-directory=/home/mike/projects/myapp –title=”Server” -e “script/server -e mikes” –tab-with-profile=Default –working-directory=/home/mike/projects/myapp –title=”Console” -e “script/console mikes”

This is a doozie but it means that my whole morning Rails set up ritual has been reduced to a single click on a launcher. Sweet!

Missing images in JavaFX on Ubuntu Karmic

Posted by: mikewilliamson on: December 10, 2009

Last weekend was spent installing Ubuntu Karmic on my laptop. Because of all the programming stuff I am working on it just made sense even though I am already missing a few of my favourite Windows programs. As soon as I got Netbeans set up I tried running a JavaFX application I had been working on. The stage icons and the images I had loaded in were nowhere to be seen. I gave this a few days to percolate and sat down this evening to sort it out. I started out thinking that it might be a problem with the file paths being different on *nix but a little experimentation showed that paths were not the problem. It took a little reading before I got a reminder; Sun is not the default JVM on Ubuntu! Grrrr.

After switching to Sun Java away from Open-JDK all my images and stage icons were loading happily and my JavaFX app runs just like it did on Windows. Here is the command:

mike@sleepycat:~$ sudo update-alternatives –config java
There are 2 choices for the alternative java (providing /usr/bin/java).

Selection    Path                                      Priority   Status
————————————————————
* 0            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      auto mode
1            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      manual mode
2            /usr/lib/jvm/java-6-sun/jre/bin/java       63        manual mode

Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/java-6-sun/jre/bin/java to provide /usr/bin/java (java) in manual mode.

Google Chrome on Ubuntu Karmic x64

Posted by: mikewilliamson on: December 6, 2009

Wow its fast.

You can download the deb from here:

It will add the Chromium repository to your software sources automatically as well.

Mysql tables – calculating size on disk.

Posted by: mikewilliamson on: November 27, 2009

Today I was getting ready to move an application at work over to a staging app that we set up at Heroku. Not wanting to absorb any extra charges for loading up a copy of the entire production database I figured I would empty out the tables that where taking up the most disk space. For that I had to query the information_schema table and add the size of the table to the size of the indexes. All the values are in bytes you have to do a little multiplication to get it displaying in something meaningful to a human like megabytes. Since this is a neat trick that I will likely end up using again I thought I would put it up here as well. Here is the query:

mysql> select table_name, round(((data_length + index_length) / (1024*1024)),2) as “size in megs” from information_schema.tables where table_schema = “myapp_development”;
+———————-+————–+
| table_name           | size in megs |
+———————-+————–+
| messages             |         0.11 |
| organisations        |         0.02 |
| rewards              |         0.02 |
| schema_migrations    |         0.02 |
| selections           |         0.02 |
| senders              |         0.02 |
| sessions             |         0.64 |
| summaries            |        15.52 |
| taggings             |         0.05 |
| tags                 |         0.02 |
| transactions         |         0.03 |
+———————-+————–+
11 rows in set (0.13 sec)

 

Change the where clause to look for the database you want or remove it completely to see all of them.

Connecting to a web server on a VirtualBox guest.

Posted by: mikewilliamson on: November 14, 2009

One of the things I did frequently when using VMware is connect from my host (usually Windows) to my guest (usually Linux). The fact that I don’t really remember how I set that up seems to indicate that it was pretty trivial or just worked “out of the box” (which is a funny thing to say about a VM). After happily using Virtualbox for a while now, the need to connect from host to guest has inevitably reared its head and I was a little surprised that there does not seem to be a straight forward way to do that. Turning as one usually does in such a situation, to Google, and since it was a bit of a fiddle I thought I would scrawl it down here.

Keep in mind my host machine is Windows Vista (I know, I know…)  and the guest is Ubuntu Karmic Koala.

Open the Windows command line and navigate to

C:\Program Files\Sun\VirtualBox>

There are three commands that need to be issued. The command is a little daunting at first glance so here are the important parts:

“karmic” is the name I gave my VM when I created it.

“pcnet” refers to the PCNet virtual network card that I am using in my VM which you can select in your network settings. e1000 is also valid if thats what you’re using.

“railsdev” is the name that will be given to the port forwarding configuration that these commands set up.

The rest should be fairly self explanatory:

C:\Program Files\Sun\VirtualBox>VBoxManage.exe setextradata “karmic” “VBoxInternal/Devices/pcnet/0/LUN#0/Config/railsdev/Protocol” TCP

C:\Program Files\Sun\VirtualBox>VBoxManage.exe setextradata “karmic” “VBoxInternal/Devices/pcnet/0/LUN#0/Config/railsdev/GuestPort” 3000

C:\Program Files\Sun\VirtualBox>VBoxManage.exe setextradata “karmic” “VBoxInternal/Devices/pcnet/0/LUN#0/Config/railsdev/HostPort” 3000

Thats about it. Not to bad when you get down to it.

Now http://localhost:3000 on your host machine connects to port 3000 on your VM. As long as you have Mongrel or Webbrick ready and waiting, things are good.

Yay!

Ditch VMware. Don’t look back.

Posted by: mikewilliamson on: October 8, 2009

After working in Ubuntu running in VMware for my Ruby on Rails development over the last few months I have come to the realization that VMware is really annoying.

First, I am tired of playing Russian roulette with their poorly chosen keyboard shortcuts. I have inadvertently rebooted the whole VM with a Control+R intended for the Firefox inside the VM more times than I care to admit. Much wailing and gnashing of teeth followed.

Equally poorly planned, but less damaging is their co-opting of the standard undo shortcut Control+Z. The fine folks at VMware decided to use that to suspend the VM which you will eventually discover after flipping between the VM and the host OS and then trying to undo something…

While the fact that switching between the guest and the host OS a few times makes their network connection crash and their seeming inability to make their shared folders work with Ubuntu in any sane way (hopefully fixed now…), both rank on my list of frustrations, the worst by far is the mouse.

I was hoping to get the mouse working better once the VMware tools were installed but that never ended up being the case. For whatever reason after the install I still had to explicitly click in the VM to get it to grab the mouse (or press Control+G… Don’t get me started…) and Control+ALT to release it. I suppose I might have been able to figure out some sort of fix for that had it really caused some acute aggravation, but for the most part it remained as a low level annoyance.

The acute aggravation came from the fact that VMware assumes that anytime you move your mouse anywhere near the top of the screen that you would like to jump out of the VM and access their menu.

Without fail this completely screws up the mouse and I have to try to click several times inside the VM to convince it to grab the mouse again.

Well I am pleased to tell you there is a fix for all of that. Virtualbox. No stupid shortcuts, is actually capable of running compiz-fusion, shared folders that actually work (sudo mount -t vboxsf sharename /mnt/share is all thats needed after you set up your share, exactly what a *nix user would expect), and a single key (the control button on the right side of the keyboard) that releases you from the VM. As a bonus it even seems faster than VMware. The best part is that you don’t have to go trawling on piratebay to get a copy, since it is open source and freely available from their website.

Ditch VMware. Don’t look back.

Heroku, Taps and Ubuntu

Posted by: mikewilliamson on: August 25, 2009

After beavering away on a Rails app for the last little while I wanted to put it up somewhere so the rest of the world can see it. I signed up with Heroku since they specialise in hosting Rails apps. Their database setup is kind of confusing. It turns out that they totally ignore your database configuration (database.yml is not used.) They just use the schema.rb to create the database that your app needs in their Postgres database. You just run your rake task to set it up. Thats pretty cool, but there is something cooler; can copy your entire local database with data and everything over to their server with the command:

heroku db:push

The only problem for me was that on Ubuntu (jaunty) the command failed telling me that I needed to intall Taps. More aggravating still was the fact that my attempt to install Taps also failed because its dependent on Sqlite3:

mike@jauntyjackalope:~$ sudo gem install taps
[sudo] password for mike:
Building native extensions.  This could take a while…
ERROR:  Error installing taps:
ERROR: Failed to build gem native extension.

/usr/bin/ruby1.8 extconf.rb install taps
checking for fdatasync() in -lrt… yes
checking for sqlite3.h… no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
–with-opt-dir
–without-opt-dir
–with-opt-include
–without-opt-include=${opt-dir}/include
–with-opt-lib
–without-opt-lib=${opt-dir}/lib
–with-make-prog
–without-make-prog
–srcdir=.
–curdir
–ruby=/usr/bin/ruby1.8
–with-sqlite3-dir
–without-sqlite3-dir
–with-sqlite3-include
–without-sqlite3-include=${sqlite3-dir}/include
–with-sqlite3-lib
–without-sqlite3-lib=${sqlite3-dir}/lib
–with-rtlib
–without-rtlib

Gem files will remain installed in /var/lib/gems/1.8/gems/sqlite3-ruby-1.2.5 for inspection.
Results logged to /var/lib/gems/1.8/gems/sqlite3-ruby-1.2.5/ext/sqlite3_api/gem_make.out

This was pretty annoying. Worse still installing sqlite3 didn’t fix it. It took some googling to figure out what needed to be installed to make Taps and therefore Heroku happy. It turns out that sqlite.h lives in the package libsqlite3-dev:

mike@jauntyjackalope:~$ sudo aptitude install libsqlite3-dev
mike@jauntyjackalope:~$ sudo aptitude install libsqlite3-doc

mike@jauntyjackalope:~$ sudo gem install taps
Building native extensions.  This could take a while…
Successfully installed sqlite3-ruby-1.2.5
Successfully installed taps-0.2.19
2 gems installed

mike@jauntyjackalope:~/dexterchief$ heroku db:push
Auto-detected local database
Sending schema
Sending data
6 tables, 53 records
comments:      100% |==========================================| Time: 00:00:01
posts:         100% |==========================================| Time: 00:00:01
roles:         100% |==========================================| Time: 00:00:00
roles_users:   100% |==========================================| Time: 00:00:00
schema_migrat: 100% |==========================================| Time: 00:00:01
users:         100% |==========================================| Time: 00:00:00
Sending indexes
Resetting sequences

Finally!

Dear Microsoft: No means no.

Posted by: mikewilliamson on: August 1, 2009

I switched from Windows XP to Ubuntu in 2007. I used Ubuntu exclusively  for tw0 years with my only real complaints being the inability to play games like Portal or run Photoshop . The purchase of a nice new Canon EOS 40D a few months ago made native Photoshop support a necessity.

When I started shopping for a laptop it quickly became apparent that I was going to be forced to purchase Windows Vista. Dell had some systems with Ubuntu preinstalled but saved their best for Vista. I held my nose and ordered.

Truth be told, after a brief adjustment, I found I kind of liked Vista. Sure it has its foibles but none of them seem so bad when you are upgrading from a seven year old computer (running the latest Ubuntu!) to a shit hot new laptop with enough power to make even Vista seem snappy.

But something had happened in those two years of Ubuntu usage. I had become accustomed to thinking this was MY computer. It was not a sales platform for some Silicon Valley company that wanted to upsell me to a “pro version”. It was not something I was allowed to use as long as I submitted to being served up advertising (like in MSN or Yahoo messenger). There was no corporate agenda being surreptitiously advanced through default settings (like ripping to Windows Media Format or Apples AAC by default just to propagate the format) or bundling programs together (iTunes).

Internet Explorer 8 appeared a several weeks ago as an “Important Update” in my Windows updates.  With IE8 struggling to get beyond a single digit slice of the browser market, it was obvious who the update was important for. Microsoft was chastised for the scummy practise at the time and I decided to deal with it by choosing the “hide this update” option and assumed that would be the end of it.

Checking out the details of a subsequent batch of updates gave me a bit of a start:

ie-update

IE8 again? Didn’t I just say no to this? I guess technically I said “hide this update” but its the closest to “NO” that Microsoft allows. Once again I chose “hide this update” and hoped Microsoft would respect my wishes. After all, this is supposed to be MY computer right?

ie-update2

So here I am again, a new update and once again, IE8 is listed as an “Important” update. This is now my third time telling it to “hide this update”, when will Microsoft learn that NO MEANS NO!

Holding the line

Posted by: mikewilliamson on: May 26, 2009

“On average, Office users spend more 1-on-1 time with Office than with their spouse”

This (unfortunately unsourced) gem comes from Jensen Harris’s presentation on the creation of the new “ribbon” based interface in Office 2007. While I think that quote probably says quite a bit about what is wrong with the world, it also tells you that how humans interact with computers is a very big deal. Ones relationship with the tools of their trade in any line of work is going to be necessarily intense and emotional. As software becomes more of a requirement than an option in most lines of work, companies like Microsoft and Apple spend staggering amounts of money studying people interacting with their software.  “Hundreds of millions” were supposedly spent on developing the new interface for Office 2007 according to Harris.

For all the fanfare, the ribbon is just the latest reshuffling of the same windows, icons, menus and folders that were developed at Xerox PARC in the early seventies. The problems in interface design today are largely to do with programs so rich with features that their menus are beginning to look like a rats nest of pop-ups, fly-outs, toolbars, menus, sub-menus and sub-sub-menus (and often sub- sub-sub-menus). Harris says that the research his team has done showed that users felt a loss of control and a loss of a sense of mastery.

I can’t help but wonder if some of these feelings are common to all GUI programs, not just Office. Most people seem to think of the Command Line Interface as the absence of an interface, and are terrified by the monochrome starkness and requirement that at least a few commands are known before the user can start. The first GUI based personal computers (Apple’s Lisa and Macintosh) were a rejection of the CLI and a way to open up computing to a wider audience.

“No command line interface was available on the Macintosh; you talked to it with the mouse, or not at all. This was a statement of sorts, a credential of revolutionary purity. It seemed that the designers of the Mac intended to sweep Command Line Interfaces into the dustbin of history.”    ~~ Neal Stephenson – In the Beginning was the Command Line

The problem was that to make these new GUI’s understandable to users the developers created the now ubiquitous “desktop metaphor”. Users would know what to do in this new virtual world because it would mirror aspects of the physical world. Everything in it would be presented to them as objects on a virtual desktop with folders to organize. However users don’t experience their desktops as a metaphor, for them they are real:

“Back in 1984, explanations of the original Mac interface to users who had never seen a GUI before inevitably included an explanation of icons that went something like this: “This icon represents your file on disk.” But to the surprise of many, users very quickly discarded any semblance of indirection. This icon is my file. My file is this icon. One is not a “representation of” or an “interface to” the other. Such relationships were foreign to most people, and constituted unnecessary mental baggage when there was a much more simple and direct connection to what they knew of reality.” ~~John Siracusa – About the Finder…

Computer use in GUI environments is exploratory, tasks are completed by hunting down menu items and unearthing option dialogs, navigating an environment, like a rat navigating a maze for a piece of cheese, that, for them, might as well be real. The reward at the end of the process might be empowering, but the path to the reward is not.

Command line interfaces offer a very different experience for the user. In many cases users can accomplish the same task but the experience of the path to that end result is very different. The CLI sets up a different kind of relationship with the user, one that also echoes the users real world experience; a master/slave relationship. Because of this, working at the command line is empowering: you issue a command, the computer does it. If I type “aptitude install firefox”, aptitude (The program Ubuntu uses to add and remove programs) installs Firefox. Commands like “su” and “sudo” only reinforce the perception of the machines subservience, allowing you to override even its objections. It’s a very different feeling than fishing through a folder tree trying to find “setup.exe” so you can double click on it and then click “next” a half dozen times.

Words like “power” and “control” tend to come up a fair bit in where the command line is discussed, but although there are plenty of good things to say about GUI’s those are not the first things that spring to mind when describing your feelings about using one. Though there are some that dismiss use of the command line as a major usability roadblock, hopefully as the use of GNU/Linux based systems grows, more people will recognise that it is an efficient and empowering way to get things done. When that happens even normal people will find XKCD funny…