harryh RSS

I don't really like tumblr much, but some of my friends use it, so I have to have one to leave "comments." Pretty much everything here should be seen as a comment and not an actual blog entry.

Archive

Feb
24th
Wed
permalink

trival backgrounding with scala actors

A simple backgrounding object:

object BackgroundOperation {
   def apply(f: => Unit) = {
     BackgroundActor ! BackgroundJob(() => f)
   }

   case class BackgroundJob(f: () => Unit)
   
   object BackgroundActor extends LiftActor {
     protected def messageHandler = {
       case BackgroundJob(f) => f()
     }
  }
}

Then you can do this whenever you want:

BackgroundOperation {
  // some complicated thing
}
Feb
10th
Wed
permalink
Why does Buzz even exist? Is it because Google wants to make my life better in some way? No. Buzz exists because Google feels threatened by Twitter and Facebook and wants to kill them. Google has become what Microsoft used to be—the Borg, the company that gobbles up ideas from smaller rivals and cranks out lame imitations in an attempt to put the little guys out of business.


Jan
28th
Thu
permalink

Scala Puzzler of the day

Many different database objects in foursquare have a foreign key to User.  So I wrote something like so:

object User {
  trait FK[T <: FK[T]] extends LongKeyedMapper[T] {
    self: T=>
    object userid extends MappedLongForeignKey(this, User)
    def hasUser_? = userid.defined_?
  }

  class FKList[A <: FK[A]](list: List[A]) {    
    def primeUsers: List[A] = {
      if (!list.isEmpty) {
        val uids = list.filter(_.hasUser_?).map(_.userid.is)
        val users = findAll(ByList(User.id, uids))
        list.foreach(item => {
          item.userid.primeObj(users.find(_.id.is == item.userid.is))
        })
      }
      list
    }
  }
}

So that things can extend User.FK[Foo] and get automatic extra functionality for dealing with their User parents.  But you’ll notice that the field name is hard coded in the above.  Some things have two user parents.  For example Venues have creators and mayors.  Is there some way to enhance the code above so that a single model can extend User.FK twice with different field names?  Pondering what might be a good way to do this.

Dec
10th
Thu
permalink
As a general rule, if nothing bad will happen to you if you free ride, it’s smart to free ride. Worrying that other countries are pulling ahead is like worrying that the other oarsman in your boat will beat you to the destination if you’re lazy. You’re in the same boat! The smart thing is to goad everyone else into going as fast and hard as they can. For a good while now, America has been a dim kid with ape strength happy to carry half the world as long as he gets to fist-pump, flex his pecs, and chant U.S.A.! U.S.A.! in the mirror each night. It’s a darn good deal for the rest of the world. America’s just too dumb to feel exploited. And too idiotically vain to enjoy a free ride.
Dec
1st
Tue
permalink

NFL Suicide League

I’m 12 weeks into my NFL Suicide Leage.  So far I have used up: Baltimore, Washington, Dallas, Chicago, Pittsburgh, Green Bay, New England, San Diego, Seattle, Minnesota, Jacksonville, and Cincinnati.  Looking ahead to the remaining 5 weeks I see these two as the best options:

OPTION 1:

Indianapolis over Tennessee
NY Jets over Tampa Bay
Arizona over Detroit
New Orleans over Tampa Bay
Denver over Kansas City

OPTION 2:

New Orleans over Washington
NY Jets over Tampa Bay
Denver over Oakland
Arizona over St Louis
Indianapolis over Buffalo

Any thoughts?

Nov
23rd
Mon
permalink
rickwebb:
via www.atpfestival.com
Ordered. Not sold out as of 9:20 PM EST. Get it now, there are only 1,000 of them.

Whoa, I almost forgot. Thx for the reminder. DONE BEEN ORDERED!

rickwebb:

via www.atpfestival.com

Ordered. Not sold out as of 9:20 PM EST. Get it now, there are only 1,000 of them.

Whoa, I almost forgot. Thx for the reminder. DONE BEEN ORDERED!

Aug
20th
Thu
permalink

functional programming ftw

Simple, but fun:

def partition[T](items: List[T], p: (T, T) => Boolean): List[List[T]] = {
  items.foldRight[List[List[T]]](Nil)((item: T, items: List[List[T]]) => items match {
    case (first :: rest) :: last if p (first, item) =>
      (List(item)) :: (first :: rest) :: last
    case (first :: rest) :: last =>
      (item :: first :: rest) :: last
    case _ => List(List(item))
  })
}

If you understand what this does, or know someone who does, I’m hiring. Send me an e-mail.

Aug
6th
Thu
permalink

Party Reminder

Karaoke tonight for my birthday and Alice’s return to NYC. 2nd on 2nd @ 10pm. Pre party @ Tom & Jerry’s. Facebook invite is here.

See all y’all tonight!

Aug
3rd
Mon
permalink
Take a look at how Apple would be able to quickly build a large search engine business:
#1 The Apple fanboy market would leave Google in a heartbeat. No question. That’s about 5 per cent of the computer market, and that’s not counting the iPod, iPhone users.

Schmidt Resignation: Is Apple Building Apple Search Service? - SiliconValleyWatcher

Apple doesn’t have the technical expertise to build a quality search engine.  It isn’t even close.

Jul
29th
Wed
permalink
Danita&#8217;s Dessert Burger (seen today in the google cafeteria)

Danita’s Dessert Burger (seen today in the google cafeteria)