Dogsby's Blog – Its a Dogs(by's) Life

Dogsby's Blog – Its a Dogs(by's) Life -

Why is the sky blue?

Somewhere on the internet there must exist a science FAQ for parents to call upon when their offspring develop an inquiring mind. At the top of that list should be the question “Why is the sky blue?”.

From what I can tell, hardly anyone actually knows the answer. So, if you don’t understand how bears fishing for salmon and Rayleigh scattering determine the colour of the sky, then take the time to listen to Episode 32 of the Titanium Physicists podcast.

The Titanium Physicists produce a great series of podcasts which explain physics concepts in a manner that is gentle on the brain. This podcast teaches me something amazing every time I listen. Thanks guys.

Aldington Soap Box Derby 2013

These pictures are from the Aldington Soap Box Derby which showcased the best of the local engineering talent and raised money for the Pilgrims Hospice and other local charities.

The official web site for the event is here. More pictures from this years event can be found on the Folkestone Herald web site.

RaspBMC – How to fix “vchiq_lib: Incompatible VCHIQ library” errors

The Raspberry Pi running RaspBMC had entered a continuous cycle of resetting, showing the message “Relax, XBMC will restart shortly”.

Looking in /var/log/syslog the culprit was found:


Mar 11 21:55:24 raspbmc xbmc: vchiq_lib: Incompatible VCHIQ library - driver version 2 (min 2), library version 6 (min 3)
Mar 11 21:55:25 raspbmc xbmc: vchiq_lib: Incompatible VCHIQ library - driver version 2 (min 2), library version 6 (min 3)
Mar 11 21:55:25 raspbmc xbmc: * failed to open vchiq instance

Various suggestions on the forums were tried, including:

rm -rf ~/.xbmc-current – this failed
and
sudo apt-get update – this failed

The problem was resolved using the rpi-update command provided by Hexxeh. The command is not already installed but the process is well documented on the rpi-update GitHub page.

Using SQLite with Google Visualisations and Python

Essentially, this is the example python code taken from Python gviz_api library. The hard coded data section has been replaced with the contents of a sqlite database.  Before starting SQLite must be installed, instructions and the download can be found on the SQLite web site.

Firstly, we need to recreate the hard coded data in a sqlite database, so open up a sqlite session with:

sqlite3 exampledb

Now create a “salaries” table and fill it with the data from the example:

create table salaries (name VARCHAR(10), salary REAL, full_time INTEGER);

insert into salaries values (“Mike”, 10000.0, 1);
insert into salaries values (“Jim”, 800.0, 0);
insert into salaries values (“Alice”, 12500.0, 1);
insert into salaries values (“Bob”, 7000.0, 1);

.quit

The converted example code (see here for the original) that reads from the sqlite database is as follows:

#!/usr/bin/python

import gviz_api
import sqlite3

page_template = """
<html>
  <script src="https://www.google.com/jsapi" type="text/javascript"></script>
  <script>
    google.load('visualization', '1', {packages:['table']});

    google.setOnLoadCallback(drawTable);
    function drawTable() {
      %(jscode)s
      var jscode_table = new google.visualization.Table(document.getElementById('table_div_jscode'));
      jscode_table.draw(jscode_data, {showRowNumber: true});

      var json_table = new google.visualization.Table(document.getElementById('table_div_json'));
      var json_data = new google.visualization.DataTable(%(json)s, 0.6);
      json_table.draw(json_data, {showRowNumber: true});
    }
  </script>
  <body>
    <H1>Table created using ToJSCode</H1>
    <div id="table_div_jscode"></div>
    <H1>Table created using ToJSon</H1>
    <div id="table_div_json"></div>
  </body>
</html>
"""

def main():
    # Don't forget to change this to match the data to be displayed
    description = {"name": ("string", "Name"),
                 "salary": ("number", "Salary"),
                 "full_time": ("boolean", "Full Time Employee")}

    #Open Sqlite database
    conn = sqlite3.connect('exampledb')

    # Loading the description into the gviz_api.DataTable
    data_table = gviz_api.DataTable(description)

    #Select the data using a cursor
    conn.row_factory = sqlite3.Row
    c = conn.cursor()
    c.execute('select * from salaries')

    # Data is a list used to hold dictionaries of salary data
    data =[]
    salary_data = {}

    for r in c.fetchall():
            salary_data = {"name": r['name'], "salary": r['salary'], "full_time": r['full_time']}
            data.append(salary_data)

    #Close the cursor
    c.close()

    #Now load the data retrieved from the database into the data table.
    data_table.LoadData(data)

    # Creating a JavaScript code string
    jscode = data_table.ToJSCode("jscode_data",
                               columns_order=("name", "salary", "full_time"),
                               order_by="salary")
    # Creating a JSon string
    json = data_table.ToJSon(columns_order=("name", "salary", "full_time"),
                           order_by="salary")

    # Putting the JS code and JSon string into the template
    print "Content-type: text/html"
    print
    print page_template % vars()

if __name__ == '__main__':
  main()

Raft Race at St. Rumwolds Church, Bonnington, 2011

Keen rafters and in some cases submariners, will be disappointed to hear that there will be no raft race at St. Rumwolds church this year.

The organisers are taking a well earned year off, but I have been told to listen out for a date for next summer.

London Eye by Night

Having a Merlin Pass allows for spontaneous trips to top attractions without the worry of cost. This is how I came to take a “flight” on the London Eye on a drizzly February evening when most people were looking for shelter. The good news was that the queues were short.

London Eye

London Eye

Despite being dark and wet the views were still amazing and the atmosphere felt more relaxed than on the day time flights.

Parliament

Parliament at night

Charing Cross

Charing Cross

St. Rumwolds Raft Race, 2010

Only 9 months over due, here are my photos of the Great St. Rumwolds Raft Race of 2010.