2/27/2014

Dual booting Ubuntu 12.04 and FreeBSD 10

Well first install Ubuntu, creating a separate /boot partition with 256MB space, a 10GB-ish Ubuntu partition, and leave free space at the end of the hard drive for FreeBSD.
Now install FreeBSD. Boot from USB Disk, chose Install FreeBSD, partitioning for beginners. This will auto-detect the space you've left out earlier for FreeBSD; don't type anything to the Mount Path, it will automatically create a master partition, where it handles the mount points automatically. Unless of course, you want a different partition-setup which you do with the tool here.
Be sure to have the / mounted to a UFS-formatted partition (this should be done for you automatically if you've followed the earlier steps), and proceed with the installation.
After the FreeBSD installer finished and you reboot your computer, you'll get the Linux bootloader, of course with no option to start FreeBSD. So here we go, let's fix GRUB:
sudo grub-probe -d /dev/sda1 -t fs_uuid  
should tell you the disk you have a UUID for. That should be your FreeBSD disk - now replace my UUID with yours for grub:
sudo vi /etc/grub.d/40_custom
should fire you up VI, here's my file:
menuentry 'FreeBSD' {
   insmod ufs2
   insmod bsd
   search --fs-uuid --no-floppy --set=root 011c86ed-6f2d-48a0-a132-f020c23a045c
   kfreebsd /boot/kernel/kernel
   kfreebsd_loadenv /boot/device.hints
   set FreeBSD.vfs.root.mountfrom=ufs:/dev/ufsid/011c86ed-6f2d-48a0-a132-f020c23a045c
   set FreeBSD.vfs.root.mountfrom.options=rw
}
Exit vi with :wq, update grub on disk:
sudo update-grub
Reboot your computer and you should be able to select FreeBSD in Grub now. Drop me a comment how it worked. Cheers!

12/28/2013

Building http://bellebonnesage.sourceforge.net/ generates fatal error: 'freetype/ftglyph.h' file not found

If you are on Mac OS, and trying to build Belle, Bonne, Sage from sources, you may experience the following error:

#svn co https://bellebonnesage.svn.sourceforge.net/svnroot/bellebonnesage/trunk bbs
#cd bbs
#./Scripts/MakeAll

Cleaning Build
Building Beaming
Building BlankPage
Building Chopin
Building Color
Building ConvertFont
Building Graph
Building Image
Building Spiral
Building Springs
Building Springs2
Building Text
Building Tutorial0
Building Tutorial1
Building Tutorial2
Building Tutorial3
In file included from ../Examples/Color.cpp:40:
In file included from ../Examples/../BelleBonneSage.h:95:
../Examples/../Modules/FreeType.h:48:10: fatal error: 'freetype/ftglyph.h' file not found
#include 
         ^
In file included from ../Examples/ConvertFont.cpp:40:
In file included from ../Examples/../BelleBonneSage.h:95:
../Examples/../Modules/FreeType.h:48:10: fatal error: 'freetype/ftglyph.h' file not found
#include 
         ^

That's because you don't have the ftgl library installed:

#brew install ftgl

3/05/2010

Make Ubuntu look like OSX

Installing the Aurora Leopard BSM Theme

The Aurora Leopard BSM Theme provides a beautiful, minimalistic appearance to Ubuntu. This is how it looks like:

First we have to install the GTK engine. The steps to take:

sudo aptitude install build-essential libgtk2.0-dev
wget http://gnome-look.org/CONTENT/content-files/56438-aurora-1.5.1.tar.bz2
tar -xvjf 56438-aurora-1.5.1.tar.bz2
tar xvzf aurora-gtk-engine-1.5.tar.gz
cd aurora-1.5
./configure --prefix=/usr --enable-animation
make
sudo make install

Now we can install the theme, by downloading it from here. Save it to the desktop, then open System->Preferences->Appearance, and drag&drop the downloaded file to this window. Ubuntu will install the theme for us.

Looks a bit like OSX? Indeed it does. To go one step further,  we can change the order of the buttons too (this is a copy from here):
1 - Press "Alt + F2"
2 - Type "gconf-editor" and press "Enter"
3 - Browse to "Apps -> metacity -> general"
4 - On right panel, double click on "button_layout"
5 - Change the value to "close,minimize,maximize:menu"
6 - Press "OK"

Now we have the chance to install their icon-libraries. I ended up using a built-in icon library instead. This is how it looks like:

To install it:

sudo apt-get install gnome-human-icon-theme

Now if you click "Customize" under System->Preferences->Appearance->Aurora Leopard BSM, under the Icons tab you'll find GNOME-Human.

One more thing. You can use the (already enabled by default) desktop effects if you like, but after a while it can become disturbing, so I usually disable it under System->Preferences->Appearance->Visual Effects (not to mention that Desktop Effects still have some compatibilty issues, if I'm not mistaken Google Earth didn't like it).

Still, compositing makes the user-interface snappier; if you go back to gconf-editor, at the same place where you've had the button_layout (apps->metacity->general), you can enable the compositing_manager by checking it. This is the setting I've found the most performing; let me know if you think otherwise or if you've found some other hacks!

Hope you like it! Cheers!
Lajos











3/04/2010

Ubuntu post-installation tasks

After the installation is done, some additional steps must be taken to have a nicely configured system. Just for the record, I'll collect here all the steps I've followed with a brand-new Ubuntu installation.

64 bit Flash-player

Like it or not, flash is a must these days. We keep on receiving youtube-links from friends, etc. Still, if you install through Synaptic, you'll get the 32bit version, which will grab all the 32bit libraries. No good - and the 64bit version feels much more solid. So let's install the 64bit version.

I followed more or less this post; for the record here are the steps I've taken in Terminal:
wget http://download.macromedia.com/pub/labs/flashplayer10/libflashplayer-10.0.45.2.linux-x86_64.so.tar.gz
tar xvzf libflashplayer-10.0.45.2.linux-x86_64.so.tar.gz
mkdir -p ~/.mozilla/plugins
mv libflashplayer.so ~/.mozilla/plugins/
Youtube works like a charm after.

64 bit Skype

Easy. Just download the 64bit version from here. Double-click the downloaded .deb file, which opens Package Installer. Click Install and voila.

Now is a good time to call the beautiful lady at Skype Call Testing Service, hopefully she's there - if you can't here your own voice, check if the microphone is your default input device.

I didn't find the 64bit version in any official ubuntu repositories, so had to go away with the .deb file: this means Skype will have to be updated manually from the Skype website if a new version is released. If you found a repo, let us know!

3/03/2010

Configuring Ubuntu to mount a shared HFS partition

If you have followed along the earlier series of this article, you may have already met one of the limitations of Ubuntu's HFS support: it can't write journaled HFS volumes. Thus, it makes sense to partition the drives with non-case-sensitive and non-journaled HFS where there is a need to read/write. You can also manually disable journaling if you already finished partitioning and you've had the journaled option turned on.

A decision to take: move the home folder, or make symbolic links?
In earlier iterations of my dual-boot configurations, I had my OSX home folder moved to the shared partition. This works quite well, at least up to the point when the system starts up after a "dirty shutdown" when the regular shutdown procedure was not executed properly: like when the computer was frozen and was killed with the power switch (or facing a power-outage on an iMac, or running out of battery on macbooks). In these cases, a disk-check was performed during startup, but since the check can't finish until the computer boots up (and OSX does not wait for the check to finish, rendering the shared volume inaccessible temporarly), we may face an empty home-folder after a dirty shutdown (so you'll face a brand-new configuration, like you have just finished installation, since it uses the unmounted /Users/username folder). This can be fixed by a logout-login, nevertheless it is not nice.

Not to mention if we do the same with Ubuntu: if the home folder is moved to the shared partition and the partition is dirty on boot-up, it will be read-only; if I'm not mistaken this has resulted being not able to login to the system at all. This sounds really bad, so in my experience the best option is to leave the home folders where they are (e.g. Ubuntu will have its' home folder on the EXT3 drive, OSX on the HFS drive), and we'll make symbolic links to the documents, pictures, videos folders on the shared partition. Until we keep our documents where they belong, they will be on the shared drive.

Mounting an HFS volume on Ubuntu

There are two ways to identify a partition to mount on linux: either by the device's name (like /dev/sda1) or by its UUID, which is just a random number. The UUID option is better, since a partition will be identified even if its' name changes (like when the number of partitions changes on a drive: /dev/sda3 won't be /dev/sda3 anymore as soon as we remove /dev/sda1 and /dev/sda2).

To see some information about your partitions, you can use the command blkid:


In this screenshot (don't let yourself fooled by the appearance, this is Ubuntu having a nice gnome-theme applied, thus looks a bit like OSX, pretty neat huh? See here how to install it) it is apparent that I have four partitions, and I will have to mount the last one. I will mount /dev/sda4. Yours can be different, so double-check.

To mount a partition, first we have to create the folder where it will be mounted. Open a terminal, and enter
sudo mkdir /mnt/shared
sudo chmod 777 /mnt/shared
Now we'll add an entry in /etc/fstab. Press Alt+F2 to bring up the Run Application dialog, and enter
gksudo gedit /etc/fstab

Enter your password when it's been asked. This will bring up the contents of the fstab file in the text-editor using the proper rights to edit it (you can use vi of course but then you won't need my assistance in any case...) Add a line to the end of this file:
/dev/sda4 /mnt/shared       hfsplus    rw        0       2
Of course, replacing my /dev/sda4 with the correct entry if needed. Save the file & exit the editor.

Using UUIDs
You could also use UUID to identify the partition; I don't know why, it didn't work for me. To acquire the UUID, copy the UUID from the blkid command (or, if you are using Jaunty you can use the sudo vol_id /dev/sda4 command too), and add the fstab line like this:

UUID=aae739de-bfb8-39d6-b60a-a6e47222e74a /mnt/shared       hfsplus    rw        0       2
Somehow, even though it worked the first time, it didn't work after a reboot, so I've had to fall back to the name. If you figured out the reason, please let us know!

Now we have everything in place. If you reboot, this should mount automagically, but you can mount it right away by entering
sudo mount -a
to a terminal-window. This mounts all filesystems mentioned in fstab - since all others are mounted anyway, ours will be mounted now. To see your mounted filesystems enter
sudo mount
Hopefully your shared partition will be on the list. To shorten the list you can also use
sudo mount | grep sda4

Preparing the shared partition

The shared partition will contain our documents, pictures, music, videos, etc. Now that we have our shared partition mounted, we can create symbolic links from our home folder, so that we don't have to navigate to the shared folder manually.

First let's create the folder for our documents:
mkdir /mnt/shared/doma
mkdir /mnt/shared/doma/Documents
Don't forget to replace my name with yours of course.
sudo or not to sudo? Using multiple accounts
We don't need sudo here, since we want to keep our credentials; by repeating this same process for another user using another name, his/her documents will be on the shared partition as well. Just don't forget to logout/login with the other user's account in this case.

Now just to be sure we don't lose anything, we can move all our may-be-existing documents already:
mv ~/Documents/* /mnt/shared/doma/Documents
Now the Documents folder should be empty. We can verify it with
ls ~/Documents
It should be empty. If it is, we are ready to create the symbolic link.

Creating the symbolic link

To create the symbolic link, enter
ln -sf /mnt/shared/doma/Documents ~
in the terminal. ln -s creates a symbolic link, the f parameter replaces the Documents folder if it exists (it does). Even if it looks like (and we wouldn't have moved our documents earlier), it does not destroy anything under the old /home/doma/Documents: if we remove the link, the contents of the (now hidden) folder would reappear. But since we've been careful and moved everything out of the folder earlier, it is empty anyway.

This same procedure can be repeated with the Pictures, Videos and other folders.

Moving the folders on OSX

In order to have a nice and clean system, we should move these folders in OSX as well. Thus, if we'll go to the Documents folder, both OSX and Ubuntu will go to the same folder.

The procedure is quite similar to the previous one. Let's create a small shell-script which will help us:
mkdir /Volumes/shared/doma/$1
mv ~/$1/* /Volumes/shared/doma/$1 && sudo rm -rf ~/$1
ln -s /Volumes/shared/doma/$1 ~
Copy these lines to TextEdit, make it Plain Text (format menu) and save the file in your home folder using the name mv.sh - and don't forget to replace my name with yours! This shell-script automates all the necessary steps for OSX. We'll have to make it executable first with
chmod +x mv.sh
Now we can execute it for all the folders we want to move. For the Documents folder, enter
./mv.sh Documents
You can do the same with your Movies, Music, Pictures folder if you like - but take iTunes' and iPhoto's proprietary folder-structure into account, you'll see the details of their file-storage in Ubuntu (that's linux anyway and supposed to be lower level right?). In any case, you'll have access to your files - and if you use some other, possibly multi-platform tool to manage your pictures and music, you may end up having a quite usable multi-platform system.

Drop a comment if it works for you, tell us how you've configured your system - and don't hesitate to ask if you have a question!

Thanks for dropping by - see y'all next time!






12/09/2009

Eclipse: quickly change perspectives with keyboard shortcuts

Perspectives offer a nice way to quickly adapt Eclipse to the kind of work we are doing; there is a perspective for development, debugging, etc. After using it a while, creating some keyboard-shortcuts helps a lot as well. At the end of this article, we'll have perspective-icons like these:



Let's see what the buttons do:
  • JavaEE Perspective (Alt+1)
    • In this perspective the Project Explorer (tree) is displayed on the left, on the right we have the code-editor window and the tool-windows benefiting from a wide display are on the bottom. The icon shows a tree, that's why it makes sense to use this perspective for the one displaying the tree.
    • To open this perspective, select Window->Open Perspective->Other, and select JavaEE. The defaults are almost right, we just have to either close the outline and task list view if we don't use it, or move them to the left (next to the Project Explorer) so that they won't occupy so much space.
    •  To attach it to Alt+1, press Ctrl+Shift+L twice (this is a double-shortcut which on first press shows the available options in a tooltip, on a second press presents us the Preferences->Key window); in type filter text enter java ee; click on Show Perspective (Parameter Java EE) ; click binding, then press the new bind-key Alt+1 and Apply and OK.
  • Java Perspective (Alt+2)
    • This one is very similar to the previous one, except that we don't have the tree displayed, which results in a much wider source-window (for developers fancying long lines...)
    • To open this perspective, select Window->Open Perspective->Other, and select Java (Default). Let's close the Outline / Task List / Spring Explorer view as well as the Package Explorer and Hierarchy view. 
    • Attach the Show Perspective (Parameter: Java) command to Alt+2
    • This results in a very clean interface; we just have to get used to press Alt+1 to switch to the view we declared previously if we need the views we just closed. Just try pressing Alt+1 and Alt+2 repetitively a couple of times; you'll see easy it is to switch. In no time we get used to press Alt+2 when we need a "code-and-tool" like environment and Alt+1 when we want to browse around in the Package Explorer / Ant / etc views.
  • Debug Perspective (Alt+3)
    • The debug-layout really depends on the developer, but the methology is similar. So open this perspective and customize it the way you want.
    • Attach it to Alt+3.
  • Team Synchronizing Perspective (Alt+4)
    • Customize / attach key like earlier.
  • Database Development Perspective (Alt+5)
    • Customize / attach key like earlier.
The last ones are really depending on your development workflow. A typical workflow using these shortcuts can be something like this:
  • Find and Open the needed class or resource:
    • Alt+1 for browsing in Project Explorer
    • Alt+2 and press Ctrl+Shift+R to quickly open the source-file/resource. Here the first couple of characters of the classname should be enough to type - or CaMeL case, e.g. if you want to open DeadLetterChannel, just enter DLC. Neat, huh? And highly addictive...
  • After the modifications are done starting the debugger switches immediately to the Debug Perspective, but if the wide code-view is needed just press Alt+2 (it's a real relief after the very-useful-but-so-crowded Debug perspective); and when you need something from the debugger tool windows, it's very easy to switch back to the Debug  Perspective with Alt+3. Since the usual shortcuts like F5 (step into), F6 (step over) and F7 (step return) work in Java perspective as well, I usually find myself stepping thru the code there, and only when I arrive at the troublesome part, I switch to the Debug Perspective to see the watches, call stacks, etc.
  • When everything is ready, debugged, etc, Alt+4 switches to the Synchronising Perspective to submit the changes to source-control.
  • After a rebuild on the development server, the Database perspective (Alt+5) can be used to interact with the database.
The order of the buttons on the top-right corner depends on the order we opened the perspectives; I usually order them the same way as my keyboard-shortcuts (e.g. the first one is JavaEE because Alt+1 activates it, etc); thus the mouse usage is coherent to the keyboard. The buttons can be easily re-ordered with the mouse by dragging them to their place (Note: the "Show Text" option is turned off on the screenshot on the top of this post)

Comments and opinions are warmly welcome!
How does your developer workflow look like?

Thanks for reading and have a nice day!

11/27/2009

AppFuse Struts2 Tutorial with Eclipse / SpringSource Tools Suite

Excerpt from AppFuse's website:

AppFuse is an open source project and application that uses open source tools built on the Java platform to help you develop Web applications quickly and efficiently. It was originally developed to eliminate the ramp-up time found when building new web applications for customers. At its core, AppFuse is a project skeleton, similar to the one that's created by your IDE when you click through a wizard to create a new web project.

AppFuse builds on Maven to accomplish its goal. AppFuse + Maven can be used command line, creating our application with just a single line; but here we will be using Eclipse.

In this tutorial we'll go through the creation of a simple Struts2 web-application, which we'll extend later. We'll use SpringSource Tools Suite 2.2.1 (STS) which is a free tool based on Eclipse 3.5.1 with a pre-configured set of plugins useful for web-development. STS has the Maven2 plugin which we'll use to configure AppFuse for us.

So, grab a copy of SpringSource Tools from http://www.springsource.com/products/sts. After the installation, select File->New->Project... Type maven, and click Next:



Leave "Use default Workspace location" checked and click Next.



Enter struts in the filter, and select struts2-archetype-starter. This is a so called "Maven Archetype", a ready-to-be-used project template built around the Project Object Model (POM), which will create a starter application for Apache Struts 2.0. Click Next.



Now enter the following info:
  • Group Id: org.techmissive
  • Artifact Id: testdrive-struts
  • Version: 1.0.0
  • Package: org.techmissive.testdrive.struts
And click "Finish":



We have created our template project. Now Eclipse (I mean STS of course) will start downloading all our dependencies, and build the project for us. On OSX, we can see directly the Maven-log; on Windows we have to open the Console view (Alt+Shift+Q then C), and click the down-arrow next to the Open Console button on its toolbar (the window-like button left of the green lamp) and select Maven console to see what Maven is doing.



Included with this template is Jetty, a lightweight servlet container, which can be used to test our application locally without installing a full blown J2EE Server. Let's see how we can start it from STS.

Select Run -> Run Configurations... from the Menu, here we'll specify what happens when we start our application. Select 'Maven Build' from the list, and click on the New icon on the top of the window to create a new configuration.



To set the Base directory, click on Browse Workspace. Now click on testdrive-struts and OK. This sets ${workspace_loc:/testdrive-struts} in the Base directory field, which is a relative resolution from our workspace location.

To run Jetty, we have to run a given goal, so enter jetty:run-war in the goals field.

Replace the New_configuration default name with something more meaningful, like Run Jetty.



Click Apply to save, and Run to start the configuration we just created.

Now Eclipse is working again, starts to download all kind of stuff. But in the end proudly confirms the successful starting of Jetty:



Let's test if it works. Jetty is listening by default on the port 8080, so let's start a browser and check what is there. Start Safari and enter http://localhost:8080/testdrive-struts in the address field:



We have a running Web-application and we didn't have to write a single line of code. This is the main purpose of AppFuse: to provide us a skeleton application we can start working on without hours of hunting for the libraries, configuring them, etc. I just wish all the profiles would work the first time like this one...