Spot any errors? let me know, but Unleash your pedant politely please.

Sunday, 30 January 2011

Python FTW: Clearing an FTP folder.

I'm doing some testing that involves kicking off a lot of concurrent processes. Some of these write files to an FTP server. I don't need those files once I've checked that they exist, but FTP doesn't allow deletion of multiple files (AFAIK). The first time we cleared the server, we took a directory listing and wrote an FTP script from that. It worked well enough, but we'd need to write that script each time.

So a little play with Python gave me this...


from ftplib import FTP

def clearFTPDirectory(address,
username,
directory):

server=FTP(address)
server.login(username)
server.cwd(directory)

directory=[]
server.dir(directory.append)

# list comprehension, baby!
filenames=[entry.split(':')[-1][3:] for entry in directory]

for filename in filenames:
try:
server.delete(filename)
print 'Deleted:%s'%filename
except:
print ('failed to delete "%s"'%filename)

server.quit()
…it should save a fair few cumulative hours, but more importantly, it'll save a fair few hours of tedium.

The bit that tripped me up for a little while was server.dir(directory.append) which takes the append function as a parameter. Makes perfect sense now.

Note: if you use this, you may need to check the format of the strings returned by dir(), and adjust the line that extracts the filename.

Briefly Sexist Dad

I caught myself being an old-fashioned gender-stereotype father this morning. I have a chest of drawers to put together for my daughter's bedroom. Last night I thought that I'd see if my son would like to help put it together. Then this morning I realised that was a bit daft. There's no reason why my daughter shouldn't help put it together. It's for her room after all.

So I asked her.

"Nah", she said, and turned back to watching some crap on the Disney channel.

Sunday, 2 January 2011

When i became a skeptic

I've sometimes wondered whether I've ever had faith. Ever believed in God. I don't think I ever have. I don't have any memory of faith. I went to a church pre-school, to Sunday school, to state schools that did the obligatory Christian service each morning at assembly. But I don't think I ever believed it.

I do recall though, the first time I thought faith was bollocks. It was in an R.E. lesson with Mrs Stone, aka Ol' Ma' Brick. She explained faith in terms of the chairs the class was sitting on. That we had unquestioning faith in each chair's ability to support us. I couldn't articulate why I thought this was bollocks at the time, but bollocks it most certainly was. I'd have been 11 or 12, I think.

We don't have blind faith in chairs. We have years of experience of chairs and knowledge of the physical world to inform us that the chair will support our weight. Sometimes a chair will break. A old and brittle plastic garden chair might lose a leg. A wooden glued chair may have joint that's worked loose and come apart.

Sometimes we might see a new design of chair that seems impossibly flimsy, perhaps made of wire, that becomes stronger when we sit on it. Or that appears not to have a full complement of legs. When we sit on these, we don't do so with blind faith, we do so tentatively, half expecting it to collapse, preparing for it to break, and being pleasantly surprised when it doesn't.

Saturday, 1 January 2011

Another iPad Epiphany

My wife bought a traditional compendium of games for the family for Christmas. A nice wooden box with Chess, Draughts (Checkers), Backgammon, Othello (Reversi), etc. The pieces for the games are hidden inside the box, the lid is reversible with different game boards painted on each side.

It's like a primitive, manual iPad.

Looked at another way, the iPad is like a compendium of apps, but the box under the board is like a TARDIS, and you can't lose the pieces in or under the sofa.

I'm going to start saving for iPad II.

Thursday, 30 December 2010

Elton John

The first I heard of Elton John having a child was when I read that the BBC had sought the opinion of the despicable Stephen Green on the news. Stephen Green is, in my unqualified opinion, delusional bordering on insane.

It's not (just) because I'm an atheist and he's religious. Some of my best acquaintances are religious. It's because he's a hateful biblical literalist, a Leviticus believing religious nutjob.

My opinion on gay sex, gay marriage, gay adoption, gay surrogacy, gay parents and gay elderly parents is that it's not really any of my business.

It's worth remembering, before judging these new parents, that children are born to terrible parents, to elderly fathers, to cuckolded husbands, into loveless marriages etc, all the time. No licence is required, no exam needs to be passed. The same applies here.

The objections are simply about homophobia, about man-on-man action, not about parenting. Usually, when sex is discussed, I'd say it's OK as long as it's consensual. The ambivalent and those supporting Elton don't see it as being about sex though, and so it's not about consent. Children do not give consent to their parents. Children do not choose their parents.

I'm not a fan, incidentally. If anything will make me turn the radio off, it's Elton bloody John.


Budgeting

I've been looking at my bank statements for the last 6 months to try to figure out where all the money's gone. I seem to spend a lot, but I don't actually buy much. Or at least I don't have much to show for it, except an expanding waistline.

My plan for 2011 is to have a budget. Unavoidable things will still go out as direct debits, petrol will go on the debit card. Food and drink will come out of a weekly cash allowance, and when it's gone, it's gone. If I want something, I'm going to save for it. I hope to find that by the time I've saved enough to make the purchase, I'll no longer really want it. I also hope that by using real cash, I'll become more aware of what I'm spending.

Tuesday, 28 December 2010

Level scores on Angry Birds

Game Centre doesn't give scores or ranking per level. This makes it difficult to target levels that are potentially going to yield more points. Below are my scores. I'm particularly interested in any scores you have that beat mine.

Angry Birds…

1. Poached Eggs.

1 - 1 34240
1 - 2 61200
1 - 3 42820
1 - 4 31120
1 - 5 64930
1 - 6 36570
1 - 7 45610
1 - 8 56410
1 - 9 55440
1 - 10 68560
1 - 11 59960
1 - 12 53560
1 - 13 53010
1 - 14 78180
1 - 15 52590
1 - 16 65760 [66300]
1 - 17 56620
1 - 18 50400 [56080]
1 - 19 39130
1 - 20 60590
1 - 21 83440

2 - 1 68350
2 - 2 73710
2 - 3 117740
2 - 4 56480
2 - 5 92550
2 - 6 74130
2 - 7 55300
2 - 8 55390
2 - 9 29420
2 - 10 43840
2 - 11 95430
2 - 12 63920
2 - 13 89760
2 - 14 52310 [56050]
2 - 15 67510
2 - 16 68490 [73150]
2 - 17 43690
2 - 18 64450 [70730]
2 - 19 54780
2 - 20 56490
2 - 21 82640

3 - 1 64560 [65420]
3 - 2 54920
3 - 3 76550
3 - 4 39650
3 - 5 105590
3 - 6 63030
3 - 7 56620
3 - 8 82290
3 - 9 66740
3 - 10 55090
3 - 11 50940 [56550]
3 - 12 50010
3 - 13 48680
3 - 14 52100 [55260]
3 - 15 63530
3 - 16 75460 [76490]
3 - 17 74160
3 - 18 91200
3 - 19 68260 [69500]
3 - 20 121630
3 - 21 130400


2. Mighty Hoax

4 - 1 67130
4 - 2 58250
4 - 3 62540
4 - 4 63880
4 - 5 93380
4 - 6 60040
4 - 7 71120
4 - 8 52880
4 - 9 42370 [46920]
4 - 10 46990 [54510]
4 - 11 95890
4 - 12 99200
4 - 13 77360
4 - 14 87000
4 - 15 88260
4 - 16 83180
4 - 17 30460
4 - 18 89400
4 - 19 52110
4 - 20 108660
4 - 21 90800 [94100]

5 - 1 58810
5 - 2 52900
5 - 3 89430
5 - 4 72990
5 - 5 84560
5 - 6 93830
5 - 7 87250
5 - 8 83650
5 - 9 72830 [79120]
5 - 10 52340
5 - 11 69260
5 - 12 73520
5 - 13 62190
5 - 14 58400
5 - 15 60790 [ 64950]
5 - 16 116840 [117770]
5 - 17 103620
5 - 18 112190 [116910]
5 - 19 115250
5 - 20 103620 [104780]
5 - 21 175600


3. Danger Above

6 - 1 69180
6 - 2 87140
6 - 3 76220
6 - 4 93430
6 - 5 70170
6 - 6 79000
6 - 7 125970 [124830]
6 - 8 101150
6 - 9 109640 (Don't think this will yield much more)
6 - 10 103590 [103820]
6 - 11 105670
6 - 12 111720
6 - 13 88930 [93520]
6 - 14 95850
6 - 15 139720

7 - 1 131030
7 - 2 143230
7 - 3 68410
7 - 4 86680 [86740]
7 - 5 83190 84840
7 - 6 80140
7 - 7 103750 [104070]
7 - 8 90290 [96080]
7 - 9 136720
7 - 10 107110 [115680]
7 - 11 113320
7 - 12 90110 [91290]
7 - 13 67270
7 - 14 65460 [69750]
7 - 15 158350 158650

8 - 1 107430
8 - 2 71330 [73020]
8 - 3 128600 [135380]
8 - 4 117670
8 - 5 97400
8 - 6 115610
8 - 7 167140
8 - 8 113640 [125310]
8 - 9 143550 [143560]
8 - 10 124500
8 - 11 108260 [110810]
8 - 12 106900 115020
8 - 13 152690 [153610]
8 - 14 90410
8 - 15 150290 [152750]


4.The Big Setup

9 - 1 24150
9 - 2 38830
9 - 3 44660
9 - 4 55890 [58440]
9 - 5 40090
9 - 6 53330
9 - 7 82830
9 - 8 58320 [61950]
9 - 9 47240
9 - 10 80970
9 - 11 57610 [58380]
9 - 12 66980 [71530]
9 - 13 78050 [83880]
9 - 14 71150 [73650]
9 - 15 86210 [88980]

10 - 1 71370
10 - 2 96290 [96960]
10 - 3 77060 [80880]
10 - 4 101850
10 - 5 93870
10 - 6 112100
10 - 7 89290 [97300]
10 - 8 75770
10 - 9 67620
10 - 10 73530
10 - 11 135470
10 - 12 85460
10 - 13 80270 [82020]
10 - 14 107700
10 - 15 105880 [109140]

11 - 1 117850 [121610]
11 - 2 112110 [115190]
11 - 3 131750 [153290]
11 - 4 89130 [95150]
11 - 5 125980 [137640]
11 - 6 100680 [104850]
11 - 7 124440
11 - 8 126010 [130760]
11 - 9 106430 [108810]
11 - 10 77020 [82090]
11 - 11 92120 [95520]
11 - 12 84390 [87010]
11 - 13 100000 [113450]
11 - 14 91400 [95860]
11 - 15 95690 [101340]


5.Ham 'Em High

12 - 1 76200
12 - 2 83020 [83740]
12 - 3 60280
12 - 4 83780 [88590]
12 - 5 79980
12 - 6 62150 [62170]
12 - 7 70140 [71240]
12 - 8 60260
12 - 9 101640
12 - 10 85520 [96250]
12 - 11 75650 [79370]
12 - 12 78350 [80880]
12 - 13 77370
12 - 14 91680
12 - 15 150510

13 - 1 79340
13 - 2 82470
13 - 3 78610
13 - 4 93700
13 - 5 100480
13 - 6 97160
13 - 7 147700
13 - 8 60280
13 - 9 78630
13 - 10 65240
13 - 11 88460
13 - 12 90670
13 - 13 54300
13 - 14 82650
13 - 15 129810

14 - 1 120950
14 - 2 110460
14 - 3 63670
14 - 4 122830
14 - 5 68450
14 - 6 104710
14 - 7 58080
14 - 8 70670
14 - 9 102260
14 - 10 108310
14 - 11 94580
14 - 12 104520
14 - 13 87240
14 - 14 81990
14 - 15 129920

f - 1 114070
f - 2 67940
f - 3 92000

Angry Birds Seasons…

Easter Eggs

1 - 1 - 79640
1 - 2 - 121940
1 - 3 - 116990
1 - 4 - 121610
1 - 5 - 127710
1 - 6 - 90400
1 - 7 - 95190
1 - 8 - 96570
1 - 9 - 98600
1 - 10 - 100280
1 - 11 - 130110
1 - 12 - 94780
1 - 13 - 92640
1 - 14 - 109350
1 - 15 - 120770
1 - 16 - 106820
1 - 17 - 106120
1 - 18 - 121000

Hogs and Kisses

1 - 1 - 56830
1 - 2 - 118640
1 - 3 - 60230
1 - 4 - 168680
1 - 5 - 102940
1 - 6 - 67270
1 - 7 - 95650
1 - 8 - 65200
1 - 9 - 56150
1 - 10 - 58370
1 - 11 - 70400
1 - 12 - 66120
1 - 13 - 102070
1 - 14 - 110130
1 - 15 - 151560
1 - 16 - 113470
1 - 17 - 94940
1 - 18 - 78850

Season's Greedings

1 - 1 71140
1 - 2 82190
1 - 3 60730
1 - 4 95700
1 - 5 116820
1 - 6 63960
1 - 7 73570
1 - 8 91330
1 - 9 102050
1 - 10 60370
1 - 11 70480
1 - 12 85280
1 - 13 122200
1 - 14 102830
1 - 15 58880
1 - 16 100060
1 - 17 64230
1 - 18 113210
1 - 19 48820
1 - 20 50430
1 - 21 73900
1 - 22 100480
1 - 23 77360
1 - 24 59000
1 - 25 158630

Trick or Treat

1 - 1 48400
1 - 2 79150
1 - 3 75410
1 - 4 66090
1 - 5 71940
1 - 6 69530
1 - 7 84250
1 - 8 110310
1 - 9 102070
1 - 10 102090
1 - 11 110600
1 - 12 75350
1 - 13 103850
1 - 14 88710
1 - 15 85010

2 - 1 101650
2 - 2 98910
2 - 3 88090
2 - 4 93520
2 - 5 105290
2 - 6 91550
2 - 7 106390
2 - 8 91600
2 - 9 54120
2 - 10 83339
2 - 11 103270
2 - 12 101820
2 - 13 75250
2 - 14 100970
2 - 15 107520

3 - 1 120980
3 - 2 92040
3 - 3 110200
3 - 4 48840
3 - 5 73630
3 - 6 112110
3 - 7 96550
3 - 8 101080
3 - 9 77040
3 - 10 118620
3 - 11 112170
3 - 12 79940
3 - 13 113850
3 - 14 102620
3 - 15 102490


Angry Birds Rio…

Smuggler's Den

1 - 1 63060
1 - 2 48100
1 - 3 59320
1 - 4 60730
1 - 5 59360
1 - 6 74100
1 - 7 59240
1 - 8 121680
1 - 9 78690
1 - 10 84150
1 - 11 89430
1 - 12 85890
1 - 13 94500
1 - 14 84690
1 - 15 71410

2 - 1 96490
2 - 2 84290
2 - 3 95900
2 - 4 72980
2 - 5 52400
2 - 6 96920
2 - 7 63500
2 - 8 117340
2 - 9 84060
2 - 10 79780
2 - 11 61700
2 - 12 65440
2 - 13 108420
2 - 14 65880
2 - 15 92460


Jungle Escape

3 - 1 84420
3 - 2 76160
3 - 3 52150
3 - 4 106150
3 - 5 90960
3 - 6 70320
3 - 7 93350
3 - 8 147110
3 - 9 105480
3 - 10 94390
3 - 11 57040
3 - 12 98950
3 - 13 105100
3 - 14 84390
3 - 15 118020

4 - 1 63850
4 - 2 98760
4 - 3 68910
4 - 4 108210
4 - 5 75870
4 - 6 79910
4 - 7 94160
4 - 8 121320
4 - 9 56630
4 - 10 78340
4 - 11 88500
4 - 12 73040
4 - 13 63220
4 - 14 97740
4 - 15 72420


Note: Updated with new high scores.

The scores in square brackets are the highest known scores from other people.

My son is appalled by this. "Oh My God!", he said, "You're an Angry Birds nerd!"

20110429: Updated with Ham 'Em High, Rio and Easter Seasons scores.