2009-12-21

Start up Windows software optionally

There are plenty of good software programs that will do this for you, but if you don't want to trust anyone else then you can write it all yourself.

Start NotePad and customise the following script to point at the software you want to load optionally.
' Ask if you want to optionally start a program

RunMyProgram "Pidgin", "C:\Program Files\Pidgin\pidgin.exe"
'RunMyProgram "Skype", "C:\Program Files\Skype\Phone\Skype.exe"

'************************
SUB RunMyProgram (SoftwareName, SoftwarePath)
Dim ClickResult, myShell
ClickResult = MsgBox ("Did you want to run " & SoftwareName & "?", vbYesNo, "Run " & SoftwareName & "?")
If ClickResult = vbYes Then
 SET myShell = WScript.CreateObject("WScript.Shell")
 Set myExec = myShell.Exec(SoftwarePath)
 Set myShell = Nothing
End If
END SUB
'************************
If you don't know the "SoftwarePath" for your program then you can find that out by right clicking on the icon of the software and selecting "Properties", examine the field "Target".

Save the file with a .vbs extension (.wsh should work as well), in this case "Pidgin.vbs". Ideally you would place this in a special tools folder, or even directly in your startup folder.
Windows 7: C:\Users\username\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
You are going to have to at least place a short cut to the vbs file in this start up folder.

If you want this feature for the startup item for everyone who uses your computer then place the file or shortcut in
Windows 7: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup

What if the software starts automatically by itself? You're going to have to stop this behaviour. Hopefully this happens just from a shortcut in the StartUp program group which you can get to by examining the paths above. You could also run MSCONFIG and disable the software there. A warning though, you can mess up your computer pretty badly if you start disabling items without knowing what you are doing.

2009-06-17

SAS - How merge (mal)functions

The normal MERGE statement in SAS simply fouls up on MANY to MANY relationships. You are far better off using SQL but even then there are pitfalls. Check the examples below.
Data setsSetA
SETA
Alpha   Beta Desc
1000    1    Ax1 Bx2
2000    2    Ax1 Bx0
4000    3    Ax2 Bx1
4000    4    Ax2 Bx1
5000    5    Ax3 Bx2
5000    6    Ax3 Bx2
5000    7    Ax3 Bx2
SetB
SETB
Alpha   Gamma
1000    11
1000    12
3000    13
4000    14
5000    15
5000    16

SAS Merge
Does not perform combinatorial on 5000.
This is rediculous
DATA SetAB01;
MERGE SetA SetB;
BY Alpha;
RUN;
Alpha Beta Desc    Gamma
1000  1    Ax1 Bx2 11
1000  1    Ax1 Bx2 12
2000  2    Ax1 Bx0 
3000               13
4000  3    Ax2 Bx1 14
4000  4    Ax2 Bx1 14
5000  5    Ax3 Bx2 15
5000  6    Ax3 Bx2 16
5000  7    Ax3 Bx2 16
SAS SQL Simple Join
Does not include unmatched.
Where is Alpha=2000,3000?
PROC SQL;
CREATE TABLE SetAB02 AS
SELECT *
FROM SetA, SetB
WHERE SetA.Alpha = SetB.Alpha;
QUIT;
Alpha Beta Desc    Gamma
1000  1    Ax1 Bx2 11
1000  1    Ax1 Bx2 12
4000  3    Ax2 Bx1 14
4000  4    Ax2 Bx1 14
5000  5    Ax3 Bx2 15
5000  6    Ax3 Bx2 15
5000  7    Ax3 Bx2 15
5000  5    Ax3 Bx2 16
5000  6    Ax3 Bx2 16
5000  7    Ax3 Bx2 16
SAS SQL Full Join
Drops the Alpha value for unmatched left.
Where is Alpha=3000?
PROC SQL;
CREATE TABLE SetAB03 AS
SELECT *
FROM SetA FULL JOIN SetB
ON SetA.Alpha = SetB.Alpha;
QUIT;
Alpha Beta Desc    Gamma
1000  1    Ax1 Bx2 11
1000  1    Ax1 Bx2 12
2000  2    Ax1 Bx0    
13
4000  3    Ax2 Bx1 14
4000  4    Ax2 Bx1 14
5000  5    Ax3 Bx2 15
5000  5    Ax3 Bx2 16
5000  6    Ax3 Bx2 15
5000  6    Ax3 Bx2 16
5000  7    Ax3 Bx2 15
5000  7    Ax3 Bx2 16
SAS SQL Full Join Coalesce
Works!
PROC SQL;
CREATE TABLE SetAB03A AS
SELECT
COALESCE(SetA.Alpha, SetB.Alpha)
AS Alpha, *
FROM SetA FULL JOIN SetB
ON SetA.Alpha = SetB.Alpha;
QUIT;
Alpha Beta Desc    Gamma
1000  1    Ax1 Bx2 11
1000  1    Ax1 Bx2 12
2000  2    Ax1 Bx0 
3000               13
4000  3    Ax2 Bx1 14
4000  4    Ax2 Bx1 14
5000  5    Ax3 Bx2 15
5000  5    Ax3 Bx2 16
5000  6    Ax3 Bx2 15
5000  6    Ax3 Bx2 16
5000  7    Ax3 Bx2 15
5000  7    Ax3 Bx2 16
SAS SQL Left Join
Probably what you want.
No left unmatched
Where is 3000?
PROC SQL;
CREATE TABLE SetAB04 AS
SELECT *
FROM SetA LEFT JOIN SetB
ON SetA.Alpha = SetB.Alpha;
QUIT;
Alpha Beta Desc    Gamma
1000  1    Ax1 Bx2 11
1000  1    Ax1 Bx2 12
2000  2    Ax1 Bx0 
4000  3    Ax2 Bx1 14
4000  4    Ax2 Bx1 14
5000  5    Ax3 Bx2 15
5000  6    Ax3 Bx2 15
5000  7    Ax3 Bx2 15
5000  5    Ax3 Bx2 16
5000  6    Ax3 Bx2 16
5000  7    Ax3 Bx2 16

A nice Venn Diagram display of SQL linking

2009-05-26

Audio Books

Audio books are much better than I thought.

I have occasionally listened to radio readings every now and again, they were on at strange times and were usually serialised into timeslots that I could never arrange into consistent listening sessions. I borrowed the star wars trilogy dramatisation on CD from a friend and was blown away by the show in audio.

A number of years ago I spotted some free audio books on iTunes, notably EarthCore by Scott Sigler from PodioBooks or iTunes. The story was great and well told. I consumed the entire novel in a few nights then hunted around for other free audio books. I downloaded a couple from non iTunes sources such as PodioBooks and Cory Doctorow, but never got around to putting them into iTunes.

There were always plenty of podcasts to listen to. Many of these podcasts have Audible as a sponsor. I would listen to the podcaster's book recommendations with interest and always nod and think that I should sign up some day, but I had these other books that I should listen to before I did that.

A couple days ago I just signed up. I picked Audible's $7.50/month for three months deal and selected "Stranger in a Strange Land" by Robert Heinlein for no other reason than I thought I should have read that classic by now. Initially I was very disappointed as the sound quality was metallic (bit rate of 32kbps), however I quickly got used to it and just fell right into the story.

Audio books are awesome! I highly highly recommend seeking out the freely available books, then when you realise that you are hooked, sign up for an audible account and start listening some new and classic books. The major downside is that being Australian we have a small subset of books available due to the restrictive trade practices of the publication industry. It appears that publishers are forcing their customers to misrepresent themselves as a US resident, seek out non mainstream books, resort to piracy or go without.

2009-04-21

Shutdown Windows Later

at 23:45 shutdown -s

Command Prompt ATFor when you want to leave the computer on but have it shutdown at some later point in time. Just open up a command prompt (click "Start" (and "RUN" in XP) and type CMD and tap enter) then type the above command tap enter. Yes you can close the CMD prompt dialogue.

To get this to work in Windows Vista you are going to have to get the command prompt to run as administrator. Right click on the CMD Prompt Icon if you can find it, Properties, Shortcuts, Advanced, "Run as administrator". Now you get an annoying warning everytime you start the command prompt, but you don't get "Access Denied" error when using the AT command.

The "AT" command is quite powerful, allowing you to schedule all sorts of tasks, but over the years it is just the late shutdowns that I use it for on my home windows machines.

With Mac OS X I guess I would just issue a "sudo shutdown" with a time at a terminal code, but I have my Mac's set up with nice energy saver settings so haven't used that command in ages. Just "man shutdown" for more info.

2009-03-08

Save the whales, again.

The International Whaling Commission had placed a moratorium on whaling since the mid 80s with an exception for scientific studies which Japan has been abusing ever since. Norway just ignores the moratorium and hunts under its own regulations. The moratorium was to allow for the conservation of whale stock because of over hunting.

During the 18 year Japanese scientific whaling program there were 6,800 whales killed and only 4 papers published. It isn't science, it would never pass an ethics committee. Extracted from ABC radio national.

There are several hundred thousand minke whales left, which sounds like a lot, but really isn't that many. You don't want to wait until they are endangered before stopping the hunt.

Japan also claims they hunt a limited number of endangered fin whales and threatened humpback whales under the guise of science. This really isn't on at all, and for my mind, is justification for everything the Sea Shepherd group does.

There are approx over 1 billion sheep and 1.5 billion cattle and 16 trillion chickens. Over 1.5 billion of combined goats, pigs, buffalo. Compare this with the several hundred thousand whales.

Give the whales a break. Eat a pig, put some whale flavouring on it.

For those that want to support the Sea Shepherd, they have a nice little donate button. SeaShepherd.Org After you click donate there is a PayPal option on the left.

If you support the other side then fly to Japan and chew some blubber.

There are, of course, other ways to push your opinion than donating money to the sea shepherd. Hayden Panettiere (Heroes) has started a petition to save the whales. See, it has her picture on it, you want to sign it now, right?

You could also write to your government representative and let them know your support either way you fall.

You may be asking yourself "What is this advertising of Apple and Samsung?" Well, for simply showing these adverts, money gets donated to the Whaleman Foundation. That and I like products from Apple and Samsung. Mostly. You can do this too, you just have to sign up for a free account at Social Vibe then place the ads on you blogs or what have you.









2009-02-06

Microsoft Access SQL bug

There are many bugs in Microsoft Access. Here's one that I found today.

LEFT JOIN a table to a query where the query has a literal in the SELECT clause will replicate the literal for non joined records.
Table1
KeyMyText
1A
2B
3C
4D
Table2
KeymyNum
110
320
Query1 Introduce a literal.
SELECT Key, "XYZ" AS myLit, myNum
FROM Table2;
KeymyLitmyNum
1XYZ10
3XYZ20
Query2 The bug.
SELECT Table1.Key, myText, myNum, myLit
FROM Table1 LEFT JOIN Query1 ON Table1.Key=Query1.Key;
KeyMyTextmyNummyLit
1A10XYZ
2BXYZ
3C20XYZ
4DXYZ
Query3 The fix.
SELECT DISTINCT *
FROM Query1
WHERE myLit="XYZ";
KeymyLitmyNum
1XYZ10
3XYZ20
Query4 Bug Free!
SELECT Table1.Key, myText, myNum, myLit
FROM Table1 LEFT JOIN Query3 ON Table1.Key=Query3.Key;
KeyMyTextmyNummyLit
1A10XYZ
2B
3C20XYZ
4D

2009-01-05

Climate is cool. Or is it?

Fun with numbers. Here are some hypotheses and testing with actual data. In fact the data that most sceptics prefer, good ol' University of Alabama in Huntsville.

Hypothesis (1) : Warming due to CO2 is approximated as 3 times the log of the ratio of carbon dioxide levels.

Hypothesis (2) : Temperatures in 2008 have returned to 1983 values. Problem: (a) 1983 has a nasty little peak in it thanks to an el nino and PDO positive; potential cherry picking accusations. (b) 2008 has an anomalous drop thanks to la nina, PDO cooling and a solar minimum; potential cherry picking accusations. (c) Even if true, has little/no meaning as these are global temperature instances and not trends.

Using carbon level data from Carbonify we have:
CO2 in 1983 = 341ppm
CO2 in 2008 = 384ppm
Increase = 3 x ln(384/341) = 0.37C

Using the data from UAH we get the graph below (note the 12 month mean smoothing). The simple regression line shows a 0.42C increase. Hypothesis (1) has done very well. Yay IPCC.

Climate change 1983-2008

Hypothesis (2) somewhat true but technically inaccurate. The top of the peak in 1983 does seem to be at a level with the bottom of the drop at the end of 2008. However the average temperature increase in 2008 is 0.11 and in 1983 is -0.02. So using year is somewhat disingenuous and the hypothesis should be restated to the minimums of three months in 2008 were below the maximum month of 1983. Apart from a nice sounding factoid this actually demonstrates nothing about climate change. In fact this should be exceedingly worrying, 1983 with el nino and heating PDO can only get to the minimum of 2008 with a la nina, cooling PDO and solar minimum.

Hypothesis (3) : There has been cooling since 1998. Problem: (a) That's a very short time to find climate change effects. (b) 1998 was an exceedingly warm year thanks to el nino and a warming PDO; potential cherry picking accusations. (c) 2008 is affected by la nina, PDO cooling and solar minimum which should easily overshadow the minuscule rise in temperature attributed to carbon dioxide over this short time period.

Use the same data, fit a regression line. Oh dear, hypothesis (3) fails. There is actually a slight increase (obviously not statistically significant given the obvious climatic variation, you will want a longer time period to identify a trend). VERY worrying given the conditions of 2008, a cooling PDO and a low solar output - we should have cooling but do not!

Climate Change 98-08

All of these experiments are easily repeatable with the UAH data and a little spreadsheet skill. Usually simple linear regression lines are a click away. Alternatively you can use the SLOPE() function.

An even quicker way is to use WoodForTrees site to do it all for you. Check the 30 year trend from 1979 to 2009. On this site you can play with multiple temperature data sets as well as graph the total solar irradiance, the PDO, sunspots, CO2 levels and so on. Check out the lower PDO and TSI in the last decade of the 1979-2009 year trend: PDO down, TSI way down, however temperatures remain steady/increasing.

Pacific decadal oscillation PDO, PDO data
Southern Oscillation El nino / La nina
Solar cycle Solar minimum / maximum

For data on PDO, la nina, el nino and Solar cycle years.

These are very simple data to graph constructions. There are no other factors or alterations of that data over and above what UAH may have done. If anyone can see where I am going wrong please feel free to point it out with clear precise instructions on what algorithms will improve it or what I may be failing to take into account. Opinion and belief need not apply.


More Data
The following is a list of data of various types from various sources for anyone who fancies playing with the numbers themselves.
Temperature data UAH Here
Temperate data (etc) GISS Here
Temperature data RSS Here
Temperature data CRU Here
PDO data JISAO Here
TSI data NOAA Here
TSI data NASA Here
TSI data Max Planck Here
CO2 data Siple Station Ice Core Here
CO2 data Mauna Loa Here
GHCN raw data Here
USHCN raw data Here
UCAR raw data Here
Antarctic data: Here
European ECA raw (and gridded) data: Here
Italian Meterological Association's raw data Here
Satellite data (raw and otherwise, including solar irradiance) Here, Here, Here
The tide gauge raw data: Here
World glacier raw data: Here
ARGO (floats) data: Here
ICOADS: Here
Aerosol information: Here
More paleoclimate raw data: Here, Here, Here, Here, Here
Mann's data (for his first reconstruction) is available both on his site and at Nature: Here, Here, Here
NOAA global temperatures Here

Breaking (2009-Jan-22)
I just went back to the source data at UAH to see if the final month for 2008 had been added. The data has changed format, and the values have largely been changed from the original data set that I had downloaded. I am currently trying to find the source of the sudden vast changes to the UAH LT values but there is little information other than they are integrating in new satellite information with their current data. Frankly if their data is so unreliable that it changes by +/- 0.2C then I don't know how any credible research can be presented using these values.

Books Read 2024

Below are the books that I read during 2024 and my rating out of 5. Rating Title Author Book# 5 Moriarty: The Devil's Game ‡...