Log in

No account? Create an account

Wed, Jul. 21st, 2010, 12:38 am

More than usual, I have been absent from LJ lately (among other things). Now I finally have something to show for it!


Together with Jon, Des, and a wide variety of other friends, acquaintances, and people who perform services for money, we built an iPhone app that schedules town cars, together with a corresponding website, backend, and the business to support it. Go check it out, give us feedback, and book your next airport transportation!

I'm still working at Microsoft, and I still go to school (Right now it's summer break though.). I wonder if time is like flying in the Hitchhiker's Guide. If you're just totally distracted by what you're doing, and not checking the clock, some days acquire a 25th hour.

Sun, Nov. 22nd, 2009, 02:11 pm
Google Maps, iPhone, and the antimeridian

I've been writing a bit of mapping code recently, and found that (at least parts of) the Google Maps API doesn't support the antimeridian (i.e., 180 degrees west/east).

When you ask the geocoding API to give you the coordinates for a place, it also gives you a region. So when you search for, say, "Seattle", you get the exact location of downtown, but also a bounding box that contains the greater Seattle area. However, when you search for a place on the antimeridian, like Wrangel Island or Fiji, you get an impossibly small bounding box that makes sure not to cross 180 degrees.

The iPhone Maps interface goes one step further: It will never show you a map that contains the antimeridian. I can't believe that I have owned an iPhone for over a year, and I never noticed that.

I suppose the prudent thing to do would be to test Yahoo Maps, Bing Maps, Mapquest, etc., but it's really more of a curiosity than a limitation.

Tue, Nov. 17th, 2009, 12:45 am
Project Euler in Haskell, Problem 4:

I just finished problem 4:

A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91*99.
Find the largest palindrome made from the product of two 3-digit numbers.

And this is the solution:
Read more...Collapse )

I'd appreciate some suggestions about formatting code like this.

It's dawning on me that this exercise will only teach me a small subset of the language. The problems are fun and all, but not usually the problems I have to solve when I code something.

Mon, Nov. 16th, 2009, 11:17 pm
Project Euler in Haskell, Problems 3 and 7:

I just finished problems 3 and 7:

The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143?

By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
What is the 10001st prime number?

And this is the solution:
Read more...Collapse )

While it's really nice to put the a prime sieve into two lines of code, this is also really slow. It's too slow to answer problem 10, "Find the sum of all primes smaller than 2000000.".

Sun, Nov. 15th, 2009, 12:17 pm
Project Euler in Haskell, Problem 5:

I just finished another of the Project Euler problems. This is problem 5:

2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
What is the smallest number that is evenly divisible by all of the numbers from 1 to 20?

And this is the solution:
Read more...Collapse )

Now on to some real work!

Sun, Nov. 15th, 2009, 11:51 am
Project Euler in Haskell, Problem 2:

I've started teaching myself Haskell by going through the Project Euler problems. This is problem 2:

Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
Find the sum of all the even-valued terms in the sequence which do not exceed four million.

And this is the solution:
Read more...Collapse )

Fri, Dec. 5th, 2008, 10:01 pm
Attention to Detail

On the iPhone, there is a standard control that lets you select a date. On that control, it is impossible to select any date in the year 1582. 1581 is fine, and so is 1583, but 1582 does not show up.

Why is that? I don't know, but I suspect that it has something to do with the fact that in 1582, the calendar system switched officially from Julian to Gregorian. As part of that change, the date jumped from October 4th, 1582 (a Thursday) directly to October 15th, 1582 (Friday). Maybe they decided that it's too hard to implement that into the date control, so they just left out the whole year.

I'm a bit surprised though, because there is precedent for left-out days. The control doesn't allow you to select February 29th in non-leap years. Why couldn't they just use the same mechanism to blank out the days from the 5th to the 14th? It would make the control a bit awkward, because to get from the 4th to the 15th, you'd have to scroll backwards through the days until it wraps around, but surely that's better than removing a whole year?

Either way, Apple has already exceeded my expectations by handling this case at all. Go Apple!

Sat, Nov. 1st, 2008, 04:05 pm
You have to check your pointers after all

A while back I heard an interesting rumor: In some configurations, a call to malloc() will never return NULL. If you ask for more memory than there is space for, the kernel (or the runtime) will give you a pointer anyways, and hope that you'll never use it, or at least free some other memory before you do. If by the time you use it, there still isn't enough space, your process gets killed.

I verified this a little bit at the time, filed it under "Hmm", and didn't think about it any more for a while. Recently I got interested again, and wrote this little program to try it out. My results are sadly inconclusive.

On my linux box (kernel 2.6.something), my process gets killed reliably when I allocate less than about a gigabyte at a time, but only when I turn off swap. I couldn't get it to ever kill my process with swap turned on, no matter the size of the allocation. This is different from the results I got when I first tried it out, but I don't have the program I used then anymore, so I'm not sure exactly what I tried then.

On Windows, the process never gets killed. I never tried it without swap, but I did try all kinds of different allocation sizes. You may argue over which approach is better, but at least in this case Windows seems 100% consistent.

I didn't try it on Mac OS. I meant to, but running that code is prone to ruining the session you run it in, and I need the session on my MacBook.

Wed, Jul. 9th, 2008, 02:18 pm

This makes me sad.

The worst thing is that one of the companies, I think it was Qualcomm, didn't comply with the government's requests and got punished for it by subsequently not getting millions of dollars worth of contracts. Thus, the message to big corporations is clear: If the administration says it's ok, do it, and don't ask any questions about the legality.

And what's up with passing a law now that makes things legal retroactively? Don't we have, like, rules against that stuff?

Thu, Mar. 20th, 2008, 11:42 pm
Apple and my data

I just installed Max OS X Leopard for the first time. It requires my name, address and phone number to install. The only way around it is to lie. That's ridiculous! I would like to see the firestorm of protests that would happen if Microsoft pulled something like that.

10 most recent