the open web, web development, ubuntu, and more

Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Tuesday, May 13, 2008

Tips to Drink More Water (and earn nerd points)

Water Bottle and CupDrinking water is good for you. However, this post isn't about trying to convince you of that. Instead let's assume, like me, you want to drink more water but find it difficult to consume eight 8-ounce glasses per day.

To help me drink more water I need a glass of water at my desk and a reminder to actually drink it. The reminder is a crucial part because I have had a bottle of water sitting at my desk for weeks and barely touch it. The problem is I tend to get engrossed in what I'm doing and forget to drink.

Fortunately, the solution is simple. All I need is a system that forces me to stop what I'm doing and reminds me to drink a glass of a water periodically. If you use Ubuntu or another Gnome distribution (I'm sure this can be adapted to work on any OS) you can set this up in a few easy steps with Gnome's session manager, the AT command, and a bash script.

  1. Create drink.sh in your home directory (anywhere is fine but you'll need to adjust the instructions accordingly) and copy and paste the following code into it:

    #!/bin/sh

    if [ "$1" = "schedule" ]
    then
    at 9:00am < $0
    at 10:00am < $0
    at 11:00am < $0
    at 12:00pm < $0
    at 1:00pm < $0
    at 2:00pm < $0
    at 3:00pm < $0
    at 4:00pm < $0
    at 5:00pm < $0
    echo "Drink reminders have been scheduled."
    else
    /usr/bin/gnome-screensaver-command -l
    fi

    Don't forget to give this file executable permissions. One way to do this is to right-click on the file, select Properties, select Permissions and then check the "Execute" checkbox.

  2. To verify this works, open a terminal (Applications > Accessories > Terminal), navigate to your home directory, and type ./drink.sh (WARNING: This will cause Gnome to lock you out of your current session and you will have to unlock it with your password). If this worked, go back to your terminal and type ./drink.sh schedule. You should see several lines of output and a final line, "Drink reminders have been scheduled." If you don't see this, stop and investigate.

  3. Gnome Sessions DialogueNow that this is working, you just need to tell Gnome to run the drink scheduler upon logging in. To do this, go to System > Preferences > Sessions and click "Add" under the "Startup Programs" tab. Enter whatever you like for the Name and Description, just make sure the Command points to your drink.sh file and passes the "schedule" argument (e.g. /home/username/drink.sh schedule).

And that's all there is to it. Next time you log in to your computer the drink scheduler will run and tell your computer to lock your screen every hour from 9:00am to 5:00pm. If you want to be reminded to drink at different times, just adjust drink.sh accordingly (should be fairly obvious what to do). As an added hint that it is time to drink, I set my screensaver to Ripples.

Here's to better health!

P.S. I initially tried to set this up with CRON but ran into limitations getting CRON to work with Gnome, as best summarized in this thread. If you know how to achieve similar results with CRON, please let me know.

Tuesday, March 11, 2008

Firefox 3 Beta 4 and Prism 0.9 Work Very Well

As promised, here is a follow up on my previous post about running the latest version of Prism as an extension. Good news is: Prism on Ubuntu actually works now.

It would seem that installing Firefox 3 beta 4 from the Mozilla site solved a lot of the problems I was having. So far I haven't had any problems creating Webapp shortcuts for the Google Apps I use and as an added bonus it is easy to select an alternative icon (the favicon is a bit too small for some uses).

The most noticeable improvement is really not Prism related but due to the improvements in the Gecko Platform (see beta 4 release notes). Webapps start significantly faster now.

Another nice feature is that Prism instances run in a separate process now. It used be that all Webapps shared the same process. A poorly written Webapp should not be able to take down all Prism instances (in theory). Additionally, since cookies are isolated to each instance of Prism the chance of one Webapp running in Prism making an XSRF is greatly reduced since it won't have access to session cookies from other Webapps.

Happy Webapping

Friday, February 29, 2008

Ubuntu Brainstorm For The Win

The new Ubuntu Brainstorm site has been launched and is off to an enthusiastic start. In a nutshell, this site gives users the ability to submit and vote on ideas for Ubuntu. The site has been live for less than 2 days and has already received over 1500 submissions. It will be interesting to see how Ubuntu development balances the desires of enthusiastic users and Canonical's needs.

One novel idea (of the many good ideas) proposes a new system for installing fonts. If you would like to voice your Ubuntu ideas, head on over to Brainstorm.

Sunday, November 4, 2007

Prism Available for Linux

As previously posted, the latest version of WebRunner has been released under the name Prism. Until recently, Prism was only available for Windows users but now Linux and Mac users can use Prism too. Running Web Apps in Prism has three advantages:

  • Reduces the frequency of Firefox crashes. I'm not sure why Firefox crashes as often as it does but I suspect it has to do with all the extensions and running Web Apps like GMail all day long. Hopefully Firefox 3 will fix these problems, but isolating GMail to Prism has already helped a lot.
  • Reduces the chance of a cross-site request forgery (xsrf) since cookies from Web Apps that run for a long time are not available to malicious sites (assuming you would come across a malicious site using your regular browser and not using Prism)
  • Reduces needless browser UI elements, freeing up more space the the Web App itself.
I have been using WebRunner/Prism for a bunch of Web Apps I use and, generally, I have been happy with the results. The latest release under the Prism name has made some key improvements:
  • Spell checker works all the time. I'm highly dependent on the spell checking feature in Firefox in order to compose semi-intelligent email. Suffice it to say, using GMail in WebRunner made for confusing, if not humorous, reading on behalf of my email recipients.
  • The cursor is visible when composing email in GMail. Sounds weird but actually trying to write an email without a cursor is even weirder.
  • Prism start-up time is faster. Not only compared to WebRunner but Firefox 2 as well. It also seems that Prism is able to load the Web App faster, but I have no tests to back this up.
  • Favicons appear in the panel. Before the Prism release all Web Applications running in WebRunner used the same WebRunner icon. This improvement sounds trivial but is a big usability improvement, making it much easier to move between minimized applications.
There are a few annoyances/bugs with Prism worth noting:
  • Opening multiple Web Applications simultaneously throws errors
  • No Linux version of the favicon resizing/styling tool available to Windows users
  • General rendering weirdness due to the fact that Prism uses the still-evolving Mozilla 1.9
  • Lack of Prism documentation on webapp bundles that were used in WebRunner
  • Cookies are shared between all Web Apps running in Prism. This is the norm for a browser, but leads to the xsrf vulnerability. Although less of a concern since most Web Apps running in Prism will be trusted, it would still be nice to tighten the security. Perhaps Web Apps launched from a webapp bundle instead of a uri could keep cookies isolated to themselves?
If you are a Web Developer and interested in seeing how users might be interacting with your Web Applications in the future, definitely give Prism a spin. Tombuntu posted instructions on installing WebRunner on Ubuntu and these are still applicable to Prism. Personally, I extracted the Prism archive to /opt/prism and then saved all webapp bundles in my home directory.

Monday, October 15, 2007

How to install a GoDaddy Wildcard SSL Certificate on JBoss

I write this post mainly so that I retain the knowledge of stumbling through this frustrating and poorly documented process and in the hopes that it will be of use to another poor soul on the Internet. Specifically, this how-to will be useful if you:

  • Have purchased a Wildcard SSL Certificate through GoDaddy
  • Need to enable SSL on JBoss (should apply to Tomcat too) because the Apache web server is not being used to pass requests to JBoss
  • Are running Ubuntu (or any Linux/Unix OS) on your server
  • Are running Sun Java 1.5
To summarize the steps, you need to follow the GoDaddy instructions for installing the certificate on Tomcat but add an additional step of extracting your private key from "tomcat.keystore" (a file you will create). However, for the purpose of this how-to, I'll cover all the steps.

Step 1

SSH into one of your production servers and create the directory "ssl-files" to work in as you will be creating and downloading several files. CD into "ssl-files" Then run the command:

keytool -genkey -alias tomcat -keyalg RSA -keystore tomcat.keystore

This will run a command line wizard that prompts you to enter data. Whoever wrote this tool could have spent more time on the clarifying the instructions.

Enter keystore password:
[Pick something clever and write it down]
What is your first and last name?
[Don't take this literally. It turns out that "*.yourdomain.com" is the best answer]
What is the name of your organizational unit?
[Anything, this isn't really important but should be the same as a previous certificate if you are renewing]
What is the name of your organization?
[Same as above]
What is the name of your City or Locality?
[Same as above]
What is the name of your State or Province?
[Same as above]
What is the two-letter country code for this unit?
[Same as above]

Once you finished the wizard you should now have the file "tomcat.keystore" in your current directory.

Step 2

From the "ssl-files" directory, run another command to create a certificate request (.csr) file:

keytool -certreq -keyalg RSA -alias tomcat -file <your-file-name-here>.csr -keystore tomcat.keystore

Now open the newly created file:

cat your-file-name-here.csr

Copy the contents of the file so you can paste it into the CSR field of the Certificate Request form on GoDaddy's website. I'm assuming you found the correct form on the website, but if you haven't, don't feel bad as the GoDaddy site has a deplorable UI.

Step 3 (Not found in GoDaddy's instructions - nor many other places on the net)

You now need to extract a private key from the tomcat.keystore binary. This is where any official documentation leaves you hanging. Not only are you unaware of this step but there is no easy way to do using the keytool. Luckily, someone at the University of Texas has a nice write-up on this. Scroll down to the "Additional esoteric Java keytool operations" section to the 3rd step. Copy the code, and paste it into a new file (in the "ssl-files" directory) names, "GetKeys.java". Delete the first line in the file that is specifying the package as "MyPackage" and replace the three values as indicated at the University of Texas website.

Compile GetKeys: javac GetKeys.java

Run the class: java GetKeys

If all goes well you should see some text that begins with "-----BEGIN PRIVATE KEY-----". If not, you will have to go back to GetKeys.java and debug. Once you get it working, copy all the output (including the begin and end private key lines) and paste it into a new file you create named "<your-file-name-here>.key".

Step 4

Download the .zip archive provided by GoDaddy to your server (you will likely have to download it to your desktop and then scp or ftp it to your server). Now run the unzip command (note: unzip is not installed by default on Ubuntu, but a quick sudo apt-get install unzip will fix that):

unzip <big-long-random-string.zip>

This will extract 4 .crt files into your current directory, hopefully you are still in "ssl-files". Now create your "keystore.tomcat" file (not to be confused with the existing "tomcat.keystore" file) that you can copy to the correct location on your servers:

openssl pkcs12 -export -chain -CAfile gd_bundle.crt -in <_.yourdomain.com> .crt -inkey <your-file-name-here>.key -out keystore.tomcat -name tomcat -passout pass:<your-password>

Now you should have the file "keystore.tomcat" in your current directory.

Step 5

At this point you can head back to the GoDaddy instructions in order enable/modify SSL support in server.xml. The "keystore.tomcat" file can be safely used in a clustered environment and re-used on the remaining servers.

Hopefully you found this helpful. If you find any errors or simpler alternatives, please post a comment.

Friday, October 5, 2007

Ubuntu, please improve the trash can!!

Have you ever tried to drag a file or folder from the desktop (or any nautilus window) to the Trash in Ubuntu? If you have, you might have found it challenging because the item being dragged often completely obscures the very small Trash Can icon making it difficult to know where the Trash Can is.

The screen shot snippets below depict what I am referring to (the mouse pointer wasn't captured in the screen shot - imagine it over the "Test File").

"Test File" being dragged to Trash



"Test File" dragged over Trash

Where's the Trash Can? I'm sure most users can figure this out, and, with minimal care and dexterity, it is possible to drop the "Test File" in the Trash (Extra tricky when using a laptop's track pad or eraser head). Of course there is the obvious work around of just using the delete key or even the command line, but dragging and dropping an item into the trash should be easy.

Mac OS X does a good job making this easier by expanding the Trash icon to a size that is larger than the item being discarded. Ubuntu/Gnome could implement this (should be easier with Compiz-Fusion) but this isn't the only solution. Another approach could be to make the item-to-be-discarded semi-transparent so it is possible to see where it will be dropped. I'm sure other solutions could be devised as well.

The Windows approach of placing the Recycle Bin on the desktop would seem to solve this problem too, except that it introduces a more annoying problem of having to move application windows away to make the Recycle Bin even visible. So if even nothing is done to improve the ease of dropping files into the Trash, Ubuntu/Gnome still has a better solution.

Thursday, September 20, 2007

6 Reasons for Start-ups to Install Ubuntu on their Servers

I work for a small Web 2.0 start-up company that recently had to build a server stack to run its latest Java-based application on. Previously we ran CentOS on all our servers but we chose Ubuntu's Server Edition for the new servers.

Naturally, being an enthusiastic Ubuntu user I pushed for this change. But enthusiasm alone doesn't convince most people (nor level headed programmers). After several arguments discussions with my colleagues, the reasons for running Ubuntu for our web application came down to the following points:

  1. Ubuntu is available free of charge;
  2. Ubuntu periodically releases Long Term Support versions (3 years on the desktop and 5 years on the server);
    • Ultimately we installed the latest release (at the time, the LTS version did not have simple Sun Java installation or other key features we liked), but this was definitely a strong talking point and helped ease the concerns of my colleagues that thought Ubuntu was just a hobbyist OS.
  3. Commercial support and administration tools can be purchased if you need them;
    • This is huge, since you can take the OS you downloaded and installed for free and suddenly make it "enterprise worthy" (I hate that term too but couldn't think of a better one). Correct me in I'm wrong but I don't think you can do that with Fedora or OpenSUSE.
  4. Ubuntu is Debian based and, therefore, quite mature and stable;
  5. Ubuntu also releases a Desktop Edition;
    • This allows the developer's development environment to be almost identical to the production environment
    • Knowledge gained from administering and configuring your desktop system is transferable to the server environment. I mention this as often the developer uses Windows or Mac OS on the desktop, and then something completely different on the servers - leading to a steeper learning curve with respect to server administration.
  6. The latest versions of the Sun JVM are available in a timely manner;
    • Although other Linux distributions and Windows also get the latest JVM quickly, Mac OS does not.
Many Linux distributions possess some of the characteristics above, but I think Ubuntu is unique in possessing all of them. Most commercially supported distributions are not available free of charge and most freely available distributions do not have commercial support.

Hopefully this reasoning was sound and applicable to anyone else advocating the use of Ubuntu on the server. If you see any flaws in logic, or have more reasons to add to the list, please post a comment and I will edit the post if it makes sense.

Tuesday, August 21, 2007

VirtualBox on Ubuntu 7.04 for an Easy Virtual Machine

As a web developer it is pretty hard to ignore the fact that Internet Explorer has a huge market share. Therefore testing to make sure that your web pages work properly in IE is almost always non-negotiable.

This leaves the happy Ubuntu developer with a need to run Windows in a virtual machine. There are a few options available but one solid choice is the GPL'd VirtualBox from Innotek (yes, similar to the company from Office Space - let's hope they don't burn down).

Here are the steps to install VirtualBox on Feisty Fawn (broken down into 2 parts).

Part 1: Adding the Innotek repository

  1. Go to the download page on the VirtualBox site
  2. Under the VirtualBox binaries heading you will find a list of repositories for debian based systems. Copy the line for feisty (top line at the time of this posting)
  3. Now download innotek's public key (this will bring up a simple webpage containing a lot of text - in Firefox: File > Save page as... > and save innotek.asc to the Desktop)
  4. Open Synaptic Package Manager, click Settings and then the Third-Party Software tab
  5. Click add and paste the repository information you copied from the VirtualBox site
  6. Now click the Authentication tab
  7. Click the Import Key File button and select the innotek.asc file from your desktop
  8. Close the Software Repositories dialogue and click the Reload button in Synaptic Package Manager
Part 2: Installing VirtualBox
  1. If you are also reading the VirtualBox instructions, ignore the sentence about additional libraries as the dependencies will be taken care of by Synaptic
  2. Use Synaptic Package Manager and search for VirtualBox, Mark it for installation (you'll see the dependent libraries get added) and apply the changes
  3. After VirtualBox has been installed, you will need to logout of Gnome and log back in again. This is so that the new virtualbox group is actually added (there is likely a more efficient way to do this but I am unaware of it - please let me know if you know)
  4. Once you are logged back in, go to Users and Groups, click Manage Groups, select virtualbox and add your user(s) to the group
  5. Now you should be able to go to Applications > System Tools and launch VirtualBox

The PDF User Manual on the VirtualBox site is clear and easy to follow so installing an OS like Windows XP should be easy.

So far, VirtualBox has run very well for me. It seems to lack features like seamless mouse integration between the host and guest OS, but those features have never worked well for me. I am just happy to have a stable version of Windows that I can reliably access when needed.

Thursday, August 9, 2007

Resources for Web Developers on Ubuntu

Below are some links to software and web sites that I use on a regular basis. I post these as a resource for myself (when I inevitably have to rebuild a box) and in the hopes that it is useful to others.

Applications

Firefox: the majority of readers will already be users, or at least aware of this excellent browser, but I mention it to give context to the add-ons below (and because it is so good).

Add-ons (a.k.a. Extensions)

  • Firebug: The ability to debug and step through JavaScript code is amazing. I have never used Microsoft’s products for web development (which I understand also provide this ability) so this is practically revolutionary for me.
  • Web Developer: A collection of very handy tools for Web Developers. You have the option to use it as a toolbar, or keep it out of sight, and access its tools through the context menu.
  • Live HTTP Headers: A simple tool that allows you to see the request and response HTTP headers. Although, the Firebug add-on contains header information as well, I keep coming back to Live HTTP Headers as it is simpler to use.
  • Google Browser Sync: I never found bookmarks useful until I found this add-on. With this tool you can synchronize bookmarks between multiple Firefox installations. As an added bonus, it serves as a backup when you need to unexpectedly scrub your box.

Eclipse: As an Ubuntu user, that needs a full featured Java IDE, Eclipse is a pretty solid choice. Installation is a snap (apt-get, done) and the plugins can make it very powerful.

Plugins

  • Aptana: IDEs or Eclipse Plugins to assist in AJAX development are few at this point. Aptana seems to be a pretty good choice so far and works with many of the major JavaScript libraries out-of-the-box. It has excellent documentation and is open source to boot.
  • Subversive: I just started using this plugin. Until recently I was using Subclipse but found it a bit buggy and awkward to use. So far, Subversive has been a pretty solid replacement. I’ll need more time to fully vet it though.
  • Veloeclipse: A plugin that will aid in developing velocity templates. It provides some much needed syntax highlighting and other features. What is Velocity? Velocity is an awesome Apache replacement for JSP.
  • QuickREx: An indispensable tool for writing/testing your regular expressions. Includes a very handy method of converting your RegEx into Java syntax (you know, extra escape characters to make the RegEx less readable)

Useful Sites

  • Regular-Expressions.info: A very handy reference site for looking up some of the more obscure aspects of Regular Expressions or trying to write a Regex in a new language.

Monday, August 6, 2007

My Sweet New Hackergotchi

PNG Hackergotchi

JPG Hackergotchi

Sunday, June 10, 2007

CNR for Ubuntu (and many other distros) could be huge for Linux

I've been meaning to blog about this for a while but kept getting side tracked by other distractions. And judging by the frequency of my posts, I seem to have a lot :)

As most Ubuntu users have heard, Ubuntu and Linspire announced some sort of technology pact. Linspire would base their distro on (K)Ubuntu and then Linspire would make CNR (Click and Run) available to Ubuntu users. According to the new multi-distro CNR site, this service will be launching vaguely in the 2nd quarter of 2007.

Personally, I am pretty excited about what this could mean for Linux in general. Why? A common reason that commercial desktop software is not created for Linux is that the Linux desktop market share is too small. Fair enough, businesses should put their money where it makes most sense. But even if a company decides to pursue the Linux market they are faced with the decision of choosing one or more distros to support. I imagine this is quite daunting and presents another obstacle to releasing software for Linux. CNR has the potential to solve this problem and could become the single Linux "platform" a commercial software application would need to support.

The above statement is probably not 100% true, but perhaps true enough to make it easier for a company to support may Linux distros at once. If Linspire plays their cards right, CNR could become an expert in packaging software for all the various distros and become a very important link in the software delivery chain. Not only would they be important to the company distributing the software, but also to users as CNR could offer some assurance that software in CNR is malware and spyware free.

If you compare this to the typical Windows method of downloading and installing software from random websites, it would seem that CNR is not only improving the ease of installation on Linux but actually surpassing the experience that most Windows users have. And by actually making the experience of using a computer better than it currently is, people will have a reason to try and switch to Linux.

Friday, May 25, 2007

Set Google Apps for Your Domain as Default Mail Client in Ubuntu

Recently, I read a great post over at the How-to Geek about setting GMail as your Default Mail Client in Ubuntu. Being an avid user of both Ubuntu and GMail I wanted to set this up as well. However, since I use Google Apps for Your Domain (GAFYD), the script didn’t work for me. With a little adjustment I got it to work.

To set this up, you need to do two things:

  1. Customize a short script and save it to your file system
  2. Edit your Mail Reader settings in Preferred Applications

Follow the instructions at the How-to Geek, but change the URL from Gmail to the URL used to access GAFYD. To do this, login to your GAFYD GMail account (but don't click any link after logging in) and copy the entire URL, including the parameter at the end. Now replace a small portion of the script provided by the How-to Geek.

Replace "https://mail.google.com/mail?"

With the GAFYD URL "https://mail.google.com/a/your-domain.com/?AuthEventSource=Internal&".

That’s it! Now continue with the instructions at the How-to Geek.