Sunday, August 22, 2010

VirtualBox For Windows 7 and Ubuntu 10.04

So, I decided to investigate setting up a virtual machine so I don't have to constantly reboot as I go between Windows and Linux.
After doing some quick research on all the various options out there (VMWare, VirtualBox, Microsoft Virtual PC,...) I decided to go with Sun VirtualBox.

The setup was fairly easy:
1. You decide a "host OS" that you want to use (in my case it was Windows 7).
2. Download and install VirtualBox from http://www.virtualbox.org/wiki/Downloads
3. Decide on the guest OS (or OSes) you want to install (in my case Ubuntu 10.04)
4. Run the VirtualBox console.
5. Select New Machine - this brings up the wizard.
6. Give it a name and select the operating system type from the dropdown.
7. Browse to the ISO image to install
8. Install the OS.

There is one quirk I've encountered so far - When I run my guest OS (Ubuntu) and try the switch to full screen - I see a full screen, but the actual OS itself, remains in the same size screen. I found the solution to this problem at this link :
This post was particularly useful:
Start the guest
  • Open a terminal window
  • sudo -i press enter
  • apt-get install build-essential
  • apt-get install Linux-headers-generic
Leave the terminal open you are going to need it again.

When this is done the devices tab is at the top left of the guest window (called a VM which stands for virtual machine) then click install guest additions.
This will put a CD on the desktop. Double click to open and then select the guest additions for your machine (see note below) and right click-drag and drop on the terminal window.
Click once in the terminal to get focus and then hit enter. Wait for everything to finish and then reboot the machine. Watch for any errors and if you have any report back here with the exact error message.

Note: Select VBoxLinuxAdditions-amd64.run for 64 bit or VBoxLinuxAdditions-x86.run for 32 bit

After you have the Guest additions installed you use the mouse to adjust the screen to the size you want or you can use the (Host+f) toggle for full screen or the (Host+L) toggle for seamless. The Host key is the right Ctrl key which a MAC does not have so to use this feature you will need to go into the main VirtualBox Program and at the top left click file, then preferences and then input. Click once where it says Right Control and then press the left ctrl key on your MAC keyboard. Close and then start the guest again for this to take effect.

Sunday, December 13, 2009

Getting Setup for Android-ing (Windows Vista)

1. Installing Eclipse(for java):
Downloaded Eclipse 3.5 (Galileo) for windows (will move to Ubuntu ultimately, but, starting out on my vista machine). The specific package I downloaded was Eclipse IDE for Java EE Developers (189 MB). It is big, but, the advantage is, it includes JRE and the JDT plugins as well.

C:\Users\Anil>java -version
java version "1.6.0_11"
Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
Java HotSpot(TM) Client VM (build 11.0-b16, mixed mode, sharing)


2. Getting JDK 6.0:
Downloaded JDK 6.0 from SUN's website. (~164MB). (~270MB, installed).

3. Dowloading the Android SDK:
Available from the Google Android Website . I downloaded version 2.0.1 for Windows. (~22MB). Be sure to run SDK Setup.exe after you unpack. (Note: I had to change the "https" to "http", so, you may have to do the same, for it to pull files from the android repository; getting files from repository takes a looooong time!)

4. Throwing in the ADT Eclipse Plugin:
Not a requirement, but the Android Development Toolkit (ADT), is a plugin that google wrote for eclipse that is supposed to make development easy. I figure I have the time and the disk space, so why not :). Get it from here (technically, you don't directly get it from there, just follow the instructions there on how to use eclipse to install ADT plugin).

Android-ing

I just bought my first smart phone a couple weeks ago. The DROID! and I am soo in love with the phone and the software (Android 2.0, eclair), in particular, that I've decided to do a little digging into Android myself.

I'm starting at Google's Android Development Page and exploring what it takes to develop basic applications for android.

Like I said, I am absolutely in awe with the power of this new mobile OS and I want to find out more! And, I hope to post any quirks I run into as I go about this new venture, to my little blog, here!

Sunday, April 5, 2009

RoR says "Hello"

Lets begin with a simple Hello World program in Ruby.

Open a command window and navigate to where you want to create this cookbook web application. I used D:\Developer\Rails.

D:\Developer\Rails>rails -d mysql cookbook

This will create the cookbook subdirectory D:\Developer\Rails\cookbook along with the directory tree with folders for the app, db etc.
Starting with Rails 2.0.2, rails defaults to using SQLite3 database. If you want to use a different database you can specify it using '-d' option as shown above.
To test the web application, browse to the cookbook directory and do :

D:\Developer\Rails\cookbook> ruby script\server

This boots the WEBrick HTTP server by default. You can change the server to use Apache instead.
You can browse to http://127.0.0.1:3000/ or http://localhost:3000
This shows you the "Welcome Aboard! You are riding Ruby on Rails!". Leave the command window open with the server running.

Lets create a MyTest controller that serves a simple "Hello World" HTML page.

D:\Developer\Rails\cookbook> ruby script\generate controller MyTest

This will create a file apps/controllers/my_test_controller.rb. Right-click on this file and choose Edit.
Edit the file to look like the following :

class MyTestController < ApplicationController
   def index
      render :text => "Hello World!"
   end
end

Now browse to http://localhost:3000/MyTest
If the page does not open, check the command window where the WEBrick server is running. You will find a lot of debugging messages. If you see an error like "Unknown database cookbook_development' and don't see the database in "D:\Developer\Rails\cookbook\db" then create it and try again.

Congratulations! you just successfully wrote the Hello World program.

Sunday, March 29, 2009

Setting up a Ruby-on-Rails Development Environment

Ruby as a programming language has been around for about a decade now, but, more recently it seems to be receiving a lot of attention in the web development world. So much so, that I decided I had to take the plunge myself and find out what the buzz was all about.

After playing around with it for just a few days (couple weekends actually), I was so fascinated that I decided to write a series of blog posts about it, just in the hope that others will also be drawn to it.

So, here we go, as a "first in the series" - here's a quick draw down of how to get your system set up, so you can be on your way to creating that killer web app using RoR


THINGS NEEDED:
----------------------


One of the reasons for the massive popularity of RoR recently was the creation of the rails platform and it's power to help yo connect your front end app to a database in no time and manipulate it with ease. With that basic background, the following are the elements we will need for our little project:

1. Ruby
2. Rails Framework
3. Database System (MySQL or equivalent DB, like postgreSQL or Oracle)
4. DB FrontEnd (Like HeidiSQL or equivalent)

1. Installing Ruby

Install from the following location:
http://rubyinstaller.rubyforge.org/wiki/wiki.pl

If you are a first time user, just accept the defaults.

2. Setting up the rails framework

Rails is what helps you connect your Ruby application to your database easily. Setting up the rails framework is also very easy and can be done from the
command line itself. It is kinda like installing a package in Linux.

Before we go about installing rails, we will do a quick sanity check to make sure Ruby itself was installed correctly. For this, open a command prompt and type "gem". You should see it display a help/ usage guide to the RubyGems Package manager. If you don't see this, there is a problem with the Ruby install you did in step 1, above.

D:\Developer\Rails\cookbook>gem

RubyGems is a sophisticated package manager for Ruby. This is a
basic help message containing pointers to more information.

Usage:
gem -h/--help
gem -v/--version
gem command [arguments...] [options...]

Examples:
gem install rake
gem list --local
gem build package.gemspec
gem help install

Further help:
gem help commands list all 'gem' commands
gem help examples show some examples of usage
gem help platforms show information about platforms
gem help show help on COMMAND
(e.g. 'gem help install')
Further information:
http://rubygems.rubyforge.org

If, all is good so far, do the following to install the rails framework:

D:\Developer\Rails\cookbook>gem install rails --remote

Note: RubyGems will also install all of the other libraries that Rails depends on. For each of these dependencies, RubyGems will ask you if you want to install it. Answer "y" to each one.

That's it, you have the rails framework installed. Now, move to set up the database system

3. Setting up the DBMS (mySQL)

There are a number of free (opensource) and paid data base systems out there you can use. For my example, I am going to use mySQL.

To install mySQL, go to the following page: http://dev.mysql.com/downloads/mysql/4.1.html

The installation should be pretty straightforward -- double click the installer file to start the installer, just accept all defaults and click finish to bring up the configuration wizard. There is just one small change to be made here - when it brings up the "security panel", be sure to uncheck the "modify security settings" checkbox. The reason for doing this is because, the authentication algorithm used in mySQL may or may not be compatible with your version of rails. Unchecking it also means that you can access mySQL without a password. Other than that, accept all the default settings in the configuration wizard to complete the DB install.

4. Installing a DB FrontEnd (HeidiSQL)

The DB FrontEnd is used to access (CRUD =Create, Read, Update, Delete) a the database system, with ease. It is not absolutely essential to have this, you can access mySQL from the SQL> prompt, at the command line.But, having a nice frontend saves a lot of time and effort and makes life easy (while keeping you focused on the "bigger picture")

There are multiple free and paid applications that are frontends to SQL and Oracle database. The one I will use it called "HeidiSQL"

Install HeidiSQL from http://www.heidisql.com/?


AND THAT'S IT!!
You are now all set to develop that killer Ruby-on-Rails database driver application (I will cover the basics of doing that in the next few posts, so stay tuned!)

Oh, and do let me know (comments) if you find any errors/ issues with the above, or if you found it useful

Tuesday, February 24, 2009

Facebook Connect Test

I just discovered a cool way to connect Facebook with my blogs. If this works, it will allow all my FB pals (whos opinions I greatly value :-) to comment on any of my blog posts, using their Facebook IDs!!

If you want to help with this experiment, just click on the "comments" link, at the end of this post, where you should find an option to login, using your facebook ID (in addition to a couple others). Selecting the FB option should, depending on whether you are logged into FB on another tab of this browser or not, ask you to log in using your FB ID. Once you do that, you can post a comment and your FB profile pic will show up an an icon next to it, so you are not "Anonymous" anymore :)

How does it work?
It combines Blogger with Discuss and Facebook Connect through a simple FB application.

Is it secure?
Yes. It uses the same security features that are used to secure your facebook identity (API Keys and Application Secrets). What that means is, even though eveyone will see your FB profile pic as a small icon next to your comment, what they get to see when they click on it, depends on your FB security settings. If they are you friend, and are logged into FB, it'll take them to your profile page. If they are not your friend, they will see your "basic" public profile (whatever you have set that too).

If this works, I am hoping to enable this cool feature on my other two blogs (see top left side bar of this page) as well.

So, let me know how it goes!

Monday, February 23, 2009

From Gutsy Gibbon to Interpid Ibex in under 20

So, like I wrote in my previous post, my experience migrating to Ubuntu was pretty effortless and painless for the most part. There are just two small issues that remain before I can consider myself "completely up-and-running"

1. The resolution of my monitor is kinda crappy (a max of 800x600)
2. My wireless card doesn't work.

Now, while I go about trying to resolve those issues, I am sure I'll have to do a bit of packet updating and installing. So, I figure why not be systematic and figure out how package management is handled under Ubuntu

With that in mind, I decided to get up to speed with the Ubuntu package manager, today. And may I say it is just a charm to use. It took me under 20min to upgrade my system (yes my entire Debian system) from 7.10 to 8.10! How did I do it. Just one line:

anil@anil-laptop:/home$ sudo apt-get -u dist-upgrade

That's it! That's the power of the APT manager in Ubuntu!

APT is basically the Debian Packet Management Utility in Ubuntu. What it does is, maintains a database of packages, dependencies and versions and then pulls whatever has changed or doesn't exist on your system out of a "repository" (fancy name for a server that stores .deb files, which are the equivalents of .rpms, in Ubuntu).

Using APT to install/ upgrade/ remove packages, can be done in two ways

Command Line: If you are like me and prefer this, you'll find this quick cheatsheet useful:
* apt-get update app: updates etc/apt/sources.list file that is a local database of all updates
* apt-get install app : installs app (installs dependencies as well)
* apt-get --reinstall install app : WIll repair or reinstall new version of app
* apt-get remove app : removes app (will take out dependent packages as well)
* apt-get purge remove app : removes app + any configuration files.
* apt-get -u upgrade: upgrades packages and lists (-u option) what is being upgraded.
* apt-get -u dist-upgrade: upgrades the entire distro (ubuntu)

GUI mode: For this, there is Synaptic, which is a graphical frontend implementation of APT, and can be accessed from the taskbar under System | Administration | Synaptic Package Manager