ADAM'S WEB PRESENCE

21 September 2009

Textapox is catching

Filed under: General — adam @ 9:53 am

Look out for this new disease sweeping the children of the world. Symptoms include coloured spots on exposed areas of skin and uncontrollable giggling.


16 September 2009

Python function is not callable

Filed under: Nerd Notes — adam @ 8:39 pm

Here’s a Python gotcha that got me. Here is my function to print out a range of sinusoidal values:

import math

def cycle(centre, range):
        theta = 4.71
        speed = 0.1
        for i in range(0,80):
                theta = theta + speed
                value = centre + (range * math.sin(theta))
                print value

I got the following error which confused the hell out of me:

Traceback (most recent call last):
  File "cycle2.py", line 11, in 
    cycle(0.0,10.0)
  File "cycle2.py", line 6, in cycle
    for i in range(0,80):
TypeError: 'float' object is not callable

Can you see it? It took me a while. I’d assigned a variable called range and then tried to call the range() function. I’d overloaded a built-in function. Duh!

I just had to rename my variable and it was good.


9 September 2009

Girls have more stuff

Filed under: Bizarre Stuff — adam @ 9:11 pm

I just want to say that women just have more stuff. Here is the state of our dressing table right now, you can just see my stuff in the corner there if you look closely but look at my wife’s stuff – handbags and hats and jewellery oh my!


3 September 2009

More Spreadsheet Tomfoolery

Filed under: General — adam @ 2:10 pm

I’m still messing around with my bookkeeping. Here is another nifty formula for OpenOffice Calc. I have a list of revenue and the dates that revenue was received like so:

Date Amount
10 Jul 2009 $1,080.00
18 Jul 2009 $144.45
30 Jul 2009 $2,248.40
2 Aug 2009 $1,000.00
5 Aug 2009 $522.30

I want to create a month-by-month summary of these figures. Here is the (rather complex) formula to make that happen:

=SUMPRODUCT(A1:A5>=DATEVALUE("01 Jul 2009");A1:A5<DATEVALUE("01 Aug 2009");B1:B5)

That formula will give the total of all amounts for July. By repeating this for each month, you can get monthly summaries for the whole year.


Powered by WordPress