Monthly Archives: November 2012

ActiveRecord and MySQL Setup on Ubuntu 12.04.1

As a .Net developer I thought I would give Ruby and ActiveRecord a try for a simple web application. When I say simple I mean it’s only two operations. One consists of non-authenticated data entry and the other of data retrieval. Install of everything went fine, or so I thought. It turns out that there are some intricacies in getting the right activerecord to work on Ubuntu.

This is a quick blog post of getting activerecord to work with MySQL on Ubuntu 12.04.1 LTS. This is a result of me searching a bunch of other blogs and tutorials to figure out what I was doing wrong.

Getting the files

>sudo apt-get install mysql-server
>sudo apt-get install ruby
>sudo apt-get install rubygems
>sudo gem install activerecord
>sudo apt-get install libmysqlclient15-dev
Note: this may install “libmysqlclient-dev” instead, which should be fine.
>sudo gem install activerecord-mysql2-adapter

You should now have all the required files.

Setup test database

Connect to MySQL and create a database and table.

>create database dummy;
>use dummy;
>create table tests(id bigint primary key auto_increment, text varchar(100));

A test ruby file: atest.rb

#! /usr/bin/ruby
require ‘rubygems’
gem ‘activerecord’, ‘=3.2.9’
require ‘active_record’

class Test < ActiveRecord::Base
end

ActiveRecord::Base.establish_connection( :adapter => ‘mysql2’,
  :host => ‘localhost’,
  :username => ‘username’,
  :password => ‘password’,
  :database => ‘dummy’
)

Record = Test.create(:text => ‘new record text’)
Inserted_records = Test.where(:id => 1)
# It is recommended to use “find” instead of “where“ when selecting by the primary key.
# I used where as a test to make sure I had everything installed and working
Puts inserted_records[0].text

Make sure you have a reference to the gem in your ruby file. If you don’t, when you go to use the ”where” method you will receive a method_missing error. As of writing, the active record gem version was 3.2.9.
Also make sure the adapter in the establish_connection method is ‘mysql2’. Using the older ‘mysql’ adapter will also cause issues.

Note

I did skip creating a new user and granting access to the mysql database as that was an easy web search.

Initial thoughts on the HTC 8x 16GB WP8

I recently picked up two Windows Phone 8 devices. The HTC 8x 16GB and a Nokia Lumia 920. Out of the kindness of my heart, I gave the Nokia to my wife and I kept the HTC. I am giving my thoughts after using the HTC 8x for a few days.

Now, let me preface this by saying the HTC 8x is a very nice device. I do like it. There are a couple of issues that I am going to have to get used to. These issues may go away when I get a case for the phone. It also may sound like I am envious of my wife’s Lumia 920. This may be the case, but there are things about my phone that she is envious of. To be honest, if I had the choice again… to hell with being nice. I would keep the Nokia Lumia 920 for myself.

Starting with what came out of the box. The phone, of course. A micro usb cable, a 5v 1A charger, and documents. This is the basics. I was a little surprised there were no earbuds and mic. I thought for sure there would be considering it has Beats Audio. My wife’s Nokia Lumia 920 had head phones. Maybe I received a box where the earphones were missing? It’s ok though. I can use the ones that came with my Samsung Focus. Basics out of the box are phone, micro usb cord, charger, and documents.

I do like the sound the phone is able to reproduce. The HTC 8x automatically enables Beats Audio when you plug headphones in. I was testing using earbuds from my old Samsung Focus. I thought the music sounded pretty good. The speaker itself did well providing I didn’t have it muffled on my desk. I was going to test the audio for movies, but that will have to wait until we are allowed to load movies purchased through Zune. Overall, I thought the speakers and Beats Audio were very well done.

The HTC 8x had four custom apps out of the box. The HTC came with a flashlight app, unit converter app, photo enhancer app, and the HTC app (this includes local weather, news, and stock quotres). My wife is envious of the unit converter app. The app is elegant, fast, and easy to switch unit types. Photo enhancer is for adding effects to your pictures, such as making them look vintage. The Lumia 920 on the other hand came with an array of apps. I think there were four camera apps alone for the Lumia 920. There are a modest number of apps for the HTC 8x compared to the Lukia 920.

I haven’t had a chance to tinker with all the settings on this phone. There is a setting for those with hearing aids. This will increase the volume while you are talking on the phone. There is also attentive phone. This allows the phone to adjust to external actions during ringing. When enabled, the phone can quiet the ring on pickup, mute the ringer if you flip over your phone, or use a loud ring when the phone is in your pocket or purse. I don’t get many phone calls, that’s why I haven’t gotten to all the settings.

The phone is a good size and aesthetically pleasing. It is smaller and lighter than the Lumia 920. The HTC 8x has a nice feel to it. There are issues for the way I hold my phone. I prefer holding the phone using three edges instead of using a death grip on two. I hold the phone with my pinkie finger supporting the bottom edge of the phone. The phone has rounded edges on all sides and the micro usb port is located on the bottom edge. I find that because the phone is rounded, the edges of the usb port rub against my finger. This will probably not be an issue once the gel cover case arrives. The screen is very clear and the phone looks very nice.

Now, here is my main gripe with the phone. The power button is located on the top edge. I am finding it very inconvenient since I hold the phone using the bottom edge. Whenever I want to turn on the phone I either have to adjust the phone in my hand (fingers aren’t quite long enough) or use my other hand. Two hands to turn on your phone is non-optimal. This is where the Lumia 920 is really better suited for me. All three buttons are on the right edge of the phone. Ideal for one handed access and use of all three phone buttons. I may get used of it, or become more eficient of one handed turn on using my face (chin works well. I may look stupid in public though). The power button on the top is kind of a deal breaker for me.

Results so far: If I had known then what I know now. I would have gone with the Lumia 920. Just so I could have the power button on the side. Other than that, the HTC 8x is a very nice phone. At 16GB it is less than what the Lumia 920 has, but I never filled my old Samsung Focus with only 8GB. Am I happy with this phone? Yes, for the most part.

I know what people are thinking, “don’t hold it like that”.