VirtualBox Shared Folders under Linux
My work machine runs Windows (go ahead and laugh. I’ll wait). While I’ve been able to tweak the machine and get a moderately acceptable setup, there are times when I’d really like to use Linux for something, so I spin up a virtual machine with VirtualBox. While that works, I don’t really like having source code — especially with changes in flight — on the VM, as it makes it a bit more dangerous/difficlt to destroy the VM should I need the disk space (which happens more often than I’d like). I set out, then to get shared folders working so I can keep the source on my host machine, and just do the work in the VM. Unfortunately, it doesn’t seem to be as simple as adding a shared folder to the VirtualBox config. This post, then, will detail the steps I took to make things work for me.
Roku and Hotel Wifi
I was recently on a business trip and, as is my custom, I took along my Roku box so that I would have something to watch in the hotel room in the evenings. Unfortunately, the hotel wifi required that you sign in on each device in order to access the internet, but this Roku is old enough that it didn’t offer way to do that. I found some options in The Tubes, but I didn’t care for them for various reasons, but, fortunately, I found an easy — and free — way to do what I needed.
The two options I found included buying a "travel router", which might have worked, but that required that I buy the device (they appear to be about $15), but I’m kinda cheap at times, and even if I weren’t, that didn’t help me much at 10:00 at night in the hotel room, so that was out. Another option involved downloading some software to a Windows machine, which, when run, would set up a small wifi network to which I’d connect my Roku. Since I have a Linux laptop, that would be a bit difficult, but, even in the Windows VM I have installed, it also required downloading and running software from a site I’ve not heard of, so I passed.
What I finally did was a very simple hack.
On the Roku, I looked at the network configuration and took note of the Mac address for the device.
On my laptop, I changed the Mac address of my wireless adapter
Disconnected and reconnected from the laptop to make the Mac address change take effect.
From the laptop, I authenticated on the hotel’s wifi network
Also from the laptop, disconnect the laptop’s wifi.
Clear the overridden Mac address and reconnected.
From the Roku, connect to the hotel wifi
Stream until I fall asleep
Firefox, Wine, and Linux
Wise or not, I recently made the move to Linux on my work machine. For the most part, it works wonderfully. For reasons that aren’t too terribly relevant here, I found myself needing (or wanting) to run the Windows version of Firefox. While I could run it successfully, it wouldn’t connect to the internet. After a whole lot of digging, I finally found the answer, which I thought I should document here with the hope that it will be easier for others to find (including me when I go through this again in a few years ;).
The culprit, it seems, is a couple of Firefox settings: browser.tabs.remote.autostart and browser.tabs.remote.autostart2
Once you have Firefox running under Wine, go to about:config in the browser, and enter remote.autostart in the Search box, and change the value of both settings to false:
Restart Firefox, and you should be golden.
For what it’s worth, credit where credit is due: this is the post that finally got me over the hump.
Writing Bash Scripts with Parameters
In the course of my work, I often find myself writing a script to automate a routine task. Almost invariably, there are cases where I need the script to behave in slightly different fashion, but only occassionally. My early scripts rather crudely used one
ifafter, which is not very elegant. Finally, after tiring of this clumsy approach, I searched for a better way and found one:
getopts. In this shortish entry, I’ll give a very brief introduction to
getopts, and show how I write my scripts now.
If you follow me on Twitter, you may have seen that I’ve been looking for a good media player. This long, painful process involved installing project Foo, along with its 87 dependencies, only to see that I didn’t like it, then running into the same thing with Bar and Baz. Now I have a ton of packages installed that I don’t need, which will irritate me as I think of all the wasted disk space. This morning, I decided to give Cinnamon a try. After seeing its long list of dependencies, I decided to tackle that problem and (the sadly named)
Firefox, Linux, and the Java Plugin
In a perfect world, Firefox, Linux and the Java plugin would get along happily. You’d install all three, and things would just work. If memory serves, that’s exactly what happened under Ubuntu. However, after installing Fedora 17, it just didn’t want to work for me (I’m not blaming Fedora, mind you. I like to live on the bleeding edge, so I install Java 7 nightlies from tar balls and not RPMs, so I probably broke something along the way). After much fumbling and guessing, I finally found a solution, which I’ll share here in case you’re in the same boat:
$ mkdir $HOME/.mozilla/plugins $ ln -s $PATH_TO_JRE/lib/amd64/libnpjp2.so $HOME/.mozilla/plugins/libnpjp2.so
And restart Firefox. You can verify that Java (i.e., applets and webstart) is working by going here.
From OS X to Linux
When I joined Sun Microsystems "way back" in 2008, I was asked if I wanted a Mac for my work system. Having heard many extol the numerous virtues of the OS, I jumped at the chance. Since then, I’ve even migrated my wife and family to the OS. Trouble arose last fall, though, with the delivery of a new MacBook Pro (whose purchase was somewhat a miracle, brought about by the tireless efforts from my upper management). Simply put, I got a lemon. After five trips to the Apple Store, which resulted in overnight diagnostic runs; shipment to an offsite, more advanced repair facility; the replacement of the hard drive; and the replacement of the motherboard, I finally broke down and asked for a new machine, knowing it wouldn’t be a Mac. Just over a week ago, a new Lenovo Thinkpad arrived, and, after putting Linux on it, I have to say I’m generally very happy with the system.more
In general, Apple puts together a very nice system in the MacBook Pro. The machine is a physical beauty, and the OS is veyr polished and user-friendly. As a developer, though, there were somethings that bothered me. The lack of any real visibility (that I could find) into the packaging system, the use of plists over conventional Unix configuration files, the odd command-line parameter parsing in the shell, the nearly universal requirement to use the mouse, the odd keyboard layout, etc. had been grating on me. Now I’l grant that many of these are silly or easily resolved, but they were different enough from years of habit-building that I never could get completely used to them, nor could I find workarounds that I really cared for.
From a user experience, my complaints realy boil down to personal preferences. Many will likely read this list and think I’m quite a crank for my age, and that’s fine. We all have different preferences (I recently read a blurb about a Haskell developer — I forget his name — who prefers Windows!. Now that’s crazy, right? ;). At the end of the day, I had some minor quibbles with the OS, but I sucked it up and pressed on, and was generally pretty productive. Much more than I was on the Windows laptop at my last gig.
Enter Linux. Or, I should say, re-enter Linux. I’ve been using Linux for many, many years now, so many of the annoyances I found when using OS X were the result of forming habits in that other Unix-like OS. On this new machine, I installed Linux Mint, which seems to the flavor of the day in some circles, and was mostly pleased. I had some odd issues with menus in NetBeans that seem to be GNOME-related, so I tried LXDE, which I found to be a bit…ugly, and finally KDE, with which I had some stability issues. Over the course of part of an afternoon, then, I installed Ubuntu 12.04, since I had read that they fixed all the woes that at first plagued Unity. Surprisingly, I’m pretty happy with Unity. It has its issues, but the system is fast and stable, and lets me work the way I prefer, which is all I really wanted.
Given my experience with this latest system, I doubt I’ll return to OS X in the near future. For me, Linux on the desktop is just about right. The price certainly is.
Run GlassFish V3 As a Non-Root Service on Gentoo Linux
Byron Nevins, a colleague of mine here at Oracle, has a couple of nice blog entries showing how to run GlassFish as a service, both as root and non-root users, on Ubuntu or Debian. As a Gentoo user, that doesn’t help me much, unfortunately, but, some time ago, I developed a script that works great for me, so I thought I’d share it here.