Categories
Computers

Got a beeping disk? Don’t despair!

I had a power outage a couple of weeks ago and when the power came back up I noticed that one of my servers made a strange beeping sound that I had not heard before.

My first thought was that all the data was lost. I knew that there are professional services that may be able to recover data but that they are typically very expensive. This was a private server and most of the data had been backed up anyway so paying that sort of money to salvage the disk was not an option I considered.

As it turns out, this particular issue is actually quite simple to solve by almost anyone. The only thing you need is a T6 torx screwdriver, a clean surface, a toothpick, a steady hand and some luck. It also helped that the data was not extremely valuable for me. I would perhaps not recommend this procedure if you care very much about the data on the disk. In that case it may be better to pay up. You can definitely make things worse. Don’t say I didn’t warn you.

Note that these instructions only apply if the disk beeps like in this audio clip. If the disk makes a more mechanical noise then the error is caused by some other issue and you should not follow these instructions as they could worsen the situation.

When the disk is beeping with a steady period (typically around 1Hz) it typically means that the disk head is not in its parked position when the disk is about to spin up. Normally the head moves away from the disk before the disk is shut down and does not move in over the platters until they are spinning at full speed. The rotating disks create an air flow that acts as a cushion for the heads so that they do not touch the surface. If the heads are over the platters when the disk is off then the disk will just refuse to spin up.

To fix the issue one just needs to open the hard drive and gently move the head to its parking position while at the same time turning the platters counter-clockwise.

The lid covering the internals of the drive is usually held in place by seven screws. Six of those are along the edge and readily visible. The seventh is in the centre of the disk head arm and normally covered by a sticker.

You may be concerned about opening up the disk outside of a proper clean room. While it is true that the internals of the disk are delicate you should not be too concerned. The disk is constructed to be able to handle small amounts of dust that could be released from the internals of the disk during operation. The white item in the bottom right on the photo is a filter that is there to catch dust particles. The heads do not leave their parking position until the disk it at full speed and their speed creates an air flow that should remove any dust from the disk and deposit it on the filter.

When you move the head back it may feel like it is stuck at first due to static electricity. Just rotate the disk counter-clockwise while you gently move the arm back and you should be fine. I found that a toothpick is a good tool for this. The image below shows how the arm should be positioned when you are done. Then just put the lid back on and keep your fingers crossed.

If it worked then congratulations. But make sure to copy the data to a new disk and consider the old disk used, never to be trusted again.

HD OK

Categories
Blog Mobility Wearables

Watch out for Apple Watch

Almost exactly eight years ago the late Steve Jobs presented the iPhone at MacWorld 2007. “It’s a widescreen iPod with touch control, a revolutionary mobile phone and a breakthrough Internet communications device”. The audience was enthusiastic, yet very few fully realised the impact this would have on an entire industry. As a phone and compared with what we have today it was lacklustre. There was no app store, that was to come much later. And as far as connectivity goes it was inferior to other phones, having only 2G connectivity. You could not copy and paste text when texting or writing email, nor attach photos. Which was probably just as well, since the camera was only 2MP and produced rather ordinary photos and no video. And, like the T-Ford, you could have any display background you wanted as long as you wanted black.

We all know what happened. The iPhone improved by leaps and bounds. An app ecosystem virtually exploded around it. The connectivity has since vastly improved and the performance is now hugely better thanks to Moore’s law. In the process it completely obliterated a number of industries and companies. Nokia, the biggest phone manufacturer at the time the iPhone was introduced has since succumbed due to their inability to see and act on the shift in their industry. But the impact of the iPhone was not limited to the mobile phone industry. The iPhone is today the go-to-camera for most people and there is now very little need for a standalone GPS to find your way.

Apple Watch

This spring Apple will release the Apple Watch to the world. And even though it mostly likely is a magical device that will find its place on the arms of many people (mine included) it is probably wise to see the future evolution of Apple Watch in the light of the history of the iPhone. It may not take eight years for the Apple Watch to find its true form but we will no doubt look back on 2015 a few years from now and realise the shortcomings of this, the first generation of the Apple Watch.

The Apple Watch of 2020 will no doubt be very much thinner than the first generation, charge seamlessly and run for weeks on a charge, be connected with everything around you and have a colour display that is always on. The first generation will require a phone to run apps but it is not hard to imagine that this requirement will be dropped in later revisions. When this happens it will be the beginning of the end for other watch-like offerings for runners, golfers etc.

Make no mistake. The release of the Apple Watch this year is not just for a watch but of a new product segment that will profoundly change several industries just like the iPhone has done before it. Many companies that fail to transform their business will go under but many other companies will flourish based on applications that we have yet to imagine.

Now, I just hope that spring comes early this year.

Categories
Blog Computers Linux

Ubuntu wallpapers

For every version of Ubuntu there is a set of wallpaper images. Each version has its own set and doesn’t include the old ones. However, it is very simple to install all previous versions by running:

apt-cache search ubuntu-wallpapers- | awk '{ print $1; }' | xargs apt-get -y install

As of today (January 2015) this will install the wallpapers from:

  • Karmic (9.10)
  • Lucid (10.04)
  • Maverick (10.10 LTS)
  • Natty (11.04)
  • Oneiric (11.10)
  • Precise (12.04 LTS)
  • Quantal (12.10)
  • Raring (13.04)
  • Saucy (13.10)
  • Trusty (14.04 LTS)

If you want to use them for other purposes you will find the images in /usr/share/backgrounds/. I use them as wallpaper in OS X. In return I may just use the Yosemite wallpapers in Ubuntu to really confuse people.

Categories
Blog Computers Mac

Broken unison brew on Yosemite

I rely on Homebrew for many of the command line tools I use on my computers. One such tool is unison, a powerful synchronisation application for keeping files in synch. I use it as a way to allow me to work on any one of my computers with maintained security and without having to send my files to a cloud provider. These days there are several alternatives with Bittorrent Sync as probably the best option.

One caveat with unison is that it requires all peers to use the same version of the binary. But with a limited number of peers this is not a major issue.

For a long time I just used precompiled binaries for OS X and Ubuntu using the same unison version. Then, as I reinstalled the Ubuntu server and got a newer version I realised that this was the same version (2.40.102) that was installed with brew so I ditched the previous binaries and installed unison using brew instead. That worked for two OS X computers but on the third one I got an error when synchronising the files:

Uncaught exception Failure("input_value: bad bigarray kind")

This exception occurred on a completely reinstalled Macbook. The exception seems to be caused by unison using an incompatible version of ocaml compared with the ones on my other computers (the brew version is compiled against ocaml v4.02 while my other clients were using 4.01).

As I see it there are two potential solutions to this problem:

  1. Upgrade all peers to the new ocaml version
  2. Build a version of Unison using the older (<4.02) version of ocaml

For this article I chose the latter alternative.

First, I needed to install version 4.01 of ocaml. Brew will by default use the most recent stable version (right now 4.02) but can be made to install older versions if required. To list the existing versions run:

$ brew versions ocaml

4.02.1   git checkout a772c80 /usr/local/Library/Formula/objective-caml.rb
4.01.0   git checkout 924387b /usr/local/Library/Formula/objective-caml.rb
4.00.1   git checkout b04e346 /usr/local/Library/Formula/objective-caml.rb
4.00.0   git checkout e2140fd /usr/local/Library/Formula/objective-caml.rb
3.12.1   git checkout df16522 /usr/local/Library/Formula/objective-caml.rb
3.12.0   git checkout 0476235 /usr/local/Library/Formula/objective-caml.rb
3.11.2   git checkout ed51a5b /usr/local/Library/Formula/objective-caml.rb

If the versions command above shows ‘Error: Unknown command’ then just run

$ brew tap homebrew/boneyard

After that, run the versions command again and it should work. This will display a warning that brew-versions is unsupported. Ignore this for now and notice the line with version 4.01.0.

$ cd `brew --prefix`/Library
$ git checkout 924387b /usr/local/Library/Formula/objective-caml.rb
$ brew install ocaml

Now we should have ocaml v4.01.0. Then, compile unison from source in a temporary directory that you can remove afterwards:

$ cd /tmp
$ wget http://www.seas.upenn.edu/~bcpierce/unison//download/releases/unison-2.40.102/unison-2.40.102.tar.gz
$ tar -xvzf unison-2.40.102.tar.gz
$ cd unison-2.40.102
$ make UISTYLE=text
$ sudo cp unison /usr/local/bin/

Now you should have a working unison installation using ocaml 4.01.0

Featured photo by Giuseppe Milo (https://www.flickr.com/photos/giuseppemilo/15602907800).

Categories
Blog Computers

Android and iOS version distributions

When writing apps for Android and iOS it is important to keep in mind the different versions of each system. You want to use new cool features that are available in later versions but you do not want to alienate too many users by using features that are not compatible with their phones.

The Android documentation recommends developers to ensure that the app is compatible with at least 90% of active devices. For Android this currently means that the app must support all versions going back to Ice Cream Sandwich (version 4.0.x). This is the fifth latest release including Kitkat (version 4.4)

Android version distribution

Version Codename API Distribution
2.2 Froyo 8 0.5%
2.3.3 -2.3.7 Gingerbread 10 9.1%
4.0.3 -4.0.4 Ice Cream Sandwich 15 7.8%
4.1.x Jelly Bean 16 21.3%
4.2.x 17 20.4%
4.3 18 7.0%
4.4 KitKat 19 33.9%

Meanwhile, when developing for iOS targeting iOS 7 means that 96% of users can run your app as of today. This also means that iOS developers can focus on a more modern UI and not having to create separate look-and-feel to cater for very different operating systems. Android 4.0.3 was released in October 2011 while iOS 7 was released almost two years later in September 2013.

iOS version distribution

Data is current as of January 4th 2015. For more information and up-to-date statistics, check the developer pages for Android and iOS.

Categories
Blog Web design

Create a web site in 53 seconds

N.B. Make sure to read the follow-up to this article that explains how to support Office 365 authentication.

Do you want to create a responsive web site built on Bootstrap with support for Facebook, Twitter, Linkedin and Google+ login in less than a minute? Read on!

I have been a fan of Ruby on Rails since 2007. For those who are not familiar with the framework, Ruby on Rails, or just Rails, is a platform that makes it possible to build web sites in no time at all. But what is even more important is that the focus on convention over configuration, one of the pillars of Rails, makes it simple to extend upon a site later on, even by someone not involved in the original development. Other platforms I have had experience with do not necessarily share the level of adherence to conventions that allow this with the same ease. Or at all.

Most of the web sites I build these days are based on Rails, whether they are small simple concept sites or big complex sites. I create private sites as well as solutions for my work. And most of the time I find myself adding the same set of features to every site. They are responsive and based on Bootstrap, they allow users to log on with OAuth using Devise and they include role based permissions based on CanCan. I got tired to redoing the same steps for every single site and created a template. You can check out a demo version of the output of the template by looking at http://railyard.spotwise.net – please note that due to inactivity the site may need a few seconds to spin up. The purpose of this article is to share this template and how it is used.

To follow the instructions below you need to register at various sites:

  • A git repository. I recommend Bitbucket since creating private repositories is free for personal use. Github is a popular alternative but without an paid account the code will be open. That may or may not be acceptable by you depending on your project.
  • The OAuth providers you want to use (Facebook, Twitter, Linkedin, Google+). My guess is that most already have an account with these. Note that for Google+ the email address of the account will be visible to users logging in so you may want to consider creating an account specifically for your app.
  • Somewhere to host the site. I use Heroku and the example below is based on that. Heroku provides a free tier for small web sites that can then scale with the load. It is certainly possible to host this elsewhere, including on a server of your own. That may be a topic for another article some other time.

Walkthrough

Create Heroku site, DNS name and code repository

First, log onto Heroku and create a new app. You have a choice of hosting the site in the US or in Europe. You can also define a name for the site if you don’t want Heroku to create a name for you. I normally define a name as that makes it easier to tell them apart later on and I also add a suffix to the hostname to identify the location where the site is hosted.

For this walkthrough I will use the name “myweb” as the name of the app. A possible name in Heroku would then be myweb-eu.herokuapp.com. The herokuapp.com part is added by Heroku and is common to all sites hosted there.

If you want to use a custom DNS name now is the time to go into the configuration settings for your domain(s) and create an alias hostname that points to the name provided by Heroku. Please note that the Heroku hostname may not resolve to a static IP address so you want to create an alias for the Heroku hostname, not an A record for the IP address currently used by Heroku for the site.

Again, continuing with the example a record in the DNS zone could be

@example.com
myweb IN CNAME myweb-eu.herokuapp.com.

If you add a custom DNS name you also need to go back into the Heroku settings and add that alias to the list of names for the site. Otherwise, Heroku will not be able to associate incoming requests to the correct site. In Heroku there would thus be both the myweb-eu.herokuapp.com name as well as myweb.example.com.

Finally, you should create a repository for the code. For Bitbucket this is quickly done by clicking on “Create” and giving the repository a name (e.g. myweb). The rest of the information there is optional and pretty self-explanatory.

Create apps within the various OAuth providers

Next step is to select which OAuth providers you want to use. The template currently supports Facebook, Twitter, Linkedin and Google+ and they are selectively enabled by setting the variable at the top of the script to true for the services you want to use. Within the template there are also links to the developer portals of each of the four supported OAuth providers. In addition to these it supports local users. It is easy to configure the script to use any combination of these. You may want to include all of them or perhaps just one. The choice is yours. One thing to keep in mind is that currently the template does not support associating users with one another. If an individual user logs on using different OAuth providers those will be different local accounts. A special caveat is that if those accounts use the same email address it most likely will not work. For this reason you may want to use all of the providers but instead pick based on your app. Twitter does not provide the email address of the user and can safely be combined with any of the others.

For all of the providers you need to provide the URL of the site. This would be the myweb.example.com or, if you do not use a custom hostname, myweb-eu.herokuapp.com. In many cases you can also provide an application icon that is shown to the end user when logging on. Some specific things to keep in mind for each provider are:

  • Facebook: Copy the “app ID” & “app secret” values to the template. Do not forget to publish the app. If you do not do this only yourself (or other developers you designate) will be able to log on. It will work fine for you but when you ask others to try it out they will not be able to log on. In order to publish the app you need to provide a contact email address.
  • Twitter: Copy the “API key” & “API secret” values to the template. Twitter also requires the callback URL to be specified – http://myweb.example.com/users/auth/twitter/callback.
  • Linkedin: Copy the “API key” & “secret key” values to the template. Enable the r_emailaddress and r_basicprofile scopes.
  • Google+: Copy the “client ID” & “client secret” values to the template. Turn on the two APIs “Contact API” and “Google+ API”

Note: The template makes a differentiation between development and production mode. The keys and secrets for the production site must be unique for the individual application. However, if you plan to use this template for multiple apps you can share the development amongst them, that is how I do it. The development keys and secrets needs to be created separately. They would be very similar to the production site but the hostname would be localhost:3000 instead of myweb.example.com.

Create the actual site

OK, so I lied slightly. This has taken way more than 53 seconds. That time was for the actual creation of the site from the template, which is what we are getting to now.

Download the latest template from https://github.com/spotwise/railyard, currently fourteen-twelve.rb. In theory you could use the template directly from GitHub as described in the readme file but you should adapt it to your needs so I recommend you make a local copy, either by cloning the entire project or by downloading just the template.

Then edit the local template file with your favourite editor. If you use a Mac for your development I would personally recommend Textmate.

Some things you want to edit in the file are:

  • The choice of authentication providers
  • The keys and secrets to the OAuth providers used
  • The choice of Bootswatch theme
  • The data model
  • In general, search for the text TODO in the template file and follow the instructions.

    When you have finished updated the template it is time to actually create the site. Just run the command:

    rails new myweb -m

    Depending on your computer and your Internet connection this will take around a minute (or more). If everything worked you should be able to do:

    cd myweb
    rails s

    After that you should be able to open your browser and access http://localhost:3000.

    If you intend to deploy the code to Heroku you should add the gem rails_12factor. You do this by adding this to the file Gemfile in your application root and then run “bundle install”:

    gem 'rails_12factor'

    Deploy

    Now it is time to push the code to the repository as well as to Heroku. First Bitbucket (other repositories would be similar):

    git remote add origin git@bitbucket.org:[username]/myweb.git
    git push -u origin --all
    git push -u origin --tags

    Where [username] is your Bitbucket username. The above commands can be found in the repository web page.

    Then push the code to Heroku to deploy:

    heroku git:remote -a myweb-eu
    git push heroku master

    Finally, with the code on Heroku you need to migrate your database. To do so run the following command from the root folder of your application:

    heroku run rake db:migrate

    Good luck! If you run into problems or need help, please send a tweet to @spotwise.

css.php