Wednesday, November 2, 2011

linux is lateral - uk corridor

Linux use in UK companies, clustered on M62 and M4?


Apart from stating the obvious (Central London) where big financial is regularly advertising for Linux, the two corridors stand out.
Between Warrington and Leeds the M62. With a particular focus on Manchester.

The M4 corridor, not that it is news to see this area mentioned for startups.

Cardiff and Bristol - a nice tech cluster going on there either side of the River Severn.


Developments in 2012 and 2013:

The Silicon roundabout and other initiatives should help Linux move further east of Central London. At the moment skills are concentrated in Central London and other parts of London, but not much in East London.

( Middlesex and/or the stretch Left of Central London between M1 and M4, has always traditionally been a tech hotspot also )

The Silicon roundabout will stretch the reach of Linux a little further along that southern corridor, but what about the Midlands and North?

Tech startup success in Warrington, Manchester, and Leeds should spur on the extremes (Liverpool and Hull) to eventually play catch up.

Birmingham is underrepresented, and I will keep watching the news for any development there.


Linux and Tech Startups:

Take the map above and overlay it onto a map of startup clusters. What do you see?

Note: That map at the top is a point in time analysis, and will change month to month, however I suspect the picture will look broadly the same until those initiatives mentioned above take off.

Friday, October 21, 2011

Birmingham - city visit

Having never visited Birmingham except for business, i took the opportunity for a short two day hotel stay as a leisure visitor.


First impressions of this Pedestrian visitor to Birmingham, UK:

There is a lot to it. Do have satnav enabled on your phone if you plan to go walkabout.

If you are planning a shopping trip, then your activities are already laid out in the several great shopping areas in the city centre. No satnav required.
(If you are going purely for a shopping day, then you can probably ignore the rest of this section)

One of the things that attracts medium sized and large businesses to Birmingham is the excellent road network.

Unlike Leeds though, Birmingham have yet to reconfigure the inner ring roads and connecting arteries to suit current needs of traffic / pedestrian mix.

The car is king in Birmingham, and being on foot feels a bit like visiting London used to feel, before the congestion charging move.

There are expanses of paved area where shoppers are somewhat shielded from king car, however these are not well connected enough to complete the impression.

Having lived in Leeds for a decade, and witnessed the gradual change in the inner ring road & one way systems, I now understand why those changes were required.

Proactive traffic planning and a decade of staggered disruption is what Birmingham will have to endure to create the pedestrian / traffic complimentary mix which Leeds have succeeded in providing.

Alternatively the London model (congestion charging) and moving the arteries away from the centre, through charges, might be another alternative.

Now the 'Big City Plan' is Birmingham's answer to my comment above.
It also sets out visionary proposals in which each of the seven 'quarters' will be able to evolve.
The developments of New Street Station, the Library and Museum & Art Gallery (most of which complete in 2014 / 2015) will be a big step forward.

However the connectivity of those seven areas and, more importantly, creating one way systems or other ways of pushing the high speed traffic out, from the very centre, need to be addressed (my humble opinion).



Art and Birmingham - Wow!

Pleasantly surprised to find the central Art locations so well stocked.

The Museum and Art Gallery has some fantastic works, however the layout of the listed building in which it is housed, does the visitor few favours.

I challenge any couple to spend a few hours in the main Museum & Art Gallery and rely on just signage for directions.

When the renovation work is complete in 2015, I do intend to visit again. Part of me hopes that the signs will have improved, and that the lack of renovation work makes the difference in visitor experience.

Do visit. The range and total number of items on display is fantastic.


Culture and Birmingham - just dipping a toe:

It is impossible to understand the culture of a city in a couple of days, so I will not try. Do treat my comments lightly - they are not thoroughly researched and are really just some minor observations.

If you like a Cultural mix (I do) then you will feel right at home in Birmingham, it is a melting pot of cultures and friendly with it.

Whilst I am sure reading the local press I might find some examples of when this mix does not work, it certainly wasn't my impression, during my short visit, that this was the case.

Travel on a bus. Yes there are some groups of folks in two or threes chatting about aspects of their shared culture. But that never seemed to create a feeling of division. My impression was that it was just 60 people from Birmingham on a bus, with more in common, than otherwise.

If you live in an area that is uni-culture, then do visit Birmingham and see for yourself. But do so with the intention of being open and receptive. Otherwise why bother wasting your own time, and the time of the good folks of Birmingham.


Real Ale and Ska - now there is a potent combination:

I cannot think of a better activity than having a few pints in friendly company, whilst listening to some good jukebox music.

In Selly Oak, I followed my visit to the Barber Art Institute, with a few pints of Banks and some relaxed Reggae and Ska on the jukebox.


Notes and Further Reading:


Did I enjoy my 2 night city break in Birmingham? Yes.
Would I visit again? I will.

If you are visiting and the weather is good, then do explore the tourist trail near the canal - sun bouncing off the water will give you a good dose of Vit D.

You need the sun's ultraviolet B rays to manufacture vitamin D.

I try not to get too hung up on musical categories, but here are two links, if your interest takes you further:

Sunday, September 11, 2011

google API - command line access to googledocs

Each google service has an API.

These APIs change regularly as google develops it's services, however the core activities should always work.

If you want to take advantage of the latest features, then the API might well be developing as I write this. However things like 'Uploading a pdf' should work and be stable ... or so I thought.


I repeat the text below for easy copy/paste for future web searching:

Loading ./cal_man_EL531_509refBySharp.pdf
Failed to upload ./cal_man_EL531_509refBySharp.pdf: {'status': 415, 
'body': 'Content-Type application/pdf is not a valid input type.',
'reason': 'Unsupported Media Type'}

Other types of file might work fine, however the lack of .pdf upload facility from command line, was enough to halt my experiment.

On Debian GNU/Linux the following install will help get you started:

apt-get install python-gdata googlecl

Sunday, August 21, 2011

protecting a section / paragraph in a document

Here are the two ways which I protect portions of a document:

 ...wanting to protect it often occurs for important content which I'll also frame (hence protecting frames)

But sometimes I just want to protect a block of text to prevent accidental overtyping...

 Create a section, then paste in your text, and then 'protect' the section. Example...



Don't let the actual text (gcc / pthread, etc) put you off, I just wanted to show a real world example.

Here I have included in my document some commands, which I will later use as reference. What I don't want to happen is to accidentally overtype some of those commands whilst editing my document, and losing the concrete reference.

Frames or Sections, both will do a job for you in protecting a block of content - choose whichever you find most convenient :)


Notes and Further Reading:

How to protect a section is discussed in Chapter 4 of the LibreOffice / OpenOffice documentation (links below)

 Chapter 4 pdf is 1.4MB and the .odt version is much smaller.

If you have LibreOffice or OpenOffice installed then you might have local copies accessed by pressing F1 (help)

Monday, August 8, 2011

move / resize partitions - the zero cost way

There was a time when resizing and moving partitions required a trip to the computer store for some software.

No longer the case.

GNU Fdisk is a feature rich fdisk replacement that supports many options including:

  • v - move a partition
  • c - rescue a lost partition
  • z - resize a partition
  • h - check the consistency of a partition
  • o - copy the partition over another partition
By default GNU Fdisk will work in 'compatibility mode', so as to aid users who are making the switch from traditional fdisk.

So options v, c, z, h, o would not show in your menu.

However the -G flag turns off the compatibility mode.


By running gfdisk -G /dev/sda the extra options are available.

( Replace /dev/sda above with whatever your disk device identifier is )

In Debian GNU / Linux you will find GNU Fdisk here.

If all this is too much command line, then there is gparted for a clickable alternative:

gparted list and resize

Friday, July 1, 2011

sample data in postgres

This article takes some sample data and imports it into Postgresql (i) using CSV import and (ii) using INSERTs from an export of MySQL

Now to get the data into postgres we could go back to the spreadsheet (csv loading approach) or maybe take a compatible export from mysql and load that (compatible loading approach)

The data we will be using can be found here and I am about to start working with this file.

( If you are coming from a MySQL background and want to just load the sample 'employees' database into Postgresql, then project at  this link will help with that )

CSV loading approach:

In postgres use COPY FROM to get data from the filesystem into the database.

But wait; surely you need to already created a table so as to have a table to load into?
Yep, otherwise you would see postgres complain about a missing relation like so...

postgres=# COPY amd_bang_per_watt FROM '/tmp/amdAM3clockSpeedsAndWattage__200907.csv' WITH CSV QUOTE AS E'\042';
ERROR: relation "amd_bang_per_watt" does not exist


The table does not exist so you need to 'create table'.

I cover this in more detail in the next section 'Compatible loading approach' so either consult there or have a go yourself first perhaps.

I now assume you have the table amd_bang_per_watt created.

My table needed emptying first but you can likely ignore the next command:

: #root@156ns1(~) ;echo 'delete from amd_bang_per_watt' | psql amd_power_dissipation postgres
Password for user postgres:
DELETE 50

...and pick things up again here where I will try the COPY FROM:

amd_power_dissipation=# COPY amd_bang_per_watt FROM '/tmp/amdAM3clockSpeedsAndWattage__200907.csv' WITH CSV QUOTE AS E'\042';
ERROR: value too long for type character varying(10)
CONTEXT: COPY amd_bang_per_watt, line 1, column model_family: "Model Family"
amd_power_dissipation=#

and taking care of the header we execute

amd_power_dissipation=# COPY amd_bang_per_watt FROM '/tmp/amdAM3clockSpeedsAndWattage__200907.csv' WITH CSV HEADER QUOTE AS E'\042';
ERROR: null value in column "speed_power_ratio" violates not-null constraint
CONTEXT: COPY amd_bang_per_watt, line 4: ""X2 ","6??? x¹ ",2.3,,,"3.4 HT3 ",,,45,"x¹ 2009 ","
amd_power_dissipation=# select count(*) from amd_bang_per_watt;
count
-------
0
(1 row)

which is still not completing as we would wish so attempt 3:

amd_power_dissipation=# COPY amd_bang_per_watt FROM '/tmp/amdAM3clockSpeedsAndWattage__200907.csv' WITH CSV HEADER QUOTE AS E'\042' FORCE NOT NULL speed_power_ratio;
ERROR: invalid input syntax for type numeric: ""
CONTEXT: COPY amd_bang_per_watt, line 4, column speed_power_ratio: ""

...attempt 4...

amd_power_dissipation=# ;COPY amd_bang_per_watt (1,2,3,4,5,6,7,8,9,10) FROM '/tmp/amdAM3clockSpeedsAndWattage__200907.csv' WITH CSV HEADER QUOTE AS E'\042';
ERROR: syntax error at or near "1"
LINE 1: COPY amd_bang_per_watt (1,2,3,4,5,6,7,8,9,10) FROM '/tmp/amd...

...attempt 5...

amd_power_dissipation=# COPY amd_bang_per_watt (model_family,model,clock_speed,l2cache,l3cache,ht_bus_ghz,voltage,socket,tdp_watts,process_comments) FROM '/tmp/amdAM3clockSpeedsAndWattage__200907.csv' WITH CSV HEADER QUOTE AS E'\042';
ERROR: extra data after last expected column
CONTEXT: COPY amd_bang_per_watt, line 2: ""X2 II ","550 Black Edition ",3.1,"2x512k ","6MB ",2,"1.15-1.425 ","AM3 ",80,"45nm Callisto Q3-2009 ..."

...attempt 6...

amd_power_dissipation=# COPY amd_bang_per_watt (model_family,model,clock_speed,l2cache,l3cache,ht_bus_ghz,voltage,socket,tdp_watts,process_comments,process_comments) FROM '/tmp/amdAM3clockSpeedsAndWattage__200907.csv' WITH CSV HEADER QUOTE AS E'\042';
ERROR: column "process_comments" specified more than once

...and still no success so back to the drawing board (or rather sed in fact):

sed 's/\,$/\,0/' <> amdAM3clockSpeedsAndWattage__200907.csv-truncated
: #root@156ns1(tmp) ;sed 's/\,$/\,0/' <> amdAM3clockSpeedsAndWattage__200907.csv-edited
: #root@156ns1(tmp) ;sed 's/\,\,\,/\,0\,\,/' <> amdAM3clockSpeedsAndWattage__200907.csv-edited2

Here is some dialogue to explain how I came to have three sed commands of which the first is now redundant:

amd_power_dissipation=# COPY amd_bang_per_watt FROM '/tmp/amdAM3clockSpeedsAndWattage__200907.csv-truncated' WITH CSV HEADER QUOTE AS E'\042';
ERROR: missing data for column "speed_power_ratio"
CONTEXT: COPY amd_bang_per_watt, line 4: ""X2 ","6??? x¹ ",2.3,,,"3.4 HT3 ",,,45,"x¹ 2009 ""
amd_power_dissipation=# COPY amd_bang_per_watt FROM '/tmp/amdAM3clockSpeedsAndWattage__200907.csv-edited' WITH CSV HEADER QUOTE AS E'\042';
ERROR: null value in column "clock_speed" violates not-null constraint
CONTEXT: COPY amd_bang_per_watt, line 10: ""X2 ","6??? x¹ ",,,"2MB ","DDR2 ",,,,"x¹ 65nm Kuma Q2/2008 ",0"
amd_power_dissipation=# COPY amd_bang_per_watt FROM '/tmp/amdAM3clockSpeedsAndWattage__200907.csv-edited2' WITH CSV HEADER QUOTE AS E'\042';
COPY 50

and now a few selects to check things look okay:

amd_power_dissipation=# select count(*) from amd_bang_per_watt;
count
-------
50
(1 row)

amd_power_dissipation=# select count(*),substr(process_comments,1,4) as nm from amd_bang_per_watt group by nm;
count | nm
-------+------
2 | x¹
3 | x¹ Q
1 | x¹ 4
6 | x¹ 2
19 | 65nm
15 | 45nm
4 | x¹ 6
(7 rows)

All looks well here.

The CSV files (original, and edited using sed) are listed below:
If recommend saving the above files to your filesystem and viewing them from there, however if you do instead open them directly in your browser and you see x¹ rather than x¹ then try using Konqueror instead.

Konqueror is a clickable install on most Linux desktop distributions and is available to Windows users via KDE on Windows project.


Compatible loading approach:

Here is an extract of some ruby code which I looked up, so as I have an idea of what mysql types map to what postgres types:

def convert_type(type)
case type
when "tinyint(1)"
"boolean"
when /tinyint/
"tinyint"
when /int/
"integer"
when /varchar/
"varchar"
when /decimal/
"decimal"
else
type
end
end
You might find a more accessible read in the form of the Mark Slade migration guide for mysql to postgres. That guide includes some discussion about datatype mappings.

What I wanted to check was that decimal in mysql would mean decimal in postgres, and, yes it seems that it does.

One recommendation for using decimal fields in any database is to always specify both parameters rather than relying on database defaults.
That way if you do end up exporting/importing as part of some migration, then you will not be tripped up by differing defaults for precision.

Now in part 3 of the 'sample data and mysql' postings I used --compatible=postgresql flag to produce these files:
Having following the mysqldump documentation link through to reading about server modes it seems that a reasonable expectation is as follows:
  • Mysql is going to do what it can to help you when you ask for --compatible=somerdbms
  • Mysql will try and avoid giving you sql output it knows for sure will cause somerdbms a problem.
  • Mysql does is not promising 100% compatibility but just goes some way to making your task less onerous.
In particular you should not expect --compatible=postgresql to spit out sql which postgres can feed on right away - there is still some work to do.

To give a quick illustration I took the .mysqldump4postgresSansOpt file and removed the row inserts and tried to get psql to execute it:

cat /tmp/amd_bang_per_watt.mysqldump4postgresCreateOnly | psql amd_power_dissipation postgres
Password for user postgres:
ERROR: syntax error at or near "@"
LINE 1: SET @saved_cs_client = @@character_set_client;
^
ERROR: unrecognized configuration parameter "character_set_client"
ERROR: syntax error at or near "COMMENT"
LINE 12: ...power_ratio" decimal(5,2) NOT NULL default '0.00' COMMENT 'b...
^
ERROR: syntax error at or near "@"
LINE 1: SET character_set_client = @saved_cs_client;

As you can see postgres is not happy.

So I clean it up a bit and retry:

: #root@156ns1(~) ;cat /tmp/amd_bang_per_watt.mysqldump4postgresCreateOnlyCleanedUp | psql amd_power_dissipation postgres
Password for user postgres:
CREATE TABLE

...better. Now what I had to do was get rid of the column comment for speed_power_ratio and get rid of the set type stuff mysql had placed before and after the create table block.

Here are the files as I worked on them:
So we have the table - lets get on run the inserts as follows (abbreviated):

: #root@156ns1(~) ;cat /tmp/amd_bang_per_watt.mysqldump4postgresInsertsOnly | psql amd_power_dissipation postgres
Password for user postgres:
INSERT 0 1
...
INSERT 0 1

The 'INSERT 0 1' feedback above is what we should expect given our setup here.
Further reading of the postgres documentation for INSERT and scanning down for oid should make things clear.

A few quick selects to see if things look okay:

postgres@ns1:~$ psql
Password:
Welcome to psql 8.3.7, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit

postgres=# \l
List of databases
Name | Owner | Encoding
-----------------------+----------+----------
amd_power_dissipation | postgres | UTF8
postgres | postgres | UTF8
template0 | postgres | UTF8
template1 | postgres | UTF8
(4 rows)

postgres=# \dt
No relations found.
postgres=# \c amd_power_dissipation
You are now connected to database "amd_power_dissipation".
amd_power_dissipation=# select count(*) from amd_bang_per_watt;
count
-------
50
(1 row)

amd_power_dissipation=# select count(*),substr(process_comments,1,4) as nm from amd_bang_per_watt group by nm;
count | nm
-------+------
4 | x¹ 6
19 | 65nm
2 | x¹
3 | x¹ Q
1 | x¹ 4
6 | x¹ 2
15 | 45nm
(7 rows)

amd_power_dissipation=# select model,clock_speed,l3cache,tdp_watts,speed_power_ratio from amd_bang_per_watt where speed_power_ratio > 27;
model | clock_speed | l3cache | tdp_watts | speed_power_ratio
--------------------+-------------+---------+-----------+-------------------
550 Black Edition | 3.1 | 6MB | 80 | 38.75
545 | 3 | 6MB | 80 | 37.50
720 Black Edition | 2.8 | 6MB | 95 | 29.47
710 | 2.6 | 6MB | 95 | 27.37
705e | 2.5 | 6MB | 65 | 38.46
810 | 2.6 | 4MB | 95 | 27.37
900e | 2.4 | 6MB | 65 | 36.92
905e | 2.5 | 6MB | 65 | 38.46
910 | 2.6 | 6MB | 95 | 27.37
945 | 3 | 6MB | 95 | 31.58
9100e | 1.8 | 2MB | 65 | 27.69
9150e | 1.8 | 2MB | 65 | 27.69
(12 rows)

Sidenote: Having tried the substr() funtion, it seems that the sql statement shown below works unaltered in both mysql and postgres:

select count(*),substr(process_comments,1,4) as nm from amd_bang_per_watt group by nm;


Conclusion:

The --compatible option of mysql goes some way to getting your data into postgres and this article hopefully gives a flavour of what manual steps you might have to take.

Having worked through both options for getting the data in (csv and --compatible), I have to say that I am much in favour of using --compatible=postgresql and going that way.

Sunday, June 5, 2011

Natural Muesli - Wholegrain using your own ingredients

Just what exactly is in shop Muesli?

Well that depends where you buy, but here is one 'basic' ingredients list:
  • Wholegrain Oat Flakes (50%)
  • Wholegrain Wheat Flakes (40%)
  • Vegetarian Whey Powder (5%)
  • Raisins (3%)
  • Hazelnuts & Nuts (2%)
If you visit a 3 or 4 star hotel, then the Muesli you will be presented with, will be quite different. But just how different?


Whole grains and variety of fruit and nuts - luxury:

Premium oat flakes will be whole and perhaps of a larger size.

Whole hazelnuts or halved hazelnuts rather than a few chips scattered about.

Dried Apricots and fruit which is a bit pricier, rather than the cheapest ingredients often glazed.

Fruit which has not been processed to aid longer storage ( glazing )

Perhaps fresh seeds, rather than seeds toasted / glazed to aid preservation.

Note: I have used the term Muesli here, if you instead use the term Granola then please substitute as you read.


Toasting Seeds - Makes for Tasty Muesli some folks feel:

Dry Toast seeds over a textured heated surface for 2 to 3 minutes.

Toss regularly during toasting and do not blacken the seeds.


Evil head of Dentistry - Toasting and Oil:

Toasting seeds is one thing, toasting flakes another thing entirely.

If I were the [fictional] Evil head of Dentistry, sitting stroking my cat, here is what I would mandate adding to all muesli:
  • Glazed banana chips
  • Toasted oat flakes - toasted in oil
  • Toasted malted wheat flakes
  • Fruit all covered with a glazing agent ( vegetable oil )
  • Good old sugar ;)
Why? Because all of these things will increase the pressure on a weak tooth, and make Muesli into a crunching exercise, rather than a mild grinding exercise.

If you were Kwik Fit and wanted to sell more suspension parts, then one way is to persuade ordinary motorists to 'off-road' once every day.
No different for [fictional] Evil head of Dentistry and your daily morning meal.

Adding sugar to cereal is a great way of removing user choice.
Most folks who are aware of their sweetener intake, would make a conscious choice to sprinkle a little sugar on, or pass - might depend on mood or fancy.


Adding sugar to cereal it could be argued does remove that choice, and any extra sugar in your diet, is good news for the Dentistry business.



Tesco 'Value' Muesli - how tasty, how healthy?


'Value' ranges tend to ignore health as a measure of value and focus almost entirely on cost.


The 'Value' Muesli ingredients list:


Wheat Flakes, Oat Flakes, Barley Flakes, Malted Toasted Wheat Flakes, Raisins (4.5%), Whey Powder, Sugar, Hazelnuts

Malted Toasted Wheat Flakes contain: Wheat Flakes, Barley Malt Extract.
Raisins contain: Flame Raisins, Glazing Agent (Vegetable Oil).


Some notable figures from the Tesco 'Value' Muesli Nutrition sheet:


60% Carbohydrate
15% Fibre
10% Protein
10% Sugars
5%   Fat

How healthy? Well it helps to have something to compare it to - see next section.



Morrison 'Value' Muesli - how tasty, how healthy?

Add you own dry fruit (Apricots / Raisins / whatever)

Add you own seeds or whatever you think makes a great breakfast taste for you.


...and how healthy....


Hints quoted from the Muesli Recipe at greenfootsteps.com (below)
It is best not to have too many nuts and seeds in your muesli mix as they are rich in proteins and oils - the mix can become rather a challenge to the digestive system!
Chop the larger nuts into pieces. Almonds and coconut are best flaked.
Soak Muesli for at least half an hour before you want to eat it.

How about the Morrisons 'Value' and your Government recommended daily amount (GDA)?


How about Morrisons 'Value' versus Tesco 'Value' summary values quotes previously?

Carbohydrates and Fat - the two 'Value' Muesli are comparable.

Slightly more Protein in Morrisons

Bit less Fibre in Morrisons


Can I make my own Muesli for £1 a Kilogram?

£2->£4 per Kilogram is a more realistic figure.

If you happen to live right near a supplier of staple goods, and have no transportation costs to consider, then you might just be able to hit £1 per kilogram.

Supermarkets are really making no money at selling Muesli for £1 per Kilogram.
My feeling is that it is a 'loss leader' intended to tempt you into the supermarket, rather than being a profitable line.

At the top end of the market is £10 per kg "Ultimate" organic muesli


Soak Muesli - Surely you can just eat it right after adding milk?

Soaking Muesli helps break down the phytates in the fibre.

Unsoaked Muesli (phytates intact) might prevent the absorption of Iron and other minerals by your system.

If you don't like the idea of adding milk then waiting 30 minutes, then instead perhaps fortify your Muesli with iron rich additions such as:
  • Chopped Almonds
  • Dates
  • Prunes
  • Pumpkin
  • Raisins
  • Wheat Bran
  • Sesame Seeds
Having a Muesli made of Wholegrain Oats and Wholegrain Wheatflakes is higher in Iron, but higher in Phytates also, so do soak if you can.

Phytates are an anti-nutrient, and by soaking you are helping to stop those compounds from binding to your nutrients, thus allowing your body to gain the nutrients as intended.


Notes and Further Reading:

Most Health Foods stores and Supermarkets offer a 'Luxury' or 'Premium' muesli, and some are very good.

The more pricier offerings, are probably little different to your 3* or 4* hotel variety, once you add some premium fresh / unpreserved fruit, seed, nuts to brighten further :)

Waitrose Muesli takes an interesting approach with main ingredients being Barley Flakes (12%) and Rye Flakes (8%) and Spelt Flakes (8%)
*Buying for a commune or social housing project, you might be able to justify a 25kg pack of Wheatflakes, however a single person might take 20 -> 50 weeks to eat there way through that pack!

Ingredient amounts in cups / mugs - some examples to help with conversion to grams:

Cup of Oats is 70 grams
Mug of Oats is 100 grams 

Cup of Morrisons 'Value' Muesli is 90 grams
Mug of Morrisons 'Value' Muesli is 130 grams

For dry cereals you can approximate using Mug = 1.45 Cups

All figures above are approximate. Use your own cup and scales for exact figures.

Tuesday, May 31, 2011

Beep Beep - pcspkr and snd_pcsp quiet please!

Having the flexibility to have the pc speaker / beep active in different contexts is useful, however it does require you to know, how to switch off beep, in each context.


tty terminal Ctrl+Alt+F1 - silence the beep:


Here (as root) I created a file named /etc/profile.d/beep-pcspkr-pcbeep-disable.sh and included a setterm command.

Permissions of 644 work okay for this file.


What you should now experience is a TTY console having no beep.

Switch to a tty console login using Ctrl+Alt+F1 and login, your shell completion should now be free of any audible feedback beep.


X terminal - xfce4 terminal - silence the beep:

Graphical desktops (X based) have their own preferences for audio feedback beep, and in my terminal xfce4-terminal, the preference is shown below:

MiscBell=FALSE

...which can be found in the file .config/Terminal/terminalrc


But my MiscBell=TRUE?

Change it to FALSE using an editor if you want to silence the beep.

But my user does not have a file .config/Terminal/terminalrc  - does not exist?

Xfce4-terminal has a preferences screen in Edit->Preferences, go into there and change 'initial title' from Terminal to Xfce4terminal and select 'Close'

What your action above did, was trigger the creation of .config/Terminal/terminalrc

Now you can make your edit.

Why would you want a beep anyway?

Some command line novices find the audible beep a useful feedback mechanism.

Being a novice, back before Red Hat became Red Hat Enterprise Linux, I remember using the feature myself.




But I still have a bootup and reboot Beep - absolute silence please?

Mute the 'PC Beep' column in alsamixer using the 'm' key.


  • Startup alsamixer from a terminal (not required to be root)
  • Navigate right until the PC beep column is highlighted
  • Press 'm' to mute that column
Exit alsamixer using Esc (avoid pressing Q as this is the key for volume increase)

There is no need to explicitly save alsa settings, as simply exiting using Esc is enough to make your new settings persistent.

Note: PC Beep '00' is probably not going to be complete silence. Mute the thing.


Notes and Further Reading:


The alsa-utils package contains the program alsamixer. The package alsa-utils should already be installed on your system. If not use the following:

apt-get install alsa-utils

( apt-get above is for Debian and derivatives including Ubuntu)

yum install -y alsa-utils

( yum for Fedora / Red Hat / MeeGo and similar )

That alsa-utils package includes a utility named aplay, which can be used to check which sound devices in your system are known to alsa.


The above is a Dell Inspiron 1525 laptop, which I am currently setting up with Debian Squeeze. This laptop will have an Xfce desktop, and I have yet to test HDMI audio output, as HDMI port is not something I use regularly.

Saturday, May 28, 2011

Terminal Preferences - #C0C0C0 and "Terminus Bold" 16

Terminal and "Grey on Black":

I am fascinated by folks who use white on black, and often wonder if it is just a lack of knowing, where / how to change the text colour.


#C0C0C0 is an nice Grey for text appearing on a Pure Black (#000000) background


Terminal Font - Monospace or Terminus:

The default in my Xfce terminal on Debian is 'Monospace', which is a perfectly usable font.

Going a little retro with Terminus

For widescreen desktop: "Terminus Bold" 16

For 15" laptop: "Terminus Bold" 14


Terminal Bell - love it or loath it:

For Xfce terminal, there is a MiscBell option in preferences file which should be set TRUE if you want to hear beep.



Terminal programs and terminal fonts - listings:

Just a quick hint or two for programs / fonts you might try.


Thursday, May 26, 2011

Onboard Sata type - Ahci or IDE - which best

If you are a Windows user then you will have to go search based on your particular version - advice varies per version, and read up about install time drivers.

For GNU / Linux there is just a single set of current advice.
However if you are installing with a motherboard that has secure boot / Uefi, then you need to get familiar with these gatekeepers or experiment (some suggestions below )

This post has been edited since it was first published, and this 4 point summary is added:
  1. Use Ahci rather than Ide mode where you are doing a new install
  2. Existing installs should not switch from Ahci to Ide or vice versa once the operating system is already configured
  3. The main thing that Ahci will give you is support for Native Command Queuing which is a hard drive feature.
  4. If you are unable to install GNU/Linux with secure boot / uefi or other restrictive gatekeeper software with Ahci setting, then try ide mode and see if that allows the disk to be recognised (Later you can rebuild initrd and flick the bios switch if you feel you desperately need NCQ support)
If your problem is that the drive (hard drive / usb drive) is not being recognised so you cannot install Linux, then you can either become a master of secure boot zzzzzz, or just switch the thing off (there is usually a secure boot Yes/No in bios)


Choose at the outset - don't try changing it later:


The reasons for choosing Ahci or IDE will be covered next. But first you should make a commitment now to 'get it right' and stick with that setting.

To enable fast booting, grub (by default) will only includes the drivers it really needs, based on your initial system configuration.*

If you set your system up with 'Onboard Sata type' as Ahci, then later try and switch that mode in your bios, then you are asking for trouble.

If you set your system up with 'Onboard Sata type' as IDE, then later try and switch that mode in your bios, then you are asking for trouble.

Read on to make sure you 'get it right' at the outset.

*Sometimes this minimal approach is termed 'targeted' grub.


SATA and IDE emulation:

Do not use 'IDE mode' for Sata for any new install unless you are installing operating systems which had an initial release prior to 2007.

Use Ahci for current Debian and current Red Hat and similar.

The whole point of having a 'IDE mode' for SATA controllers was to help then current software ( Red Hat 5 & Windows XP ) cope with the change in disk standards.

The change to a newer version of Windows from Windows XP is not to be taken lightly for organisations with > 50 employees, which is why some IT departments continue to support that stable release.

Moving versions of Debian (Lenny -> Squeeze -> Wheezy) is much less of an issue, which is why most Debian installs were migrated from Etch long ago.

Moving point release of Red Hat Enterprise Linux (6.2 -> 6.3 -> 6.4) is also not a big deal, however there is just one caveat.

Red Hat is extremely popular as a base system for lots of virtualisation 'hosting containers'. If this is your situation, then that might require a little more planning  as hosting 40->200 VPS atop of Red Hat does make a migration a bit more involved.


Grub (initrd) and Ahci:

What will happen if you have 'Onboard Sata Type' set Ahci, and then do a GNU / Linux install, is that the boot mechanism (grub and initrd) will be built during install with --preload=ahci

To keep boot times down and loading from disk optimal, GNU / Linux installs keep the initrd minimal (only what your system needs*).

This approach gives sub 30 second boot times on my laptop (which I appreciate), however it does put the onus on you to choose the right bios setting and stick with it.

If 'Onboard Sata Type' was IDE mode when you installed, and then later you switched bios to be 'Onboard Sata Type' as Ahci, then ...
the workaround is to build a new initrd containing the AHCI module.
Source: Wikipedia

There is a great Fedora specific posting here describing in more detail why changing the bios setting after your install was done, will lead to issues.

*The latest Debian installer, specifically asks you if you want a 'targetted' boot setup or the more bloated but future proofed version - the choice is yours :)


Initially bios option was set 'Ahci' but for some reason now want IDE:

Hey maybe this is a little dose of nostalgia...what you are saying is in 2011 my system will be set to act like a 2006 / 2007 system.

Have no idea why you might choose to do this, however the kernel boot time option all_generic_ide might be what you require.


Ahci is not listed as an option in my bios - what should I do:

The bios menu selection might be titled 'Sata Controller Mode' or 'Onboard Sata Type' and should list two or three options.

Some bios have a selectable option named 'Compatible (sata only)', which is I guess just another way of saying Ahci



My operating system is very early version of Red Hat Enterprise Linux 5:

Check your kernel version. Kernel 2.6.18 is 5 years old now. Kernel 2.6.19 and newer, all support Ahci.

If you are thinking about doing an install today of a version of GNU / Linux that uses Kernel 2.6.18 then think again. Justify your choice to yourself.

The current 'stable' of Debian uses 2.6.32 and that is pretty conservative.

RHEL6 kernel is RHEL 6.0, Linux 2.6.32-71.29.1.el6.x86_64

Any kernel configured from the current kernel tree in the last 5 years,
should be > kernel 2.6.19 and therefore have Ahci support.

Kernel 2.6.32 and newer and Kernel 3.2 and newer have excellent support for Ahci.



There are other reasons why Kernel 2.6.18 for an OS acting as host container, might not be ideal.


Notes and further reading:


If you are working with bios that make necessary choice between Ahci and IDE today, then perhaps rather than being nostalgic, you are installing GNU / Linux on second hand machines.

Plenty of non-profits and charities are using donated hardware, and this might be your work.

If so, you might also find this link regarding AC97 audio, handy for new installs of Debian Squeeze, on that legacy hardware.

For native English speakers a translation here

    Monday, May 16, 2011

    mercurial init - git init - summary clone and push

    hg init            or      git init

    ...are generally the first commands I use.


    Have your code ready and a reasonable directory structure in place.

    Add a README and a LICENSE file (OSI approved licenses in my case)

    hg init

    ...and you are up and running (for your git stuff   git init)

    If you are working from an existing codebase then you might want 'clone'

    hg clone http://hg.savannah.nongnu.org/hgweb/someproject


    Publishing one time projects via git lends itself well to a set recipe:

    1. git init
    2. git add .
    3. git commit -m 'first commit of GPL3 licensed python scripts'
    4. git remote add origin git@github.com:someuser/apt-utils-python-shell.git
    5. git push -u origin master
            [ Above we used -u switch (--set-upstream) which is correct ]
    6. git add README
    7. git commit -m 'added some to README'
    8. git push origin master
            [ Note there is no -u switch here which is correct ]

    Openshift and git - what commands there?

    In order to commit to your new project, ...

    Make your changes, then run:

    git commit -a -m 'Some commit message'
    git push

    Then reload this page

    Note: The above is quoted from the openshift page


    Notes and further reading:

    If you feel the desire to host your own Mercurial from which other folks can pull, then:


    hg serve 

    and the point browser at http://localhost:8000/


    Note: If your machine is internet facing rather than on a private company network, then you should think about authentication / security, and follow this guide:
      Setting up a Mercurial CGI server

    Alternatively you could think about Trac



    If you feel the desire to host your own Git from which other folks can pull, then:

    git-daemon 

    and the point browser at http://localhost:9418/

    Note: If your machine is internet facing rather than on a private company network, then you should think about authentication / security, and read up about gitosis or gitweb.


    Saturday, May 14, 2011

    mailserver A is "inherently" better than mailserver B

    For GNU / Linux there are several good mailserver packages.

    Here are a handful (in alphabetical order):
    • Exim
    • Postfix
    • Qmail
    • Sendmail
    There are others, but for the purposes of this article that is enough to go on.

    Each of these packages will have their own fanbase. If you have a long history with Plesk hosting automation, then you might well love Qmail ... why? Because you know it inside out.


    Exim 4 is inherently more secure than Postfix:

    No it is not.

    Neither is Exim 4 inherently less secure than Postfix.

    But there was recently a vulnerability in Exim 4 around dkim signatures?

    Yes there was. Debian users should have the security repository of Debian active (by default) and automatic updates (usually active by default on login to Gnome).
    ( See links at the end for further information about Debian and automatic updates)

    However postfix does get vulnerabilities also.

    Mailservers are complicated and involve a huge codebase. Recent changes have been made, particularly to incorporate functionality around dkim.

    When humans code, other humans will review and sometimes mistakes will be found and then corrected.


    But what about Qmail - there is a stable codebase that has changed little in 10 years? Well Qmail has a small core codebase and recent functionality is added via patches. Is this a better way to maintain a mailserver? You decide.


    Debian and Automatic Updates:

    For Gnome desktop users (including Ubuntu migrants), the easiest way is to install update-manager-gnome

    Here are some other useful packages if you run a different desktop, or prefer to have updates happen, without a graphical interaction:
    • cron-apt which is a utility for background download (optional email output)

          [ once installed issue  ln -s /usr/sbin/cron-apt /etc/cron.daily/ ]
    • aptdaemon another daemon, that can be used with user privileges and an optional frontend

    • package named unattended-upgrades (see below)


    If you are really comfortable with cron anyway, you might just want something like this for your updates:

    50 11  * * * ( apt-get -q update && apt-get -qy upgrade -u )



    The Debian project, and how an active upstream can influence choice:

    Distributions are a little like biological systems in some ways, things become more popular, things become less popular. Not unlike natural selection in a fashion.

    One of the things that Debian novices and even some experienced SysAdmins do not appreciate, is the importance of 'upstream'

    It might be the tastiest code morsal your system has chewed in years, however somebody has to package the thing and maintain it
      
    If upstream is inactive or uncooperative (it does happen), then it sometimes can put undue pressure on the maintainer.

    With no upstream support, a complex package, will perhaps, have more outstanding bugs, or the maintainer might decide the weight it too much to carry alone.

    Even if you are not doing Debian packaging, but might be making a commitment to a certain mailserver, then do ask about upstream.

    How active is the upstream of Mailserver A?
    How active is the upstream of Mailserver B?


    If you are going to build a business around systems that include mailserver installs, then you want to know this!

    Here is Exim own bug tracking system - how convenient :)


    Crackers and mailservers - the case for mailserver diversity:

    ( Crackers: Folks who break into systems - think hackers if that is clearer for you )

    If there was only one single GNU / Linux distribution, and every desktop and server in the world was GNU / Linux - wouldn't the world be great!

    Well actually, NO.

    Folks who make a business out of breaking into systems, have a skillset, just like regular developers and System Administrators.

    The less the diversity in commonly run server based services, the better for the cracker.

    In todays diverse GNU / Linux world that cracker is not going to just crack mailservers, he will likely have a toolkit of useful things s/he is knowledgeable in. SSL, file obfuscation, whatever.

    However the wider the skill set required to be effective, the fewer people will be drawn into seeing 'blackhat' activities as an easy career.

    Now if that cracker wants to compromise the mail server on a Red Hat system, then he needs to know Sendmail and it's vulnerabilities / attack vectors.

    Now if that cracker wants to compromise the mail server on a Plesk automation system, then he needs to know Qmail and it's vulnerabilities / attack vectors.

    Now if that cracker wants to compromise the mail server on a Debian system, then he needs to know Exim and it's vulnerabilities / attack vectors.

    This is all assuming that the mailserver administrator has just 'gone with the flow'. They might not, they might have installed any of the 4 mailservers in my original list.

    You know the Red Hat admin might have installed Exim, or the Debian admin might have installed Postfix.

    My point is, that reducing diversity in mailservers, to the point that there is only one type of mailserver, might be considered making it easy for crackers.

    Modern day cracking toolkits have lowered the barriers to entry for crackers somewhat. Let's not make it too easy for intruders by trying to extinguish choice through rabid fanboyism.

    There are arguments for 'biodiversity' in the plant world. In this article, I have presented one argument for diversity in server based services.

    I personally hope Qmail is around for another decade ... my argument for diversity.


    Notes and Further reading:

    An Extract from the Exim4 description:
    If you build exim4 from the source package locally, you can also build an exim4-daemon-custom package tailored to your own feature set.

    If your business is going to create some custom functionality around a mailserver, then that sort of thing might appeal.

    Here is an example of the type of debate that starts up when somebody asks "What mailserver for Debian".
    ( Nothing wrong with that sort of discussion, however do bear in mind my earlier point, about mailservers and fanbase. )

    Wednesday, April 13, 2011

    python - roots in teaching, now in enterprise

       .
    How suitable is Python for teaching folks who have no programming experience?

    It is just this situation that prompted Guido Van Rossum to create Python.

    Without wishing to paraphrase (see links at the end and form your own comments), I draw out three points:

    1. Readability counts.
    2. The language should be a little familiar in style to Mathematical constructs / thinking.
    3. Resist the temptation to add new constructs all the time, and brevity is not everything (see 1)

    Such ideas might predate Ruby, and some other languages which make more use of keyboard symbols.


    I like Ruby and I have programmed in Ruby.
    However choosing Ruby as my main language, might well mean me choosing less of (1) and (3) above.

    I am not learning my first language, but those who are, might benefit from having to pick up fewer symbols.
    [ They may already be full of symbols having just left a Mathematics class :) ]


    How suitable is Python for learning - access from any Computer?



    Here I have shown a short while loop example, that is run online.
    ( Interactive web page at: http://people.csail.mit.edu/pgbovine/python/tutor.html#mode=edit )

    Python is easily to install on any computer.
    (If the school admin can install a browser, then they could certainly visit http://www.python.org/download/ and click once the download is complete. )

    Having seen an example of Python code above, this might be a good opportunity to show a slide from Guido himself (2006):


    Now look again at the code in the Fizz Buzz example above and ask:
    • Does it seen natural? Is there some feel similar to how we might express the recipe in natural language?
    • Does it require the use of plenty of symbols / constructs which a school age child would need to learn new?
    I think it stands up fairly well.
    (Explaining that elif is an abbreviation for 'else if' is one thing I see as new learning.)

    count = 1
    while (count <= 100):
      if (count % 3 + count % 5 == 0):
        print "fizz-buzz"
      elif (count % 3 == 0):
        print "fizz"
      elif (count % 5 == 0):
        print "buzz"
      else:
        print count
      count += 1
    


    A Simple IDE for Python - no install required:

    Look again at the image above for the fizz buzz example, you might spot the highlighting. That online page at Mit.edu, does simple stepping, that a learner can follow.

    What is not visible in my crop, is the box which shows the internal value of the variables as things progress. Seems a good teaching aid, and no install required.

    Visit the Mit.edu page yourself and paste in my code above, or some variant, and step it through using the buttons. Works well :)


    Pythonic programming and fizz buzz:

    The intention in this article is to act as an introduction, and provide a very simple example.

    How much rigour about Python style, you put into your teaching is up to you.

    ( It is not my intention here, to aim to be 'Pythonic', or provide a perfect coding example. If you want that, then there is a link at the end of this article. )


    Python as part of college "Introduction to Programming":


    Teaching College students programming is a little different from teaching school age.

    Philip J Guo makes some good points in this article, about why Python may be the right choice for College.


    Notes and Further Reading:

    The final few links given below are provided as a further consideration, some might argue a minor consideration. Programming languages that involve more [ non-natural ] constructs, will perhaps present greater challenges, to people who have some difficulty absorbing new symbols and associating those symbols meaningfully.

    Wednesday, April 6, 2011

    Cups - job cancellation - group membership is the key

    There are several printing systems which you might use in Debian, depending on your desktop of choice (Xfce, KDE, Gnome, Lxde, etc)

    If you use cups, then one of the tasks you will want, at some point, is "Job cancellation"

    When this task is first required, I find myself immediately leaping to the following questions:

    What port is the cups 'admin interface' running on so I can open the admin web page in a browser?

    ...and...

    Do I enter admin / root where the authentication prompt asks for "User Name"?


    ...and...

    Where in /etc/ can I find the password for the admin / root user?

    ...and lastly I am probably about to head out to websearch for 'cups admin default password'


    Turns out I am asking all the wrong questions and wasting my time.


    How to do Job cancellation in cups:

    ( should not require a 'sign-in' - the key is group membership )


    On a multi-user system, not all users will necessarily have access to a printer.
    ( It could be that your "Industrial Colour Laser 9000" is not something you want every team in the office to be able to access )

    If your OS of choice has a 'server distribution' and 'desktop distribution' (Ubuntu perhaps or the Red Hat / Fedora combination), then some might feel it is appropriate for the 'desktop' version to have automatic membership of lpadmin.

    Once your username is a member of lpadmin, then you can proceed to this screen:


    Which will list the queued jobs and offer you the option to 'Cancel' for each job in the queue*.
    ( Url is http://localhost:631/jobs/ which you can bookmark in your browser )

    *Note: you might have to log out & log back in again, in order for the new group membership to take effect, then afterwards access http://localhost:631/jobs/


    GNU / Linux has several options for backend printing systems, as I hinted earlier.

    If you prefer a different printing backend, then, for Xfce, the settings here:


    ...and here ...


    ...will help you switch to an alternative.


    Notes and Further reading:

    Cups is not universally liked, and different GNU / Linux distributions use more or less of it to their taste.

    Quoting from a Red Hat printing tutorial, two advantage of cups are:

    1. Available on all versions of Unix.
    2. Can be accessed from a terminal using a text based web browser (such as links).
    Personally I quite like the idea of http://localhost:631/ in a browser for printer control, seems simple and it works. So I do not mind a quick manual group add command, in order to set things up my end :)