Category Archives: Uncategorized

Android: How to test Local Web Apps on an Emulated Device (AVD)

Android AVD running local Web App

Editing your /etc/hosts file is great for running and testing web apps as they are under development. For a project I’m working on, I needed to be able to access one of my local Rails apps through an Android device, which meant editing the device’s /etc/hosts file. As I haven’t rooted my Nexus-S, so opted to use an emulated Android Virtual Device (AVD), as they are configured by default to allow root access.

I started by creating a simple hosts file on my desktop. It’s this file that I would push to the AVD

cd Desktop
vim hosts # or your favourite text editor....

Use your text editor to create a simple hosts file pointing to your local web app. Remember to also include a localhost entry:

  # hosts
  127.0.0.1       localhost 
  192.168.1.10    rails-app

Next, copy your new hosts file to the AVD:

adb push hosts /etc/hosts

Access Denied

Despite having root access, though, adb wouldn’t let me push the new hosts file because the system partition is mounted as read-only. You can remount the system partition in read-write mode using adb remount, and then try pushing the hosts file up to the device:

adb remount
abd push hosts /etc/hosts

I kept getting an Out of Memory error, which seems to be a common problem. The solution (gleaned from scattered forum posts) is to use the emulator’s -partition-size option.

Using this option means you won’t be able to launch the AVD directly from Eclipse, but instead need to use the command line. Close down any running AVDs, and then run, and then re-launch the AVD passing in the -partition-size option with a reasonable value:

emulator -avd Samsung_Galaxy-Tab -partition-size 128
 
# ...wait the avd to boot up...
 
adb remount
abd push hosts /etc/hosts

The hosts file should now successfully be copied to your AVD. If you launch the AVD’s browser and enter the local URL from your hosts file (e.g. http://rails-app:3000/), the AVD will connect to the local IP address you specified.

Note: You’ll need to keep hold of your hosts file as your settings will be wiped when you shut down the AVD. You can reinstall the file next time by performing the adb remount; adb push hosts /etc/hosts script each time you boot the AVD.

References

  1. Google Groups Thread
  2. Cute Android Tips: Failed to Copy File to System

Thoughts: On Agile Project Estimating and Pricing

Tasks Board

The usual approach to pricing service work is the hourly rate – a simple model that is easily understood, and translates well across different disciplines and businesses. Service work often has so many variables that an hourly rate seems to offer a good compromise between a fixed-price quote, and ensuring the supplier has flexibility to charge for unknown future work.

However, in practice, the hourly rate is a poor option for both parties. Taking software development as an example, it can be hard as a supplier to demand (or not to demand) extra fees for hours incurred over original quote. For the customer, there is the worry that the hours will rack up quickly without results, or that she may end up paying for unused hours. At its most basic level, rewarding time with money encourages laziness – what incentive is there for a supplier to finish the job quickly, only to be paid less?

Charging an hourly rate really does no favours for either the supplier or the customer, yet continues to be the status-quo, as it’s hard to find any simple alternative.

The Goal: Remove Time from the Equation

Like others, one of the many reasons I set up business was to escape the confines of time equals money. In fact, as any business owner will likely attest, you’ll often spend considerably more time working on your business than for which you’ll ever see financially reward – but that’s all part of the fun!

In trying to break the reliance of time from income, I started looking at different ways of estimating and managing my client projects. This is usually achieved in two ways: employ people, and generate profits on their time; or build and sell assets.

For a small software company, assets are often the dream: a product – or range of products – that keeps selling, and requires roughly the same investment in time whether you’ve sold one or one thousand. Whilst this is the dream, there is more often than not a huge upfront cost involved. If you’re bootstrapping your company, it’s likely client work will be essential in generating income to cover your bills.

Trial and Errors

After a few projects based on a standard hourly rate, I decided to embrace iterative development. The idea was to charge on a per-iteration development cycle. Each iteration was a fixed period of time (usually 2 weeks), and was charged at a fixed price. The amount of work completed in this cycle would be used to estimate the amount of work that could be completed in the next iteration. This was very simple interpretation of agile project management with velocity tracking.

The process seemed to make sense, but in practice was still bound to time. Essentially, I was quoting on a bi-weekly rate rather than an hourly rate. This resulted in the same problems, just without the fidelity of tracking individual hours.

Another realisation was just how rarely projects fit into the neat time-boxes we assign them. Often an iteration would extend beyond 2, or even 3 weeks, simply because the day-to-day running of business (for both parties) takes time. In this situation, it would be completely inappropriate to charge for 2 iterations, but with the project held up, and my velocity was reduced to 1!

I’d fallen into the trap of worrying more about the process (paperwork!) than the end-result. It was clear I needed to completely remove time from the equation, and concern myself with output.

Focus on Results: Agile Project Estimation & Tracking

With this in mind, I’ve decided to revise my iterative estimation and projection process using a simplified take on the agile process. Throughout a project, each user feature (or story) is assigned a number of points based on its estimated difficulty. The majority of stories should be 1 point, a story that is known to prove difficult is assigned 2 points, and an unknown (e.g. developing something that is likely to require a high degree of research) is assigned 3 points. There are alternatives, such as using the Fibonacci sequence, but to my mind the simplicity of this model is an advantage for both me and the customer.

Rather than charging by time, I’ll cost a project on the total number of points it contains, with each point priced at a known constant. For example, assuming a £200-per-point price, then a 2-point story would be charged at £400.

Of course, the accuracy of using this approach is in gathering, and successfully distilling, initial requirements. But by breaking the project into achievable stories and points, the customer can see a break-down of exactly where their budget is being spent, and revise or prioritise accordingly.

From the developer’s point of view, this approach maintains the flexibility that comes from hourly rates. If the customer requests new or changed functionality, then new features (and hence points) will be allocated to the project. I’ll continue to use the iterative project approach in estimating how much work can be completed within a fixed time-frame, and continue to track velocity so that the accuracy of these estimates can be improved.

Things Will Change: Stay Agile

There are, of course, going to be imperfections in the process. This will certainly be the case with the subjective parts of a project. Stories are necessarily concrete and describe functionality, so how can points be assigned to the graphic design of an application’s interface? I think this will just have to be left to experience of estimating, but I hope that using a pricing structure that is measurable, flexible and rewards efficient and effective development will prove beneficial to both parties.

I’ll post updates on how this approach goes, but in the meantime please feel free to discuss your thoughts in the comments below.

Resource: Google Nexus-S Graphic for Inkscape (SVG / XCF)

I needed a reasonable representation of the Google Nexus S for my site and some client proposal work. There are some stunning examples out there already, but those I found were generally in PSD or non-scalable PNG formats.

Being a long-time Ubuntu convert, I needed something that was scalable and worked nicely with Inkscape and GIMP – so I set about drawing my own.

The graphic is far from pixel-perfect, but gives a good representation of an Android device for proposals and mock-ups, etc. The XCF is sized so the screen area is 480×800; the SVG is of course scalable.

This is my first release. The source files in SVG and XCF format are included in the download, and licensed under MIT. Free to use and improve however you wish.

Download .zip

Rails 3: How to Autoload and Autorequire your Custom Library Code

Every time I start a new Rails 3 project, I’m always caught out by its autoloading behaviour. Rails 3 will only require (and so autoload) a module when it is first encountered within the application code, for example by a call to include or require.

Whilst the reasoning behind this decision is sound, I usually just want to load some common functionality into, for example ActiveRecord, and have it available to all of my models.

So, as a reminder to myself and to help anyone else caught out by this, here is how to autoload (and autorequire) your own library code in Rails 3:

Ensure that your library code’s path is set in config/application.rb. By default, Rails 3 autoloads from a /extras folder, but I conventionally keep custom library code in a /lib folder:

# config/application.rb
config.autoload_paths += %W(#{config.root}/extras #{config.root}/lib)

Next, we need to tell Rails to require our library code (so it is available to the application). Create a new initializer called application.rb in config/initializers and require your library modules:

# config/initializers/application.rb
require 'my_modules'
require 'my_modules/active_record/active_record_extensions'
# ... require any other custom modules your application uses

All that’s left to do is restart your Rails server to load your custom modules into the application. Remember that if you change your custom code, you’ll need to restart the server again to reload the changes.

Ubuntu 11.04 Beta – How to test Unity in VirtualBox 4

Ubuntu 11.04 Beta ScreenshotIf you like to test out the latest and greatest builds of Ubuntu, you might like to try the latest 11.04 beta in VirtualBox.

Unfortunately, I’ve found the standard VirtualBox guest additions don’t offer the graphics support to run compiz on Ubuntu 11.04, so testing Unity didn’t seem possible. Thankfully, I stumbled across this post (Portugese) which shows you can install guest additions directly from the Ubuntu repositories:

With a freshly installed copy of Ubuntu 11.04 Beta running in VirtualBox, open a terminal window and type the following:

sudo apt-get update; sudo apt-get install virtualbox-ose-guest-utils -y; sudo reboot

Update: Also make sure you’ve enabled 3D acceleration in the guest machine’s settings.

This line will install the up-to-date VirtualBox guest utilities, and reboot the virtual machine. You should now find the new – and very impressive – Unity interface ready to try out.

References

Ubuntu 11.04 in VirtualBox with Natty Narwhal Unity