Monday, December 13, 2010

Including Jpeg support in PIL on centos box

There are a lot of posts out that say to install the libraries jpeg and jpeg-devel prior to installing PIL, but this did not work for me on Cento. For example this site http://www.jroller.com/RickHigh/entry/installing_pil_python_image_library suggests using the command:

$ sudo yum install freetype freetype-devel jpeg jpeg-devel libpng libpng-devel
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
No Match for argument: jpeg <<----- note the error here
No Match for argument: jpeg-devel <<----- and here
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for libpng to pack into transaction set.
......



Instead use:

$ sudo yum install freetype freetype-devel libpng libpng-devel libjpeg libjpeg-devel


If you have already got as far as installing PIL, delete it from the site-packages directory and reinstall, I use easy_install PIL, and this will rebuild PIL, this time with jpeg support.

--------------------------------------------------------------------
*** TKINTER support not available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
--- FREETYPE2 support available
*** LITTLECMS support not available
--------------------------------------------------------------------

Sunday, October 3, 2010

Training Horses like learning a Language?


I've been trying to articulate how my methods of training horses have changed over the last couple of years, thanks to a number of books and in particular Clinton Anderson. It's about teach that when a give a certain aid, this is what I want the horse to do. But isn't that what I've always done? Take for example teach a rein back. I would apply some pressure on the reins and a bit of leg and keep increasing the pressure until the horse would step back, then I would reward him. Over time I would hope to reduce the amount of pressure I'd require to get the rein back.

The new method is only subtly different. First I will teach the reinback from the ground, light pressure on the chest means go back, then when I'm on board apply gentle pressure with the reins at the same time a pulling a rope around the horses neck. The instant the horse makes any attempt to go back, I drop the reins to indicate that was the right thing to do. After a bit I'll stop using the rope and include moving my weight back and finally add use of the legs. This way I've broken down the problem into steps and never had to apply a lot of pressure to show what I want. This second approach has meant my horses have become much lighter and stop and reinback with much less resistance because they have learnt the language of the aids.

So I would say my old method was like arriving in a new country where nobody speaks my language and beyond speaking a bit slower and louder, I don't get any help in learning this language. It is a slow and painful process! The second method is like having a teacher coming with you a helping gain fluency step by step at a pace that suits you. So as a horse trainer, I am focusing more on my skills as a teacher than my skills as a rider.

Tuesday, May 4, 2010

Mad Dog the Superstar


Travelled up to Kilkenny yesterday (3.5 hours each way) for the excellent Amateur show that is held there on May Bank Holiday each year. It's been lucky for me in the past, but with no show since last October and straight into one of the toughest competitions of the year, I was stomach churningly nervous as I wait for the class to get under way. I needn't have worried, Mad Dog shook off the winter blues and returned to form to win the class in fine style, loving all the excitement and attention. Supercub finished fourth in the later speed class so very tired but happy horses and rider arrived home late last night.

http://stabletostable.com/en/2010/05/kilkenny-sji-amateurs-warrington-ec-03052010/

Saturday, May 1, 2010

Dolores has healthy French Buffet Foal - the waiting is over



Phew, the waiting is over! Dolores broke her pelvis when she was 1 year old and nobody except me and the vet thought she had a chance. But after waiting for 6 month, minding her day and night, neighbours all being called on more than once to help me get her on her feet again in the middle of the night, waiting for the scan at 3 years old to see if I could put in her in foal, waiting to see if she would go in foal, waiting to see if she would carry the foal full term, waiting for her to foal, the waiting is over and the horse count has gone up once more.

In the early hours of the 1st of May, out in the field because I thought I had more waiting to do, Dolores gave birth to a health filly foal. She is proving a calm and competent mother and is delighted with her foal. More photos to follow!

Saturday, April 24, 2010

SPCs Talk at Labour Party Environment Forum

Here is what I plan to say - but there is an hours journey to get there - it could all change!

Hello, my name is Phoebe Bright and I'm a member of Cork Environmental Forum, on the executive of Feasta (an Economics think tank), a Long Term Thinker, a Techie and a horse addict. I'm going to speak very briefly, only the role of SPCs, my experience of sitting on one of the Cork County SPCs and a couple of suggestions for how we can make them more effective.


Each County and City Council has a number Strategic Policy Committees made up roughly equal numbers of councillors and external representatives from organisations representing the environment, economic and social pillars. The expectation for SPCs was that they could provide a different perspective during policy development. For example, the policy planning unit might feel they don't more input into the farmer's market's. Should there be provisions in the upcoming Development Plans and if so what? A good question for an SPC. Or, are there enough provisions for dogs in the City? If not, what changes to policy should we consider?

That, as far as I can see from the documentation, was the expectation. The reality for me, and many of my fellow external representatives, was that the SPC had become another tick box on the road to policy implementation. Typically, we would receive documents for the next meeting a few days before the meeting, or at the meeting and we would spend 20 mins reviewing the Retail Policy for the City. As the councillors had already participated in discussion on this policy during it's development, they had nothing more to say other than to repeat their position on this policy and the external representatives were desperately looking to find something intelligent to contribute from a hasty reading of the document. As we saw these documents near the end of their progress from idea to publication, there was little chance of our input having any impact, even when we were able to make useful contributions. There was an understandable air of frustration from many of those involved.

The SPCs have lately been disbanded and reformed and we hope for better things going forward. I certainly feel the idea of the SPC is valid and could of great benefit in widening the discussion on policy and helping the external representatives and their organisations to better understand the thinking behind policy development and to challenge the mindset of the of the elected councillors.

I would ask you to consider two thoughts going forward, first the questions we ask and second the language we use.

Beth Novak did a talk on for the Long Now Foundation on what Obama's administration has done on Open Government in the last year, what they have learned and their plans for the future. On President Obama's first day in office he signed a memorandum on Open Government, committing all the departments and agencies to "transparency, participation, and collaboration. One of the lessons they have learnt to successfully encourage participation and collaboration is to ask good questions. In this case, good questions are SMART questions (Specific, Measurable, Achievable, Relavent and Time bound) http://en.wikipedia.org/wiki/SMART_criteria. So if you are an elected member and an issue arises during the development of policy, why not suggest that this be brought before an SPC? If you are on an SPC, try to get these types of questions on the agenda.

Beth Novak's talk on Open Government: http://www.longnow.org/seminars/02010/mar/04/transparent-government/



The second suggestion comes from a gem in the book The Intelligence Advantage . The book talks about how culture is about language, the way we talk about our problems, the way we listen and the way we discuss. If we want to test whether change is happening, then all we have to do is listen to the way that language is used. If that has not changed, the culture is not changing either.

So if we want a different discussion in our SPCs, a different perspective and viewpoint, then we need to change the balance so that the councillors are drawn into a different conversation. At present the Chair of each SPC is part of the council, so my suggestion is to have the meetings chaired or facilitated by an external representative.

I could am happy to share further experiences and ideas for SPCs and open government, so please feel free to catch me in the next break or contact me later.

Thursday, April 22, 2010

The Language of Change


Dipping into The Intelligence Advantage - Organizing for Complexity by Michael D McMaster a gem of a book, I came across this section, which seems particularly pertinent to our situation in Ireland.

Organisations first appear in Language

Language is at the center of society, cooperation and the coordination of action. All social organization occurs in language. Community is a function of language. How we distinguish those who "belong" from those who do not is by the way they speak. Even when the distinction is based on common practices, these practices emerge from a society where language was the fundamental organizing medium.

A corporation, like a community, is held together by it's language, given meaning by its language, and is distinguished from other corporations by its language. IBM, Apple and NEC (that dates it!) all have unique language, unique stories and unique ways of speaking. Equally important, their unique ways of understanding things and listening. These ways of speaking, listening and understanding not only constitute the culture of a company, but they also constitute a company's unique way of organizing, managing and relating to the marketplace....

and further on...

If there is no change in the way that problems are described, the way challenges are spoken about, or the way values are stated, then it is very unlikely that any major change is occurring in that corporation.


I think there is a groundswell of opinion in Ireland that significant change is required in the culture of our public organisations. We will know that our decision makers and politicians also want change when we here a change in the language they use to describe our problems and how they talk about the future.

Friday, March 26, 2010

Installing GIT on Centos 5.4

Following directions from this site:http://www.how-to-linux.com/2009/01/install-git-161-on-centos-52/

I got the error:

[root@tricostar-nwlc git-1.7.0.3]# make prefix=/usr/local all
/bin/sh: curl-config: command not found
GIT_VERSION = 1.7.0.3
/bin/sh: curl-config: command not found
* new build flags or prefix
CC fast-import.o
....


When trying to make GIT. After a bit of googling, found that I needed to include curl-devel as a dependancy so the following instructions worked for me:

yum install zlib-devel openssl-devel perl cpio expat-devel gettext-devel
yum install libcurl3-openssl-dev
wget http://kernel.org/pub/software/scm/git/git-1.7.0.3.tar.gz
tar xvfz git-1.7.0.3.tar.gz
cd git-1.7.0.3
make prefix=/usr/local all
make prefix=/usr/local install

Friday, February 19, 2010

Lessons learnt on Smart Meter rollout

Just reading an interesting post on Greenmonks Blog http://greenmonk.net/pge-smart-meter-communication-failure/ on how not to roll out a smart meter system.

The crux of it is that if you want people to change their behavior, you have to make the information they need to adapt highly visible. In this rollout, the company was expecting customers to shift their loads from peak (high cost) periods to off peak (low cost) periods and thereby reduce their overall bills. But there were no displays on the meters giving the current cost of electricity, no way of seeing current consumption or current spend. I previously suggested in this blog, that to reduce our car driving we have the current cost of our journeys displayed in real-time on the car dashboard to keep reminding us how much we have spent. As it stands, we only have the short pain of filling up our tanks followed by a long period of driving for free, and judging from our steadfast reluctance to reducing the time we spend in our cars, fuel price increases don't lead to behaviour change.

Sunday, February 14, 2010

Very chocolatey Cookies/Brownies

400g of Lidl 40% chocolate grated
115g butter
-- melt together --

2 eggs, wisk with
140g demarara sugar

Add melted chocolate/butter
Add 1 tsp cinnamon
Add chocolate chips
Add about 40g cup of flour pending on whether you want cookies or brownies. For brownies add flour until just pourable, for cookies add flour until they can be shaped.


Bake for about 12 mins in 170/180 oven until just cooked.

Keep eating one more but try and stop before you feel sick!

Banning the use of the word Sustainable


In a finite world due to be sucked into the sun in only 7.5billion years, nothing is truly sustainable. "Sustainable" has become so meaningless that the local chamber of commerce referred to a "return to a sustainable economy" recently, so would we be lost for words if we banned the use of "Sustainable"?

I'm going to try very hard to remove the word from my vocabulary from now on and use some of these instead:

Resilience - the ability to bounce back, and often the opposite of efficiency. A highly efficient system is designed for the highest gain in the short term. It is tuned to current circumstances and as soon as those circumstances change it is no longer efficient. The more efficient and specialised a system, business or organism becomes the less adaptable and resilient. Resillience is about the boring stuff. The boring banks were more resillient, the boring businesses producing essential goods and services for local markets - funeral directors, tyre sales, food markets are all ticking away. Resillience is about reliability and repairability. Resillience is about having an infrastructure we can trust - energy, transport, broadband, water.

Continuity - the value in keeping some things the same while others change. The loss of a business is not simply a monetary loss for the economy but the loss of intelligence. An established company has an intelligence and learning of it's own which is held by it's staff. While some of that intelligence may be written down, breaking up the people means losing that intelligence. Continuity is about keeping and using that collective intelligence, even if the original purpose has changed.

Balanced Portfolio - In the old days, a couple of decades ago, financial advisors talked about a balanced portfolio. You had your safe (!) bonds and blue chip stocks, your more risky stocks and shares and a few high risk investments. If our economy was a balanced portfolio, the safe investments would be investing in our own elf-sufficiency, making goods and services that are needed in our own economy. The medium risk would be making goods for export markets, attracting multinational FDR and investing in foreign businesses. High risk would be relying on cycles that are likely to be short lived - housing booms have historically been followed by housing busts and there seems to escape from that cycle.

Natural Lifespan - while long term thinking, continuity and resilience have their place, being able to exploit short term opportunities, the high risk element of the balanced portfolio, is also of great benefit and the trick here is to build in the demise as well as the creation and the skill is in knowing when to change.

What all of these words have in common is a longer term view of success than we have become used to, so rather than asking for the speaker's or author's definition of "Sustainable" as I have in the past, I will ask "Do you mean continue indefinitely, or do you have a more realistic timeframe in mind?".

Sunday, February 7, 2010

Installing OpenCV 2 on OSX with Python

Starting with instructions on the Willow Garage site, I fell at the first hurdle because thought I didn't need to install svn. Briefly, this is what I did and the more detailed explanation follows.

The short route:

1. sudo fink install svn-ssl (which takes a long time!)
2. sudo port install cmake
3. svn co https://code.ros.org/svn/opencv/trunk opencv
4. cd opencv
5. mkdir opencv/build
6. cd opencv/build
7. cmake ..
8. ccmake . (option c then option g)
9. make
10. sudo make install

On my osx 10.5 it copied the shared objects file to:

/usr/local/lib/python2.5/site-packages/cv.so

so I needed to move it to the site-packages I was using

11. cp /usr/local/lib/python2.5/site-packages/cv.so /Users/phoebebr/Development/site-packages

Now I can do:

python
>>> import cv

no error

and I can run the tests in my downloaded opencv folder,

cd opencv/opencv/tests/python
python test.py

This did report a few problems but most stuff seemed to run. Tried to run some tests calling opencv from Aptana but this caused the following error: " cp /usr/local/lib/python2.5/site-packages/cv.so /Users/phoebebr/Development/site-packages". Having installed successfully (I hope!) will have a go a writing a few programs next week....




The long route:

Already had svn so did:
svn co https://code.ros.org/svn/opencv/trunk opencv
and got
svn: SSL is not supported
so thought, I don't need https
svn co http://code.ros.org/svn/opencv/trunk opencv

and got

svn: PROPFIND request failed on '/svn/opencv/trunk'
svn: PROPFIND of '/svn/opencv/trunk': 301 Moved Permanently (http://code.ros.org)


So tried the instructions from the top:

The-Black-Book-2:site-packages phoebebr$ sudo port install subversion
Password:
---> Fetching apr
---> Attempting to fetch apr-1.3.5.tar.bz2 from http://www.mirrorservice.org/sites/ftp.apache.org/apr
---> Attempting to fetch apr-1.3.5.tar.bz2 from http://apache.multidist.com/apr
---> Attempting to fetch apr-1.3.5.tar.bz2 from http://apache.mirroring.de/apr
---> Attempting to fetch apr-1.3.5.tar.bz2 from http://archive.apache.org/dist/apr
---> Verifying checksum(s) for apr
---> Extracting apr
---> Configuring apr
---> Building apr
---> Staging apr into destroot
---> Installing apr @1.3.5_0
---> Activating apr @1.3.5_0
Error: Target org.macports.activate returned: Image error: /opt/local/bin/apr-1-config already exists and does not belong to a registered port. Unable to activate port apr.
Error: The following dependencies failed to build: apr apr-util expat libiconv gperf sqlite3 ncurses ncursesw readline cyrus-sasl2 openssl zlib gettext neon serf
Error: Status 1 encountered during processing.

So found this URL:
http://project-tigershark.com/people/rob/blog/2006/08/21/svn-on-os-x-with-fink-part-i-installation/
which explained that I needed the server version of svn and I only had the client version installed.

and did

sudo fink install svn-ssl


and that install svn so could continue with instructions above, missing the first step. Phew....

Thursday, January 28, 2010

I want an iPad


Apple have done it again, leapt ahead of the competition with the new iPad. Now I just have to find a business reason to justify buying one.

I can see a whole new market with the oldies and the computer phobes. This isn't a computer, just a simple of doing the essentials.

Want, want, want...

Wednesday, January 27, 2010

Dr Seuss and Copenhagen

Thanks to Tin Harper who started it http://cientifica.eu/blog/2009/12/cop-15-as-reported-by-dr-seuss/ and Bruce Darrell who forwarded it!

Monday, January 25, 2010

Using Pyparsing to extract dates from text block


This is very much work in progress, but I thought I'd post in case it helps anyone.

I'm currently using two bits of code, one to handle relative dates like "today", "2 days ago" and the other to handle specific dates like "3rd November 2009". These bits of code are building on work already done by others. I've tweeked them and added tests for parsing using parseString - expecting whole text to be a date, eg. "13th December 2009" and scanning using scanString where the date or dates is buried in the text, eg. "projects starts on 12th Nov 09 and finishes 3/2/10".


Relative dates:

Original code is in the Examples - In development on the pyparsing site: http://pyparsing.wikispaces.com/UnderDevelopment

Actual dates:



Sunday, January 24, 2010

Can you read this ok?

A good day for the terrsitros tadoy, wohse gaol atefr all is not to klil ppolee, but to sreapd trroer. The ppear and tv are flul of reotprs of the lteast inrasece in toerrr alret and all the mnay pisbosle rsaoens for it. And all the treisrort had to do was fial to klil a panle laod of peolpe and feed the mdeia. Are tehy vrey sarmt or are we vrey giulblle?

Stumbled across this blog and had to have a go myself http://blog.ggvic.com/2006/12/it-doesnt-matter-what-order-letters.html

Our brains are so smart that we only need the first and last letters in the correct order to be able to make a very accurate guess at the word.

For a bigger challenge, read Iain M Banks, Feersum Endjinn, much of which is written phonetically, for example:

Woak up. Got dresd. Had brekfast. Spoke wif Ergates thi ant who sed itz juss been wurk wurk wurk 4 u lately master Bascule, Y dont u ½ a holiday? & I agr.
Amazon

Have a go jumbling your text:

http://www.stevesachs.com/jumbler.cgi

Saturday, January 23, 2010

Getting started with Pyparsing

Pyparsing is especially useful for those of us who don't use regexp enough to get any good at it! It is a deceptively simple parser for all kinds of text.

Here are a few resources and tutorials I found useful.

And here is my first program. The requirement is to decode an instruction into two chunks. An opening "o" or "-", followed by a mix of "?", "!", "&","^".

from pyparsing import *


def matching(list1, list2):

if len(list1) != len(list2):
return False

for key in list1.keys():
if (not list2.has_key(key)) or (list2.has_key(key) and list2[key] != list1[key]):
return False
return True

tests = [
('o?',{'status':'o', 'stype':'?'}),
('-!',{'status':'-', 'stype':'!'}),
('-!!!',{'status':'-', 'stype':'!'}),
('o?!',{'status':'o', 'stype':'?'}),
]


def handleStuff(string, location, tokens):

print 'string',string
print 'tokens', tokens, tokens[0][0]
return tokens[0][0]


status = Word("-o")
stype = Word("!?&^").setParseAction(handleStuff)


search = ZeroOrMore(status("status"))+ZeroOrMore(stype("stype"))


for (test, result) in tests:
print '---------------'
parsed = search.parseString(test,parseAll=True)
return_value = {'status':parsed.status, 'stype':parsed.stype}
print test, return_value, result, matching(return_value, result)

The bits I had to google a while for:

How to return named tokens.

If you did:

search = ZeroOrMore(status("myvar"))

and this is recommended above using setResultsName I believe.

then to get the return value:

parsed = search.parseString("My test string")
print parsed.myvar


The other question was what does setParseAction return and the answer is an updated token. See example above which returns the first character in the first token.


Results of the program are:

---------------
string o?
tokens ['?'] ?
o? {'status': 'o', 'stype': '?'} {'status': 'o', 'stype': '?'} True
---------------
string -!
tokens ['!'] !
-! {'status': '-', 'stype': '!'} {'status': '-', 'stype': '!'} True
---------------
string -!!!
tokens ['!!!'] !
-!!! {'status': '-', 'stype': '!'} {'status': '-', 'stype': '!'} True
---------------
string o?!
tokens ['?!'] ?
o?! {'status': 'o', 'stype': '?'} {'status': 'o', 'stype': '?'} True

Sunday, January 17, 2010

Freeze, Flood, Rollkur and Riding

Yesterday, for the first time in nearly a month, the arena was not either frozen or flooded and three hairy, unfit horse got exercised by an unfit rider. This is a first for most people in Ireland. We understand wet, all to0 well, but frozen! Accident and Emergency have been clogged with broken bones, meetings cancelled, hunting a distant memory, water shortages because of people leaving their taps on to prevent freezing (again).

Anyway, a month of not riding has left me with time to think and get some of my ideas down on paper. Everyone has a book in their head apparently, and mine from an early age, was one on training horses. The problem is, I always feel I'm only just starting to get the hang of it, and that's after a more than 30 years!

One of the questions I've been pondering since a recent conversation is what is a good rider? With the hoo-ha going on in dressage around Rollkur (see http://epona.tv for video), there are clearly very very different opinions out there. To summarise the Rollkur issue, as I see it. Rollkur is the practice of riding the horse with his chin nearly touching his
chest, which is supposed to stretch his back and encourage submission. The Epona site shows an interesting video of riders of both dressage and show jumping horses warming up for competition and initially I could see nothing wrong. This is the way the pros warm up it's not the way I would ride my horses, but what do I know. Then I looked again and saw something I recognised but did not like. That feeling of power you get from putting a big powerful horse in a position of total submission, head arched, moving wherever you choose. I know that feeling of power, and I'm afraid it is called being a bully, and just because it's not only accepted, but encouraged by many in the horse world, does not make it ok.

To be clear what I mean by bullying, it's forcing a person or a horse to do something totally unnecessary just because you can. It's showing no respect for the person/horse and respect, I'm coming to find, is one of the keys to successful training. So coming back to what makes a good rider? First, what makes a competent rider?

The competent rider achieves three things: Firstly, a competent rider has a respectful relationship with their horse - they show respect for their horse and they expect, and get, respect in return. Respect is a bit out of fashion, it's a good deal harder than showing "Who's boss" or showing love and affection for our horses. Respect requires that I ask, not demand, that I listen carefully, not just assume any show of resistance is naughtiness. To my shame only today, I found Fred's reluctance to pick up his foot for the farrier was because he had a stone in the one he was expected to stand on, not a dislike of the farrier. Respect requires that I am consistent in where I draw the line. It's not fair to accept the yearling bouncing around on the end of the headcollar today because she is feeling fresh and I'm tired, only expect her to walk quietly beside me tomorrow. If I want respect I have to set a standard and stick by it.

Secondly, a competent rider does not get in the way of the horse. They stay in balance, not throwing themselves up the horses neck just as he tries to take off, or catching them in the mouth as they land, or hanging on to the reins to help them balance.

Thirdly, a competent rider gives clear aids to their horse, so he knows what is expected of him.

And that's all. The competent rider may not look that great, may not be successful in competition but their horses will be confident, relaxed and a pleasure to handle and ride.

A good rider, goes an extra step. They understand when a horse is having a problem and can help them with a slight shift in weight, increased leg pressure at just the right moment. They know from some kind of natural instinct and/or years of experience, when to put more pressure on a horse and when to easy off. They are like the perfect host at a party who puts everyone at their ease and keeps the conversation going, food and drink flowing all with without apparent effort.

The inexperienced rider does a lot to little effect, the competent rider learns to do less and achieves more, and the good rider does very little, but just the right thing and at just the right time.