All entries for December 2009

December 28, 2009

Find screen resolution from Mac OS X command line.

Today I found myself wondering if it was possible to find the current screen resolution from the command line (and hence from a shell script) in Mac OS X. My first thought was to try the same method I use in Linux which is extract it from the output of xdpyinfo. That turned out to be no use though. Firstly running xdpyinfo causes X11.app to launch, which is messy. Second, I rather suspect that if X11.app isn't installed then neither is xdpyinfo and X11 is an optional install pre-Leopard. Finally, it gives me the wrong value for the vertical resolution. My screen resolution is 16080x1050 but xdpyinfo says:

case:~ mike$ xdpyinfo  | grep dimensions
dimensions:    1680x1028 pixels (445x272 millimeters)

It's probably incorrect to say that it's giving the wrong value for the vertical resolution. More likely I expect is that it's the correct value for what it's measuring but what it's measuring is not what I want to measure. I find myself wondering if the Mac OS X Menu Bar (MenuBar? Menubar?) is 22 pixels high but I don't feel inclined to check.

I couldn't find any other method of getting the screen resolution via Google so the method I came up with to get the horizontal resolution is:

$ defaults read ~/Library/Preferences/ByHost/com.apple.windowserver.$(/sbin/ifconfig  en0 | grep ether | cut -d " " -f 2 | sed 's/://g')  | grep " Width =" | cut -d "=" -f 2 | sed 's/[ ;]//g'

To get vertical resolution replace 'Width' with 'Height'. It's rather long winded, but it works. I don't like the grep cut sed stuff at the end but I couldn't find a way to get the defaults command to directly read the relevant value.


December 21, 2009

I think you'll find it's a bit more complicated than that.

Writing about web page http://www.badscience.net/

Book front cover
Title:
Bad Science
Author:
Ben Goldacre
ISBN:
000728487X
Rating:
5 out of 5 stars

Homeopathy is a system of medicine which is based on treating the individual with highly diluted substances given in mainly tablet form, which triggers the body’s natural system of healing.

Dilutions are made up to either 1 part tincture to 10 parts water (1x) or 1 part tincture to 100 parts water (1c). Repeated dilution results in the familiar 6x, 6c or 30c potencies that can be bought over the counter: the 30c represents an infinitessimal part of the original substance.

Quotes copy/pasted from http://www.homeopathy-soh.org/about-homeopathy/what-is-homeopathy/

So a 30c dilution will be a one part tincture diluted in to 100 parts of water, which is diluted with another 100 parts of water, which is diluted with another 100 parts of water, repeat another 27 times. Homeopaths claim that the result of this process is an effective medical treatment.

In Bad Science, Ben Goldacre describes a 30c dilution thus:

Imagine a sphere of water with a diameter of 150 million kilometres (the distance form the earth to the sun). It takes light eight minutes to travel that distance. Picture a sphere of water that size, with one molecule of a substance in it: that's a 30c dilution.

If you read the above linked homepathy page you will of course find an explanation of how such a substance can be an effective medial treatment. The explanation is not one I find credible, but there are plenty of people who do.

Another part of this book which has stuck in my mind is the manner in which HIV and AIDS has been handled by the South African government.

South Africa's stand at the 2006 World AIDS Conference in Toronto was described by delegates as the 'salad stall'. It consisted of some garlic, some beetroot, the African potato, and assorted other vegetables.

Ben Goldacre is a medical doctor who works for the NHS and the topics covered in this book are almost exclusively of a medical nature. It's not just about medicine though, or even just about bad science. It's very often about the appallingly inaccurate and/or misleading manner in which most science stories are reported by the media. It's about how a study which finds that under certain circumstances the number of instances of X appears to have risen from the previously observed 4% to 6% will appear in a newspaper as 'new study finds 50% increase in cases of X'. It's about how a lot of medical studies have flaws but how, despite what some people mistakenly believe, those flaws do not necessarily invalidate the findings. It's about how some people can't understand that when the scientific community decides that something previously considered to be true is not actually true after all, or is only true under certain circumstances, this is called progress, not failure. It's about how in this country a storm of controversy can rage for the best part of decade regarding the use of a vaccine, whilst in the rest of the developed world it's use continued unabated by any such contraversy. It's about how some people will dress up common sense as something proprietary, the difference between someone who lies and someone who bullshits and about how people who do one or more of these things in relation to matters of science have managed to make a lot of money out of it.

You should read this book.


December 20, 2009

'no' man

Snow Man/Heap

I can't remember the last time I built a snowman. Arguably I didn't build one today, the above portrayed attempt being more of a heap and a small heap that took the collaboration of two men in their thirties to create at that. (The wrong type of snow... honest) The nearly-three year old girl who commissioned it seemed reasonably satisfied. Although shortly after the photo was taken I was told it needed ears.


December 15, 2009

9 degrees celcius

The weather indicator in the top right of my GNOME desktop has been saying 9 degrees celcius for the last few days:

Wrong Weather

Which is clearly wrong. I think I've just worked out why it's not updating. A common source of weather data is airports. GNOME gets it's weather information from airports. For Coventry it uses Coventry Airport. Coventry Airport has been closed due to financial difficulties. Various sites which would usually display information from it's weather data feed all say 'no data'. So looks like the closure of Coventry Airport extends to it's weather data feed. Later on I might look at making it use an alternate data source.


December 07, 2009

Walt Disney World to become twin town of Swindon

Writing about web page http://news.bbc.co.uk/1/hi/england/wiltshire/8399996.stm

In the future, when people say 'stranger things have happened', this will be a citable example.


December 03, 2009

University Advent Calender as your (though maybe not your) wallpaper.

Writing about web page http://www.warwick.ac.uk/adventcalendar/

For no good reason other than because the idea got stuck in my head, a script (advent wallpaper script) which grabs an image of the University advent calender, does some stuff to it, sets it as your wallpaper and then adds a launcher to the panel that when clicked shows what's 'behind' today's door with the icon for the corresponding door as it's icon. Assuming you use GNOME for your desktop environment that is. Which statistically speaking, you probably don't.

Example screengrab (to click is to make larger):

Uni Advent Calender as wallpaper



Requires ImageMagick, gnome-web-photo, curl and Epiphany (the web browser not the holiday). Call from a cron-job or login script of something to automatically update wallpaper should you feel the desire to do so.


Blah twit blah Go to 'Twitter / 6byNine'

Search this blog

Tags

Not signed in
Sign in

Powered by BlogBuilder
© MMXII