Discovr: a flickr experiment gone wrong

I need help with this. I had a dream… Well, not so much as a dream, maybe a “It’d be cool to…”

I thought it’d be nice to discover new photos on flickr using your favorite photos and the people who also favorited those photos, and the favorite photos of those who also favorited my pictures. Still with me?

It’s actually a quite simple code (about 500 lines, check it on github: discovr), but it’s terribly slow. Some possible reasons:

  • Way too much data. I’ve found people with around more than 18000 favorites, and there are photos with more than 2k fans. After limiting to 50 last favorites, the numbers are still creepy. Following from my personal favorites (366), I discovered 1268 users and 52632 photos
  • Too complicated for an API. This is the kind of feature that wouldn’t be so hard to implement if you have access to the flickr database directly, but having to do so many requests adds a lot of time to the process.
  • Inefficient library. I had to do some modifications to the flickr ruby library just to make it work, but it’s still quite inefficient in some cases. Want to know the url of a picture (knowing the picture id)? 4 (completely unnecessary) API calls
  • My code is bad. OK, I know it’s ugly to start blaming everyone else. I know my code is not very good, as it’s a quick prototype. Still, I’m not sure if making my code/libraries better would be enough improvement given the network/api bottleneck

The simplified algorithm goes like this.

  # method from class User
  def similar_pictures
    similar = {}

    favorites.each do |favorite|
      favorite.favorited_by.each do |user|
        user.favorites.each do |v|
          similar[k] ||= {:weight => 0, :picture => v[:picture]}
          similar[k][:weight] += 1
        end
      end
    end

    similar.values.sort {|a,b| b[:weight]  a[:weight]}.select {|v| v[:weight] > 1}
  end

So I’ve created a github repository and uploaded the code: discovr at github. Feel free to clone, test and improve

42foo: all the virtual hosts you need for your web development

I’ve done a fair amount of web “design” (mostly implementing designs of others) and development in the past, I usually set up a lot of virtual hosts in my local apache. I’ve done that in three different ways.

The quick&dirty hosts file

Point any of your development domains to 127.0.0.1 in the /etc/hosts file. It’s the easiest way, but you need to add them one by one. At some point, mine could look like this:

127.0.0.1 warp.dev
127.0.0.1 ebox-platform.dev
127.0.0.1 ebox-technologies.dev
127.0.0.1 jorgebernal.dev
127.0.0.1 projectA.dev
# ... and so on

Getting smart with dnsmasq

This is a more automated method. You install dnsmasq and configure 127.0.0.1 as your DNS server. Then add this to your conf:

address=/.dev/127.0.0.1

This worked well, and acted as a dns cache. But I had some trouble with dynamic dns entries at our old office: projects.warp.es would point to a local address inside the office and our remote IP from outside, so I found myself clearing the cache too often.

42foo: the zero-code web service

So I made it external. I bought 42foo.com and set up a bind zone with this:

@                       A       127.0.0.1
*                       A       127.0.0.1

So warp.42foo.com, ebox-platform.42foo.com or whateveryourprojectis.42foo.com always point to 127.0.0.1

You still have to set up the virtual host, but there is one step less for web development. Feel free to use it, and let me know if you set up something similar with a shorter domain name :)

Probably the best compact camera out there: Panasonic Lumix DMC-LX3

LX3k_slant_500

Sorry for the title. Actually there is no overall “best camera”, “best laptop” or “best whatever”. It always depends on what you need. If you just need a compact camera to take some pictures of your family trips or your college parties, almost any camera will do the trick for a much lower price.

That said, if you are serious about learning photography you should probably get a DSLR. You can get a Nikon D40 for about $400 or a Canon Rebel XS (aka 1000D) for about $500. I own the older Nikon D50 and I love it. Most of the pictures in this website were taken with that camera. I would only upgrade to the Nikon D700 but the gain isn’t worth $3000 to me.

Then, why am I recommending the LX3? Simple. The only problem I have with my D50 (and any other DSLR for that matter) is the size. It’s not too big for a DSLR, but it’s not a gadget to carry everywhere.

So, if you want a portable camera which allows you to learn photography, the LX3 is for you. I won’t go too technical here, but let’s highlight some of the features

  • 10 Megapixels (large enough for screen and print)
  • Shoots in RAW
  • It has manual exposure and manual focus modes, so you can learn all the basics
  • And the automatic modes are really smart
  • It’s actually a leica (in fact this one but with the lumix logo and $200 less in the price)
  • Very good optics
  • Shoots video in HD

If you want more details, read the full review at dpreview.

Some samples:

I added more contrast on this one, but the original was already amazing.

Macro focus works like a charm

Not actually a video, but a time-lapse. It has a hi-speed burst mode where it can take 3-megapixel stills at 6fps
http://vimeo.com/moogaloop.swf?clip_id=5595252&server=vimeo.com&show_title=1&show_byline=1&show_portrait=1&color=b1c800&fullscreen=1
Get a drink on Vimeo

Not mine, but shot with a LX3, although it seems to have gone through some good post-production
http://vimeo.com/moogaloop.swf?clip_id=2383305&server=vimeo.com&show_title=1&show_byline=1&show_portrait=1&color=b1c800&fullscreen=1
Words Don’t Mean The Same Thing To You… on Vimeo

If you like what you see, you can get the LX3 on Amazon for $567.99

Lock screen in OSX while saving energy

UPDATE: It seems it’s not working on snow leopard so I uploaded a new version: BlankIt.saver-snowleopard.zip

One of the things I miss most is a way to lock the screen in OSX. There are some ways, but they all come to the same idea: “require password to wake up form sleep or screen saver” and then sleep or start screen saver.

There are some times when I don’t want my computer to sleep, but still want it locked: I’ll be away but…

  • …downloading/installing something
  • …want remote access
  • …you name it

The problem with screen savers in mac is that there is no blank screen saver. They’re all beautiful OpenGL savers that look really nice (even when nobody is looking at them), but consume CPU and I usually found my laptop hot as hell when I come back.

It turns out that creating a blank screen saver is way easier than I thought.

  1. Open Xcode
  2. New Project -> Standard Apple Plug-In -> Screen Saver
  3. Build it
  4. Install it

The base template for a screen saver in Xcode is just that. A blank view. It’s not so efficient as putting the display to sleep, but it’s a start.
If you don’t have Xcode and/or don’t want to waste a couple minutes following the steps, you can download it: BlankIt.saver.zip

I’m not uploading the source, since the only change from the template was to change the update interval from 1/30 of a second to 10 seconds.