chromebook and external monitor continued

Mission

Hook up my mother’s old tv to the Chromebook as an external monitor and use the new tv for tv.

Prep work

Back in NY, I tried to setup the Chromebook to use an external monitor and failed because I needed a display port to VGA adapter.  So I ordered one.

Why this still wasn’t trivial

When the adapter got delivered, I encountered some other problems.  Fir st a surprise. I paid $2 extra to Amazon for fast delivery.  It came via the Postal Service in 3 days.  It was fast, just odd because it said the package was coming via Fed Ex.

Anyway, I tried testing the Chromebook and new adapter with the new TV to make sure the adapter was good and the Chromebook could handle an external monitor.  It could of course.

Challenge 1 – DCI vs VGA

The old TV I wanted to connect it to had a DCI-I port and not VGA.  It didn’t even occur to me this might be a problem.  Radio Shack doesn’t sell a converter.  Suprisingly Staples does.  Which I found out when Radio Shack suggested I look at Staples.

Challenge 2 – The missing remote

This particular TV had a lost remote.  And a remote is needed to change from TV mode to DCI or PC mode.  We found a universal remote and the instructions for it.  Then we switched the mode.

Challenge 3 – The TV isn’t long enough

The VGA wire plus adapter is longer than the horizontal space in that part of the tv.  In particular the stand blocks it.  Hmm.  What to do about this.  I tried shoving it in to no avail.  I then tried unplugging the adapter from the VGA cable.  I inserted just the DCI adapter into the tv and screwed it in tightly.  I then inserted the VGA cable into the adapter at an angle and screwed it in as tight as I could.  Amazingly this worked!

Success

It was a lot harder to do this than it should have been.  But the result was an external monitor and a new tv.  Interestingly, setting up an external monitor for my mac was trivial.  I already had a mini display port to vga adapter from when I used to plug the mac into my real tv.  From then on, it was plug and play.

chromebook recovery disk and external monitor

I bought a Chromebook and have been using it/testing it out before actually giving it to my mother.  This weekend, I tried to create a recovery disk and hook it up to an external monitor.  Here’s how it went.

Recovery disk

The Chromebook help page covers how to create a USB drive with a bootable ChomeOS recovery disk.  It took me a few tries though:

  1. Inserted 8GB USB flash drive into Chromebook and went to chrome://imageburner.  A third of the way through the 300-400 MB download it would fail with an unclear error message.
  2. Tried Chrome OS Image Creator on Mac.  However it asks for a model number like “Sams Alex2 Gamma0-US 1234.”.  I emailed the “Chrome Ninja Team” (google support) as I would like to know the answer to this.  I then guessed one and tried to download onto USB.  Same error.  I’ve used this USB drive for other things but maybe it is the drive.
  3. Tried a 4GB USB flash drive and created recovery disk successfully.
How to find your chromebook model # 
Per the Ninja team, if your machine still works, you can enter:
 chrome://system   (which shows a lot of interesting other info too; at least interesting if you are a geek)
How to find your chromebook model #   – approach 2
Per the Ninja team (parens are mine)
  1. Follow the steps 1 – 4 via this link http://support.google.com/chromeos/a/bin/answer.py?hl=en&answer=1360642  (I didn’t feel the switch move but it clearly did.  I hadn’t shut down fully (or knocked into the power button while doing this and had to do this twice.)
  2. Step 5) Press the space bar and then you will be able to see your model number.  (This worked.)
  3. (Flip switch back and restart – I got prompted for my internet connection again and given the welcome message so I think it did a partial reset.  But all settings are in the cloud so this isn’t a big deal.)

External monitor

My goal was to hook up the tiny 12.1 inch Chromebook screen to an external monitor.  I already have a VGA cable.  The Chromebook does not have a VGA or HDMI port.  Check what your model has.  Mine has a Display Port.   I learned it isn’t easy to buy a Display Port to VGA adapter.  Here’s what happened:

  • Radio Shack: Sells mini display port adapter because Mac’s use it.  (I already have one of these)
  • PC Richard: “That doesn’t exist; tvs use wifi now.” (Not true and useless advice)
  • Best Buy: Sells same things as Radio Shack.  Recommends buying it online
  • B and H: I suspect B and H does have this adapter in stock.  The trains aren’t fully running yet so I don’t feel the need to go into Manhattan to find out.  And they were closed today anyway for the holiday.
  • Amazon: I bought this on Amazon.  Will find out how it works in a few days.

more postgres tuning in jforum

A teammate installed a new feature on CodeRanch JForum that uses a 4,515,409 row table. When dealing with over a million rows, scans become a huge performance drain. To the point where one query was slow but real usages with many at the same time brought down the app. The reason why the query was slow was interesting so I asked him if I could blog about it.

The original query

select countryCode, countryName, region, city
     from ip2location
     where 540815125 >= low and 540815125 <= high;

Running this through explain says it uses the index with a cost of:

Bitmap Heap Scan on ip2location (cost=5949.66..54170.71 rows=219870 width=32)

That’s a really high cost explain plan.

My first thought was to change it to:

explain  select countryCode, countryName, region, city
     from ip2location
     where 540815125 >= low and 540815125 <= high;

Which has a much better explain plan of

Index Scan using ip2l_low_asc_idx on ip2location (cost=0.00..8.77 rows=1 width=32)

The reason is that in the first query, postgres needs to scan the large index from the beginning until it hits the low value. In the second, I gave it permission to start really close to the target row. I subtracted 1000 but that was arbitrary. It just needs to high enough to be in the vicinity of the row without missing out on any data.

My approach also makes the lookup time consistent. It is always looking through 1000 worth of index. (Which is always less than 1000 rows given the bunching of low to high.) The original is immediate through a full index scan.

Then the original teammate switched it to:

select countryCode, countryName, region, city
     from ip2location
     where  low =
           (select max(low)
            from   ip2location
            where 540815125 >= low)

This has the same explain cost as the hacky one and is clearer.  Same logic though – it doesn’t require scanning/returning extra results.