hit counter

Timeline

My development logbook

The Most Cost-effective Way to Store a DNA Sequence … Is the DNA Itself

[The most cost-effective way to store a DNA sequence … is the DNA itself] (http://www.youtube.com/watch?v=9SzwiZMSBeQ)

DNA material, if stored in dark, cool and dry space, can survive thousand years. It is a lot more cost-effective than storing the sequence on tapes, which needs to be rotated and maintained, and will degrade overtime. Proper storage of DNA can keep it in good condition for multiple epochs.

Side Effect Programming Is Bad

This bit of code is trying to calculate a list of mid prices based on bid and ask prices

1
2
3
def mids(self, bids, asks):
    f = lambda X, Y: (X is not None) and (Y  is not None) and (X+Y)/2 or None
    return [f(bid, ask) for bid, ask in zip(bids, asks)

It works fine unTIL one day there is a None in mids.

The bid and ask of the corresponding item are both zero. We expect to see zero in the result.

So what happened?

The original lambda, f, rely on the side effect of short-circuit behaviour of and/or operator to return the mid price (if there is data) or None (if both are None)

But it will not work if both X and Y are zero, because zero is evaluated to false. While zero is the answer we want, the execution falls to the β€˜or’ part of the expression.

A better to write the lambda:

1
f = lambda X, Y:  (X+Y)/2.0 if (X is not None) and (Y  is not None)  else None

iMac Woe

This 27” iMac brings me endless issue.

When I first bought it, it got recalled right away.

I have to take a cab to and from the apple store because it is too hard to find parking in the CBD near the Apple Store. Have to move this heavy beast up and down to get to the genius bar.

From then on there is a lot of stability issue.

I am trying to upgrade it to Mountain Lion today.

My previous attempts on Macbook air and Macbook Pro are very smooth.

But not on this iMac.

For days, I cannot download the Mountain Lion installer to Launder.

Fine.

Prepared an mountain lion OSX thumb drive and boot it up. Cannot run installer because it cannot download components for installation!

Should never buy an iMac. Look stunning but really unreliable. Should have bough a mac mini + display instead. At least it will make it easier to visit a Genius Bar when there is a trouble.